History

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

Ziyao committed 4 years ago

Commit e588b651 parent a83b2852 files · +2 −24Browse files

Unified · Split

2 files
  1. tccpp.c +2 −5
  2. tests/tcctest.c +0 −19
tccpp.c+2−5
@@ -944,19 +944,16 @@ static uint8_t *parse_pp_string(uint8_t *p, · 943 unmodified lines
944 }944 }
945 }945 }
946 } else if (c == '\n') {946 } else if (c == '\n') {
947 file->line_num++;947 tcc_error("missing terminating %c character",sep);
948 goto add_char;
949 } else if (c == '\r') {948 } else if (c == '\r') {
950 PEEKC_EOB(c, p);949 PEEKC_EOB(c, p);
951 if (c != '\n') {950 if (c != '\n') {
952 if (str)951 if (str)
953 cstr_ccat(str, '\r');952 cstr_ccat(str, '\r');
954 } else {953 } else {
955 file->line_num++;954 tcc_error("missing terminating %c character",sep);
956 goto add_char;
957 }955 }
958 } else {956 } else {
959 add_char:
960 if (str)957 if (str)
961 cstr_ccat(str, c);958 cstr_ccat(str, c);
962 p++;959 p++;
tests/tcctest.c+0−19
@@ -4253,11 +4253,6 @@ void func_arg_test(void) · 4252 unmodified lines
4253/* gcc 2.95.3 does not handle correctly CR in strings or after strays */4253/* gcc 2.95.3 does not handle correctly CR in strings or after strays */
4254#define CORRECT_CR_HANDLING4254#define CORRECT_CR_HANDLING
4255 4255
4256/* deprecated and no longer supported in gcc 3.3 */
4257#ifdef __TINYC__
4258# define ACCEPT_CR_IN_STRINGS
4259#endif
4260
4261/* keep this as the last test because GCC messes up line-numbers4256/* keep this as the last test because GCC messes up line-numbers
4262 with the ^L^K^M characters below */4257 with the ^L^K^M characters below */
4263void whitespace_test(void)4258void whitespace_test(void)
@@ -4279,20 +4274,6 @@ ntf("aaa=%d\n", 3); · 15 unmodified lines
4279\4274\
4280ntf("min=%d\n", 4);4275ntf("min=%d\n", 4);
4281 4276
4282#ifdef ACCEPT_CR_IN_STRINGS
4283 printf("len1=%d\n", strlen("
4284"));
4285#ifdef CORRECT_CR_HANDLING
4286 str = "
4287";
4288 printf("len1=%d str[0]=%d\n", strlen(str), str[0]);
4289#endif
4290 printf("len1=%d\n", strlen(" a
4291"));
4292#else
4293 printf("len1=1\nlen1=1 str[0]=10\nlen1=3\n");
4294#endif /* ACCEPT_CR_IN_STRINGS */
4295
4296#ifdef __LINE__4277#ifdef __LINE__
4297 printf("__LINE__ defined\n");4278 printf("__LINE__ defined\n");
4298#endif4279#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t