mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
181edd12a0
commit
d242ae60d8
5 changed files with 55 additions and 26 deletions
|
@ -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
|
quotes should not be regarded as meta character. This bug or
|
||||||
maybe feature was inherited from Perl's shellwords.pl.
|
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>
|
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
|
* bignum.c (rb_cstr_to_inum): should not erase all 0s, but
|
||||||
|
|
5
hash.c
5
hash.c
|
@ -101,10 +101,7 @@ rb_any_hash(a)
|
||||||
default:
|
default:
|
||||||
DEFER_INTS;
|
DEFER_INTS;
|
||||||
hval = rb_funcall(a, id_hash, 0);
|
hval = rb_funcall(a, id_hash, 0);
|
||||||
if (FIXNUM_P(hval)) {
|
if (!FIXNUM_P(hval)) {
|
||||||
hval %= 536870923;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
|
hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
|
||||||
}
|
}
|
||||||
ENABLE_INTS;
|
ENABLE_INTS;
|
||||||
|
|
25
lib/cgi.rb
25
lib/cgi.rb
|
@ -942,21 +942,24 @@ convert string charset, and set language to "ja".
|
||||||
private :initialize_query
|
private :initialize_query
|
||||||
|
|
||||||
def [](key)
|
def [](key)
|
||||||
value = @params[key][0]
|
value, = @params[key]
|
||||||
def value.to_ary
|
unless value.nil?
|
||||||
[self.dup]
|
value = value.dup
|
||||||
end
|
def value.to_ary
|
||||||
def value.[](key)
|
[self]
|
||||||
$stderr.puts <<END
|
end
|
||||||
|
def value.[](key)
|
||||||
|
$stderr.puts <<END
|
||||||
CAUTION! cgi['key'] == cgi.params['key'][0] If want Array, use cgi.params['key']
|
CAUTION! cgi['key'] == cgi.params['key'][0] If want Array, use cgi.params['key']
|
||||||
END
|
END
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
def value.first
|
def value.first
|
||||||
$stderr.puts <<END
|
$stderr.puts <<END
|
||||||
CAUTION! cgi['key'] == cgi.params['key'][0] If want Array, use cgi.params['key']
|
CAUTION! cgi['key'] == cgi.params['key'][0] If want Array, use cgi.params['key']
|
||||||
END
|
END
|
||||||
self
|
self
|
||||||
|
end
|
||||||
end
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
44
regex.c
44
regex.c
|
@ -698,7 +698,18 @@ set_list_bits(c1, c2, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
unsigned long c;
|
||||||
const unsigned char *b;
|
const unsigned char *b;
|
||||||
{
|
{
|
||||||
|
@ -706,9 +717,6 @@ is_in_list(c, b)
|
||||||
unsigned short i, j;
|
unsigned short i, j;
|
||||||
|
|
||||||
size = *b++;
|
size = *b++;
|
||||||
if ((int)c / BYTEWIDTH < (int)size && b[c / BYTEWIDTH] & 1 << c % BYTEWIDTH) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
b += size + 2;
|
b += size + 2;
|
||||||
size = EXTRACT_UNSIGNED(&b[-2]);
|
size = EXTRACT_UNSIGNED(&b[-2]);
|
||||||
if (size == 0) return 0;
|
if (size == 0) return 0;
|
||||||
|
@ -727,6 +735,14 @@ is_in_list(c, b)
|
||||||
return 0;
|
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
|
static void
|
||||||
print_partial_compiled_pattern(start, end)
|
print_partial_compiled_pattern(start, end)
|
||||||
unsigned char *start;
|
unsigned char *start;
|
||||||
|
@ -3815,19 +3831,25 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
||||||
int cc, c;
|
int cc, c;
|
||||||
|
|
||||||
PREFETCH;
|
PREFETCH;
|
||||||
cc = c = (unsigned char)*d++;
|
c = (unsigned char)*d++;
|
||||||
if (ismbchar(c)) {
|
if (ismbchar(c)) {
|
||||||
if (d + mbclen(c) - 1 <= dend) {
|
if (d + mbclen(c) - 1 <= dend) {
|
||||||
|
cc = c;
|
||||||
MBC2WC(c, d);
|
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())
|
else {
|
||||||
cc = c = (unsigned char)translate[c];
|
if (TRANSLATE_P())
|
||||||
|
c = (unsigned char)translate[c];
|
||||||
not = is_in_list(c, p);
|
not = is_in_list_sbc(c, p);
|
||||||
if (!not && cc != c) {
|
|
||||||
part = not = is_in_list(cc, p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*(p - 1) == (unsigned char)charset_not) {
|
if (*(p - 1) == (unsigned char)charset_not) {
|
||||||
not = !not;
|
not = !not;
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,6 +375,7 @@ r([1,2,[]]){next *[1,2]}
|
||||||
r([nil,nil,[]]){next *[*[]]}
|
r([nil,nil,[]]){next *[*[]]}
|
||||||
r([1,nil,[]]){next *[*[1]]}
|
r([1,nil,[]]){next *[*[1]]}
|
||||||
r([1,2,[]]){next *[*[1,2]]}
|
r([1,2,[]]){next *[*[1,2]]}
|
||||||
|
|
||||||
test_check "condition"
|
test_check "condition"
|
||||||
|
|
||||||
$x = '0';
|
$x = '0';
|
||||||
|
|
Loading…
Reference in a new issue