This commit is contained in:
parent
fc2d1d0edd
commit
0495f5fb58
@ -406,6 +406,102 @@
|
||||
+#endif
|
||||
+
|
||||
+#endif /* _MBCHAR_H */
|
||||
--- src/dfa.c
|
||||
+++ src/dfa.c
|
||||
@@ -122,6 +122,7 @@ extern void free();
|
||||
#include "regex.h"
|
||||
#include "dfa.h"
|
||||
#include "hard-locale.h"
|
||||
+#include "mbchar.h"
|
||||
|
||||
/* HPUX, define those as macros in sys/param.h */
|
||||
#ifdef setbit
|
||||
@@ -378,6 +379,7 @@ static int hard_LC_COLLATE; /* Nonzero i
|
||||
#ifdef MBS_SUPPORT
|
||||
/* These variables are used only if (MB_CUR_MAX > 1). */
|
||||
static mbstate_t mbs; /* Mbstate for mbrlen(). */
|
||||
+static bool cur_mb_in_shift;
|
||||
static int cur_mb_len; /* Byte length of the current scanning
|
||||
multibyte character. */
|
||||
static int cur_mb_index; /* Byte index of the current scanning multibyte
|
||||
@@ -426,7 +428,14 @@ update_mb_len_index (unsigned char const
|
||||
next character is a multibyte character or not. */
|
||||
if (! cur_mb_index)
|
||||
{
|
||||
- cur_mb_len = mbrlen(p, len, &mbs);
|
||||
+ if (!cur_mb_in_shift && is_basic (*p))
|
||||
+ cur_mb_len = 1;
|
||||
+ else
|
||||
+ {
|
||||
+ cur_mb_len = mbrlen(p, len, &mbs);
|
||||
+ if (!mbsinit (&mbs))
|
||||
+ cur_mb_in_shift = true;
|
||||
+ }
|
||||
if (cur_mb_len > 1)
|
||||
/* It is a multibyte character.
|
||||
cur_mb_len was already set by mbrlen(). */
|
||||
@@ -472,12 +481,22 @@ fetch_wc (char const *eoferr)
|
||||
return WEOF;
|
||||
}
|
||||
|
||||
- cur_mb_len = mbrtowc(&wc, lexptr, lexleft, &mbs);
|
||||
- if (cur_mb_len <= 0)
|
||||
- {
|
||||
+ if (!cur_mb_in_shift && is_basic (*lexptr))
|
||||
+ {
|
||||
cur_mb_len = 1;
|
||||
wc = *lexptr;
|
||||
}
|
||||
+ else
|
||||
+ {
|
||||
+ cur_mb_len = mbrtowc(&wc, lexptr, lexleft, &mbs);
|
||||
+ if (!mbsinit (&mbs))
|
||||
+ cur_mb_in_shift = true;
|
||||
+ if (cur_mb_len <= 0)
|
||||
+ {
|
||||
+ cur_mb_len = 1;
|
||||
+ wc = *lexptr;
|
||||
+ }
|
||||
+ }
|
||||
lexptr += cur_mb_len;
|
||||
lexleft -= cur_mb_len;
|
||||
return wc;
|
||||
@@ -1429,6 +1448,7 @@ dfaparse (char const *s, size_t len, str
|
||||
{
|
||||
cur_mb_index = 0;
|
||||
cur_mb_len = 0;
|
||||
+ cur_mb_in_shift = false;
|
||||
memset(&mbs, 0, sizeof(mbstate_t));
|
||||
}
|
||||
#endif /* MBS_SUPPORT */
|
||||
@@ -2839,6 +2859,7 @@ dfaexec (struct dfa *d, char const *begi
|
||||
if (MB_CUR_MAX > 1)
|
||||
{
|
||||
int remain_bytes, i;
|
||||
+ bool in_shift = false;
|
||||
buf_begin = begin;
|
||||
buf_end = end;
|
||||
|
||||
@@ -2851,9 +2872,16 @@ dfaexec (struct dfa *d, char const *begi
|
||||
{
|
||||
if (remain_bytes == 0)
|
||||
{
|
||||
- remain_bytes
|
||||
- = mbrtowc(inputwcs + i, begin + i,
|
||||
- end - (unsigned char const *)begin - i + 1, &mbs);
|
||||
+ if (!in_shift && is_basic (begin[i]))
|
||||
+ remain_bytes = 1;
|
||||
+ else
|
||||
+ {
|
||||
+ remain_bytes
|
||||
+ = mbrtowc(inputwcs + i, begin + i,
|
||||
+ end - (unsigned char const *)begin - i + 1, &mbs);
|
||||
+ if (!mbsinit (&mbs))
|
||||
+ in_shift = true;
|
||||
+ }
|
||||
if (remain_bytes <= 1)
|
||||
{
|
||||
remain_bytes = 0;
|
||||
--- src/search.c
|
||||
+++ src/search.c
|
||||
@@ -43,6 +43,7 @@
|
||||
@ -416,7 +512,7 @@
|
||||
|
||||
#define NCHAR (UCHAR_MAX + 1)
|
||||
|
||||
@@ -140,40 +141,60 @@ kwsmusts (void)
|
||||
@@ -140,40 +141,59 @@ kwsmusts (void)
|
||||
are not single byte character nor the first byte of a multibyte
|
||||
character. Caller must free the array. */
|
||||
static char*
|
||||
@ -428,7 +524,7 @@
|
||||
mbstate_t cur_state;
|
||||
wchar_t wc;
|
||||
int i;
|
||||
+ int in_shift = 0;
|
||||
+ bool in_shift = false;
|
||||
|
||||
memset(&cur_state, 0, sizeof(mbstate_t));
|
||||
- memset(mb_properties, 0, sizeof(char)*size);
|
||||
@ -446,40 +542,37 @@
|
||||
mbclen = 1;
|
||||
+ wc = buf[i];
|
||||
+ if (case_convert && iswupper ((wint_t)wc))
|
||||
+ wc = towlower ((wint_t) wc);
|
||||
+ {
|
||||
+ wc = towlower((wint_t)wc);
|
||||
+ wcrtomb(buf + i, wc, &cur_state);
|
||||
+ }
|
||||
}
|
||||
- else if (match_icase)
|
||||
+ else
|
||||
{
|
||||
- if (iswupper((wint_t)wc))
|
||||
+ in_shift = true;
|
||||
+ mbclen = mbrtowc(&wc, buf + i, size - i, &cur_state);
|
||||
+ if (!mbsinit (&cur_state))
|
||||
+ in_shift = true;
|
||||
+
|
||||
+ if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0)
|
||||
{
|
||||
- wc = towlower((wint_t)wc);
|
||||
- wcrtomb(buf + i, wc, &cur_state);
|
||||
+ {
|
||||
+ /* An invalid sequence, or a truncated multibyte character.
|
||||
+ We treat it as a single byte character. */
|
||||
+ mbclen = 1;
|
||||
}
|
||||
+ else if (case_convert)
|
||||
+ {
|
||||
+ if (iswupper((wint_t)wc))
|
||||
+ {
|
||||
+ wc = towlower((wint_t)wc);
|
||||
+ wcrtomb(buf + i, wc, &cur_state);
|
||||
+ }
|
||||
+ }
|
||||
+ if (mbsinit (&cur_state))
|
||||
+ in_shift = false;
|
||||
+ }
|
||||
+ else if (case_convert && iswupper((wint_t)wc))
|
||||
{
|
||||
wc = towlower((wint_t)wc);
|
||||
wcrtomb(buf + i, wc, &cur_state);
|
||||
}
|
||||
}
|
||||
- mb_properties[i] = mbclen;
|
||||
+ if (mbclen != 1 && !mb_properties)
|
||||
+ {
|
||||
+ mb_properties = xcalloc (1, size);
|
||||
+ memset (mb_properties, 1, i);
|
||||
}
|
||||
- mb_properties[i] = mbclen;
|
||||
+ }
|
||||
+ if (mb_properties)
|
||||
+ mb_properties[i] = mbclen;
|
||||
i += mbclen;
|
||||
@ -490,7 +583,7 @@
|
||||
}
|
||||
#endif /* MBS_SUPPORT */
|
||||
|
||||
@@ -311,9 +332,8 @@ EXECUTE_FCT(EGexecute)
|
||||
@@ -311,9 +331,8 @@ EXECUTE_FCT(EGexecute)
|
||||
if (start_ptr)
|
||||
start_ptr = case_buf + (start_ptr - buf);
|
||||
buf = case_buf;
|
||||
@ -501,24 +594,18 @@
|
||||
}
|
||||
#endif /* MBS_SUPPORT */
|
||||
|
||||
@@ -336,8 +356,14 @@ EXECUTE_FCT(EGexecute)
|
||||
@@ -335,10 +354,6 @@ EXECUTE_FCT(EGexecute)
|
||||
run it through DFA. */
|
||||
end = memchr(beg, eol, buflim - beg);
|
||||
end++;
|
||||
#ifdef MBS_SUPPORT
|
||||
-#ifdef MBS_SUPPORT
|
||||
- if (MB_CUR_MAX > 1 && mb_properties[beg - buf] == 0)
|
||||
- continue;
|
||||
+ if (MB_CUR_MAX > 1)
|
||||
+ {
|
||||
+ if (!mb_properties)
|
||||
+ mb_properties = check_multibyte_string (buf, size, 0);
|
||||
+ if (mb_properties != (char *) -1
|
||||
+ && mb_properties[beg - buf] == 0)
|
||||
+ continue;
|
||||
+ }
|
||||
#endif
|
||||
-#endif
|
||||
while (beg > buf && beg[-1] != eol)
|
||||
--beg;
|
||||
@@ -478,7 +504,7 @@ EXECUTE_FCT(EGexecute)
|
||||
if (kwsm.index < kwset_exact_matches)
|
||||
@@ -478,7 +493,7 @@ EXECUTE_FCT(EGexecute)
|
||||
{
|
||||
if (match_icase)
|
||||
free((char*)buf);
|
||||
@ -527,7 +614,7 @@
|
||||
free(mb_properties);
|
||||
}
|
||||
#endif /* MBS_SUPPORT */
|
||||
@@ -527,8 +553,8 @@ EXECUTE_FCT(Fexecute)
|
||||
@@ -527,8 +542,8 @@ EXECUTE_FCT(Fexecute)
|
||||
if (start_ptr)
|
||||
start_ptr = case_buf + (start_ptr - buf);
|
||||
buf = case_buf;
|
||||
@ -537,7 +624,7 @@
|
||||
}
|
||||
#endif /* MBS_SUPPORT */
|
||||
|
||||
@@ -538,8 +564,14 @@ EXECUTE_FCT(Fexecute)
|
||||
@@ -538,8 +553,14 @@ EXECUTE_FCT(Fexecute)
|
||||
if (offset == (size_t) -1)
|
||||
goto failure;
|
||||
#ifdef MBS_SUPPORT
|
||||
@ -554,7 +641,7 @@
|
||||
#endif /* MBS_SUPPORT */
|
||||
beg += offset;
|
||||
len = kwsmatch.size[0];
|
||||
@@ -595,7 +627,7 @@ EXECUTE_FCT(Fexecute)
|
||||
@@ -595,7 +616,7 @@ EXECUTE_FCT(Fexecute)
|
||||
{
|
||||
if (match_icase)
|
||||
free((char*)buf);
|
||||
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 14 17:22:17 CEST 2008 - schwab@suse.de
|
||||
|
||||
- More speedups.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 3 11:29:37 CEST 2008 - schwab@suse.de
|
||||
|
||||
@ -6,7 +11,7 @@ Tue Jun 3 11:29:37 CEST 2008 - schwab@suse.de
|
||||
-------------------------------------------------------------------
|
||||
Tue May 27 18:45:20 CEST 2008 - schwab@suse.de
|
||||
|
||||
- Some speadups.
|
||||
- Some speedups.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Feb 11 17:45:07 CET 2008 - schwab@suse.de
|
||||
|
20
grep.spec
20
grep.spec
@ -2,13 +2,19 @@
|
||||
# spec file for package grep (Version 2.5.2)
|
||||
#
|
||||
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# This file and all modifications and additions to the pristine
|
||||
# package are under the same license as the package itself.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
# norootforbuild
|
||||
|
||||
|
||||
Name: grep
|
||||
@ -20,7 +26,7 @@ Provides: base:/usr/bin/grep
|
||||
AutoReqProv: on
|
||||
PreReq: %{install_info_prereq}
|
||||
Version: 2.5.2
|
||||
Release: 72
|
||||
Release: 90
|
||||
Summary: Print lines matching a pattern
|
||||
Source: grep-%{version}.tar.bz2
|
||||
Patch: grep-%{version}.diff
|
||||
@ -61,9 +67,9 @@ Authors:
|
||||
%patch7
|
||||
%patch8
|
||||
rm -f lib/regex.[ch]
|
||||
rm -f m4/header.m4 m4/install.m4 m4/isc-posix.m4 m4/largefile.m4 m4/missing.m4 m4/sanity.m4
|
||||
|
||||
%build
|
||||
rm -f m4/header.m4 m4/install.m4 m4/isc-posix.m4 m4/largefile.m4 m4/missing.m4 m4/sanity.m4
|
||||
AUTOPOINT=true autoreconf --force --install
|
||||
./configure CFLAGS="$RPM_OPT_FLAGS" \
|
||||
--prefix=/usr --mandir=%{_mandir} --infodir=%{_infodir} \
|
||||
@ -95,10 +101,12 @@ ln -sf ../../bin/grep $RPM_BUILD_ROOT/usr/bin/grep
|
||||
%doc %{_infodir}/*.gz
|
||||
|
||||
%changelog
|
||||
* Thu Aug 14 2008 schwab@suse.de
|
||||
- More speedups.
|
||||
* Tue Jun 03 2008 schwab@suse.de
|
||||
- Fix last change.
|
||||
* Tue May 27 2008 schwab@suse.de
|
||||
- Some speadups.
|
||||
- Some speedups.
|
||||
* Mon Feb 11 2008 schwab@suse.de
|
||||
- Fix another icase bug.
|
||||
* Wed Nov 28 2007 schwab@suse.de
|
||||
|
Loading…
x
Reference in New Issue
Block a user