summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--hash.c5
-rw-r--r--lib/cgi.rb25
-rw-r--r--regex.c44
-rw-r--r--sample/test.rb1
5 files changed, 55 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index a29b67011f..0ac3916b42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/hash.c b/hash.c
index 257a4c8e47..249bc645a5 100644
--- a/hash.c
+++ b/hash.c
@@ -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;
diff --git a/lib/cgi.rb b/lib/cgi.rb
index bf7aa85f59..a69fb4cc87 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -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
diff --git a/regex.c b/regex.c
index 90fc5302d5..360b7a8efc 100644
--- a/regex.c
+++ b/regex.c
@@ -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;
}
diff --git a/sample/test.rb b/sample/test.rb
index d4a3b20c07..c47ceedd43 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -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';