diff options
author | pl@ninthfloor.org <pl@ninthfloor.org> | 2016-11-11 17:45:52 +0100 |
---|---|---|
committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2016-11-14 18:36:38 +0100 |
commit | 902a392b905107c7b8a318c103837c54e47a068e (patch) | |
tree | 0054abef4993d7a5b2a6d419113c111a084f99b3 | |
parent | 8c99915608beee03eca3bae6ed92264a0da87e2f (diff) | |
download | st-902a392b905107c7b8a318c103837c54e47a068e.tar.gz st-902a392b905107c7b8a318c103837c54e47a068e.zip |
Make strdump(), csidump(), print to stderr
The two functions strdump(), csidump() are called to show errors and
their output is introduced by a message printed to stderr. Thus, it it
more consistent to have them print to stderr.
Moreover stderr is unbuffered (at least on Linux), making problems
immediately visible.
-rw-r--r-- | st.c | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -2490,22 +2490,22 @@ csidump(void) | |||
2490 | int i; | 2490 | int i; |
2491 | uint c; | 2491 | uint c; |
2492 | 2492 | ||
2493 | printf("ESC["); | 2493 | fprintf(stderr, "ESC["); |
2494 | for (i = 0; i < csiescseq.len; i++) { | 2494 | for (i = 0; i < csiescseq.len; i++) { |
2495 | c = csiescseq.buf[i] & 0xff; | 2495 | c = csiescseq.buf[i] & 0xff; |
2496 | if (isprint(c)) { | 2496 | if (isprint(c)) { |
2497 | putchar(c); | 2497 | putc(c, stderr); |
2498 | } else if (c == '\n') { | 2498 | } else if (c == '\n') { |
2499 | printf("(\\n)"); | 2499 | fprintf(stderr, "(\\n)"); |
2500 | } else if (c == '\r') { | 2500 | } else if (c == '\r') { |
2501 | printf("(\\r)"); | 2501 | fprintf(stderr, "(\\r)"); |
2502 | } else if (c == 0x1b) { | 2502 | } else if (c == 0x1b) { |
2503 | printf("(\\e)"); | 2503 | fprintf(stderr, "(\\e)"); |
2504 | } else { | 2504 | } else { |
2505 | printf("(%02x)", c); | 2505 | fprintf(stderr, "(%02x)", c); |
2506 | } | 2506 | } |
2507 | } | 2507 | } |
2508 | putchar('\n'); | 2508 | putc('\n', stderr); |
2509 | } | 2509 | } |
2510 | 2510 | ||
2511 | void | 2511 | void |
@@ -2594,24 +2594,25 @@ strdump(void) | |||
2594 | int i; | 2594 | int i; |
2595 | uint c; | 2595 | uint c; |
2596 | 2596 | ||
2597 | printf("ESC%c", strescseq.type); | 2597 | fprintf(stderr, "ESC%c", strescseq.type); |
2598 | for (i = 0; i < strescseq.len; i++) { | 2598 | for (i = 0; i < strescseq.len; i++) { |
2599 | c = strescseq.buf[i] & 0xff; | 2599 | c = strescseq.buf[i] & 0xff; |
2600 | if (c == '\0') { | 2600 | if (c == '\0') { |
2601 | putc('\n', stderr); | ||
2601 | return; | 2602 | return; |
2602 | } else if (isprint(c)) { | 2603 | } else if (isprint(c)) { |
2603 | putchar(c); | 2604 | putc(c, stderr); |
2604 | } else if (c == '\n') { | 2605 | } else if (c == '\n') { |
2605 | printf("(\\n)"); | 2606 | fprintf(stderr, "(\\n)"); |
2606 | } else if (c == '\r') { | 2607 | } else if (c == '\r') { |
2607 | printf("(\\r)"); | 2608 | fprintf(stderr, "(\\r)"); |
2608 | } else if (c == 0x1b) { | 2609 | } else if (c == 0x1b) { |
2609 | printf("(\\e)"); | 2610 | fprintf(stderr, "(\\e)"); |
2610 | } else { | 2611 | } else { |
2611 | printf("(%02x)", c); | 2612 | fprintf(stderr, "(%02x)", c); |
2612 | } | 2613 | } |
2613 | } | 2614 | } |
2614 | printf("ESC\\\n"); | 2615 | fprintf(stderr, "ESC\\\n"); |
2615 | } | 2616 | } |
2616 | 2617 | ||
2617 | void | 2618 | void |