main.c (8ca5c256cb0a0ac117493557f3fc397f68f16759) | main.c (8fb3f3f68288ae2b1b53dd65e3dd673d83c80f4c) |
---|---|
1/* $FreeBSD$ 2 */ 3#include <stdio.h> 4#include <string.h> 5#include <sys/types.h> 6#include <regex.h> 7#include <assert.h> 8 --- 23 unchanged lines hidden (view full) --- 32 regex_t re; 33# define NS 10 34 regmatch_t subs[NS]; 35 char erbuf[100]; 36 int err; 37 size_t len; 38 int c; 39 int errflg = 0; | 1/* $FreeBSD$ 2 */ 3#include <stdio.h> 4#include <string.h> 5#include <sys/types.h> 6#include <regex.h> 7#include <assert.h> 8 --- 23 unchanged lines hidden (view full) --- 32 regex_t re; 33# define NS 10 34 regmatch_t subs[NS]; 35 char erbuf[100]; 36 int err; 37 size_t len; 38 int c; 39 int errflg = 0; |
40 register int i; | 40 int i; |
41 extern int optind; 42 extern char *optarg; 43 44 progname = argv[0]; 45 46 while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF) 47 switch (c) { 48 case 'c': /* compile options */ --- 166 unchanged lines hidden (view full) --- 215 regmatch_t subs[NSUBS]; 216# define NSHOULD 15 217 char *should[NSHOULD]; 218 int nshould; 219 char erbuf[100]; 220 int err; 221 int len; 222 char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE"; | 41 extern int optind; 42 extern char *optarg; 43 44 progname = argv[0]; 45 46 while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF) 47 switch (c) { 48 case 'c': /* compile options */ --- 166 unchanged lines hidden (view full) --- 215 regmatch_t subs[NSUBS]; 216# define NSHOULD 15 217 char *should[NSHOULD]; 218 int nshould; 219 char erbuf[100]; 220 int err; 221 int len; 222 char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE"; |
223 register int i; | 223 int i; |
224 char *grump; 225 char f0copy[1000]; 226 char f2copy[1000]; 227 228 strcpy(f0copy, f0); 229 re.re_endp = (opts®_PEND) ? f0copy + strlen(f0copy) : NULL; 230 fixstr(f0copy); 231 err = regcomp(&re, f0copy, opts); --- 80 unchanged lines hidden (view full) --- 312 - options - pick options out of a regression-test string 313 == int options(int type, char *s); 314 */ 315int 316options(type, s) 317int type; /* 'c' compile, 'e' exec */ 318char *s; 319{ | 224 char *grump; 225 char f0copy[1000]; 226 char f2copy[1000]; 227 228 strcpy(f0copy, f0); 229 re.re_endp = (opts®_PEND) ? f0copy + strlen(f0copy) : NULL; 230 fixstr(f0copy); 231 err = regcomp(&re, f0copy, opts); --- 80 unchanged lines hidden (view full) --- 312 - options - pick options out of a regression-test string 313 == int options(int type, char *s); 314 */ 315int 316options(type, s) 317int type; /* 'c' compile, 'e' exec */ 318char *s; 319{ |
320 register char *p; 321 register int o = (type == 'c') ? copts : eopts; 322 register char *legal = (type == 'c') ? "bisnmp" : "^$#tl"; | 320 char *p; 321 int o = (type == 'c') ? copts : eopts; 322 char *legal = (type == 'c') ? "bisnmp" : "^$#tl"; |
323 324 for (p = s; *p != '\0'; p++) 325 if (strchr(legal, *p) != NULL) 326 switch (*p) { 327 case 'b': 328 o &= ~REG_EXTENDED; 329 break; 330 case 'i': --- 43 unchanged lines hidden (view full) --- 374int c; 375char *s; 376{ 377 return(strchr(s, c) != NULL); 378} 379 380/* 381 - fixstr - transform magic characters in strings | 323 324 for (p = s; *p != '\0'; p++) 325 if (strchr(legal, *p) != NULL) 326 switch (*p) { 327 case 'b': 328 o &= ~REG_EXTENDED; 329 break; 330 case 'i': --- 43 unchanged lines hidden (view full) --- 374int c; 375char *s; 376{ 377 return(strchr(s, c) != NULL); 378} 379 380/* 381 - fixstr - transform magic characters in strings |
382 == void fixstr(register char *p); | 382 == void fixstr(char *p); |
383 */ 384void 385fixstr(p) | 383 */ 384void 385fixstr(p) |
386register char *p; | 386char *p; |
387{ 388 if (p == NULL) 389 return; 390 391 for (; *p != '\0'; p++) 392 if (*p == 'N') 393 *p = '\n'; 394 else if (*p == 'T') --- 9 unchanged lines hidden (view full) --- 404 == char *check(char *str, regmatch_t sub, char *should); 405 */ 406char * /* NULL or complaint */ 407check(str, sub, should) 408char *str; 409regmatch_t sub; 410char *should; 411{ | 387{ 388 if (p == NULL) 389 return; 390 391 for (; *p != '\0'; p++) 392 if (*p == 'N') 393 *p = '\n'; 394 else if (*p == 'T') --- 9 unchanged lines hidden (view full) --- 404 == char *check(char *str, regmatch_t sub, char *should); 405 */ 406char * /* NULL or complaint */ 407check(str, sub, should) 408char *str; 409regmatch_t sub; 410char *should; 411{ |
412 register int len; 413 register int shlen; 414 register char *p; | 412 int len; 413 int shlen; 414 char *p; |
415 static char grump[500]; | 415 static char grump[500]; |
416 register char *at = NULL; | 416 char *at = NULL; |
417 418 if (should != NULL && strcmp(should, "-") == 0) 419 should = NULL; 420 if (should != NULL && should[0] == '@') { 421 at = should + 1; 422 should = ""; 423 } 424 --- 88 unchanged lines hidden --- | 417 418 if (should != NULL && strcmp(should, "-") == 0) 419 should = NULL; 420 if (should != NULL && should[0] == '@') { 421 at = should + 1; 422 should = ""; 423 } 424 --- 88 unchanged lines hidden --- |