]> diplodocus.org Git - nmh/commitdiff
Always emit an STR instruction for terminal escape sequences, otherwise you
authorKen Hornstein <kenh@pobox.com>
Thu, 2 Jan 2014 20:04:17 +0000 (15:04 -0500)
committerKen Hornstein <kenh@pobox.com>
Thu, 2 Jan 2014 20:04:17 +0000 (15:04 -0500)
can get unintended results (like printint the previous contents of the str
register, which is almost certainly what you don't want).

sbr/fmt_compile.c

index 4ae85bc..c4476f8 100644 (file)
@@ -1119,19 +1119,20 @@ get_term_stringcap(struct ftable *t, char *cap)
     if (termstatus == 0)
        initialize_terminfo();
 
     if (termstatus == 0)
        initialize_terminfo();
 
+    termcbufp = termcbuf;
+
     if (termstatus == -1)
     if (termstatus == -1)
-       return;
+       goto out;
 
     parm = tigetstr(cap);
 
     if (parm == (char *) -1 || parm == NULL) {
 
     parm = tigetstr(cap);
 
     if (parm == (char *) -1 || parm == NULL) {
-       return;
+       goto out;
     }
 
     }
 
-    termcbufp = termcbuf;
-
     tputs(parm, 1, termbytes);
 
     tputs(parm, 1, termbytes);
 
+out:
     termcbufp = '\0';
 
     LS(t->f_type, termcbuf);
     termcbufp = '\0';
 
     LS(t->f_type, termcbuf);