summaryrefslogtreecommitdiff
path: root/textproc/grep/patches/patch-ab
blob: 158c9b8e84a02e518e49f2d475fb314e220aae7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$NetBSD: patch-ab,v 1.2 2004/07/06 20:36:58 bouyer Exp $

--- src/dfa.c.orig	2001-09-26 18:57:55.000000000 +0200
+++ src/dfa.c	2004-07-06 22:33:02.000000000 +0200
@@ -44,7 +44,7 @@
 # include <locale.h>
 #endif
 
-#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC
+#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC && defined HAVE_WCTYPE
 /* We can handle multibyte string.  */
 # define MBS_SUPPORT
 #endif
@@ -1052,12 +1052,17 @@
 			  setbit_case_fold (c, ccl);
 		      } else {
 			/* POSIX locales are painful - leave the decision to libc */
-			char expr[6] = { '[', c, '-', c2, ']', '\0' };
+			char expr[6] = { '[', '\0', '-', '\0', ']', '\0' };
 			regex_t re;
+
+			expr[1] = c;
+			expr[3] = c2;
 			if (regcomp (&re, expr, case_fold ? REG_ICASE : 0) == REG_NOERROR) {
 			  for (c = 0; c < NOTCHAR; ++c) {
-			    char buf[2] = { c, '\0' };
+			    char buf[2] = { '\0', '\0' };
 			    regmatch_t mat;
+
+			    buf[0] = c;
 			    if (regexec (&re, buf, 1, &mat, 0) == REG_NOERROR
                                && mat.rm_so == 0 && mat.rm_eo == 1)
                               setbit_case_fold (c, ccl);