guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] guile-snarf: allow multiple init actions on one line


From: BT Templeton
Subject: Re: [PATCH] guile-snarf: allow multiple init actions on one line
Date: Tue, 22 Feb 2011 18:09:38 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Andy Wingo <address@hidden> writes:

> On Tue 22 Feb 2011 20:14, BT Templeton <address@hidden> writes:
>
>> Guile-SDL contains some cpp macros that define multiple subrs. To allow
>> that, this patch modifies guile-snarf to recognize more than one
>> initialization action per line, which is necessary because GNU's C
>> preprocessor removes newlines from macro expansions.
>
> Thanks for the patch.  I don't understand the sed; can some sedi master
> check this one to make sure it's compatible with guile-snarf as it is?

There is one significant difference: currently guile-snarf outputs any
lines containing "^^" markers but with "^^"/"^:^" deleted, whereas my
version outputs only text *between* "^^" … "^:^". This shouldn't affect
programs using the snarfing macros as intended, but a line like
"a;SCM_SNARF_INIT(b);" would result in the output "a;b;" with the
current version and "b;" with this patch applied.

> Ideally some tests would be nice, as well...

How's the attached patch look?

>From 4f7f85f0f8b62e471ee67d68a73d390b31f1d4b6 Mon Sep 17 00:00:00 2001
From: BT Templeton <address@hidden>
Date: Tue, 22 Feb 2011 15:15:33 -0500
Subject: [PATCH] add guile-snarf tests

* test-suite/standalone/test-guile-snarf: New file.
* test-suite/standalone/Makefile.am: Add `test-guile-snarf'.
---
 test-suite/standalone/Makefile.am      |    3 +++
 test-suite/standalone/test-guile-snarf |   21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
 create mode 100755 test-suite/standalone/test-guile-snarf

diff --git a/test-suite/standalone/Makefile.am 
b/test-suite/standalone/Makefile.am
index 861e668..0e9eaf7 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -66,6 +66,9 @@ TESTS += test-bad-identifiers
 check_SCRIPTS += test-require-extension
 TESTS += test-require-extension
 
+check_SCRIPTS += test-guile-snarf
+TESTS += test-guile-snarf
+
 # test-num2integral
 test_num2integral_SOURCES = test-num2integral.c
 test_num2integral_CFLAGS = ${test_cflags}
diff --git a/test-suite/standalone/test-guile-snarf 
b/test-suite/standalone/test-guile-snarf
new file mode 100755
index 0000000..032bfaa
--- /dev/null
+++ b/test-suite/standalone/test-guile-snarf
@@ -0,0 +1,21 @@
+#!/bin/sh
+snarf ()
+{
+    echo "$1" | guile-snarf - | tail -n +2 | tr -d ' \t\n'
+}
+
+snarf_test ()
+{
+    local x
+    x=$(snarf "$1")
+    if [ x"$x" != x"$2" ]; then
+        echo "Incorrect output: expected \"$2\", but got \"$x\""
+        exit 1
+    fi
+}
+
+snarf_test "^^a^:^" "a;"
+snarf_test "  ^  ^  b  ^  :  ^  " "b;"
+snarf_test "c\n^^d^:^\ne" "d;"
+snarf_test "f^^g^:^h" "g;"
+snarf_test "^^i^:^j^^k^:^" "i;k;"
-- 
1.7.2.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]