attregex: make it build
authorMarko Kreen <markokr@gmail.com>
Wed, 15 Sep 2010 12:15:32 +0000 (15:15 +0300)
committerMarko Kreen <markokr@gmail.com>
Wed, 15 Sep 2010 12:15:32 +0000 (15:15 +0300)
test/attregex/Makefile [new file with mode: 0644]
test/attregex/run.sh [new file with mode: 0755]
test/attregex/testregex.c

diff --git a/test/attregex/Makefile b/test/attregex/Makefile
new file mode 100644 (file)
index 0000000..1b053fc
--- /dev/null
@@ -0,0 +1,21 @@
+
+CFLAGS = -O -g
+CPPFLAGS = -I../.. -DUSUAL -DUSE_INTERNAL_REGEX
+LDFLAGS = -g
+LIBS = ../libusual.a
+
+all: testregex.usual testregex.libc
+
+testregex.usual: testregex.o
+       $(CC) $(LDFLAGS) -o $@ $< $(LIBS)
+
+testregex.o: testregex.c
+       $(CC) $(DEFS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
+testregex.libc: testregex.c
+       $(CC)  $(CFLAGS) -o $@ $<
+
+
+clean:
+       rm -f testregex testregex.o testregex.usual testregex.libc
+
diff --git a/test/attregex/run.sh b/test/attregex/run.sh
new file mode 100755 (executable)
index 0000000..4da6e59
--- /dev/null
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+rxtest=./testregex.libc
+rxtest=./testregex.usual
+
+tests="basic.dat categorize.dat nullsubexpr.dat"
+tests="$tests rightassoc.dat"
+#tests="$tests leftassoc.dat"
+tests="$tests forcedassoc.dat"
+tests="$tests repetition.dat"
+
+for t in $tests; do
+  #printf "%-16s" "$t"
+  #$rxtest < data/$t | grep -vE '(NOTE|Research)'
+  $rxtest < data/$t | tail -n +5 | grep -vE 'haskell|mimi'
+done
+
+#$rxtest < data/categorize.dat | tail -n +4
+
index 2bc43d5dffedd47311ef183228d01d285aa2636a..a24d21c7eb643d82980d26afcded191aa1b4e8e5 100644 (file)
@@ -43,7 +43,6 @@ static const char id[] = "\n@(#)$Id: testregex (AT&T Research) 2009-11-11 $\0\n"
 #endif
 
 #include <stdio.h>
-#include <regex.h>
 #include <ctype.h>
 #include <setjmp.h>
 #include <signal.h>
@@ -55,6 +54,13 @@ static const char id[] = "\n@(#)$Id: testregex (AT&T Research) 2009-11-11 $\0\n"
 #include <locale.h>
 #endif
 
+#define getline(x) xgetline(x)
+#ifdef USUAL
+#include <usual/regex.h>
+#else
+#include <regex.h>
+#endif
+
 #if !_PACKAGE_ast
 #undef REG_DISCIPLINE
 #endif
@@ -1950,7 +1956,7 @@ main(int argc, char** argv)
                                                                else
                                                                {
                                                                        report("re_nsub incorrect", fun, re, NiL, -1, msg, flags, test);
-                                                                       printf("at least %d expected, %d returned\n", nsub, preg.re_nsub);
+                                                                       printf("at least %d expected, %d returned\n", nsub, (int)preg.re_nsub);
                                                                        state.errors++;
                                                                }
                                                        }