Fix wrong handling of strings which do not end properly at the end of line

This commit is contained in:
Ziyao 2022-07-13 15:43:26 +08:00
parent a83b285685
commit e588b65390
No known key found for this signature in database
GPG Key ID: A32FA9E5C3BB744D
2 changed files with 2 additions and 24 deletions

View File

@ -944,19 +944,16 @@ static uint8_t *parse_pp_string(uint8_t *p,
}
}
} else if (c == '\n') {
file->line_num++;
goto add_char;
tcc_error("missing terminating %c character",sep);
} else if (c == '\r') {
PEEKC_EOB(c, p);
if (c != '\n') {
if (str)
cstr_ccat(str, '\r');
} else {
file->line_num++;
goto add_char;
tcc_error("missing terminating %c character",sep);
}
} else {
add_char:
if (str)
cstr_ccat(str, c);
p++;

View File

@ -4253,11 +4253,6 @@ void func_arg_test(void)
/* gcc 2.95.3 does not handle correctly CR in strings or after strays */
#define CORRECT_CR_HANDLING
/* deprecated and no longer supported in gcc 3.3 */
#ifdef __TINYC__
# define ACCEPT_CR_IN_STRINGS
#endif
/* keep this as the last test because GCC messes up line-numbers
with the ^L^K^M characters below */
void whitespace_test(void)
@ -4279,20 +4274,6 @@ ntf("aaa=%d\n", 3);
\
ntf("min=%d\n", 4);
#ifdef ACCEPT_CR_IN_STRINGS
printf("len1=%d\n", strlen("
"));
#ifdef CORRECT_CR_HANDLING
str = "
";
printf("len1=%d str[0]=%d\n", strlen(str), str[0]);
#endif
printf("len1=%d\n", strlen(" a
"));
#else
printf("len1=1\nlen1=1 str[0]=10\nlen1=3\n");
#endif /* ACCEPT_CR_IN_STRINGS */
#ifdef __LINE__
printf("__LINE__ defined\n");
#endif