httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [PATCH] regex -Wall cleanup, take 2
Date Sun, 16 Feb 1997 04:00:48 GMT
Ok this one compiles cleanly under gcc -Wall on Linux 2.x, Solaris 2.5.1,
BSDI 2.1, IRIX 5.3 and 6.2.  (And with IRIX cc on 5.3 and 6.2.)

I've only run it on linux however.

Dean

Index: regex/cclass.h
===================================================================
RCS file: /export/home/cvs/apache/src/regex/cclass.h,v
retrieving revision 1.1
diff -c -3 -r1.1 cclass.h
*** cclass.h	1996/07/23 22:06:42	1.1
--- cclass.h	1997/02/16 03:53:23
***************
*** 4,31 ****
  	char *chars;
  	char *multis;
  } cclasses[] = {
! 	"alnum",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
! 0123456789",				"",
! 	"alpha",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
! 					"",
! 	"blank",	" \t",		"",
! 	"cntrl",	"\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
! \25\26\27\30\31\32\33\34\35\36\37\177",	"",
! 	"digit",	"0123456789",	"",
! 	"graph",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
  0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
! 					"",
! 	"lower",	"abcdefghijklmnopqrstuvwxyz",
! 					"",
! 	"print",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
  0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
! 					"",
! 	"punct",	"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
! 					"",
! 	"space",	"\t\n\v\f\r ",	"",
! 	"upper",	"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
! 					"",
! 	"xdigit",	"0123456789ABCDEFabcdef",
! 					"",
! 	NULL,		0,		""
  };
