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

* parse.y (yylex): ternary ? can be followed by newline.

* eval.c (rb_f_require): should check static linked libraries
  before raising exception.

* array.c (rb_ary_equal): check identiry equality first.

* string.c (rb_str_equal): ditto.

* struct.c (rb_struct_equal): ditto.

* numeric.c (Init_Numeric): undef Integer::new.

* eval.c (rb_eval): NODE_WHILE should update result for each
  conditional evaluation.

* eval.c (rb_eval): NODE_UNTIL should return last evaluated value
  (or value given to break).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-08-29 06:28:51 +00:00
parent 5f224f6869
commit b47a99485b
15 changed files with 100 additions and 60 deletions

View file

@ -1,3 +1,20 @@
Wed Aug 29 02:18:53 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (yylex): ternary ? can be followed by newline.
Tue Aug 28 00:40:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_f_require): should check static linked libraries
before raising exception.
Fri Aug 24 15:17:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_equal): check identiry equality first.
* string.c (rb_str_equal): ditto.
* struct.c (rb_struct_equal): ditto.
Fri Aug 24 14:38:17 2001 Usaku Nakamura <usa@ruby-lang.org>
* dln.c (dln_strerror): fix a bug that sometimes made null message on
@ -5,6 +22,18 @@ Fri Aug 24 14:38:17 2001 Usaku Nakamura <usa@ruby-lang.org>
* win32/win32.c (mystrerror): ditto.
Fri Aug 24 03:15:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (Init_Numeric): undef Integer::new.
Fri Aug 24 00:46:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): NODE_WHILE should update result for each
conditional evaluation.
* eval.c (rb_eval): NODE_UNTIL should return last evaluated value
(or value given to break).
Thu Aug 23 21:59:38 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* enum.c (sort_by_i): fix typo.

View file

