[hackers] [scc] Fix escape sequences parsing || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 31 Oct 2015 09:39:25 +0100 (CET)

commit 7bef3d1fcbbb59778de9e883f818978696a39617
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Oct 31 09:37:49 2015 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Oct 31 09:37:49 2015 +0100

    Fix escape sequences parsing
    
    We were not incrementing the pointer in the case of escape sequences of only
    1 letter, and it was generating garbage fat the end of the character.

diff --git a/cc1/lex.c b/cc1/lex.c
index 827185b..f4a0d26 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -398,16 +398,16 @@ escape(void)
         int c, base;
 
         switch (*++input->p) {
- case '\\': return '\\';
- case 'a': return '\a';
- case 'f': return '\f';
- case 'n': return '\n';
- case 'r': return '\r';
- case 't': return '\t';
- case 'v': return '\v';
- case '\'': return '\\';
- case '"': return'"';
- case '?': return '?';
+ case '\\': c = '\\'; goto escape_letter;
+ case 'a': c = '\a'; goto escape_letter;
+ case 'f': c = '\f'; goto escape_letter;
+ case 'n': c = '\n'; goto escape_letter;
+ case 'r': c = '\r'; goto escape_letter;
+ case 't': c = '\t'; goto escape_letter;
+ case 'v': c = '\v'; goto escape_letter;
+ case '\'': c = '\\'; goto escape_letter;
+ case '"': c = '"'; goto escape_letter;
+ case '?': c = '?'; goto escape_letter;
         case 'u': base = 10; break;
         case 'x': base = 16; break;
         case '0': base = 8; break;
_AT_@ -420,6 +420,10 @@ escape(void)
         if (errno || c > 255)
                 warn("character constant out of range");
         return c;
+
+escape_letter:
+ ++input->p;
+ return c;
 }
 
 static unsigned
Received on Sat Oct 31 2015 - 09:39:25 CET

This archive was generated by hypermail 2.3.0 : Sat Oct 31 2015 - 09:48:11 CET