git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-11-13 05:39:35 +00:00
parent 1db8e80b29
commit 2a1b0ff232
9 changed files with 77 additions and 22 deletions

View File

@ -1,3 +1,13 @@
Sat Nov 11 22:57:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (arg): uniformed treatment of -a**b, where a is a
number literal; hacky but behavior appears uniformed.
* parse.y (newline_node): reduce newline node (one per line).
* random.c (rb_f_srand): should be prohibited in safe level
greater than 4.
Sat Nov 11 08:34:18 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp> Sat Nov 11 08:34:18 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.31. * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.31.
@ -8,7 +18,9 @@ Sat Nov 11 08:34:18 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
Fri Nov 10 16:15:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Nov 10 16:15:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* error.c: T_SYMBOL was misplaced my T_UNDEF. * numeric.c (rb_num2long): use to_int, not to_i.
* error.c: T_SYMBOL was misplaced by T_UNDEF.
* parse.y (yylex): eval("^") caused infinite loop. * parse.y (yylex): eval("^") caused infinite loop.

View File

@ -237,7 +237,7 @@ AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\
truncate chsize times utimes fcntl lockf lstat symlink readlink\ truncate chsize times utimes fcntl lockf lstat symlink readlink\
setitimer setruid seteuid setreuid setrgid setegid setregid pause\ setitimer setruid seteuid setreuid setrgid setegid setregid pause\
getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\ getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\
dlopen sigprocmask sigaction _setjmp setsid telldir seekdir) dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod)
AC_STRUCT_TIMEZONE AC_STRUCT_TIMEZONE
AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight, AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
[AC_TRY_LINK([#include <time.h> [AC_TRY_LINK([#include <time.h>

8
file.c
View File

@ -940,12 +940,12 @@ rb_file_chmod(obj, vmode)
mode = NUM2INT(vmode); mode = NUM2INT(vmode);
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
#if defined(DJGPP) || defined(NT) || defined(__BEOS__) || defined(__EMX__) #ifdef HAVE_FCHMOD
if (!fptr->path) return Qnil; if (fchmod(fileno(fptr->f), mode) == -1)
if (chmod(fptr->path, mode) == -1)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
#else #else
if (fchmod(fileno(fptr->f), mode) == -1) if (!fptr->path) return Qnil;
if (chmod(fptr->path, mode) == -1)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
#endif #endif

View File

@ -227,6 +227,7 @@ VALUE rb_obj_untaint _((VALUE));
VALUE rb_obj_freeze _((VALUE)); VALUE rb_obj_freeze _((VALUE));
VALUE rb_obj_id _((VALUE)); VALUE rb_obj_id _((VALUE));
VALUE rb_convert_type _((VALUE,int,const char*,const char*)); VALUE rb_convert_type _((VALUE,int,const char*,const char*));
VALUE rb_to_int _((VALUE));
VALUE rb_Integer _((VALUE)); VALUE rb_Integer _((VALUE));
VALUE rb_Float _((VALUE)); VALUE rb_Float _((VALUE));
VALUE rb_String _((VALUE)); VALUE rb_String _((VALUE));

4
io.c
View File

@ -2481,7 +2481,11 @@ next_argv()
fw = rb_fopen(fn, "w"); fw = rb_fopen(fn, "w");
#ifndef NO_SAFE_RENAME #ifndef NO_SAFE_RENAME
fstat(fileno(fw), &st2); fstat(fileno(fw), &st2);
#ifdef HAVE_FCHMOD
fchmod(fileno(fw), st.st_mode); fchmod(fileno(fw), st.st_mode);
#else
chmod(fn, st.st_mode);
#endif
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) { if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
fchown(fileno(fw), st.st_uid, st.st_gid); fchown(fileno(fw), st.st_uid, st.st_gid);
} }

View File

@ -1564,6 +1564,7 @@ Init_Numeric()
rb_define_method(rb_cInteger, "next", int_succ, 0); rb_define_method(rb_cInteger, "next", int_succ, 0);
rb_define_method(rb_cInteger, "chr", int_chr, 0); rb_define_method(rb_cInteger, "chr", int_chr, 0);
rb_define_method(rb_cInteger, "to_i", int_to_i, 0); rb_define_method(rb_cInteger, "to_i", int_to_i, 0);
rb_define_method(rb_cInteger, "to_int", int_to_i, 0);
rb_define_method(rb_cInteger, "floor", int_to_i, 0); rb_define_method(rb_cInteger, "floor", int_to_i, 0);
rb_define_method(rb_cInteger, "ceil", int_to_i, 0); rb_define_method(rb_cInteger, "ceil", int_to_i, 0);
rb_define_method(rb_cInteger, "round", int_to_i, 0); rb_define_method(rb_cInteger, "round", int_to_i, 0);

View File

@ -871,12 +871,37 @@ rb_convert_type(val, type, tname, method)
return val; return val;
} }
static VALUE
rb_to_integer(val, method)
VALUE val;
char *method;
{
struct arg_to arg1, arg2;
arg1.val = arg2.val = val;
arg1.s = method;
arg2.s = "Integer";
val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2,
rb_eStandardError, rb_eNameError, 0);
if (!rb_obj_is_kind_of(val, rb_cInteger)) {
rb_raise(rb_eTypeError, "%s#%s_i should return Integer",
method, rb_class2name(CLASS_OF(arg1.val)));
}
return val;
}
VALUE
rb_to_int(val)
VALUE val;
{
return rb_to_integer(val, "to_int");
}
VALUE VALUE
rb_Integer(val) rb_Integer(val)
VALUE val; VALUE val;
{ {
struct arg_to arg1, arg2;
switch (TYPE(val)) { switch (TYPE(val)) {
case T_FLOAT: case T_FLOAT:
if (RFLOAT(val)->value <= (double)FIXNUM_MAX if (RFLOAT(val)->value <= (double)FIXNUM_MAX
@ -897,17 +922,7 @@ rb_Integer(val)
default: default:
break; break;
} }
return rb_to_integer(val, "to_i");
arg1.val = arg2.val = val;
arg1.s = "to_i";
arg2.s = "Integer";
val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2,
rb_eStandardError, rb_eNameError, 0);
if (!rb_obj_is_kind_of(val, rb_cInteger)) {
rb_raise(rb_eTypeError, "%s#to_i should return Integer",
rb_class2name(CLASS_OF(arg1.val)));
}
return val;
} }
static VALUE static VALUE

24
parse.y
View File

@ -749,7 +749,26 @@ arg : lhs '=' arg
} }
| arg tPOW arg | arg tPOW arg
{ {
int need_negate = Qfalse;
if (nd_type($1) == NODE_LIT) {
switch (TYPE($1->nd_lit)) {
case T_FIXNUM:
case T_FLOAT:
case T_BIGNUM:
if (RTEST(rb_funcall($1->nd_lit,'<',1,INT2FIX(0)))) {
$1->nd_lit = rb_funcall($1->nd_lit,rb_intern("-@"),0,0);
need_negate = Qtrue;
}
default:
break;
}
}
$$ = call_op($1, tPOW, 1, $3); $$ = call_op($1, tPOW, 1, $3);
if (need_negate) {
$$ = call_op($$, tUMINUS, 0, 0);
}
} }
| tUPLUS arg | tUPLUS arg
{ {
@ -1891,6 +1910,7 @@ yyerror(msg)
} }
static int heredoc_end; static int heredoc_end;
static int last_newline;
int ruby_in_compile = 0; int ruby_in_compile = 0;
int ruby__end__seen; int ruby__end__seen;
@ -1930,6 +1950,7 @@ yycompile(f, line)
ruby__end__seen = 0; ruby__end__seen = 0;
ruby_eval_tree = 0; ruby_eval_tree = 0;
heredoc_end = 0; heredoc_end = 0;
last_newline = 0;
ruby_sourcefile = f; ruby_sourcefile = f;
ruby_in_compile = 1; ruby_in_compile = 1;
n = yyparse(); n = yyparse();
@ -3823,9 +3844,10 @@ newline_node(node)
{ {
NODE *nl = 0; NODE *nl = 0;
if (node) { if (node) {
if (nd_line(node) == last_newline) return node;
nl = NEW_NEWLINE(node); nl = NEW_NEWLINE(node);
fixpos(nl, node); fixpos(nl, node);
nl->nd_nth = nd_line(node); last_newline = nl->nd_nth = nd_line(node);
} }
return nl; return nl;
} }

View File

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.2" #define RUBY_VERSION "1.6.2"
#define RUBY_RELEASE_DATE "2000-11-10" #define RUBY_RELEASE_DATE "2000-11-13"
#define RUBY_VERSION_CODE 162 #define RUBY_VERSION_CODE 162
#define RUBY_RELEASE_CODE 20001110 #define RUBY_RELEASE_CODE 20001113