--- 4,31 ----
  	char *chars;
  	char *multis;
  } cclasses[] = {
! 	{ "alnum",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
! 0123456789",				"" },
! 	{ "alpha",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
! 					"" },
! 	{ "blank",	" \t",		"" },
! 	{ "cntrl",	"\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
! \25\26\27\30\31\32\33\34\35\36\37\177",	"" },
! 	{ "digit",	"0123456789",	"" },
! 	{ "graph",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
  0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
! 					"" },
! 	{ "lower",	"abcdefghijklmnopqrstuvwxyz",
! 					"" },
! 	{ "print",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
  0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
! 					"" },
! 	{ "punct",	"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
! 					"" },
! 	{ "space",	"\t\n\v\f\r ",	"" },
! 	{ "upper",	"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
! 					"" },
! 	{ "xdigit",	"0123456789ABCDEFabcdef",
! 					"" },
! 	{ NULL,		0,		"" }
  };
Index: regex/cname.h
===================================================================
RCS file: /export/home/cvs/apache/src/regex/cname.h,v
retrieving revision 1.1
diff -c -3 -r1.1 cname.h
*** cname.h	1996/07/23 22:06:43	1.1
--- cname.h	1997/02/16 03:53:23
***************
*** 3,102 ****
  	char *name;
  	char code;
  } cnames[] = {
! 	"NUL",	'\0',
! 	"SOH",	'\001',
! 	"STX",	'\002',
! 	"ETX",	'\003',
! 	"EOT",	'\004',
! 	"ENQ",	'\005',
! 	"ACK",	'\006',
! 	"BEL",	'\007',
! 	"alert",	'\007',
! 	"BS",		'\010',
! 	"backspace",	'\b',
! 	"HT",		'\011',
! 	"tab",		'\t',
! 	"LF",		'\012',
! 	"newline",	'\n',
! 	"VT",		'\013',
! 	"vertical-tab",	'\v',
! 	"FF",		'\014',
! 	"form-feed",	'\f',
! 	"CR",		'\015',
! 	"carriage-return",	'\r',
! 	"SO",	'\016',
! 	"SI",	'\017',
! 	"DLE",	'\020',
! 	"DC1",	'\021',
! 	"DC2",	'\022',
! 	"DC3",	'\023',
! 	"DC4",	'\024',
! 	"NAK",	'\025',
! 	"SYN",	'\026',
! 	"ETB",	'\027',
! 	"CAN",	'\030',
! 	"EM",	'\031',
! 	"SUB",	'\032',
! 	"ESC",	'\033',
! 	"IS4",	'\034',
! 	"FS",	'\034',
! 	"IS3",	'\035',
! 	"GS",	'\035',
! 	"IS2",	'\036',
! 	"RS",	'\036',
! 	"IS1",	'\037',
! 	"US",	'\037',
! 	"space",		' ',
! 	"exclamation-mark",	'!',
! 	"quotation-mark",	'"',
! 	"number-sign",		'#',
! 	"dollar-sign",		'$',
! 	"percent-sign",		'%',
! 	"ampersand",		'&',
! 	"apostrophe",		'\'',
! 	"left-parenthesis",	'(',
! 	"right-parenthesis",	')',
! 	"asterisk",	'*',
! 	"plus-sign",	'+',
! 	"comma",	',',
! 	"hyphen",	'-',
! 	"hyphen-minus",	'-',
! 	"period",	'.',
! 	"full-stop",	'.',
! 	"slash",	'/',
! 	"solidus",	'/',
! 	"zero",		'0',
! 	"one",		'1',
! 	"two",		'2',
! 	"three",	'3',
! 	"four",		'4',
! 	"five",		'5',
! 	"six",		'6',
! 	"seven",	'7',
! 	"eight",	'8',
! 	"nine",		'9',
! 	"colon",	':',
! 	"semicolon",	';',
! 	"less-than-sign",	'<',
! 	"equals-sign",		'=',
! 	"greater-than-sign",	'>',
! 	"question-mark",	'?',
! 	"commercial-at",	'@',
! 	"left-square-bracket",	'[',
! 	"backslash",		'\\',
! 	"reverse-solidus",	'\\',
! 	"right-square-bracket",	']',
! 	"circumflex",		'^',
! 	"circumflex-accent",	'^',
! 	"underscore",		'_',
! 	"low-line",		'_',
! 	"grave-accent",		'`',
! 	"left-brace",		'{',
! 	"left-curly-bracket",	'{',
! 	"vertical-line",	'|',
! 	"right-brace",		'}',
! 	"right-curly-bracket",	'}',
! 	"tilde",		'~',
! 	"DEL",	'\177',
! 	NULL,	0,
  };
--- 3,102 ----
  	char *name;
  	char code;
  } cnames[] = {
! 	{ "NUL",	'\0' },
! 	{ "SOH",	'\001' },
! 	{ "STX",	'\002' },
! 	{ "ETX",	'\003' },
! 	{ "EOT",	'\004' },
! 	{ "ENQ",	'\005' },
! 	{ "ACK",	'\006' },
! 	{ "BEL",	'\007' },
! 	{ "alert",	'\007' },
! 	{ "BS",		'\010' },
! 	{ "backspace",	'\b' },
! 	{ "HT",		'\011' },
! 	{ "tab",		'\t' },
! 	{ "LF",		'\012' },
! 	{ "newline",	'\n' },
! 	{ "VT",		'\013' },
! 	{ "vertical-tab",	'\v' },
! 	{ "FF",		'\014' },
! 	{ "form-feed",	'\f' },
! 	{ "CR",		'\015' },
! 	{ "carriage-return",	'\r' },
! 	{ "SO",	'\016' },
! 	{ "SI",	'\017' },
! 	{ "DLE",	'\020' },
! 	{ "DC1",	'\021' },
! 	{ "DC2",	'\022' },
! 	{ "DC3",	'\023' },
! 	{ "DC4",	'\024' },
! 	{ "NAK",	'\025' },
! 	{ "SYN",	'\026' },
! 	{ "ETB",	'\027' },
! 	{ "CAN",	'\030' },
! 	{ "EM",	'\031' },
! 	{ "SUB",	'\032' },
! 	{ "ESC",	'\033' },
! 	{ "IS4",	'\034' },
! 	{ "FS",	'\034' },
! 	{ "IS3",	'\035' },
! 	{ "GS",	'\035' },
! 	{ "IS2",	'\036' },
! 	{ "RS",	'\036' },
! 	{ "IS1",	'\037' },
! 	{ "US",	'\037' },
! 	{ "space",		' ' },
! 	{ "exclamation-mark",	'!' },
! 	{ "quotation-mark",	'"' },
! 	{ "number-sign",		'#' },
! 	{ "dollar-sign",		'$' },
! 	{ "percent-sign",		'%' },
! 	{ "ampersand",		'&' },
! 	{ "apostrophe",		'\'' },
! 	{ "left-parenthesis",	'(' },
! 	{ "right-parenthesis",	')' },
! 	{ "asterisk",	'*' },
! 	{ "plus-sign",	'+' },
! 	{ "comma",	',' },
! 	{ "hyphen",	'-' },
! 	{ "hyphen-minus",	'-' },
! 	{ "period",	'.' },
! 	{ "full-stop",	'.' },
! 	{ "slash",	'/' },
! 	{ "solidus",	'/' },
! 	{ "zero",		'0' },
! 	{ "one",		'1' },
! 	{ "two",		'2' },
! 	{ "three",	'3' },
! 	{ "four",		'4' },
! 	{ "five",		'5' },
! 	{ "six",		'6' },
! 	{ "seven",	'7' },
! 	{ "eight",	'8' },
! 	{ "nine",		'9' },
! 	{ "colon",	':' },
! 	{ "semicolon",	';' },
! 	{ "less-than-sign",	'<' },
! 	{ "equals-sign",		'=' },
! 	{ "greater-than-sign",	'>' },
! 	{ "question-mark",	'?' },
! 	{ "commercial-at",	'@' },
! 	{ "left-square-bracket",	'[' },
! 	{ "backslash",		'\\' },
! 	{ "reverse-solidus",	'\\' },
! 	{ "right-square-bracket",	']' },
! 	{ "circumflex",		'^' },
! 	{ "circumflex-accent",	'^' },
! 	{ "underscore",		'_' },
! 	{ "low-line",		'_' },
! 	{ "grave-accent",		'`' },
! 	{ "left-brace",		'{' },
! 	{ "left-curly-bracket",	'{' },
! 	{ "vertical-line",	'|' },
! 	{ "right-brace",		'}' },
! 	{ "right-curly-bracket",	'}' },
! 	{ "tilde",		'~' },
! 	{ "DEL",	'\177' },
! 	{ NULL,	0 }
  };
