Lubomir Rintel 0efa5e
From 68f09677b7aaedafa8c29280ccd76a034fe269f1 Mon Sep 17 00:00:00 2001
Lubomir Rintel 0efa5e
From: Debian <debian>
Lubomir Rintel 0efa5e
Date: Sun, 23 Nov 2008 17:28:46 +0100
Lubomir Rintel 0efa5e
Subject: [PATCH] Case-insensitive list matching fix
Lubomir Rintel 0efa5e
Lubomir Rintel 0efa5e
This fixes case-insensitive matching of lists in multi-byte character sets.
Lubomir Rintel 0efa5e
Original comment:
Lubomir Rintel 0efa5e
Lubomir Rintel 0efa5e
fix the following problem in multibyte locales.
Lubomir Rintel 0efa5e
 % echo Y | egrep -i '[y]'
Lubomir Rintel 0efa5e
 %
Lubomir Rintel 0efa5e
Lubomir Rintel 0efa5e
derived from gawk's dfa.c.
Lubomir Rintel 0efa5e
Lubomir Rintel 0efa5e
Original ticket: https://bugzilla.redhat.com/show_bug.cgi?id=123363
Lubomir Rintel 0efa5e
Debian: 61-dfa.c-case_fold-charclass.patch
Lubomir Rintel 0efa5e
---
Lubomir Rintel 0efa5e
 src/dfa.c |   14 ++++++++++++++
Lubomir Rintel 0efa5e
 1 files changed, 14 insertions(+), 0 deletions(-)
Lubomir Rintel 0efa5e
Lubomir Rintel 0efa5e
diff --git a/src/dfa.c b/src/dfa.c
Lubomir Rintel 0efa5e
index 934be97..088c379 100644
Lubomir Rintel 0efa5e
--- a/src/dfa.c
Lubomir Rintel 0efa5e
+++ b/src/dfa.c
Lubomir Rintel 0efa5e
@@ -689,6 +689,20 @@ parse_bracket_exp_mb ()
Lubomir Rintel 0efa5e
 	  REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al,
Lubomir Rintel 0efa5e
 			       work_mbc->nchars + 1);
Lubomir Rintel 0efa5e
 	  work_mbc->chars[work_mbc->nchars++] = (wchar_t)wc;
Lubomir Rintel 0efa5e
+	  if (case_fold && (iswlower((wint_t) wc) || iswupper((wint_t) wc)))
Lubomir Rintel 0efa5e
+	    {
Lubomir Rintel 0efa5e
+		wint_t altcase;
Lubomir Rintel 0efa5e
+
Lubomir Rintel 0efa5e
+		altcase = wc;		/* keeps compiler happy */
Lubomir Rintel 0efa5e
+		if (iswlower((wint_t) wc))
Lubomir Rintel 0efa5e
+		  altcase = towupper((wint_t) wc);
Lubomir Rintel 0efa5e
+		else if (iswupper((wint_t) wc))
Lubomir Rintel 0efa5e
+		  altcase = towlower((wint_t) wc);
Lubomir Rintel 0efa5e
+
Lubomir Rintel 0efa5e
+		REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al,
Lubomir Rintel 0efa5e
+			       work_mbc->nchars + 1);
Lubomir Rintel 0efa5e
+		work_mbc->chars[work_mbc->nchars++] = (wchar_t) altcase;
Lubomir Rintel 0efa5e
+	    }
Lubomir Rintel 0efa5e
 	}
Lubomir Rintel 0efa5e
     }
Lubomir Rintel 0efa5e
   while ((wc = wc1) != L']');
Lubomir Rintel 0efa5e
-- 
Lubomir Rintel 0efa5e
1.5.5.1
Lubomir Rintel 0efa5e