Fixed escape of string
This commit is contained in:
parent
1896b2b905
commit
efebedc08a
2 changed files with 4 additions and 3 deletions
|
@ -381,9 +381,10 @@ static int valid_utf8_char (const char *str) {
|
|||
return n + 1;
|
||||
}
|
||||
|
||||
static void print_escaped_string (const char *str) {
|
||||
static void print_escaped_string (const char *str, int len) {
|
||||
eprintf ("\"");
|
||||
while (*str) {
|
||||
const char *end = str + len;
|
||||
while (str < end) {
|
||||
int n = valid_utf8_char (str);
|
||||
if (n < 0) {
|
||||
eprintf ("\\x%02x", (int)(unsigned char)*str);
|
||||
|
|
|
@ -832,7 +832,7 @@ void gen_constructor_fetch (struct tl_combinator *c) {
|
|||
printf (" if (l < 0 || (l >= (1 << 22) - 2)) { return -1; }\n");
|
||||
printf (" memcpy (buf, fetch_str (l), l);\n");
|
||||
printf (" buf[l] = 0;\n");
|
||||
printf (" print_escaped_string (buf);\n");
|
||||
printf (" print_escaped_string (buf, l);\n");
|
||||
printf (" return 0;\n");
|
||||
printf ("}\n");
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue