PERFORCE change 144934 for review
Gabor Kovesdan
gabor at FreeBSD.org
Wed Jul 9 09:50:12 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=144934
Change 144934 by gabor at gabor_server on 2008/07/09 09:50:00
- Clean up the wflag part
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/grep/util.c#54 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/grep/util.c#54 (text+ko) ====
@@ -240,35 +240,18 @@
if (pmatch.rm_so != 0 || pmatch.rm_eo != l->len)
r = REG_NOMATCH;
if (r == 0 && wflag) {
- char *begin, *end;
- wchar_t *wbegin, *wend;
- size_t size;
+ wchar_t *wbegin;
+ wint_t wend;
- begin = grep_malloc(sizeof(char) * (pmatch.rm_so + 1));
- end = grep_malloc(sizeof(char) * (strlen(l->dat) - pmatch.rm_eo));
- strlcpy(begin, l->dat, pmatch.rm_so);
- strlcpy(end, &(l->dat[pmatch.rm_eo]), (strlen(l->dat) - pmatch.rm_eo));
-
- size = mbstowcs(NULL, begin, 0);
- wbegin = grep_malloc(sizeof(wint_t) * size);
- if (mbstowcs(wbegin, begin, size) == -1) {
+ wbegin = grep_malloc(mbstowcs(NULL, l->dat, pmatch.rm_so));
+ if (mbstowcs(wbegin, l->dat, pmatch.rm_so) == -1)
r = REG_NOMATCH;
- continue;
- }
- free(begin);
- size = mbstowcs(NULL, end, 0);
- wend = grep_malloc(sizeof(wint_t) * size);
- if (mbstowcs(wend, end, size) == -1) {
- r = REG_NOMATCH;
- continue;
- }
- free(end);
- if ((pmatch.rm_so != 0 && iswword(wbegin[wcslen(wbegin -1)]))
- || (pmatch.rm_eo != l->len && iswword(wend[0])))
+ 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);
- free(wend);
}
if (r == t) {
if (m == 0)
More information about the p4-projects
mailing list