1 Submitted By: Matt Burgess <matthew_at_linuxfromscratch_dot_org>
3 Initial Package Version: 3.2.8
4 Upstream Status: Submitted
5 Origin: http://wiki.linuxfromscratch.org/lfs/ticket/2113
6 Description: Fixes a unicode related bug in the watch program
8 diff -Naur procps-3.2.8.orig/Makefile procps-3.2.8/Makefile
9 --- procps-3.2.8.orig/Makefile 2009-05-10 18:50:48.000000000 +0000
10 +++ procps-3.2.8/Makefile 2009-05-12 19:06:50.000000000 +0000
12 # plus the top-level Makefile to make it work stand-alone.
18 # This seems about right for the dynamic library stuff.
19 # Something like this is probably needed to make the SE Linux
20 diff -Naur procps-3.2.8.orig/watch.c procps-3.2.8/watch.c
21 --- procps-3.2.8.orig/watch.c 2007-05-28 03:13:23.000000000 +0000
22 +++ procps-3.2.8/watch.c 2009-05-12 19:17:25.000000000 +0000
26 #include "proc/procps.h"
37 +readwc(FILE *stream, mbstate_t *mbs)
49 + len = mbrtowc(&wc, &c, 1, mbs);
50 + if (len == (size_t)-1)
51 + memset(mbs, 0, sizeof(*mbs));
52 + else if (len != (size_t)-2)
58 main(int argc, char *argv[])
66 if (screen_size_changed) {
72 + memset(&mbs, 0, sizeof(mbs));
73 for (y = show_title; y < height; y++) {
74 int eolseen = 0, tabpending = 0;
75 for (x = 0; x < width; x++) {
79 + int attr = 0, c_width;
84 /* if there is a tab pending, just spit spaces until the
85 next stop instead of reading characters */
89 - while (c != EOF && !isprint(c)
93 + c = readwc(p, &mbs);
94 + while (c != WEOF && !iswprint(c)
98 if (!oldeolseen && x == 0) {
103 - else if (c == '\t')
104 + else if (c == L'\t')
106 - if (c == EOF || c == '\n' || c == '\t')
108 + if (c == WEOF || c == L'\n' || c == L'\t')
110 if (tabpending && (((x + 1) % 8) == 0))
115 + setcchar (&cc, wstr, 0, 0, NULL);
117 if (option_differences) {
118 - chtype oldch = inch();
119 - char oldc = oldch & A_CHARTEXT;
121 + wchar_t oldwstr[2];
126 + getcchar(&oldc, oldwstr, &attrs, &colors, NULL);
128 - && ((char)c != oldc
129 + && (wstr[0] != oldwstr[0]
131 (option_differences_cumulative
132 - && (oldch & A_ATTRIBUTES)));
142 + c_width = wcwidth(c);
147 oldeolseen = eolseen;