|
From: Andre R. <and...@us...> - 2006-02-08 21:24:06
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22592 Modified Files: langregexp.c Log Message: Eliminated Xcode 1.5 compiler warning about uninitialized variable, probably indicative of an actual bug. Index: langregexp.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langregexp.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** langregexp.c 11 Jan 2005 22:48:07 -0000 1.9 --- langregexp.c 8 Feb 2006 21:23:55 -0000 1.10 *************** *** 1294,1304 **** static int regexpstringnumberfrompattern (const char *cptr, int len, Handle hcp) { ! int res, top, mid, bot, entrysize, c; unsigned char *entry, *nametable; ! res = pcre_fullinfo (getpatternref (hcp), nil, PCRE_INFO_NAMECOUNT, (void *) &top); if (res == 0) ! res = pcre_fullinfo (getpatternref (hcp), nil, PCRE_INFO_NAMEENTRYSIZE, (void *) &entrysize); if (res == 0) --- 1294,1310 ---- static int regexpstringnumberfrompattern (const char *cptr, int len, Handle hcp) { ! /* ! 2006-02-08 aradke: rewrote conditional logic in loop body. the previous version ! may have yielded incorrect results if one of the two strings that are compared ! in the loop is the leading substring of the other, e.g. "spam" and "spamalot". ! */ ! ! int res, top, mid, bot, entrysize, elen, c; unsigned char *entry, *nametable; ! res = pcre_fullinfo (getpatternref (hcp), nil, PCRE_INFO_NAMECOUNT, (void *) &top); /* number of entries in table */ if (res == 0) ! res = pcre_fullinfo (getpatternref (hcp), nil, PCRE_INFO_NAMEENTRYSIZE, (void *) &entrysize); /* length of longest entry in table */ if (res == 0) *************** *** 1313,1331 **** while (top > bot) { ! mid = (top + bot) / 2; ! ! entry = nametable + entrysize * mid; ! ! if (strlen ((char *)(entry + 2)) == len) ! c = memcmp (cptr, (char *)(entry + 2), len); ! ! if (c == 0) { ! return (entry[0] << 8) + entry[1]; ! } ! if (c > 0) ! bot = mid + 1; ! else ! top = mid; } --- 1319,1340 ---- while (top > bot) { ! mid = (top + bot) / 2; ! entry = nametable + entrysize * mid; ! ! elen = strlen ((char *)(entry + 2)); ! ! c = memcmp (cptr, (char *)(entry + 2), min(len, elen)); ! ! if (c < 0) /* 2006-02-08 aradke */ ! top = mid; ! else if (c > 0) ! bot = mid + 1; ! else if (elen > len) /* implicitely c == 0 from here on... */ ! top = mid; /* shorter entries are lower in table */ ! else if (elen < len) ! bot = mid + 1; /* longer entries are higher in table */ ! else ! return (entry[0] << 8) + entry[1]; /* implicitly c == 0 and elen == len, i.e. named pattern found */ } |