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
944944 }
945945 }
946946 } else if (c == '\n') {
947− file->line_num++;
948− goto add_char;
947+ tcc_error("missing terminating %c character",sep);
949948 } else if (c == '\r') {
950949 PEEKC_EOB(c, p);
951950 if (c != '\n') {
952951 if (str)
953952 cstr_ccat(str, '\r');
954953 } else {
955− file->line_num++;
956− goto add_char;
954+ tcc_error("missing terminating %c character",sep);
957955 }
958956 } else {
959− add_char:
960957 if (str)
961958 cstr_ccat(str, c);
962959 p++;
tests/tcctest.c+0−19
@@ -4253,11 +4253,6 @@ void func_arg_test(void) · 4252 unmodified lines
42534253 /* gcc 2.95.3 does not handle correctly CR in strings or after strays */
42544254 #define CORRECT_CR_HANDLING
42554255
4256−/* deprecated and no longer supported in gcc 3.3 */
4257−#ifdef __TINYC__
4258−# define ACCEPT_CR_IN_STRINGS
4259−#endif
4260−
42614256 /* keep this as the last test because GCC messes up line-numbers
42624257 with the ^L^K^M characters below */
42634258 void whitespace_test(void)
@@ -4279,20 +4274,6 @@ ntf("aaa=%d\n", 3); · 15 unmodified lines
42794274 \
42804275 ntf("min=%d\n", 4);
42814276
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−
42964277 #ifdef __LINE__
42974278 printf("__LINE__ defined\n");
42984279 #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