summaryrefslogtreecommitdiffstats
path: root/src/cmd/upas/send/regtest.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-10-29 16:26:44 +0000
committerrsc <devnull@localhost>2005-10-29 16:26:44 +0000
commit5cdb17983ae6e6367ad7a940cb219eab247a9304 (patch)
tree8ca1ef49af2a96e7daebe624d91fdf679814a057 /src/cmd/upas/send/regtest.c
parentcd3745196389579fb78b9b01ef1daefb5a57aa71 (diff)
downloadplan9port-5cdb17983ae6e6367ad7a940cb219eab247a9304.tar.gz
plan9port-5cdb17983ae6e6367ad7a940cb219eab247a9304.zip
Thanks to John Cummings.
Diffstat (limited to 'src/cmd/upas/send/regtest.c')
-rw-r--r--src/cmd/upas/send/regtest.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cmd/upas/send/regtest.c b/src/cmd/upas/send/regtest.c
new file mode 100644
index 00000000..52e31258
--- /dev/null
+++ b/src/cmd/upas/send/regtest.c
@@ -0,0 +1,36 @@
+#include <u.h>
+#include <libc.h>
+#include <regexp.h>
+#include <bio.h>
+
+main(void)
+{
+ char *re;
+ char *line;
+ Reprog *prog;
+ char *cp;
+ Biobuf in;
+
+ Binit(&in, 0, OREAD);
+ print("re> ");
+ while(re = Brdline(&in, '\n')){
+ re[Blinelen(&in)-1] = 0;
+ if(*re == 0)
+ break;
+ prog = regcomp(re);
+ print("> ");
+ while(line = Brdline(&in, '\n')){
+ line[Blinelen(&in)-1] = 0;
+ if(cp = strchr(line, '\n'))
+ *cp = 0;
+ if(*line == 0)
+ break;
+ if(regexec(prog, line, 0))
+ print("yes\n");
+ else
+ print("no\n");
+ print("> ");
+ }
+ print("re> ");
+ }
+}