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

* eval.c (rb_thread_restore_context): save current value of

lastline and lastmatch in the thread struct for later restore.

* eval.c (rb_thread_save_context): restore lastline and lastmatch.

* numeric.c (flo_to_s): should handle negative float value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-09-08 14:06:14 +00:00
parent 3081543be9
commit b12951c688
11 changed files with 72 additions and 58 deletions

View file

@ -1,4 +1,4 @@
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@zetabits.com>. Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
You can redistribute it and/or modify it under either the terms of the GPL You can redistribute it and/or modify it under either the terms of the GPL
(see the file GPL), or the conditions below: (see the file GPL), or the conditions below:

View file

@ -3,6 +3,17 @@ Sat Sep 8 07:13:42 2001 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/net/telnet.rb: waitfor(): improvement. thanks to * lib/net/telnet.rb: waitfor(): improvement. thanks to
nobu.nakada@nifty.ne.jp nobu.nakada@nifty.ne.jp
Sat Sep 8 04:34:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_restore_context): save current value of
lastline and lastmatch in the thread struct for later restore.
* eval.c (rb_thread_save_context): restore lastline and lastmatch.
Fri Sep 7 11:27:56 2001 akira yamada <akira@ruby-lang.org>
* numeric.c (flo_to_s): should handle negative float value.
Fri Sep 7 09:44:44 2001 Wakou Aoyama <wakou@fsinet.or.jp> Fri Sep 7 09:44:44 2001 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/net/telnet.rb: waitfor(): bug fix. * lib/net/telnet.rb: waitfor(): bug fix.

View file

@ -121,7 +121,7 @@ realclean: distclean
@rm -f parse.c @rm -f parse.c
@rm -f lex.c @rm -f lex.c
test: miniruby$(EXEEXT) test: miniruby$(EXEEXT) rbconfig.rb
@./miniruby$(EXEEXT) $(srcdir)/rubytest.rb @./miniruby$(EXEEXT) $(srcdir)/rubytest.rb
rbconfig.rb: miniruby$(EXEEXT) $(srcdir)/mkconfig.rb config.status rbconfig.rb: miniruby$(EXEEXT) $(srcdir)/mkconfig.rb config.status

2
README
View file

@ -97,7 +97,7 @@ See the file COPYING.
Feel free to send comments and bug reports to the author. Here is the Feel free to send comments and bug reports to the author. Here is the
author's latest mail address: author's latest mail address:
matz@zetabits.com matz@netlab.jp
------------------------------------------------------- -------------------------------------------------------
created at: Thu Aug 3 11:57:36 JST 1995 created at: Thu Aug 3 11:57:36 JST 1995

View file

@ -145,7 +145,7 @@ COPYING.ja
* Ãø¼Ô * Ãø¼Ô
コメント,バグレポートその他は matz@zetabits.com まで. コメント,バグレポートその他は matz@netlab.jp まで.
------------------------------------------------------- -------------------------------------------------------
created at: Thu Aug 3 11:57:36 JST 1995 created at: Thu Aug 3 11:57:36 JST 1995
Local variables: Local variables:

14
eval.c
View file

