diff -Naur procps-3.2.7.old/Makefile procps-3.2.7/Makefile
|
old
|
new
|
|
| 67 | 67 | # plus the top-level Makefile to make it work stand-alone. |
| 68 | 68 | _TARFILES := Makefile |
| 69 | 69 | |
| 70 | | CURSES := -lncurses |
| | 70 | CURSES := -lncursesw |
| 71 | 71 | |
| 72 | 72 | # This seems about right for the dynamic library stuff. |
| 73 | 73 | # Something like this is probably needed to make the SE Linux |
diff -Naur procps-3.2.7.old/watch.c procps-3.2.7/watch.c
|
old
|
new
|
|
| 25 | 25 | #include <termios.h> |
| 26 | 26 | #include <locale.h> |
| 27 | 27 | #include "proc/procps.h" |
| | 28 | #include <wchar.h> |
| | 29 | #include <wctype.h> |
| 28 | 30 | |
| 29 | 31 | #ifdef FORCE_8BIT |
| 30 | 32 | #undef isprint |
| … |
… |
|
| 134 | 136 | } |
| 135 | 137 | } |
| 136 | 138 | |
| | 139 | static wint_t |
| | 140 | readwc(FILE *stream, mbstate_t *mbs) |
| | 141 | { |
| | 142 | for (;;) { |
| | 143 | int chr; |
| | 144 | char c; |
| | 145 | wchar_t wc; |
| | 146 | size_t len; |
| | 147 | |
| | 148 | chr = getc(stream); |
| | 149 | if (chr == EOF) |
| | 150 | return WEOF; |
| | 151 | c = chr; |
| | 152 | len = mbrtowc(&wc, &c, 1, mbs); |
| | 153 | if (len == (size_t)-1) |
| | 154 | memset(mbs, 0, sizeof(*mbs)); |
| | 155 | else if (len != (size_t)-2) |
| | 156 | return wc; |
| | 157 | } |
| | 158 | } |
| | 159 | |
| 137 | 160 | int |
| 138 | 161 | main(int argc, char *argv[]) |
| 139 | 162 | { |
| … |
… |
|
| 239 | 262 | FILE *p; |
| 240 | 263 | int x, y; |
| 241 | 264 | int oldeolseen = 1; |
| | 265 | mbstate_t mbs; |
| 242 | 266 | |
| 243 | 267 | if (screen_size_changed) { |
| 244 | 268 | get_terminal_size(); |
| … |
… |
|
| 266 | 290 | do_exit(2); |
| 267 | 291 | } |
| 268 | 292 | |
| | 293 | memset(&mbs, 0, sizeof(mbs)); |
| 269 | 294 | for (y = show_title; y < height; y++) { |
| 270 | 295 | int eolseen = 0, tabpending = 0; |
| 271 | 296 | for (x = 0; x < width; x++) { |
| 272 | | int c = ' '; |
| 273 | | int attr = 0; |
| | 297 | wint_t c = L' '; |
| | 298 | int attr = 0, c_width; |
| | 299 | cchar_t cc; |
| | 300 | wchar_t wstr[2]; |
| 274 | 301 | |
| 275 | 302 | if (!eolseen) { |
| 276 | 303 | /* if there is a tab pending, just spit spaces until the |
| 277 | 304 | next stop instead of reading characters */ |
| 278 | 305 | if (!tabpending) |
| 279 | 306 | do |
| 280 | | c = getc(p); |
| 281 | | while (c != EOF && !isprint(c) |
| 282 | | && c != '\n' |
| 283 | | && c != '\t'); |
| 284 | | if (c == '\n') |
| | 307 | c = readwc(p, &mbs); |
| | 308 | while (c != WEOF && !iswprint(c) |
| | 309 | && c != L'\n' |
| | 310 | && c != L'\t'); |
| | 311 | if (c == L'\n') |
| 285 | 312 | if (!oldeolseen && x == 0) { |
| 286 | 313 | x = -1; |
| 287 | 314 | continue; |
| 288 | 315 | } else |
| 289 | 316 | eolseen = 1; |
| 290 | | else if (c == '\t') |
| | 317 | else if (c == L'\t') |
| 291 | 318 | tabpending = 1; |
| 292 | | if (c == EOF || c == '\n' || c == '\t') |
| 293 | | c = ' '; |
| | 319 | if (c == WEOF || c == L'\n' || c == L'\t') |
| | 320 | c = L' '; |
| 294 | 321 | if (tabpending && (((x + 1) % 8) == 0)) |
| 295 | 322 | tabpending = 0; |
| 296 | 323 | } |
| | 324 | wstr[0] = c; |
| | 325 | wstr[1] = 0; |
| | 326 | setcchar (&cc, wstr, 0, 0, NULL); |
| 297 | 327 | move(y, x); |
| 298 | 328 | if (option_differences) { |
| 299 | | int oldch = inch(); |
| 300 | | char oldc = oldch & A_CHARTEXT; |
| | 329 | cchar_t oldc; |
| | 330 | wchar_t oldwstr[2]; |
| | 331 | attr_t attrs; |
| | 332 | short colors; |
| | 333 | |
| | 334 | in_wch(&oldc); |
| | 335 | getcchar(&oldc, oldwstr, &attrs, &colors, NULL); |
| 301 | 336 | attr = !first_screen |
| 302 | | && (c != oldc |
| | 337 | && (wstr[0] != oldwstr[0] |
| 303 | 338 | || |
| 304 | 339 | (option_differences_cumulative |
| 305 | | && (oldch & A_ATTRIBUTES))); |
| | 340 | && attrs)); |
| 306 | 341 | } |
| 307 | 342 | if (attr) |
| 308 | 343 | standout(); |
| 309 | | addch(c); |
| | 344 | add_wch(&cc); |
| 310 | 345 | if (attr) |
| 311 | 346 | standend(); |
| | 347 | c_width = wcwidth(c); |
| | 348 | if (c_width > 1) |
| | 349 | x += c_width - 1; |
| 312 | 350 | } |
| 313 | 351 | oldeolseen = eolseen; |
| 314 | 352 | } |