Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/src/cmd/upas/send/regtest.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#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> ");
	}
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].