Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Aug 2008 23:03:12 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 148756 for review
Message-ID:  <200808282303.m7SN3C4U002008@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=148756

Change 148756 by gabor@gabor_server on 2008/08/28 23:02:40

	- Be more error-prone in the -w part
	
	Suggested by:	ache

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/grep/util.c#74 edit

Differences ...

==== //depot/projects/soc2008/gabor_textproc/grep/util.c#74 (text+ko) ====

@@ -289,14 +289,22 @@
 				if (r == 0 && wflag && pmatch.rm_so != 0 && pmatch.rm_eo != l->len) {
 					wchar_t	*wbegin;
 					wint_t	 wend;
+					size_t	 size;
+
+					size = mbstowcs(NULL, l->dat, pmatch.rm_so);
 
-					wbegin = grep_malloc(mbstowcs(NULL, l->dat, pmatch.rm_so));
-					if (mbstowcs(wbegin, l->dat, pmatch.rm_so) == -1)
+					if (size = -1)
 						r = REG_NOMATCH;
-					wend = sscanf(&l->dat[pmatch.rm_eo], "%lc", &wend);
-					if (iswword(wbegin[wcslen(wbegin)]) ||iswword(wend))
-						r = REG_NOMATCH;
-					free(wbegin);
+					else {
+						wbegin = grep_malloc(size);
+						if (mbstowcs(wbegin, l->dat, pmatch.rm_so) == -1)
+							r = REG_NOMATCH;
+						else if (sscanf(&l->dat[pmatch.rm_eo], "%lc", &wend) != 1)
+							r = REG_NOMATCH;
+						else if (iswword(wbegin[wcslen(wbegin)]) ||iswword(wend))
+							r = REG_NOMATCH;
+						free(wbegin);
+					}
 				}
 				if (r == 0) {
 					if (m == 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808282303.m7SN3C4U002008>