Browse code

avoid name collisions on AIX (bb #947) sync with libc: minor cleanups

git-svn: trunk@3842

Török Edvin authored on 2008/05/09 20:58:17
Showing 4 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri May  9 13:58:27 EEST 2008 (edwin)
2
+-------------------------------------
3
+  * libclamav/regex: avoid name collisions on AIX (bb #947)
4
+                     sync with libc: minor cleanups 
5
+
1 6
 Wed May  7 11:51:54 CEST 2008 (tk)
2 7
 ----------------------------------
3 8
   * clamscan: new switches --structured-ssn-format, --structured-ssn-count,
... ...
@@ -240,7 +240,7 @@ cli_regcomp(regex_t *preg, const char *pattern, int cflags)
240 240
 	preg->re_magic = MAGIC1;
241 241
 #ifndef REDEBUG
242 242
 	/* not debugging, so can't rely on the assert() in cli_regexec() */
243
-	if (g->iflags&BAD)
243
+	if (g->iflags&REGEX_BAD)
244 244
 		SETERROR(REG_ASSERT);
245 245
 #endif
246 246
 
... ...
@@ -1059,8 +1059,8 @@ allocset(struct parse *p)
1059 1059
 
1060 1060
 		(void) memset((char *)p->g->setbits + (nbytes - css), 0, css);
1061 1061
 	}
1062
-
1063
-	if(!p->g->sets || !p->g->setbits)
1062
+	/* XXX should not happen */
1063
+	if (p->g->sets == NULL || p->g->setbits == NULL)
1064 1064
 		goto nomem;
1065 1065
 
1066 1066
 	cs = &p->g->sets[no];
... ...
@@ -1177,10 +1177,7 @@ mcadd( struct parse *p, cset *cs, const char *cp)
1177 1177
 	void *np;
1178 1178
 
1179 1179
 	cs->smultis += strlen(cp) + 1;
1180
-	if (cs->multis == NULL)
1181
-		np = cli_malloc(cs->smultis);
1182
-	else
1183
-		np = cli_realloc(cs->multis, cs->smultis);
1180
+	np = cli_realloc(cs->multis, cs->smultis);
1184 1181
 	if (np == NULL) {
1185 1182
 		if (cs->multis)
1186 1183
 			free(cs->multis);
... ...
@@ -1423,8 +1420,8 @@ static void
1423 1423
 findmust(struct parse *p, struct re_guts *g)
1424 1424
 {
1425 1425
 	sop *scan;
1426
-	sop *start;
1427
-	sop *newstart;
1426
+	sop *start;    /* start initialized in the default case, after that */
1427
+	sop *newstart; /* newstart was initialized in the OCHAR case */
1428 1428
 	sopno newlen;
1429 1429
 	sop s;
1430 1430
 	char *cp;
... ...
@@ -1458,7 +1455,7 @@ findmust(struct parse *p, struct re_guts *g)
1458 1458
 				/* assert() interferes w debug printouts */
1459 1459
 				if (OP(s) != O_QUEST && OP(s) != O_CH &&
1460 1460
 							OP(s) != OOR2) {
1461
-					g->iflags |= BAD;
1461
+					g->iflags |= REGEX_BAD;
1462 1462
 					return;
1463 1463
 				}
1464 1464
 			} while (OP(s) != O_QUEST && OP(s) != O_CH);
... ...
@@ -1523,6 +1520,6 @@ pluscount(struct parse *p, struct re_guts *g)
1523 1523
 		}
1524 1524
 	} while (OP(s) != OEND);
1525 1525
 	if (plusnest != 0)
1526
-		g->iflags |= BAD;
1526
+		g->iflags |= REGEX_BAD;
1527 1527
 	return(maxnest);
1528 1528
 }
... ...
@@ -138,7 +138,7 @@ struct re_guts {
138 138
 	int iflags;		/* internal flags */
139 139
 #		define	USEBOL	01	/* used ^ */
140 140
 #		define	USEEOL	02	/* used $ */
141
-#		define	BAD	04	/* something wrong */
141
+#		define	REGEX_BAD	04	/* something wrong */
142 142
 	int nbol;		/* number of ^ used */
143 143
 	int neol;		/* number of $ used */
144 144
 	int ncategories;	/* how many character categories */
... ...
@@ -150,8 +150,8 @@ cli_regexec(const regex_t *preg, const char *string, size_t nmatch,
150 150
 
151 151
 	if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
152 152
 		return(REG_BADPAT);
153
-	assert(!(g->iflags&BAD));
154
-	if (g->iflags&BAD)		/* backstop for no-debug case */
153
+	assert(!(g->iflags&REGEX_BAD));
154
+	if (g->iflags&REGEX_BAD)		/* backstop for no-debug case */
155 155
 		return(REG_BADPAT);
156 156
 	eflags = GOODFLAGS(eflags);
157 157