commit a64383b5e55ca6d2da9cf4039bd8926222a7d9b9
parent e22d82e7c5eff9eb5b0390e06b7df8e11c7e4599
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Tue, 26 May 2026 00:29:39 +0200
cc1: Don't escape \ out of "" or ''
Diffstat:
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/cmd/scc-cc/cc1/cpp.c b/src/cmd/scc-cc/cc1/cpp.c
@@ -309,6 +309,8 @@ stringoper(char **bpp, int *sizep, char *arg)
siz--;
break;
case '\\':
+ if (!delim)
+ goto copy;
if (siz < 4)
return 0;
*bp++ = '\\';
@@ -326,6 +328,7 @@ stringoper(char **bpp, int *sizep, char *arg)
++arg;
c = ' ';
}
+ copy:
if (siz < 3)
return 0;
*bp++ = c;
diff --git a/tests/cc/execute/0273-cpp.c b/tests/cc/execute/0273-cpp.c
@@ -1,11 +1,7 @@
#define a(x) # x
-static char *s1 = a(3);
-static char *s2 = a( 3 );
-static char *s3 = a( 3 2 );
-static char *s4 = a ( 3
+static char *s = a ( 3
2);
-static char *s5 = a("3 2 1\n");
static int
cmp(char *s1, char *s2)
@@ -18,20 +14,22 @@ cmp(char *s1, char *s2)
int
main(void)
{
- if (!cmp(s1, "3"))
+ if (!cmp(a(3), "3"))
return 1;
- if (!cmp(s2, "3"))
+ if (!cmp(a( 3 ), "3"))
return 2;
- if (!cmp(s3, "3 2"))
+ if (!cmp(a( 3 2 ), "3 2"))
return 3;
- if (!cmp(s4, "3 2"))
+ if (!cmp(s, "3 2"))
return 4;
- if (!cmp(s5, "\"3 2 1\\n\""))
+ if (!cmp(a("3 2 1\n"), "\"3 2 1\\n\""))
return 5;
if (!cmp(a('\n'), "'\\n'"))
return 6;
if (!cmp(a('"'), "'\"'"))
return 6;
+ if (!cmp(a(: @\n), ": @\n"))
+ return 7;
return 0;
}