[hackers] [scc] Simplify escape() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 8 Dec 2015 19:04:04 +0100 (CET)

commit 6d01242876fda6bd9861414b477196e6f25bc8d8
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Dec 8 19:02:56 2015 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Dec 8 19:02:56 2015 +0100

    Simplify escape()
    
    Why assign and return instead of returning directly?.
    This patch also fixes an error in case '\'', where
    escape() was returning '\\' instead of '\''.

diff --git a/cc1/lex.c b/cc1/lex.c
index 2bcdb98..32d6246 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -395,19 +395,19 @@ number(void)
 static char
 escape(void)
 {
- int c, base;
+ int n, base;
 
         switch (*++input->p) {
- case '\\': c = '\\'; return c;
- case 'a': c = '\a'; return c;
- case 'f': c = '\f'; return c;
- case 'n': c = '\n'; return c;
- case 'r': c = '\r'; return c;
- case 't': c = '\t'; return c;
- case 'v': c = '\v'; return c;
- case '\'': c = '\\'; return c;
- case '"': c = '"'; return c;
- case '?': c = '?'; return c;
+ 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 '\?': return '\?';
         case 'u':
                 /*
                  * FIXME: universal constants are not correctly handled
Received on Tue Dec 08 2015 - 19:04:04 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 08 2015 - 19:12:12 CET