shithub: scc

Download patch

ref: 6d01242876fda6bd9861414b477196e6f25bc8d8
parent: 9e29fc687fadb6d0ef18e986825c1b788ddd7284
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Dec 8 14:02:56 EST 2015

Simplify escape()

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

--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -395,19 +395,19 @@
 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