Index: regex/debug.c
===================================================================
RCS file: /export/home/cvs/apache/src/regex/debug.c,v
retrieving revision 1.1
diff -c -3 -r1.1 debug.c
*** debug.c	1996/07/23 22:06:43	1.1
--- debug.c	1997/02/16 03:53:23
***************
*** 216,222 ****
  			fprintf(d, ">");
  			break;
  		default:
! 			fprintf(d, "!%d(%d)!", OP(*s), opnd);
  			break;
  		}
  		if (!done)
--- 216,222 ----
  			fprintf(d, ">");
  			break;
  		default:
! 			fprintf(d, "!%ld(%ld)!", OP(*s), opnd);
  			break;
  		}
  		if (!done)
Index: regex/engine.c
===================================================================
RCS file: /export/home/cvs/apache/src/regex/engine.c,v
retrieving revision 1.1
diff -c -3 -r1.1 engine.c
*** engine.c	1996/07/23 22:06:44	1.1
--- engine.c	1997/02/16 03:53:23
***************
*** 75,82 ****
  	struct match mv;
  	register struct match *m = &mv;
  	register char *dp;
! 	const register sopno gf = g->firststate+1;	/* +1 for OEND */
! 	const register sopno gl = g->laststate;
  	char *start;
  	char *stop;
  
