summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rw-r--r--enum.c5
-rw-r--r--eval.c1
-rw-r--r--hash.c4
-rw-r--r--parse.y13
5 files changed, 36 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d2f8499..4ec7f2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+Thu Jun 13 09:43:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (svalue_to_avalue): v may be Qundef. This fix was
+ suggested by Guy Decoux.
+
+Thu Jun 13 00:33:49 2002 takuma ozawa <metal@mine.ne.jp>
+
+ * hash.c (rb_hash_s_create): use rb_hash_aset() instead of calling
+ st_insert() directly, to dup&freeze string keys.
+
+Thu Jun 13 00:12:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): proper error message for "@@0".
+
+ * parse.y (yylex): paren to parse_string() must be zero for
+ unparenthesized strings.
+
+ * parse.y (str_extend): broken string when unterminated "#{".
+
+ * enum.c (enum_sort_by): had a bug in 1 element enumeration.
+
Wed Jun 12 18:04:44 2002 akira yamada <akira@arika.org>
* uri/common.rb (REGEXP::PATTERN::X_ABS_URI): 'file:/foo' is valid.
diff --git a/enum.c b/enum.c
index 321d084..29f507c 100644
--- a/enum.c
+++ b/enum.c
@@ -280,8 +280,9 @@ enum_sort_by(obj)
ary = rb_ary_new2((TYPE(obj) == T_ARRAY) ? RARRAY(obj)->len : 2000);
rb_iterate(rb_each, obj, sort_by_i, ary);
- if (RARRAY(ary)->len <= 1) return ary;
- qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp);
+ if (RARRAY(obj)->len > 1) {
+ qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp);
+ }
for (i=0; i<RARRAY(ary)->len; i++) {
VALUE e = RARRAY(ary)->ptr[i];
RARRAY(ary)->ptr[i] = RARRAY(e)->ptr[1];
diff --git a/eval.c b/eval.c
index b75edd1..ec339cd 100644
--- a/eval.c
+++ b/eval.c
@@ -2100,6 +2100,7 @@ svalue_to_avalue(v)
VALUE v;
{
if (NIL_P(v)) return rb_ary_new2(0);
+ if (v == Qundef) return rb_ary_new2(0);
if (TYPE(v) == T_ARRAY) {
if (RARRAY(v)->len > 1) return v;
return rb_ary_new3(1, v);
diff --git a/hash.c b/hash.c
index 43fbd28..5cc3638 100644
--- a/hash.c
+++ b/hash.c
@@ -240,7 +240,7 @@ rb_hash_s_create(argc, argv, klass)
hash = rb_hash_s_alloc(klass);
for (i=0; i<argc; i+=2) {
- st_insert(RHASH(hash)->tbl, argv[i], argv[i+1]);
+ rb_hash_aset(hash, argv[i], argv[i + 1]);
}
return hash;
@@ -314,7 +314,7 @@ rb_hash_fetch(argc, argv, hash)
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
if (rb_block_given_p()) {
if (argc > 1) {
- rb_raise(rb_eArgError, "wrong number of arguments", argc);
+ rb_raise(rb_eArgError, "wrong number of arguments");
}
return rb_yield(key);
}
diff --git a/parse.y b/parse.y
index 72fc118..a200f0b 100644
--- a/parse.y
+++ b/parse.y
@@ -3241,11 +3241,11 @@ yylex()
return '>';
case '"':
- return parse_string(c,c,c);
+ return parse_string(c,c,0);
case '`':
if (lex_state == EXPR_FNAME) return c;
if (lex_state == EXPR_DOT) return c;
- return parse_string(c,c,c);
+ return parse_string(c,c,0);
case '\'':
return parse_qstring(c,0);
@@ -3896,7 +3896,12 @@ yylex()
c = nextc();
}
if (ISDIGIT(c)) {
- rb_compile_error("`@%c' is not a valid instance variable name", c);
+ if (tokidx == 1) {
+ rb_compile_error("`@%c' is not a valid instance variable name", c);
+ }
+ else {
+ rb_compile_error("`@@%c' is not a valid class variable name", c);
+ }
}
if (!is_identchar(c)) {
pushback(c);
@@ -4196,7 +4201,7 @@ str_extend(list, term, paren)
if (c == paren) paren_nest++;
else if (c == term && (!paren || paren_nest-- == 0)) {
pushback(c);
- list_append(list, NEW_STR(rb_str_new2("#")));
+ list_append(list, NEW_STR(rb_str_new2("#{")));
rb_warn("bad substitution in string");
tokfix();
list_append(list, NEW_STR(rb_str_new(tok(), toklen())));