From 5ffbefc3fdd48838911d76e17459610525a7aeb7 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Fri, 21 May 1999 06:27:54 +0000 Subject: [PATCH] add retest, a regex testing program --- src/backend/regex/Makefile | 9 +++++++- src/backend/regex/retest.c | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/backend/regex/retest.c diff --git a/src/backend/regex/Makefile b/src/backend/regex/Makefile index 022f073164..1bea5617b6 100644 --- a/src/backend/regex/Makefile +++ b/src/backend/regex/Makefile @@ -14,9 +14,13 @@ include ../../Makefile.global CFLAGS += -I.. CFLAGS += -DPOSIX_MISTAKE +DEBUGOBJ = + OBJS = regcomp.o regerror.o regexec.o regfree.o + ifdef MULTIBYTE CFLAGS+= $(MBFLAGS) +DEBUGOBJ += ../utils/mb/SUBSYS.o endif all: SUBSYS.o @@ -24,11 +28,14 @@ all: SUBSYS.o SUBSYS.o: $(OBJS) $(LD) -r -o SUBSYS.o $(OBJS) +retest: retest.o SUBSYS.o $(DEBUGOBJ) + $(CC) -o retest retest.o SUBSYS.o $(DEBUGOBJ) + depend dep: $(CC) -MM $(CFLAGS) *.c >depend clean: - rm -f SUBSYS.o $(OBJS) + rm -f SUBSYS.o $(OBJS) retest retest.o ifeq (depend,$(wildcard depend)) include depend diff --git a/src/backend/regex/retest.c b/src/backend/regex/retest.c new file mode 100644 index 0000000000..7ab84be0d5 --- /dev/null +++ b/src/backend/regex/retest.c @@ -0,0 +1,42 @@ +/* + * a simple regexp debug program + * + * $Header$ + */ + +#include +#include +#include "postgres.h" +#include + +int main() +{ + int sts; + regex_t re; + char buf[1024]; + char *p; + + printf("type in regexp string: "); + if (!fgets(buf,sizeof(buf),stdin)) { + exit(0); + } + p = strchr(buf, '\n'); + if (p) *p = '\0'; + + sts = pg95_regcomp(&re, buf, 1); + printf("regcomp: parses \"%s\" and returns %d\n",buf, sts); + for (;;) { + printf("type in target string: "); + if (!fgets(buf,sizeof(buf),stdin)) { + exit(0); + } + p = strchr(buf, '\n'); + if (p) *p = '\0'; + + sts = pg95_regexec(&re, buf, 0, 0, 0); + printf("regexec: returns %d\n", sts); + } +} + +void elog(int lev, const char *fmt,...) +{} -- 2.39.5