@ -7154,6 +7154,7 @@ rb_thread_save_context(th)
{ {
VALUE *pos; VALUE *pos;
int len; int len;
static VALUE tval;
len = stack_length(&pos); len = stack_length(&pos);
th->stk_len = 0; th->stk_len = 0;
@ -7181,8 +7182,12 @@ rb_thread_save_context(th)
th->tracing = tracing; th->tracing = tracing;
th->errinfo = ruby_errinfo; th->errinfo = ruby_errinfo;
th->last_status = rb_last_status; th->last_status = rb_last_status;
th->last_line = rb_lastline_get(); tval = rb_lastline_get();
th->last_match = rb_backref_get(); rb_lastline_set(th->last_line);
th->last_line = tval;
tval = rb_backref_get();
rb_backref_set(th->last_match);
th->last_match = tval;
th->safe = ruby_safe_level; th->safe = ruby_safe_level;
th->file = ruby_sourcefile; th->file = ruby_sourcefile;
@ -7246,6 +7251,7 @@ rb_thread_restore_context(th, exit)
VALUE v; VALUE v;
static rb_thread_t tmp; static rb_thread_t tmp;
static int ex; static int ex;
static VALUE tval;
if (!th->stk_ptr) rb_bug("unsaved context"); if (!th->stk_ptr) rb_bug("unsaved context");
@ -7282,8 +7288,12 @@ rb_thread_restore_context(th, exit)
FLUSH_REGISTER_WINDOWS; FLUSH_REGISTER_WINDOWS;
MEMCPY(tmp->stk_pos, tmp->stk_ptr, VALUE, tmp->stk_len); MEMCPY(tmp->stk_pos, tmp->stk_ptr, VALUE, tmp->stk_len);
tval = rb_lastline_get();
rb_lastline_set(tmp->last_line); rb_lastline_set(tmp->last_line);
tmp->last_line = tval;
tval = rb_backref_get();
rb_backref_set(tmp->last_match); rb_backref_set(tmp->last_match);
tmp->last_match = tval;
longjmp(tmp->context, ex); longjmp(tmp->context, ex);
} }

View file

@ -7,24 +7,5 @@ digest.txt.ja
extconf.rb extconf.rb
lib/md5.rb lib/md5.rb
lib/sha1.rb lib/sha1.rb
md5/extconf.rb
md5/md5.c
md5/md5.h
md5/md5init.c
rmd160/extconf.rb
rmd160/rmd160.c
rmd160/rmd160.h
rmd160/rmd160hl.c
rmd160/rmd160init.c
sha1/extconf.rb
sha1/sha1.c
sha1/sha1.h
sha1/sha1hl.c
sha1/sha1init.c
sha2/extconf.rb
sha2/sha2.c
sha2/sha2.h
sha2/sha2hl.c
sha2/sha2init.c
test.rb test.rb
test.sh test.sh

View file

