[Pkg-gauche-devel] Bug#777861: gauche-c-wrapper: ftbfs with GCC-5

Jens Thiele karme at karme.de
Fri Nov 6 10:14:47 UTC 2015


Matthias Klose <doko at debian.org> writes:

> you could use -P, or fix the parsing.

a first minimal hackish patch (not using -P)
likely this is not really good enough yet (but yes it compiles and
passes the tests)

Maybe a version using -P just using the last n lines of the cpp output
would be better?

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,7 @@ ScmObj Scm_ParseMacroCode(ScmObj in, Scm
 {
     static ScmObj trigger_line = SCM_FALSE;
     ScmObj line_str;
+    ScmObj next_line_str; /* one line look-ahead */
 
     /* skip the first line '# 1 "<stdin>"' */
     Scm_ReadLineUnsafe(SCM_PORT(in));
@@ -1682,7 +1683,20 @@ ScmObj Scm_ParseMacroCode(ScmObj in, Scm
         }
     }
 
-    while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) {
+    line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
+    next_line_str = Scm_ReadLineUnsafe(SCM_PORT(in));
+    while (!SCM_EOFP(line_str)) {
+        /* skip lines starting with "# " and join with following line */
+        while (!SCM_EOFP(next_line_str)
+               && (SCM_STRING_LENGTH(next_line_str)>2)
+               && (Scm_StringRef(SCM_STRING(next_line_str),0,0)==35)
+               && (Scm_StringRef(SCM_STRING(next_line_str),1,0)==32)) {
+            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");
         } else {
@@ -1691,6 +1705,8 @@ ScmObj Scm_ParseMacroCode(ScmObj in, Scm
             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));
         }
     }
 



More information about the Pkg-gauche-devel mailing list