|
From: <and...@us...> - 2006-04-02 20:30:00
|
Revision: 1184 Author: andreradke Date: 2006-04-02 13:29:38 -0700 (Sun, 02 Apr 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1184&view=rev Log Message: ----------- Fixed bug in textpatternmatch in strings.c where it would fail to locate a match if the search pattern was longer than 129 characters. [bug #1463056] Modified Paths: -------------- Frontier/trunk/Common/source/strings.c Modified: Frontier/trunk/Common/source/strings.c =================================================================== --- Frontier/trunk/Common/source/strings.c 2006-04-02 17:36:48 UTC (rev 1183) +++ Frontier/trunk/Common/source/strings.c 2006-04-02 20:29:38 UTC (rev 1184) @@ -1707,15 +1707,21 @@ this uses an algorithm attributed to Boyer-Moore, I believe. it uses cryptic macros above to support case-insensitivity with maximum performance. + + 2006-04-02 aradke: The search failed when the pattern was longer than 129 chars + because the jump table for the Boyer-Moore algorithm was defined as an array + of signed chars, causing an overflow for jump distances larger than 129 chars. + The fix is to define the jump table as an array of signed longs instead. [bug #1463056] + http://sourceforge.net/tracker/index.php?func=detail&aid=1463056&group_id=120666&atid=687798 */ register byte *p = ptext; byte *pend = p + lentext; byte *psave; - short i; - short dist; - short lenpattern; - char jump [256]; + long i; + long dist; + long lenpattern; + long jump [256]; boolean flcase = !flunicase; ptrstring bspattern = bsfind; #define checklower(c) (flcase? (c) : getlower (c)) @@ -1724,7 +1730,8 @@ /*fill in the jump array according to the characters in the search pattern*/ - fillchar (jump, (long) 256, (byte) lenpattern); + for (i = 0; i <= 255; i++) + jump [i] = lenpattern; for (i = 1; i <= lenpattern; i++) jump [bspattern [i]] = 1 - i; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |