Fixed escape of string
This commit is contained in:
parent
2dd006ff76
commit
302f2822dc
@ -381,9 +381,10 @@ static int valid_utf8_char (const char *str) {
|
|||||||
return n + 1;
|
return n + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_escaped_string (const char *str) {
|
static void print_escaped_string (const char *str, int len) {
|
||||||
eprintf ("\"");
|
eprintf ("\"");
|
||||||
while (*str) {
|
const char *end = str + len;
|
||||||
|
while (str < end) {
|
||||||
int n = valid_utf8_char (str);
|
int n = valid_utf8_char (str);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
eprintf ("\\x%02x", (int)(unsigned char)*str);
|
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 (" if (l < 0 || (l >= (1 << 22) - 2)) { return -1; }\n");
|
||||||
printf (" memcpy (buf, fetch_str (l), l);\n");
|
printf (" memcpy (buf, fetch_str (l), l);\n");
|
||||||
printf (" buf[l] = 0;\n");
|
printf (" buf[l] = 0;\n");
|
||||||
printf (" print_escaped_string (buf);\n");
|
printf (" print_escaped_string (buf, l);\n");
|
||||||
printf (" return 0;\n");
|
printf (" return 0;\n");
|
||||||
printf ("}\n");
|
printf ("}\n");
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user