From e588b65390bcfadabfb00c32ae0bfee12a8a8002 Mon Sep 17 00:00:00 2001
From: Ziyao <tswuyin_st127@163.com>
Date: Wed, 13 Jul 2022 15:43:26 +0800
Subject: [PATCH] Fix wrong handling of strings which do not end properly at
 the end of line

---
 tccpp.c         |  7 ++-----
 tests/tcctest.c | 19 -------------------
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/tccpp.c b/tccpp.c
index 25654b20..f070640c 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -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++;
diff --git a/tests/tcctest.c b/tests/tcctest.c
index e969c765..f7fbd656 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -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