Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 08bcc77

Browse files
committed
add retest, a regex testing program
1 parent 56b9a54 commit 08bcc77

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/backend/regex/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for regex
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/regex/Makefile,v 1.8 1998/07/26 04:30:34 scrappy Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/regex/Makefile,v 1.9 1999/05/21 06:27:54 ishii Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -14,21 +14,28 @@ include ../../Makefile.global
1414
CFLAGS += -I..
1515
CFLAGS += -DPOSIX_MISTAKE
1616

17+
DEBUGOBJ =
18+
1719
OBJS = regcomp.o regerror.o regexec.o regfree.o
20+
1821
ifdef MULTIBYTE
1922
CFLAGS+= $(MBFLAGS)
23+
DEBUGOBJ += ../utils/mb/SUBSYS.o
2024
endif
2125

2226
all: SUBSYS.o
2327

2428
SUBSYS.o: $(OBJS)
2529
$(LD) -r -o SUBSYS.o $(OBJS)
2630

31+
retest: retest.o SUBSYS.o $(DEBUGOBJ)
32+
$(CC) -o retest retest.o SUBSYS.o $(DEBUGOBJ)
33+
2734
depend dep:
2835
$(CC) -MM $(CFLAGS) *.c >depend
2936

3037
clean:
31-
rm -f SUBSYS.o $(OBJS)
38+
rm -f SUBSYS.o $(OBJS) retest retest.o
3239

3340
ifeq (depend,$(wildcard depend))
3441
include depend

src/backend/regex/retest.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* a simple regexp debug program
3+
*
4+
* $Header: /cvsroot/pgsql/src/backend/regex/Attic/retest.c,v 1.1 1999/05/21 06:27:54 ishii Exp $
5+
*/
6+
7+
#include <stdio.h>
8+
#include <string.h>
9+
#include "postgres.h"
10+
#include <regex/regex.h>
11+
12+
int main()
13+
{
14+
int sts;
15+
regex_t re;
16+
char buf[1024];
17+
char *p;
18+
19+
printf("type in regexp string: ");
20+
if (!fgets(buf,sizeof(buf),stdin)) {
21+
exit(0);
22+
}
23+
p = strchr(buf, '\n');
24+
if (p) *p = '\0';
25+
26+
sts = pg95_regcomp(&re, buf, 1);
27+
printf("regcomp: parses \"%s\" and returns %d\n",buf, sts);
28+
for (;;) {
29+
printf("type in target string: ");
30+
if (!fgets(buf,sizeof(buf),stdin)) {
31+
exit(0);
32+
}
33+
p = strchr(buf, '\n');
34+
if (p) *p = '\0';
35+
36+
sts = pg95_regexec(&re, buf, 0, 0, 0);
37+
printf("regexec: returns %d\n", sts);
38+
}
39+
}
40+
41+
void elog(int lev, const char *fmt,...)
42+
{}

0 commit comments

Comments
 (0)