添付ファイル | sed-4.1.5-bug-regex25.patch [^] (7,561 バイト) 2007-11-25 20:42 [表示] [非表示]--- sed-4.1.5/lib/regex_internal.c.orig 2005-12-06 17:46:59.000000000 +0900
+++ sed-4.1.5/lib/regex_internal.c 2007-11-25 14:20:17.000000000 +0900
@@ -482,7 +482,7 @@
mbstate_t prev_st;
int rawbuf_idx;
size_t mbclen;
- wchar_t wc = 0;
+ wchar_t wc = WEOF;
/* Skip the characters which are not necessary to check. */
for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
@@ -495,7 +495,11 @@
remain_len, &pstr->cur_state);
if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
{
- /* We treat these cases as a singlebyte character. */
+ /* We treat these cases as a single byte character. */
+ if (mbclen == 0 || remain_len == 0)
+ wc = L'\0';
+ else
+ wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx);
mbclen = 1;
pstr->cur_state = prev_st;
}
@@ -618,7 +622,6 @@
}
#endif
pstr->valid_len = 0;
- pstr->valid_raw_len = 0;
#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
{
@@ -681,6 +684,16 @@
if (wc == WEOF)
pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;
+ if (wc == WEOF)
+ pstr->tip_context
+ = re_string_context_at (pstr, pstr->valid_raw_len - 1, eflags);
+ else
+ pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
+ && IS_WIDE_WORD_CHAR (wc))
+ ? CONTEXT_WORD
+ : ((IS_WIDE_NEWLINE (wc)
+ && pstr->newline_anchor)
+ ? CONTEXT_NEWLINE : 0));
if (BE (pstr->valid_len, 0))
{
for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
@@ -689,17 +702,12 @@
memset (pstr->mbs, 255, pstr->valid_len);
}
pstr->valid_raw_len = pstr->valid_len;
- pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
- && IS_WIDE_WORD_CHAR (wc))
- ? CONTEXT_WORD
- : ((IS_WIDE_NEWLINE (wc)
- && pstr->newline_anchor)
- ? CONTEXT_NEWLINE : 0));
}
else
#endif /* RE_ENABLE_I18N */
{
int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
+ pstr->valid_raw_len = 0;
if (pstr->trans)
c = pstr->trans[c];
pstr->tip_context = (bitset_contain (pstr->word_char, c)
--- sed-4.1.5/testsuite/Makefile.in.orig 2006-02-03 18:24:36.000000000 +0900
+++ sed-4.1.5/testsuite/Makefile.in 2007-11-25 14:38:54.000000000 +0900
@@ -14,7 +14,7 @@
@SET_MAKE@
-SOURCES = bug-regex10.c bug-regex11.c bug-regex12.c bug-regex13.c bug-regex14.c bug-regex15.c bug-regex16.c bug-regex21.c bug-regex7.c bug-regex8.c bug-regex9.c runptests.c runtests.c tst-boost.c tst-pcre.c tst-regex2.c tst-rxspencer.c
+SOURCES = bug-regex10.c bug-regex11.c bug-regex12.c bug-regex13.c bug-regex14.c bug-regex15.c bug-regex16.c bug-regex21.c bug-regex25.c bug-regex7.c bug-regex8.c bug-regex9.c runptests.c runtests.c tst-boost.c tst-pcre.c tst-regex2.c tst-rxspencer.c
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -44,6 +44,7 @@
@TEST_REGEX_TRUE@ bug-regex12$(EXEEXT) bug-regex13$(EXEEXT) \
@TEST_REGEX_TRUE@ bug-regex14$(EXEEXT) bug-regex15$(EXEEXT) \
@TEST_REGEX_TRUE@ bug-regex16$(EXEEXT) bug-regex21$(EXEEXT) \
+@TEST_REGEX_TRUE@ bug-regex25$(EXEEXT) \
@TEST_REGEX_TRUE@ tst-pcre$(EXEEXT) tst-boost$(EXEEXT) \
@TEST_REGEX_TRUE@ runtests$(EXEEXT) runptests$(EXEEXT) \
@TEST_REGEX_TRUE@ tst-rxspencer$(EXEEXT) tst-regex2$(EXEEXT)
@@ -101,6 +102,10 @@
bug_regex21_OBJECTS = bug-regex21.$(OBJEXT)
bug_regex21_LDADD = $(LDADD)
bug_regex21_DEPENDENCIES = ../lib/libsed.a
+bug_regex25_SOURCES = bug-regex25.c
+bug_regex25_OBJECTS = bug-regex25.$(OBJEXT)
+bug_regex25_LDADD = $(LDADD)
+bug_regex25_DEPENDENCIES = ../lib/libsed.a
bug_regex7_SOURCES = bug-regex7.c
bug_regex7_OBJECTS = bug-regex7.$(OBJEXT)
bug_regex7_LDADD = $(LDADD)
@@ -145,11 +150,11 @@
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = bug-regex10.c bug-regex11.c bug-regex12.c bug-regex13.c \
- bug-regex14.c bug-regex15.c bug-regex16.c bug-regex21.c \
+ bug-regex14.c bug-regex15.c bug-regex16.c bug-regex21.c bug-regex25.c \
bug-regex7.c bug-regex8.c bug-regex9.c runptests.c runtests.c \
tst-boost.c tst-pcre.c tst-regex2.c tst-rxspencer.c
DIST_SOURCES = bug-regex10.c bug-regex11.c bug-regex12.c bug-regex13.c \
- bug-regex14.c bug-regex15.c bug-regex16.c bug-regex21.c \
+ bug-regex14.c bug-regex15.c bug-regex16.c bug-regex21.c bug-regex25.c \
bug-regex7.c bug-regex8.c bug-regex9.c runptests.c runtests.c \
tst-boost.c tst-pcre.c tst-regex2.c tst-rxspencer.c
HEADERS = $(noinst_HEADERS)
@@ -400,6 +405,9 @@
bug-regex21$(EXEEXT): $(bug_regex21_OBJECTS) $(bug_regex21_DEPENDENCIES)
@rm -f bug-regex21$(EXEEXT)
$(LINK) $(bug_regex21_LDFLAGS) $(bug_regex21_OBJECTS) $(bug_regex21_LDADD) $(LIBS)
+bug-regex25$(EXEEXT): $(bug_regex25_OBJECTS) $(bug_regex25_DEPENDENCIES)
+ @rm -f bug-regex25$(EXEEXT)
+ $(LINK) $(bug_regex25_LDFLAGS) $(bug_regex25_OBJECTS) $(bug_regex25_LDADD) $(LIBS)
bug-regex7$(EXEEXT): $(bug_regex7_OBJECTS) $(bug_regex7_DEPENDENCIES)
@rm -f bug-regex7$(EXEEXT)
$(LINK) $(bug_regex7_LDFLAGS) $(bug_regex7_OBJECTS) $(bug_regex7_LDADD) $(LIBS)
@@ -442,6 +450,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bug-regex15.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bug-regex16.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bug-regex21.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bug-regex25.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bug-regex7.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bug-regex8.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bug-regex9.Po@am__quote@
--- sed-4.1.5/testsuite/bug-regex25.c.jj 2006-06-02 16:14:35.000000000 +0200
+++ sed-4.1.5/testsuite/bug-regex25.c 2006-06-02 16:18:49.000000000 +0200
@@ -0,0 +1,57 @@
+/* Test re_search in multibyte locale other than UTF-8.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <locale.h>
+#include <regex.h>
+#include <stdio.h>
+#include <string.h>
+
+const char *str1 = "\xa3\xd8\xa3\xc9\xa3\xc9";
+const char *str2 = "\xa3\xd8\xa3\xc9";
+
+int
+main (void)
+{
+ setlocale (LC_ALL, "ja_JP.eucJP");
+
+ re_set_syntax (RE_SYNTAX_SED);
+
+ struct re_pattern_buffer re;
+ memset (&re, 0, sizeof (re));
+
+ struct re_registers regs;
+ memset (®s, 0, sizeof (regs));
+
+ re_compile_pattern ("$", 1, &re);
+
+ int ret = 0, r = re_search (&re, str1, 4, 0, 4, ®s);
+ if (r != 4)
+ {
+ printf ("First re_search returned %d\n", r);
+ ret = 1;
+ }
+ r = re_search (&re, str2, 4, 0, 4, ®s);
+ if (r != 4)
+ {
+ printf ("Second re_search returned %d\n", r);
+ ret = 1;
+ }
+ return ret;
+}
|