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 <sys/types.h> |
| | 29 | #include <sys/stat.h> |
| | 30 | #include <fcntl.h> |
| | 31 | #include <wchar.h> |
| | 32 | #include <wctype.h> |
| 28 | 33 | |
| 29 | 34 | #ifdef FORCE_8BIT |
| 30 | 35 | #undef isprint |
| … |
… |
|
| 134 | 139 | } |
| 135 | 140 | } |
| 136 | 141 | |
| | 142 | static wint_t |
| | 143 | readwc(FILE *stream, mbstate_t *mbs) |
| | 144 | { |
| | 145 | for (;;) { |
| | 146 | int chr; |
| | 147 | char c; |
| | 148 | wchar_t wc; |
| | 149 | size_t len; |
| | 150 | |
| | 151 | chr = getc(stream); |
| | 152 | if (chr == EOF) |
| | 153 | return WEOF; |
| | 154 | c = chr; |
| | 155 | len = mbrtowc(&wc, &c, 1, mbs); |
| | 156 | if (len == (size_t)-1) |
| | 157 | memset(mbs, 0, sizeof(*mbs)); |
| | 158 | else if (len != (size_t)-2) |
| | 159 | return wc; |
| | 160 | } |
| | 161 | } |
| | 162 | |
| 137 | 163 | int |
| 138 | 164 | main(int argc, char *argv[]) |
| 139 | 165 | { |
| 140 | 166 | int optc; |
| | 167 | int fd; |
| 141 | 168 | int option_differences = 0, |
| 142 | 169 | option_differences_cumulative = 0, |
| 143 | 170 | option_help = 0, option_version = 0; |
| … |
… |
|
| 239 | 266 | FILE *p; |
| 240 | 267 | int x, y; |
| 241 | 268 | int oldeolseen = 1; |
| | 269 | mbstate_t mbs; |
| 242 | 270 | |
| 243 | 271 | if (screen_size_changed) { |
| 244 | 272 | get_terminal_size(); |
| … |
… |
|
| 260 | 288 | mvaddstr(0, width - tsl + 1, ts); |
| 261 | 289 | free(header); |
| 262 | 290 | } |
| 263 | | |
| | 291 | close(0); |
| | 292 | fd=open("/dev/null",O_RDWR); |
| | 293 | if (fd!=0) { |
| | 294 | perror("open"); |
| | 295 | do_exit(2); |
| | 296 | } |
| | 297 | |
| 264 | 298 | if (!(p = popen(command, "r"))) { |
| 265 | 299 | perror("popen"); |
| 266 | 300 | do_exit(2); |
| 267 | 301 | } |
| 268 | 302 | |
| | 303 | memset(&mbs, 0, sizeof(mbs)); |
| 269 | 304 | for (y = show_title; y < height; y++) { |
| 270 | 305 | int eolseen = 0, tabpending = 0; |
| 271 | 306 | for (x = 0; x < width; x++) { |
| 272 | | int c = ' '; |
| 273 | | int attr = 0; |
| | 307 | wint_t c = L' '; |
| | 308 | int attr = 0, c_width; |
| | 309 | cchar_t cc; |
| | 310 | wchar_t wstr[2]; |
| 274 | 311 | |
| 275 | 312 | if (!eolseen) { |
| 276 | 313 | /* if there is a tab pending, just spit spaces until the |
| 277 | 314 | next stop instead of reading characters */ |
| 278 | 315 | if (!tabpending) |
| 279 | 316 | do |
| 280 | | c = getc(p); |
| 281 | | while (c != EOF && !isprint(c) |
| 282 | | && c != '\n' |
| 283 | | && c != '\t'); |
| 284 | | if (c == '\n') |
| | 317 | c = readwc(p, &mbs); |
| | 318 | while (c != WEOF && !iswprint(c) |
| | 319 | && c != L'\n' |
| | 320 | && c != L'\t'); |
| | 321 | if (c == L'\n') |
| 285 | 322 | if (!oldeolseen && x == 0) { |
| 286 | 323 | x = -1; |
| 287 | 324 | continue; |
| 288 | 325 | } else |
| 289 | 326 | eolseen = 1; |
| 290 | | else if (c == '\t') |
| | 327 | else if (c == L'\t') |
| 291 | 328 | tabpending = 1; |
| 292 | | if (c == EOF || c == '\n' || c == '\t') |
| 293 | | c = ' '; |
| | 329 | if (c == WEOF || c == L'\n' || c == L'\t') |
| | 330 | c = L' '; |
| 294 | 331 | if (tabpending && (((x + 1) % 8) == 0)) |
| 295 | 332 | tabpending = 0; |
| 296 | 333 | } |
| | 334 | wstr[0] = c; |
| | 335 | wstr[1] = 0; |
| | 336 | setcchar (&cc, wstr, 0, 0, NULL); |
| 297 | 337 | move(y, x); |
| 298 | 338 | if (option_differences) { |
| 299 | | int oldch = inch(); |
| 300 | | char oldc = oldch & A_CHARTEXT; |
| | 339 | cchar_t oldc; |
| | 340 | wchar_t oldwstr[2]; |
| | 341 | attr_t attrs; |
| | 342 | short colors; |
| | 343 | |
| | 344 | in_wch(&oldc); |
| | 345 | getcchar(&oldc, oldwstr, &attrs, &colors, NULL); |
| 301 | 346 | attr = !first_screen |
| 302 | | && (c != oldc |
| | 347 | && (wstr[0] != oldwstr[0] |
| 303 | 348 | || |
| 304 | 349 | (option_differences_cumulative |
| 305 | | && (oldch & A_ATTRIBUTES))); |
| | 350 | && attrs)); |
| 306 | 351 | } |
| 307 | 352 | if (attr) |
| 308 | 353 | standout(); |
| 309 | | addch(c); |
| | 354 | add_wch(&cc); |
| 310 | 355 | if (attr) |
| 311 | 356 | standend(); |
| | 357 | c_width = wcwidth(c); |
| | 358 | if (c_width > 1) |
| | 359 | x += c_width - 1; |
| 312 | 360 | } |
| 313 | 361 | oldeolseen = eolseen; |
| 314 | 362 | } |