Index: ChangeLog =================================================================== RCS file: /cvsroot/grep/grep/ChangeLog,v retrieving revision 1.204 diff -u -p -r1.204 ChangeLog --- ChangeLog 22 Nov 2004 13:40:56 -0000 1.204 +++ ChangeLog 22 Nov 2004 16:47:35 -0000 @@ -1,5 +1,9 @@ 2004-11-22 Stepan Kasal
+ * src/search.c (EGexecute, Fexecute): Clean up the fail code. + +2004-11-22 Stepan Kasal + * src/search.c: Use mbsupport.h . * src/dfa.c: Move the inclusion of mbsupport.h lower. Index: src/search.c =================================================================== RCS file: /cvsroot/grep/grep/src/search.c,v retrieving revision 1.29 diff -u -p -r1.29 search.c --- src/search.c 22 Nov 2004 13:40:56 -0000 1.29 +++ src/search.c 22 Nov 2004 16:47:35 -0000 @@ -363,13 +363,7 @@ EGexecute (char const *buf, size_t size, /* Find a possible match using the KWset matcher. */ size_t offset = kwsexec (kwset, beg, buflim - beg, &kwsm); if (offset == (size_t) -1) - { -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - free(mb_properties); -#endif - return (size_t)-1; - } + goto fail; beg += offset; /* Narrow down to the line containing the candidate, and run it through DFA. */ @@ -391,7 +385,7 @@ EGexecute (char const *buf, size_t size, /* No good fixed strings; start with DFA. */ size_t offset = dfaexec (&dfa, beg, buflim - beg, &backref); if (offset == (size_t) -1) - break; + goto fail; /* Narrow down to the line we've found. */ beg += offset; end = memchr (beg, eol, buflim - beg); @@ -464,6 +458,8 @@ EGexecute (char const *buf, size_t size, } } /* for Regex patterns. */ } /* for (beg = end ..) */ + + fail: #ifdef MBS_SUPPORT if (MB_CUR_MAX > 1 && mb_properties) free (mb_properties); @@ -519,13 +515,8 @@ Fexecute (char const *buf, size_t size, { size_t offset = kwsexec (kwset, beg, buf + size - beg, &kwsmatch); if (offset == (size_t) -1) - { -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - free(mb_properties); -#endif /* MBS_SUPPORT */ - return offset; - } + goto fail; + #ifdef MBS_SUPPORT if (MB_CUR_MAX > 1 && mb_properties[offset+beg-buf] == 0) continue; /* It is a part of multibyte character. */ @@ -558,13 +549,7 @@ Fexecute (char const *buf, size_t size, { offset = kwsexec (kwset, beg, --len, &kwsmatch); if (offset == (size_t) -1) - { -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - free (mb_properties); -#endif /* MBS_SUPPORT */ - return offset; - } + goto fail; try = beg + offset; len = kwsmatch.size[0]; } @@ -575,6 +560,7 @@ Fexecute (char const *buf, size_t size, goto success; } + fail: #ifdef MBS_SUPPORT if (MB_CUR_MAX > 1) free (mb_properties);