summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--configure.in2
-rw-r--r--file.c8
-rw-r--r--intern.h1
-rw-r--r--io.c4
-rw-r--r--numeric.c1
-rw-r--r--object.c41
-rw-r--r--parse.y24
-rw-r--r--version.h4
9 files changed, 77 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 63aa4c01e..846402202 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* 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>
- * 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.
diff --git a/configure.in b/configure.in
index fac0265e9..b24f49266 100644
--- a/configure.in
+++ b/configure.in
@@ -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\
setitimer setruid seteuid setreuid setrgid setegid setregid pause\
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_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
[AC_TRY_LINK([#include <time.h>
diff --git a/file.c b/file.c
index 737ed5d88..98098f904 100644
--- a/file.c
+++ b/file.c
@@ -940,12 +940,12 @@ rb_file_chmod(obj, vmode)
mode = NUM2INT(vmode);
GetOpenFile(obj, fptr);
-#if defined(DJGPP) || defined(NT) || defined(__BEOS__) || defined(__EMX__)
- if (!fptr->path) return Qnil;
- if (chmod(fptr->path, mode) == -1)
+#ifdef HAVE_FCHMOD
+ if (fchmod(fileno(fptr->f), mode) == -1)
rb_sys_fail(fptr->path);
#else
- if (fchmod(fileno(fptr->f), mode) == -1)
+ if (!fptr->path) return Qnil;
+ if (chmod(fptr->path, mode) == -1)
rb_sys_fail(fptr->path);
#endif
diff --git a/intern.h b/intern.h
index 6fe2783f2..913e2c085 100644
--- a/intern.h
+++ b/intern.h
@@ -227,6 +227,7 @@ VALUE rb_obj_untaint _((VALUE));
VALUE rb_obj_freeze _((VALUE));
VALUE rb_obj_id _((VALUE));
VALUE rb_convert_type _((VALUE,int,const char*,const char*));
+VALUE rb_to_int _((VALUE));
VALUE rb_Integer _((VALUE));
VALUE rb_Float _((VALUE));
VALUE rb_String _((VALUE));
diff --git a/io.c b/io.c
index 8394f9768..445832342 100644
--- a/io.c
+++ b/io.c
@@ -2481,7 +2481,11 @@ next_argv()
fw = rb_fopen(fn, "w");
#ifndef NO_SAFE_RENAME
fstat(fileno(fw), &st2);
+#ifdef HAVE_FCHMOD
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) {
fchown(fileno(fw), st.st_uid, st.st_gid);
}
diff --git a/numeric.c b/numeric.c
index 5761986ff..cc53c3660 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1564,6 +1564,7 @@ Init_Numeric()
rb_define_method(rb_cInteger, "next", int_succ, 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_int", 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, "round", int_to_i, 0);
diff --git a/object.c b/object.c
index 0e2285ee0..9b5d50a45 100644
--- a/object.c
+++ b/object.c
@@ -871,12 +871,37 @@ rb_convert_type(val, type, tname, method)
return val;
}
-VALUE
-rb_Integer(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
+rb_Integer(val)
+ VALUE val;
+{
switch (TYPE(val)) {
case T_FLOAT:
if (RFLOAT(val)->value <= (double)FIXNUM_MAX
@@ -897,17 +922,7 @@ rb_Integer(val)
default:
break;
}
-
- 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;
+ return rb_to_integer(val, "to_i");
}
static VALUE
diff --git a/parse.y b/parse.y
index bf391cf83..19def2f79 100644
--- a/parse.y
+++ b/parse.y
@@ -749,7 +749,26 @@ arg : lhs '=' 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);
+ if (need_negate) {
+ $$ = call_op($$, tUMINUS, 0, 0);
+ }
}
| tUPLUS arg
{
@@ -1891,6 +1910,7 @@ yyerror(msg)
}
static int heredoc_end;
+static int last_newline;
int ruby_in_compile = 0;
int ruby__end__seen;
@@ -1930,6 +1950,7 @@ yycompile(f, line)
ruby__end__seen = 0;
ruby_eval_tree = 0;
heredoc_end = 0;
+ last_newline = 0;
ruby_sourcefile = f;
ruby_in_compile = 1;
n = yyparse();
@@ -3823,9 +3844,10 @@ newline_node(node)
{
NODE *nl = 0;
if (node) {
+ if (nd_line(node) == last_newline) return node;
nl = NEW_NEWLINE(node);
fixpos(nl, node);
- nl->nd_nth = nd_line(node);
+ last_newline = nl->nd_nth = nd_line(node);
}
return nl;
}
diff --git a/version.h b/version.h
index 6d6ca7355..9f8914673 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#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_RELEASE_CODE 20001110
+#define RUBY_RELEASE_CODE 20001113