Skip to content

Commit

Permalink
* parse.y (yylex): ternary ? can be followed by newline.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
matz committed Aug 29, 2001
1 parent 5f224f6 commit b47a994
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 60 deletions.
29 changes: 29 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
Wed Aug 29 02:18:53 2001 Yukihiro Matsumoto <[email protected]>

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

Tue Aug 28 00:40:48 2001 Yukihiro Matsumoto <[email protected]>

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

Fri Aug 24 15:17:40 2001 Yukihiro Matsumoto <[email protected]>

* 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 <[email protected]>

* dln.c (dln_strerror): fix a bug that sometimes made null message on
win32 (Tietew <[email protected]>'s patch).

* win32/win32.c (mystrerror): ditto.

Fri Aug 24 03:15:07 2001 Yukihiro Matsumoto <[email protected]>

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

Fri Aug 24 00:46:44 2001 Yukihiro Matsumoto <[email protected]>

* 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 <[email protected]>

* enum.c (sort_by_i): fix typo.
Expand Down
1 change: 1 addition & 0 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 0 additions & 2 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions doc/NEWS
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 6 additions & 7 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ext/extmk.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
43 changes: 23 additions & 20 deletions marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions misc/ruby-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 . ?/))
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -3082,7 +3082,7 @@ yylex()
return '?';
}
c = nextc();
if (c == -1 || c == 10) {
if (c == -1) {
rb_compile_error("incomplete character syntax");
return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions prec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading

0 comments on commit b47a994

Please sign in to comment.