* regex.c (is_in_list): should work weill with UTF-8.

* regex.c (re_match_exec): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-01-20 08:29:24 +00:00
parent 181edd12a0
commit d242ae60d8
5 changed files with 55 additions and 26 deletions

View File

@ -23,6 +23,12 @@ Sun Jan 19 23:08:18 2003 Akinori MUSHA <knu@iDaemons.org>
quotes should not be regarded as meta character. This bug or
maybe feature was inherited from Perl's shellwords.pl.
Sun Jan 19 14:01:12 2003 UENO Katsuhiro <unnie@blue.sky.or.jp>
* regex.c (is_in_list): should work weill with UTF-8.
* regex.c (re_match_exec): ditto.
Sat Jan 18 14:53:49 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* bignum.c (rb_cstr_to_inum): should not erase all 0s, but

5
hash.c
View File

@ -101,10 +101,7 @@ rb_any_hash(a)
default:
DEFER_INTS;
hval = rb_funcall(a, id_hash, 0);
if (FIXNUM_P(hval)) {
hval %= 536870923;
}
else {
if (!FIXNUM_P(hval)) {
hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
}
ENABLE_INTS;

View File

@ -942,21 +942,24 @@ convert string charset, and set language to "ja".
private :initialize_query
def [](key)
value = @params[key][0]
def value.to_ary
[self.dup]
end
def value.[](key)
$stderr.puts <<END
value, = @params[key]
unless value.nil?
value = value.dup
def value.to_ary
[self]
end
def value.[](key)
$stderr.puts <<END
CAUTION! cgi['key'] == cgi.params['key'][0] If want Array, use cgi.params['key']
END
self
end
def value.first
$stderr.puts <<END
self
end
def value.first
$stderr.puts <<END
CAUTION! cgi['key'] == cgi.params['key'][0] If want Array, use cgi.params['key']
END
self
self
end
end
value
end

44
regex.c
View File

@ -698,7 +698,18 @@ set_list_bits(c1, c2, b)
}
static int
is_in_list(c, b)
is_in_list_sbc(c, b)
unsigned long c;
const unsigned char *b;
{
unsigned short size;
size = *b++;
return ((int)c / BYTEWIDTH < (int)size && b[c / BYTEWIDTH] & 1 << c % BYTEWIDTH);
}
static int
is_in_list_mbc(c, b)
unsigned long c;
const unsigned char *b;
{
@ -706,9 +717,6 @@ is_in_list(c, b)
unsigned short i, j;
size = *b++;
if ((int)c / BYTEWIDTH < (int)size && b[c / BYTEWIDTH] & 1 << c % BYTEWIDTH) {
return 1;
}
b += size + 2;
size = EXTRACT_UNSIGNED(&b[-2]);
if (size == 0) return 0;
@ -727,6 +735,14 @@ is_in_list(c, b)
return 0;
}
static int
is_in_list(c, b)
unsigned long c;
const unsigned char *b;
{
return is_in_list_sbc(c, b) || is_in_list_mbc(c, b);
}
static void
print_partial_compiled_pattern(start, end)
unsigned char *start;
@ -3815,19 +3831,25 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
int cc, c;
PREFETCH;
cc = c = (unsigned char)*d++;
c = (unsigned char)*d++;
if (ismbchar(c)) {
if (d + mbclen(c) - 1 <= dend) {
cc = c;
MBC2WC(c, d);
not = is_in_list_mbc(c, p);
if (!not) {
part = not = is_in_list_sbc(cc, p);
}
} else {
not = is_in_list_sbc(c, p);
}
}
else if (TRANSLATE_P())
cc = c = (unsigned char)translate[c];
not = is_in_list(c, p);
if (!not && cc != c) {
part = not = is_in_list(cc, p);
else {
if (TRANSLATE_P())
c = (unsigned char)translate[c];
not = is_in_list_sbc(c, p);
}
if (*(p - 1) == (unsigned char)charset_not) {
not = !not;
}

View File

@ -375,6 +375,7 @@ r([1,2,[]]){next *[1,2]}
r([nil,nil,[]]){next *[*[]]}
r([1,nil,[]]){next *[*[1]]}
r([1,2,[]]){next *[*[1,2]]}
test_check "condition"
$x = '0';