Date: Wed, 9 Jul 2008 09:55:16 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 144936 for review Message-ID: <200807090955.m699tGl6035123@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144936 Change 144936 by gabor@gabor_server on 2008/07/09 09:54:33 - Optimize the wflag part Suggested by: fjoe Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/util.c#55 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/util.c#55 (text+ko) ==== @@ -243,15 +243,16 @@ wchar_t *wbegin; wint_t wend; - wbegin = grep_malloc(mbstowcs(NULL, l->dat, pmatch.rm_so)); - if (mbstowcs(wbegin, l->dat, pmatch.rm_so) == -1) - r = REG_NOMATCH; + if (pmatch.rm_so != 0 && pmatch.rm_eo != l->len) { + wbegin = grep_malloc(mbstowcs(NULL, l->dat, pmatch.rm_so)); + if (mbstowcs(wbegin, l->dat, pmatch.rm_so) == -1) + r = REG_NOMATCH; - wend = sscanf(&l->dat[pmatch.rm_eo], "%lc", &wend); - if ((pmatch.rm_so != 0 && iswword(wbegin[wcslen(wbegin)])) - || (pmatch.rm_eo != l->len && iswword(wend))) - r = REG_NOMATCH; - free(wbegin); + wend = sscanf(&l->dat[pmatch.rm_eo], "%lc", &wend); + if (iswword(wbegin[wcslen(wbegin)]) ||iswword(wend)) + r = REG_NOMATCH; + free(wbegin); + } } if (r == t) { if (m == 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807090955.m699tGl6035123>