Date: Wed, 9 Jul 2008 09:50:11 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 144934 for review Message-ID: <200807090950.m699oBQm034697@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144934 Change 144934 by gabor@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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807090950.m699oBQm034697>