@ -1388,6 +1388,7 @@ rb_ary_equal(ary1, ary2)
{
long i;
if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
for (i=0; i<RARRAY(ary1)->len; i++) {

View file

@ -1420,8 +1420,6 @@ Init_Bignum()
{
rb_cBignum = rb_define_class("Bignum", rb_cInteger);
rb_undef_method(CLASS_OF(rb_cBignum), "new");
rb_define_method(rb_cBignum, "to_s", rb_big_to_s, 0);
rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1);
rb_define_method(rb_cBignum, "-@", rb_big_uminus, 0);

View file

@ -1,3 +1,11 @@
: Enum#sort_by
Added.
: Signal
new module, has module functions Signal::trap and Signal::list.
: Curses
Updated. New methods and constants for using the mouse, character

13
eval.c
View file

@ -2280,7 +2280,7 @@ rb_eval(self, n)
rb_eval(self, node->nd_body);
while_next:
;
} while (RTEST(rb_eval(self, node->nd_cond)));
} while (RTEST(result = rb_eval(self, node->nd_cond)));
break;
case TAG_REDO:
@ -2311,7 +2311,7 @@ rb_eval(self, n)
rb_eval(self, node->nd_body);
until_next:
;
} while (!RTEST(rb_eval(self, node->nd_cond)));
} while (!RTEST(result = rb_eval(self, node->nd_cond)));
break;
case TAG_REDO:
@ -2329,7 +2329,7 @@ rb_eval(self, n)
until_out:
POP_TAG();
if (state) JUMP_TAG(state);
RETURN(Qnil);
RETURN(result);
case NODE_BLOCK_PASS:
result = block_pass(self, node);
@ -3976,7 +3976,7 @@ handle_rescue(self, node)
if (!rb_obj_is_kind_of(argv[0], rb_cModule)) {
rb_raise(rb_eTypeError, "class or module required for rescue clause");
}
if (rb_funcall(*argv, eqq, 1, ruby_errinfo)) return 1;
if (RTEST(rb_funcall(*argv, eqq, 1, ruby_errinfo))) return 1;
argv++;
}
return 0;
@ -5494,6 +5494,8 @@ rb_f_require(obj, fname)
fname = rb_find_file(tmp);
goto load_dyna;
}
if (rb_feature_p(RSTRING(fname)->ptr, Qfalse))
return Qfalse;
rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
load_dyna:
@ -8329,9 +8331,6 @@ rb_thread_start_0(fn, arg, th_arg)
while (saved_block) {
struct BLOCK *tmp = saved_block;
if (curr_thread == main_thread) {
printf("free(%p)\n", saved_block);
}
if (tmp->frame.argc > 0)
free(tmp->frame.argv);
saved_block = tmp->prev;

View file

@ -740,7 +740,7 @@ if $extlist.size > 0
if File.exist?(f)
$extinit += format("\
\tInit_%s();\n\
\trb_provide(\"%s.so\");\n\
\trb_provide(\"%s\");\n\
", t, s)
$extobjs += "ext/"
$extobjs += f

View file

@ -357,6 +357,7 @@ VALUE rb_struct_alloc _((VALUE, VALUE));
VALUE rb_struct_aref _((VALUE, VALUE));
VALUE rb_struct_aset _((VALUE, VALUE, VALUE));
VALUE rb_struct_getmember _((VALUE, ID));
VALUE rb_struct_iv_get _((VALUE, char*));
/* time.c */
VALUE rb_time_new(ANYARGS);
/* variable.c */

View file

@ -26,7 +26,7 @@ typedef unsigned short BDIGIT;
#define SIZEOF_BDIGITS SIZEOF_SHORT
#endif
#define BITSPERSHORT (sizeof(short)*CHAR_BIT)
#define BITSPERSHORT (2*CHAR_BIT)
#define SHORTMASK ((1<<BITSPERSHORT)-1)
#define SHORTDN(x) RSHIFT(x,BITSPERSHORT)
@ -46,7 +46,7 @@ shortlen(len, ds)
num = SHORTDN(num);
offset++;
}
return (len - 1)*sizeof(BDIGIT)/sizeof(short) + offset;
return (len - 1)*sizeof(BDIGIT)/2 + offset;
}
#define SHORTLEN(x) shortlen((x),d)
#endif
@ -129,11 +129,8 @@ w_short(x, arg)
int x;
struct dump_arg *arg;
{
int i;
for (i=0; i<sizeof(short); i++) {
w_byte((x >> (i*8)) & 0xff, arg);
}
w_byte((x >> 0) & 0xff, arg);
w_byte((x >> 8) & 0xff, arg);
}
static void
@ -145,7 +142,7 @@ w_long(x, arg)
int i, len = 0;
#if SIZEOF_LONG > 4
if (!(RSHIFT(x, 32) == 0 || RSHIFT(x, 32) == -1)) {
if (!(RSHIFT(x, 31) == 0 || RSHIFT(x, 31) == -1)) {
/* big long does not fit in 4 bytes */
rb_raise(rb_eTypeError, "long too big to dump");
}
@ -452,7 +449,7 @@ w_object(obj, arg, limit)
w_unique(rb_class2name(CLASS_OF(obj)), arg);
w_long(len, arg);
mem = rb_ivar_get(rb_obj_class(obj), rb_intern("__member__"));
mem = rb_struct_iv_get(rb_obj_class(obj), "__member__");
if (mem == Qnil) {
rb_raise(rb_eTypeError, "uninitialized struct");
}
@ -601,12 +598,9 @@ r_short(arg)
struct load_arg *arg;
{
unsigned short x;
int i;
x = 0;
for (i=0; i<sizeof(short); i++) {
x |= r_byte(arg)<<(i*8);
}
x = r_byte(arg);
x |= r_byte(arg)<<8;
return x;
}
@ -619,13 +613,21 @@ long_toobig(size)
sizeof(long), size);
}
#undef SIGN_EXTEND_CHAR
#if __STDC__
# define SIGN_EXTEND_CHAR(c) ((signed char)(c))
#else /* not __STDC__ */
/* As in Harbison and Steele. */
# define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
#endif
static long
r_long(arg)
struct load_arg *arg;
{
register long x;
int c = (char)r_byte(arg);
int i;
int c = SIGN_EXTEND_CHAR(r_byte(arg));
long i;
if (c == 0) return 0;
if (c > 0) {
@ -646,7 +648,7 @@ r_long(arg)
if (c > sizeof(long)) long_toobig(c);
x = -1;
for (i=0;i<c;i++) {
x &= ~(0xff << (8*i));
x &= ~((long)0xff << (8*i));
x |= (long)r_byte(arg) << (8*i);
}
}
@ -795,7 +797,8 @@ r_object(arg)
{
VALUE c = rb_path2class(r_unique(arg));
v = r_object(arg);
if (rb_special_const_p(v)) {
if (rb_special_const_p(v) ||
!RTEST(rb_funcall(c, rb_intern("==="), 1, v))) {
rb_raise(rb_eArgError, "dump format error (user class)");
}
RBASIC(v)->klass = c;
@ -838,7 +841,7 @@ r_object(arg)
#if SIZEOF_BDIGITS == SIZEOF_SHORT
big->len = len;
#else
big->len = (len + 1) * sizeof(short) / sizeof(BDIGIT);
big->len = (len + 1) * 2 / sizeof(BDIGIT);
#endif
big->digits = digits = ALLOC_N(BDIGIT, big->len);
while (len > 0) {
@ -847,7 +850,7 @@ r_object(arg)
int shift = 0;
int i;
for (i=0; i<SIZEOF_BDIGITS; i+=sizeof(short)) {
for (i=0; i<SIZEOF_BDIGITS; i+=2) {
int j = r_short(arg);
num |= j << shift;
shift += BITSPERSHORT;

View file

@ -672,19 +672,19 @@ An end of a defun is found by moving forward from the beginning of one."
;; #{ }, #$hoge, #@foo are not comments
("\\(#\\)[{$@]" 1 (1 . nil))
;; the last $' in the string ,'...$' is not variable
("\\(^\\|[[\\s <+(,]\\)\\('\\)[^'\n\\\\]*\\(\\\\.[^'\n\\\\]*\\)*\\$\\('\\)"
("\\(^\\|[[\\s <+(,]\\)\\('\\)[^'\n\\\\]*\\(\\\\.[^'\n\\\\]*\\)*[\\?\\$]\\('\\)"
(2 (7 . nil))
(4 (7 . nil)))
;; the last $` in the string ,`...$` is not variable
("\\(^\\|[[\\s <+(,]\\)\\(`\\)[^`\n\\\\]*\\(\\\\.[^`\n\\\\]*\\)*\\$\\(`\\)"
("\\(^\\|[[\\s <+(,]\\)\\(`\\)[^`\n\\\\]*\\(\\\\.[^`\n\\\\]*\\)*[\\?\\$]\\(`\\)"
(2 (7 . nil))
(4 (7 . nil)))
;; the last $" in the string ,"...$" is not variable
("\\(^\\|[[\\s <+(,]\\)\\(\"\\)[^\"\n\\\\]*\\(\\\\.[^\"\n\\\\]*\\)*\\$\\(\"\\)"
("\\(^\\|[[\\s <+(,]\\)\\(\"\\)[^\"\n\\\\]*\\(\\\\.[^\"\n\\\\]*\\)*[\\?\\$]\\(\"\\)"
(2 (7 . nil))
(4 (7 . nil)))
;; $' $" $` .... are variables
("\\$[#\"'`$\\]" 0 (1 . nil))
("[\\?\\$][#\"'`]" 0 (1 . nil))
;; regexps
("\\(^\\|[=(,~?:;]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
(4 (7 . ?/))
@ -714,12 +714,12 @@ An end of a defun is found by moving forward from the beginning of one."
(let (beg)
(save-excursion
(if (and (re-search-backward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
(string= (match-string-no-properties 1) "begin"))
(string= (match-string 1) "begin"))
(progn
(beginning-of-line)
(setq beg (point)))))
(if (and beg (and (re-search-forward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
(string= (match-string-no-properties 1) "end")))
(string= (match-string 1) "end")))
(progn
(set-match-data (list beg (point)))
t)

View file

@ -1566,6 +1566,8 @@ Init_Numeric()
rb_define_method(rb_cNumeric, "truncate", num_truncate, 0);
rb_cInteger = rb_define_class("Integer", rb_cNumeric);
rb_undef_method(CLASS_OF(rb_cInteger), "new");
rb_define_method(rb_cInteger, "integer?", int_int_p, 0);
rb_define_method(rb_cInteger, "upto", int_upto, 1);
rb_define_method(rb_cInteger, "downto", int_downto, 1);
@ -1587,8 +1589,6 @@ Init_Numeric()
rb_define_singleton_method(rb_cFixnum, "induced_from", rb_fix_induced_from, 1);
rb_define_singleton_method(rb_cInteger, "induced_from", rb_int_induced_from, 1);
rb_undef_method(CLASS_OF(rb_cFixnum), "new");
rb_define_method(rb_cFixnum, "to_s", fix_to_s, 0);
rb_define_method(rb_cFixnum, "type", fix_type, 0);

View file

@ -3082,7 +3082,7 @@ yylex()
return '?';
}
c = nextc();
if (c == -1 || c == 10) {
if (c == -1) {
rb_compile_error("incomplete character syntax");
return 0;
}

5
prec.c
View file

@ -51,7 +51,7 @@ prec_induced_from(module, x)
}
static VALUE
prec_append_features(module, include)
prec_included(module, include)
VALUE module, include;
{
switch (TYPE(include)) {
@ -62,7 +62,6 @@ prec_append_features(module, include)
Check_Type(include, T_CLASS);
break;
}
rb_include_module(include, module);
rb_define_singleton_method(include, "induced_from", prec_induced_from, 1);
return module;
}
@ -72,7 +71,7 @@ void
Init_Precision()
{
rb_mPrecision = rb_define_module("Precision");
rb_define_singleton_method(rb_mPrecision, "append_features", prec_append_features, 1);
rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1);
rb_define_method(rb_mPrecision, "prec", prec_prec, 1);
rb_define_method(rb_mPrecision, "prec_i", prec_prec_i, 0);
rb_define_method(rb_mPrecision, "prec_f", prec_prec_f, 0);

View file

@ -694,6 +694,7 @@ static VALUE
rb_str_equal(str1, str2)
VALUE str1, str2;
{
if (str1 == str2) return Qtrue;
if (TYPE(str2) != T_STRING)
return Qfalse;

View file

@ -16,19 +16,19 @@ VALUE rb_cStruct;
static VALUE struct_alloc _((int, VALUE*, VALUE));
static VALUE
iv_get(obj, name)
VALUE obj;
VALUE
rb_struct_iv_get(c, name)
VALUE c;
char *name;
{
ID id;
id = rb_intern(name);
for (;;) {
if (rb_ivar_defined(obj, id))
return rb_ivar_get(obj, id);
obj = RCLASS(obj)->super;
if (obj == 0 || obj == rb_cStruct)
if (rb_ivar_defined(c, id))
return rb_ivar_get(c, id);
c = RCLASS(c)->super;
if (c == 0 || c == rb_cStruct)
return Qnil;
}
}
@ -40,7 +40,7 @@ rb_struct_s_members(obj)
VALUE member, ary;
VALUE *p, *pend;
member = iv_get(obj, "__member__");
member = rb_struct_iv_get(obj, "__member__");
if (NIL_P(member)) {
rb_bug("uninitialized struct");
}
@ -69,7 +69,7 @@ rb_struct_getmember(obj, id)
VALUE member, slot;
long i;
member = iv_get(rb_obj_class(obj), "__member__");
member = rb_struct_iv_get(rb_obj_class(obj), "__member__");
if (NIL_P(member)) {
rb_bug("uninitialized struct");
}
@ -130,7 +130,7 @@ rb_struct_set(obj, val)
VALUE member, slot;
long i;
member = iv_get(rb_obj_class(obj), "__member__");
member = rb_struct_iv_get(rb_obj_class(obj), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@ -255,7 +255,7 @@ rb_struct_initialize(self, values)
long n;
rb_struct_modify(self);
size = iv_get(klass, "__size__");
size = rb_struct_iv_get(klass, "__size__");
n = FIX2LONG(size);
if (n < RARRAY(values)->len) {
rb_raise(rb_eArgError, "struct size differs");
@ -280,7 +280,7 @@ struct_alloc(argc, argv, klass)
NEWOBJ(st, struct RStruct);
OBJSETUP(st, klass, T_STRUCT);
size = iv_get(klass, "__size__");
size = rb_struct_iv_get(klass, "__size__");
n = FIX2LONG(size);
st->ptr = ALLOC_N(VALUE, n);
@ -311,7 +311,7 @@ rb_struct_new(klass, va_alist)
long size, i;
va_list args;
sz = iv_get(klass, "__size__");
sz = rb_struct_iv_get(klass, "__size__");
size = FIX2LONG(sz);
mem = ALLOCA_N(VALUE, size);
va_init_list(args, klass);
@ -355,7 +355,7 @@ inspect_struct(s)
VALUE str, member;
long i;
member = iv_get(rb_obj_class(s), "__member__");
member = rb_struct_iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@ -426,7 +426,7 @@ rb_struct_aref_id(s, id)
VALUE member;
long i, len;
member = iv_get(rb_obj_class(s), "__member__");
member = rb_struct_iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@ -470,7 +470,7 @@ rb_struct_aset_id(s, id, val)
VALUE member;
long i, len;
member = iv_get(rb_obj_class(s), "__member__");
member = rb_struct_iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@ -516,6 +516,7 @@ rb_struct_equal(s, s2)
{
long i;
if (s == s2) return Qtrue;
if (TYPE(s2) != T_STRUCT) return Qfalse;
if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse;
if (RSTRUCT(s)->len != RSTRUCT(s2)->len) {

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.1"
#define RUBY_RELEASE_DATE "2001-08-24"
#define RUBY_RELEASE_DATE "2001-08-29"
#define RUBY_VERSION_CODE 171
#define RUBY_RELEASE_CODE 20010824
#define RUBY_RELEASE_CODE 20010829