summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libguile/guile-snarf.in15
-rw-r--r--libguile/snarf.h8
-rwxr-xr-xtest-suite/standalone/test-guile-snarf2
3 files changed, 23 insertions, 2 deletions
diff --git a/libguile/guile-snarf.in b/libguile/guile-snarf.in
index a1aeba577..c73e8ce1e 100644
--- a/libguile/guile-snarf.in
+++ b/libguile/guile-snarf.in
@@ -51,7 +51,20 @@ modern_snarf () # writes stdout
## empty file.
echo "/* cpp arguments: $@ */" ;
${cpp} -DSCM_MAGIC_SNARF_INITS -DSCM_MAGIC_SNARFER "$@" > ${temp} && cpp_ok_p=true
- sed -ne "s/ *\^ *: *\^/\n/;s/[^\n]*\^ *\^ *\([^\n]*\)/\1;/;tx;d;:x;P;D" ${temp}
+ sed -ne 's/ *\^ *: *\^/\
+/
+h
+s/\n.*//
+t x
+d
+: x
+s/.*\^ *\^ *\(.*\)/\1;/
+t y
+d
+: y
+p
+x
+D' ${temp}
}
## main
diff --git a/libguile/snarf.h b/libguile/snarf.h
index 9bb998eb0..7d22a3617 100644
--- a/libguile/snarf.h
+++ b/libguile/snarf.h
@@ -53,11 +53,17 @@
* The SCM_SNARF_INIT text goes into the corresponding .x file
* up through the first occurrence of SCM_SNARF_DOC_START on that
* line, if any.
+ *
+ * Some debugging options can cause the preprocessor to echo #define
+ * directives to its output. Keeping the snarfing markers on separate
+ * lines prevents guile-snarf from inadvertently snarfing the definition
+ * of SCM_SNARF_INIT if those options are in effect.
*/
#ifdef SCM_MAGIC_SNARF_INITS
# define SCM_SNARF_HERE(X)
-# define SCM_SNARF_INIT(X) ^^ X ^:^
+# define SCM_SNARF_INIT_PREFIX ^^
+# define SCM_SNARF_INIT(X) SCM_SNARF_INIT_PREFIX X ^:^
# define SCM_SNARF_DOCS(TYPE, CNAME, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING)
#else
# ifdef SCM_MAGIC_SNARF_DOCS
diff --git a/test-suite/standalone/test-guile-snarf b/test-suite/standalone/test-guile-snarf
index 78d35ea16..41a9dc64a 100755
--- a/test-suite/standalone/test-guile-snarf
+++ b/test-suite/standalone/test-guile-snarf
@@ -18,3 +18,5 @@ snarf_test " ^ ^ b ^ : ^ " "b;"
snarf_test "c\n^^d^:^\ne" "d;"
snarf_test "f^^g^:^h" "g;"
snarf_test "^^i^:^j^^k^:^" "i;k;"
+snarf_test "l^^m" ""
+snarf_test "n^:^o" ""