add octal escape in string

This commit is contained in:
Josh Holtrop 2018-04-11 21:35:03 -04:00
parent 81614c41ab
commit 3170f0870c

View File

@ -137,7 +137,14 @@ L?'\\v' (void)'\v'; return TOK_CHAR_CONST;
\\x[0-9A-Fa-f]{2} {
/* hexadecimal escape code */
unsigned int val;
(void) sscanf(yytext + 2, "%x", &val);
(void)sscanf(yytext + 1, "%x", &val);
char v[2] = {(char)val, '\0'};
String_concat(build_string, v);
}
\\[0-7][0-7]?[0-7]? {
/* octal escape code */
unsigned int val;
(void)sscanf(yytext + 1, "%o", &val);
char v[2] = {(char)val, '\0'};
String_concat(build_string, v);
}