--- 75,82 ----
  	struct match mv;
  	register struct match *m = &mv;
  	register char *dp;
! 	register const sopno gf = g->firststate+1;	/* +1 for OEND */
! 	register const sopno gl = g->laststate;
  	char *start;
  	char *stop;
  
***************
*** 613,618 ****
--- 613,619 ----
  	/* "can't happen" */
  	assert(nope);
  	/* NOTREACHED */
+ 	return( NULL );
  }
  
  /*
Index: regex/main.c
===================================================================
RCS file: /export/home/cvs/apache/src/regex/main.c,v
retrieving revision 1.1
diff -c -3 -r1.1 main.c
*** main.c	1996/07/23 22:06:44	1.1
--- main.c	1997/02/16 03:53:23
***************
*** 3,8 ****
--- 3,9 ----
  #include <sys/types.h>
  #include <regex.h>
  #include <assert.h>
+ #include <stdlib.h>
  
  #include "main.ih"
  
***************
*** 23,29 ****
  /*
   - main - do the simple case, hand off to regress() for regression
   */
! main(argc, argv)
  int argc;
  char *argv[];
  {
--- 24,30 ----
  /*
   - main - do the simple case, hand off to regress() for regression
   */
! int main(argc, argv)
  int argc;
  char *argv[];
  {
***************
*** 499,505 ****
  char *name;
  {
  	static char efbuf[100];
- 	size_t n;
  	regex_t re;
  
  	sprintf(efbuf, "REG_%s", name);
--- 500,505 ----
Index: regex/regcomp.c
===================================================================
RCS file: /export/home/cvs/apache/src/regex/regcomp.c,v
retrieving revision 1.2
diff -c -3 -r1.2 regcomp.c
*** regcomp.c	1997/01/25 22:38:29	1.2
--- regcomp.c	1997/02/16 03:53:23
***************
*** 51,57 ****
  #define	NEXTn(n)	(p->next += (n))
  #define	GETNEXT()	(*p->next++)
  #define	SETERROR(e)	seterr(p, (e))
! #define	REQUIRE(co, e)	((co) || SETERROR(e))
  #define	MUSTSEE(c, e)	(REQUIRE(MORE() && PEEK() == (c), e))
  #define	MUSTEAT(c, e)	(REQUIRE(MORE() && GETNEXT() == (c), e))
  #define	MUSTNOTSEE(c, e)	(REQUIRE(!MORE() || PEEK() != (c), e))
--- 51,57 ----
  #define	NEXTn(n)	(p->next += (n))
  #define	GETNEXT()	(*p->next++)
  #define	SETERROR(e)	seterr(p, (e))
! #define	REQUIRE(co, e)	((void)((co) || SETERROR(e)))
  #define	MUSTSEE(c, e)	(REQUIRE(MORE() && PEEK() == (c), e))
  #define	MUSTEAT(c, e)	(REQUIRE(MORE() && GETNEXT() == (c), e))
  #define	MUSTNOTSEE(c, e)	(REQUIRE(!MORE() || PEEK() != (c), e))
***************
*** 192,199 ****
  int stop;			/* character this ERE should end at */
  {
  	register char c;
! 	register sopno prevback;
! 	register sopno prevfwd;
  	register sopno conc;
  	register int first = 1;		/* is this the first alternative? */
  
--- 192,199 ----
  int stop;			/* character this ERE should end at */
  {
  	register char c;
! 	register sopno prevback = 0;
! 	register sopno prevfwd = 0;
  	register sopno conc;
  	register int first = 1;		/* is this the first alternative? */
  
***************
*** 580,586 ****
  p_bracket(p)
  register struct parse *p;
  {
- 	register char c;
  	register cset *cs = allocset(p);
  	register int invert = 0;
  
--- 580,585 ----
***************
*** 796,802 ****
  	register char *sp = p->next;
  	register struct cname *cp;
  	register int len;
- 	register char c;
  
  	while (MORE() && !SEETWO(endc, ']'))
  		NEXT1();
--- 795,800 ----
***************
*** 1171,1233 ****
  	cs->multis[cs->smultis - 1] = '\0';
  }
  
- /*
-  - mcsub - subtract a collating element from a cset
-  == static void mcsub(register cset *cs, register char *cp);
-  */
- static void
- mcsub(cs, cp)
- register cset *cs;
- register char *cp;
- {
- 	register char *fp = mcfind(cs, cp);
- 	register size_t len = strlen(fp);
- 
- 	assert(fp != NULL);
- 	(void) memmove(fp, fp + len + 1,
- 				cs->smultis - (fp + len + 1 - cs->multis));
- 	cs->smultis -= len;
- 
- 	if (cs->smultis == 0) {
- 		free(cs->multis);
- 		cs->multis = NULL;
- 		return;
- 	}
- 
- 	cs->multis = realloc(cs->multis, cs->smultis);
- 	assert(cs->multis != NULL);
- }
- 
- /*
-  - mcin - is a collating element in a cset?
-  == static int mcin(register cset *cs, register char *cp);
-  */
- static int
- mcin(cs, cp)
- register cset *cs;
- register char *cp;
- {
- 	return(mcfind(cs, cp) != NULL);
- }
- 
- /*
-  - mcfind - find a collating element in a cset
-  == static char *mcfind(register cset *cs, register char *cp);
-  */
- static char *
- mcfind(cs, cp)
- register cset *cs;
- register char *cp;
- {
- 	register char *p;
- 
- 	if (cs->multis == NULL)
- 		return(NULL);
- 	for (p = cs->multis; *p != '\0'; p += strlen(p) + 1)
- 		if (strcmp(cp, p) == 0)
- 			return(p);
- 	return(NULL);
- }
  
  /*
   - mcinvert - invert the list of collating elements in a cset
--- 1169,1174 ----
***************
*** 1497,1504 ****
  register struct re_guts *g;
  {
  	register sop *scan;
! 	sop *start;
! 	register sop *newstart;
  	register sopno newlen;
  	register sop s;
  	register char *cp;
--- 1438,1445 ----
  register struct re_guts *g;
  {
  	register sop *scan;
! 	sop *start = NULL;
! 	register sop *newstart = NULL;
  	register sopno newlen;
  	register sop s;
  	register char *cp;
Index: regex/regerror.c
===================================================================
RCS file: /export/home/cvs/apache/src/regex/regerror.c,v
retrieving revision 1.1
diff -c -3 -r1.1 regerror.c
*** regerror.c	1996/07/23 22:06:45	1.1
--- regerror.c	1997/02/16 03:53:23
***************
*** 34,56 ****
  	char *name;
  	char *explain;
  } rerrs[] = {
! 	REG_NOMATCH,	"REG_NOMATCH",	"regexec() failed to match",
! 	REG_BADPAT,	"REG_BADPAT",	"invalid regular expression",
! 	REG_ECOLLATE,	"REG_ECOLLATE",	"invalid collating element",
! 	REG_ECTYPE,	"REG_ECTYPE",	"invalid character class",
! 	REG_EESCAPE,	"REG_EESCAPE",	"trailing backslash (\\)",
! 	REG_ESUBREG,	"REG_ESUBREG",	"invalid backreference number",
! 	REG_EBRACK,	"REG_EBRACK",	"brackets ([ ]) not balanced",
! 	REG_EPAREN,	"REG_EPAREN",	"parentheses not balanced",
! 	REG_EBRACE,	"REG_EBRACE",	"braces not balanced",
! 	REG_BADBR,	"REG_BADBR",	"invalid repetition count(s)",
! 	REG_ERANGE,	"REG_ERANGE",	"invalid character range",
! 	REG_ESPACE,	"REG_ESPACE",	"out of memory",
! 	REG_BADRPT,	"REG_BADRPT",	"repetition-operator operand invalid",
! 	REG_EMPTY,	"REG_EMPTY",	"empty (sub)expression",
! 	REG_ASSERT,	"REG_ASSERT",	"\"can't happen\" -- you found a bug",
! 	REG_INVARG,	"REG_INVARG",	"invalid argument to regex routine",
! 	0,		"",		"*** unknown regexp error code ***",
  };
  
  /*
--- 34,56 ----
  	char *name;
  	char *explain;
  } rerrs[] = {
! 	{ REG_NOMATCH,	"REG_NOMATCH",	"regexec() failed to match" },
! 	{ REG_BADPAT,	"REG_BADPAT",	"invalid regular expression" },
! 	{ REG_ECOLLATE,	"REG_ECOLLATE",	"invalid collating element" },
! 	{ REG_ECTYPE,	"REG_ECTYPE",	"invalid character class" },
! 	{ REG_EESCAPE,	"REG_EESCAPE",	"trailing backslash (\\)" },
! 	{ REG_ESUBREG,	"REG_ESUBREG",	"invalid backreference number" },
! 	{ REG_EBRACK,	"REG_EBRACK",	"brackets ([ ]) not balanced" },
! 	{ REG_EPAREN,	"REG_EPAREN",	"parentheses not balanced" },
! 	{ REG_EBRACE,	"REG_EBRACE",	"braces not balanced" },
! 	{ REG_BADBR,	"REG_BADBR",	"invalid repetition count(s)" },
! 	{ REG_ERANGE,	"REG_ERANGE",	"invalid character range" },
! 	{ REG_ESPACE,	"REG_ESPACE",	"out of memory" },
! 	{ REG_BADRPT,	"REG_BADRPT",	"repetition-operator operand invalid" },
! 	{ REG_EMPTY,	"REG_EMPTY",	"empty (sub)expression" },
! 	{ REG_ASSERT,	"REG_ASSERT",	"\"can't happen\" -- you found a bug" },
! 	{ REG_INVARG,	"REG_INVARG",	"invalid argument to regex routine" },
! 	{ 0,		"",		"*** unknown regexp error code ***" }
  };
  
  /*
***************
*** 112,119 ****
  char *localbuf;
  {
  	register struct rerr *r;
- 	register size_t siz;
- 	register char *p;
  
  	for (r = rerrs; r->code != 0; r++)
  		if (strcmp(r->name, preg->re_endp) == 0)
--- 112,117 ----
Index: regex/regex2.h
===================================================================
RCS file: /export/home/cvs/apache/src/regex/regex2.h,v
retrieving revision 1.2
diff -c -3 -r1.2 regex2.h
*** regex2.h	1996/07/24 13:52:27	1.2
--- regex2.h	1997/02/16 03:53:23
***************
*** 91,98 ****
  #define	CHsub(cs, c)	((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
  #define	CHIN(cs, c)	((cs)->ptr[(uch)(c)] & (cs)->mask)
  #define	MCadd(p, cs, cp)	mcadd(p, cs, cp)	/* regcomp() internal fns */
- #define	MCsub(p, cs, cp)	mcsub(p, cs, cp)
- #define	MCin(p, cs, cp)	mcin(p, cs, cp)
  
  /* stuff for character categories */
  typedef unsigned char cat_t;
--- 91,96 ----
Index: regex/regexec.c
===================================================================
RCS file: /export/home/cvs/apache/src/regex/regexec.c,v
retrieving revision 1.1
diff -c -3 -r1.1 regexec.c
*** regexec.c	1996/07/23 22:06:47	1.1
--- regexec.c	1997/02/16 03:53:23
***************
*** 16,22 ****
--- 16,24 ----
  #include "utils.h"
  #include "regex2.h"
  
+ #ifndef NDEBUG
  static int nope = 0;		/* for use in asserts; shuts lint up */
+ #endif
  
  /* macros for manipulating states, small version */
  #define	states	long


Mime
View raw message