@ -210,21 +210,25 @@ flo_to_s(flt)
char buf[24]; char buf[24];
char *fmt = "%.10g"; char *fmt = "%.10g";
double value = RFLOAT(flt)->value; double value = RFLOAT(flt)->value;
double d1, d2; double avalue, d1, d2;
if (isinf(value)) if (isinf(value))
return rb_str_new2(value < 0 ? "-Infinity" : "Infinity"); return rb_str_new2(value < 0 ? "-Infinity" : "Infinity");
else if(isnan(value)) else if(isnan(value))
return rb_str_new2("NaN"); return rb_str_new2("NaN");
if (value < 1.0e-3) { avalue = fabs(value);
d1 = value; if (avalue == 0.0) {
fmt = "%.1f";
}
else if (avalue < 1.0e-3) {
d1 = avalue;
while (d1 < 1.0) d1 *= 10.0; while (d1 < 1.0) d1 *= 10.0;
d1 = modf(d1, &d2); d1 = modf(d1, &d2);
if (d1 == 0) fmt = "%.1e"; if (d1 == 0) fmt = "%.1e";
} }
else if (value >= 1.0e10) { else if (avalue >= 1.0e10) {
d1 = value; d1 = avalue;
while (d1 > 10.0) d1 /= 10.0; while (d1 > 10.0) d1 /= 10.0;
d1 = modf(d1, &d2); d1 = modf(d1, &d2);
if (d1 == 0) fmt = "%.1e"; if (d1 == 0) fmt = "%.1e";

View file

@ -953,16 +953,18 @@ proc_setuid(obj, id)
uid = NUM2INT(id); uid = NUM2INT(id);
#ifdef HAVE_SETREUID #ifdef HAVE_SETREUID
setreuid(uid, -1); if (setreuid(uid, -1) < 0) rb_sys_fail(0);
#else #else
#ifdef HAVE_SETRUID #ifdef HAVE_SETRUID
setruid(uid); if (setruid(uid) < 0) rb_sys_fail(0);
#else #else
{ {
if (geteuid() == uid) if (geteuid() == uid) {
setuid(uid); if (setuid(uid) < 0) rb_sys_fail(0);
else }
else {
rb_notimplement(); rb_notimplement();
}
} }
#endif #endif
#endif #endif
@ -984,17 +986,19 @@ proc_setgid(obj, id)
int gid; int gid;
gid = NUM2INT(id); gid = NUM2INT(id);
#ifdef HAS_SETRGID
setrgid((GIDTYPE)gid);
#else
#ifdef HAVE_SETREGID #ifdef HAVE_SETREGID
setregid(gid, -1); if (setregid(gid, -1) < 0) rb_sys_fail(0);
#else
#ifdef HAS_SETRGID
if (setrgid((GIDTYPE)gid) < 0) rb_sys_fail(0);
#else #else
{ {
if (getegid() == gid) if (getegid() == gid) {
setgid(gid); if (setgid(gid) < 0) rb_sys_fail(0);
else }
else {
rb_notimplement(); rb_notimplement();
}
} }
#endif #endif
#endif #endif
@ -1013,17 +1017,19 @@ static VALUE
proc_seteuid(obj, euid) proc_seteuid(obj, euid)
VALUE obj, euid; VALUE obj, euid;
{ {
#ifdef HAVE_SETEUID
if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0);
#else
#ifdef HAVE_SETREUID #ifdef HAVE_SETREUID
if (setreuid(-1, NUM2INT(euid)) < 0) rb_sys_fail(0); if (setreuid(-1, NUM2INT(euid)) < 0) rb_sys_fail(0);
#else
#ifdef HAVE_SETEUID
if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0);
#else #else
euid = NUM2INT(euid); euid = NUM2INT(euid);
if (euid == getuid()) if (euid == getuid()) {
setuid(euid); if (setuid(euid) < 0) rb_sys_fail(0);
else }
else {
rb_notimplement(); rb_notimplement();
}
#endif #endif
#endif #endif
return euid; return euid;
@ -1042,17 +1048,19 @@ proc_setegid(obj, egid)
VALUE obj, egid; VALUE obj, egid;
{ {
rb_secure(2); rb_secure(2);
#ifdef HAVE_SETEGID
if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0);
#else
#ifdef HAVE_SETREGID #ifdef HAVE_SETREGID
if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0); if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0);
#else
#ifdef HAVE_SETEGID
if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0);
#else #else
egid = NUM2INT(egid); egid = NUM2INT(egid);
if (egid == getgid()) if (egid == getgid()) {
setgid(egid); if (setgid(egid) < 0) rb_sys_fail(0);
else }
else {
rb_notimplement(); rb_notimplement();
}
#endif #endif
#endif #endif
return egid; return egid;

4
ruby.1
View file

@ -1,4 +1,4 @@
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@zetabits.com>. .\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
.na .na
.TH RUBY 1 "ruby 1.6" "2000-09-11" "Ruby Programmers Reference Guide" .TH RUBY 1 "ruby 1.6" "2000-09-11" "Ruby Programmers Reference Guide"
.SH NAME .SH NAME
@ -288,4 +288,4 @@ state messages during compiling scripts. You don't have to specify
this switch, unless you are going to debug the Ruby interpreter. this switch, unless you are going to debug the Ruby interpreter.
.PP .PP
.SH AUTHOR .SH AUTHOR
Ruby is designed and implemented by Yukihiro Matsumoto <matz@zetabits.com>. Ruby is designed and implemented by Yukihiro Matsumoto <matz@netlab.jp>.

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.5" #define RUBY_VERSION "1.6.5"
#define RUBY_RELEASE_DATE "2001-09-06" #define RUBY_RELEASE_DATE "2001-09-08"
#define RUBY_VERSION_CODE 165 #define RUBY_VERSION_CODE 165
#define RUBY_RELEASE_CODE 20010906 #define RUBY_RELEASE_CODE 20010908