ref: 61d8cb619913f5b54df22c02c97b999e592ef70f
parent: b17cc0af133dcaeb60d742159836cae7d0d431f7
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Oct 31 05:51:32 EDT 2021
cc1: Improve escaped characters in outcpp() The reverse escaping was lacking a lot of the escape sequences, making a bit unusable the output of cpp.
--- a/src/cmd/cc/cc1/cpp.c
+++ b/src/cmd/cc/cc1/cpp.c
@@ -805,7 +805,7 @@
printf("%s ", yytext);
continue;
}
- for (s = yytext; c = *s; ++s) {
+ for (s = yytext; (c = *s) != '\0'; ++s) {
switch (c) {
case '\n':
t = "\\n";
@@ -822,9 +822,27 @@
case '\a':
t = "\\a";
goto print_str;
+ case '\f':
+ t = "\\f";
+ goto print_str;
+ case '\r':
+ t = "\\r";
+ goto print_str;
+ case '"':
+ if (s == yytext || s[1] == '\0')
+ goto print_chr;
+ t = "\\\"";
+ goto print_str;
+ case '\'':
+ t = "\\'";
+ goto print_str;
+ case '\?':
+ t = "\\\?";
+ goto print_str;
case '\\':
putchar('\\');
default:
+ print_chr:
if (!isprint(c))
printf("\\x%x", c);
else