[hackers] [st] Make strdump(), csidump(), print to stderr || pl_AT_ninthfloor.org

From: <git_AT_suckless.org>
Date: Mon, 14 Nov 2016 19:29:33 +0100 (CET)

commit 902a392b905107c7b8a318c103837c54e47a068e
Author: pl_AT_ninthfloor.org <pl_AT_ninthfloor.org>
AuthorDate: Fri Nov 11 17:45:52 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Nov 14 18:36:38 2016 +0100

    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.

diff --git a/st.c b/st.c
index 4d44388..0980082 100644
--- a/st.c
+++ b/st.c
_AT_@ -2490,22 +2490,22 @@ csidump(void)
         int i;
         uint c;
 
- printf("ESC[");
+ fprintf(stderr, "ESC[");
         for (i = 0; i < csiescseq.len; i++) {
                 c = csiescseq.buf[i] & 0xff;
                 if (isprint(c)) {
- putchar(c);
+ putc(c, stderr);
                 } else if (c == '\n') {
- printf("(\\n)");
+ fprintf(stderr, "(\\n)");
                 } else if (c == '\r') {
- printf("(\\r)");
+ fprintf(stderr, "(\\r)");
                 } else if (c == 0x1b) {
- printf("(\\e)");
+ fprintf(stderr, "(\\e)");
                 } else {
- printf("(%02x)", c);
+ fprintf(stderr, "(%02x)", c);
                 }
         }
- putchar('\n');
+ putc('\n', stderr);
 }
 
 void
_AT_@ -2594,24 +2594,25 @@ strdump(void)
         int i;
         uint c;
 
- printf("ESC%c", strescseq.type);
+ fprintf(stderr, "ESC%c", strescseq.type);
         for (i = 0; i < strescseq.len; i++) {
                 c = strescseq.buf[i] & 0xff;
                 if (c == '\0') {
+ putc('\n', stderr);
                         return;
                 } else if (isprint(c)) {
- putchar(c);
+ putc(c, stderr);
                 } else if (c == '\n') {
- printf("(\\n)");
+ fprintf(stderr, "(\\n)");
                 } else if (c == '\r') {
- printf("(\\r)");
+ fprintf(stderr, "(\\r)");
                 } else if (c == 0x1b) {
- printf("(\\e)");
+ fprintf(stderr, "(\\e)");
                 } else {
- printf("(%02x)", c);
+ fprintf(stderr, "(%02x)", c);
                 }
         }
- printf("ESC\\\n");
+ fprintf(stderr, "ESC\\\n");
 }
 
 void
Received on Mon Nov 14 2016 - 19:29:33 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 14 2016 - 19:36:17 CET