1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (svalue_to_avalue): v may be Qundef. This fix was

suggested by Guy Decoux.

* hash.c (rb_hash_s_create): use rb_hash_aset() instead of calling
  st_insert() directly, to dup&freeze string keys.

* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-06-13 03:55:44 +00:00
parent a2020f907a
commit b3ecbfaa01
5 changed files with 36 additions and 8 deletions

View file

@ -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.

5
enum.c
View file

@ -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];

1
eval.c
View file

@ -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);

4
hash.c
View file

@ -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);
}

13
parse.y
View file

@ -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())));