grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v2.6.1-26-g222e774


From: Paolo Bonzini
Subject: grep branch, master, updated. v2.6.1-26-g222e774
Date: Mon, 29 Mar 2010 09:08:42 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  222e774d684d64cfb0713cba8c921eb94e54a91f (commit)
      from  faeb8340a6635a8e5e3177da547a938d387ce778 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=222e774d684d64cfb0713cba8c921eb94e54a91f


commit 222e774d684d64cfb0713cba8c921eb94e54a91f
Author: Paolo Bonzini <address@hidden>
Date:   Mon Mar 29 09:36:17 2010 +0200

    tests: add program to detect locales
    
    * tests/Makefile.am (check_PROGRAMS): Add get-mb-cur-max.
    * tests/get-mb-cur-max.c: New.
    * tests/euc-mb: Use it.  Fail if the former detection test fails.
    * tests/sjis-mb: Use it.  Fail if the former detection test fails.  Expand
    comments.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6920d21..81a10b5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,6 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+check_PROGRAMS = get-mb-cur-max
+LDADD = ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a
+
 TESTS =                                                \
   backref.sh                                   \
   backref-word                                 \
diff --git a/tests/euc-mb b/tests/euc-mb
index becb032..590bd91 100644
--- a/tests/euc-mb
+++ b/tests/euc-mb
@@ -3,7 +3,9 @@
 # too greedily.
 # Derived from https://savannah.gnu.org/bugs/?23814
 : ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "$srcdir/init.sh"; path_prepend_ . ../src
+
+locale=ja_JP.EUC-JP
 
 make_input () {
   echo "$1" | tr AB '\244\263'
@@ -11,14 +13,21 @@ make_input () {
 
 euc_grep () {
   pat=`make_input "$1"`
-  LC_ALL=ja_JP.EUC-JP grep "$pat"
+  LC_ALL=$locale grep "$pat"
 }
 
-if make_input BABA |euc_grep AB ; then
-  skip_ 'EUC-JP locale seems not to work'
-fi
 
-make_input BABAAB |euc_grep AB || \
-  fail_ 'whole line rejected after matching in the middle of a multibyte char'
+case `get-mb-cur-max $locale` in
+  2|3) ;;
+  *) skip_ 'EUC-JP locale not found' ;;
+esac
+
+fail=0
+
+# Does EUC-JP work at all?
+make_input BABA |euc_grep AB && fail=1
+
+# Whole line rejected after matching in the middle of a multibyte char?
+make_input BABAAB |euc_grep AB || fail=1
 
-Exit 0
+Exit $fail
diff --git a/tests/get-mb-cur-max.c b/tests/get-mb-cur-max.c
new file mode 100644
index 0000000..f7384d5
--- /dev/null
+++ b/tests/get-mb-cur-max.c
@@ -0,0 +1,36 @@
+/* Auxiliary program to detect support for a locale.
+   Copyright 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include <config.h>
+#include <locale.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char **argv)
+{
+  set_program_name (argv[0]);
+  if (setlocale (LC_ALL, argv[1]))
+    {
+      printf ("%d\n", MB_CUR_MAX);
+      exit (EXIT_SUCCESS);
+    }
+
+  exit (EXIT_FAILURE);
+}
diff --git a/tests/sjis-mb b/tests/sjis-mb
index 4454ea1..07ef34c 100644
--- a/tests/sjis-mb
+++ b/tests/sjis-mb
@@ -4,20 +4,27 @@
 # character, and a suffix of a valid double-byte character
 
 : ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "$srcdir/init.sh"; path_prepend_ . ../src
 
 require_timeout_
 
-# % becomes a half-width katakana in SJIS, and an invalid sequence
-# in UTF-8.  Use this to try skipping implementations that do not
-# support SJIS.
+locale=ja_JP.SHIFT_JIS
+
+# Sequences used in this test ("%" and "@" become 8-bit characters, while "A"
+# is the real ASCII character for "A"):
+# - "%" becomes an half-width katakana in SJIS, but it is an invalid sequence
+#   in UTF-8.
+# - "@@" and "@A" are both valid sequences in SJIS.  We try to fool grep into
+#   matching "A" against "@A", or mistaking a valid "A" match for the second
+#   byte of a multi-byte character.
+
 encode() { echo "$1" | tr @% '\203\301'; }
 
 k=0
 test_grep_reject() {
   k=$(expr $k + 1)
   encode "$2" | \
-    LC_ALL=ja_JP.SHIFT_JIS \
+    LC_ALL=$locale \
       timeout 10s grep $1 $(encode "$3") > out$k 2>&1
   test $? = 1
 }
@@ -25,13 +32,12 @@ test_grep_reject() {
 test_grep() {
   k=$(expr $k + 1)
   encode "$2" > exp$k
-  LC_ALL=ja_JP.SHIFT_JIS \
+  LC_ALL=$locale \
     timeout 10s grep $1 $(encode "$3") exp$k > out$k 2>&1
   test $? = 0 && compare out$k exp$k
 }
 
-test_grep_reject -F @@ @ || skip_ 'system does not seem to know about SJIS'
-test_grep -F %%AA A || skip_ 'system seems to treat SJIS the same as UTF-8'
+test "$(get-mb-cur-max $locale)" = 2 || skip_ 'SJIS locale not found'
 
 address@hidden
 successful_tests='%%AA @AA @A@@A'
@@ -42,6 +48,8 @@ for i in $successful_tests; do
   test_grep -E $i A || fail=1
 done
 
+test_grep_reject -F @@ @
+test_grep_reject -E @@ @
 for i in $failure_tests; do
   test_grep_reject -F $i A || fail=1
   test_grep_reject -E $i A || fail=1

-----------------------------------------------------------------------

Summary of changes:
 tests/Makefile.am                         |    3 ++
 tests/euc-mb                              |   25 +++++++++++++------
 src/mbsupport.h => tests/get-mb-cur-max.c |   37 ++++++++++++++---------------
 tests/sjis-mb                             |   24 ++++++++++++------
 4 files changed, 54 insertions(+), 35 deletions(-)
 copy src/mbsupport.h => tests/get-mb-cur-max.c (54%)


hooks/post-receive
-- 
grep




reply via email to

[Prev in Thread] Current Thread [Next in Thread]