summarylogtreecommitdiffstats
path: root/04_build_with_gcc5.patch
blob: c45246d9c8036adb991c71cd8385b3c017008df5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Description: Fix ftbfs with GCC-5
Author: Jens Thiele <karme@karme.de>
Reviewed-by: NIIBE Yutaka <gniibe@fsij.org>
Bug-Debian: https://bugs.debian.org/777861
Last-Update: 2015-12-21

Index: gauche-c-wrapper-0.6.1/src/c-parser.c
===================================================================
Index: gauche-c-wrapper-0.6.1/src/c-parser.c
===================================================================
--- gauche-c-wrapper-0.6.1.orig/src/c-parser.c
+++ gauche-c-wrapper-0.6.1/src/c-parser.c
@@ -1668,6 +1668,8 @@ ScmObj Scm_ParseMacroCode(ScmObj in, Scm
 {
     static ScmObj trigger_line = SCM_FALSE;
     ScmObj line_str;
+    ScmObj next_line_str; /* one line look-ahead */
+    ScmObj skip_regex;
 
     /* skip the first line '# 1 "<stdin>"' */
     Scm_ReadLineUnsafe(SCM_PORT(in));
@@ -1682,17 +1684,35 @@ ScmObj Scm_ParseMacroCode(ScmObj in, Scm
         }
     }
 
-    while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) {
+    skip_regex = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^# [0-9]+ \"<stdin>\"")), 0);
+    line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
+    next_line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
+    while (!SCM_EOFP(line_str)) {
+        /* skip lines starting with "# [0-9]+ <stdin>" and join with following line */
+        while (!SCM_EOFP(next_line_str)
+               && (SCM_STRING_LENGTH(next_line_str) > 2)
+               && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(skip_regex), SCM_STRING(next_line_str)))) {
+            next_line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
+            if (!SCM_EOFP(next_line_str)) {
+                line_str = Scm_StringAppend2(SCM_STRING(line_str), SCM_STRING(next_line_str));
+                next_line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
+            }
+        }
         if (SCM_NULLP(macro_list)) {
-            Scm_Error("[bug] lost macro body");
+            Scm_Error("[bug] more cpp output than expected");
         } else {
             ScmObj pos_name_args = SCM_CDAR(macro_list);
             macro_list = SCM_CDR(macro_list);
             Scm_FilenameSet(SCM_CAAR(pos_name_args));
             Scm_LineNumberSet(SCM_INT_VALUE(SCM_CDAR(pos_name_args)));
             parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), line_str);
+            line_str = next_line_str;
+            next_line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
         }
     }
+    if (!(SCM_NULLP(macro_list))) {
+        Scm_Error("[bug] less cpp output than expected");
+    }
 
     SCM_RETURN(SCM_UNDEFINED);
 }