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.

* class.c (rb_include_module): should check whole ancestors to
  avoid duplicate module inclusion.

* string.c (trnext): should check backslash before updating "now"
  position.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-09-08 14:17:53 +00:00
parent 1bcc5eb922
commit 67245eec71
16 changed files with 143 additions and 69 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.
@ -31,28 +42,6 @@ Thu Sep 6 14:25:15 2001 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/digest.c (rb_digest_base_s_hexdigest): remove a debug * ext/digest/digest.c (rb_digest_base_s_hexdigest): remove a debug
print. print.
Sun Aug 26 20:26:40 2001 Koji Arai <JCA02266@nifty.ne.jp>
* ext/readline/readline.c: restore terminal mode
even if readline() interrupted.
* ext/readline/readline.c: returned string need to
be tainted.
* ext/readline/readline.c: fixed memory leak.
* ext/readline/readline.c: allow negative index.
* ext/readline/readline.c: added Readline::HISTORY.size
same as Readline::HISTORY.length
* ext/readline/readline.c: allow conditional parsing
of the ~/.inputrc file by `$if Ruby'.
* ext/readline/extconf.rb: check whether the
libreadline has the variable `rl_completion_append_character'
(this feature was implemented from GNU readline 2.1).
Thu Sep 6 13:56:14 2001 Akinori MUSHA <knu@iDaemons.org> Thu Sep 6 13:56:14 2001 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/digest.c (rb_digest_base_s_digest, * ext/digest/digest.c (rb_digest_base_s_digest,
@ -72,6 +61,16 @@ Thu Sep 6 07:16:14 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* ext/socket/socket.c (Init_socket): remove duplicating constants. * ext/socket/socket.c (Init_socket): remove duplicating constants.
Thu Sep 6 03:15:24 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* class.c (rb_include_module): should check whole ancestors to
avoid duplicate module inclusion.
Wed Sep 5 20:02:27 2001 Shin'ya Adzumi <adzumi@denpa.org>
* string.c (trnext): should check backslash before updating "now"
position.
Wed Sep 5 17:41:11 2001 WATANABE Hirofumi <eban@ruby-lang.org> Wed Sep 5 17:41:11 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/jcode.rb (_regexp_quote): fix quote handling. * lib/jcode.rb (_regexp_quote): fix quote handling.
@ -7205,6 +7204,28 @@ Fri Aug 28 17:32:55 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
* eval.c (rb_eval): should set return value (nil) explicitly if a * eval.c (rb_eval): should set return value (nil) explicitly if a
value is omitted for return statement. value is omitted for return statement.
Sun Aug 26 20:26:40 2001 Koji Arai <JCA02266@nifty.ne.jp>
* ext/readline/readline.c: restore terminal mode
even if readline() interrupted.
* ext/readline/readline.c: returned string need to
be tainted.
* ext/readline/readline.c: fixed memory leak.
* ext/readline/readline.c: allow negative index.
* ext/readline/readline.c: added Readline::HISTORY.size
same as Readline::HISTORY.length
* ext/readline/readline.c: allow conditional parsing
of the ~/.inputrc file by `$if Ruby'.
* ext/readline/extconf.rb: check whether the
libreadline has the variable `rl_completion_append_character'
(this feature was implemented from GNU readline 2.1).
Thu Aug 26 15:06:11 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp> Thu Aug 26 15:06:11 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
* gc.c (rb_gc): local variables may be placed beyond stack_end, so * gc.c (rb_gc): local variables may be placed beyond stack_end, so

View file

@ -122,7 +122,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:

16
class.c
View file

@ -291,7 +291,7 @@ void
rb_include_module(klass, module) rb_include_module(klass, module)
VALUE klass, module; VALUE klass, module;
{ {
VALUE p; VALUE p, c;
int changed = 0; int changed = 0;
rb_frozen_class_p(klass); rb_frozen_class_p(klass);
@ -312,22 +312,20 @@ rb_include_module(klass, module)
} }
OBJ_INFECT(klass, module); OBJ_INFECT(klass, module);
c = klass;
while (module) { while (module) {
/* ignore if the module included already in superclasses */ /* ignore if the module included already in superclasses */
for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) { for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
if (BUILTIN_TYPE(p) == T_ICLASS && if (BUILTIN_TYPE(p) == T_ICLASS &&
RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) { RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
if (RCLASS(module)->super) { goto skip;
rb_include_module(p, RCLASS(module)->super);
}
if (changed) rb_clear_cache();
return;
} }
} }
RCLASS(klass)->super = include_class_new(module, RCLASS(klass)->super); RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
klass = RCLASS(klass)->super; c = RCLASS(c)->super;
module = RCLASS(module)->super;
changed = 1; changed = 1;
skip:
module = RCLASS(module)->super;
} }
if (changed) rb_clear_cache(); if (changed) rb_clear_cache();
} }

9
dir.c
View file

@ -75,6 +75,13 @@ char *strchr _((char*,char));
#define downcase(c) (nocase && ISUPPER(c) ? tolower(c) : (c)) #define downcase(c) (nocase && ISUPPER(c) ? tolower(c) : (c))
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
# if defined(DJGPP)
# define CharNext(p) ((p) + mblen(p, MB_CUR_MAX))
# else
# define CharNext(p) ((p) + 1)
# endif
#endif
#if defined DOSISH #if defined DOSISH
#define isdirsep(c) ((c) == '/' || (c) == '\\') #define isdirsep(c) ((c) == '/' || (c) == '\\')
static char * static char *
@ -84,7 +91,7 @@ find_dirsep(s)
while (*s) { while (*s) {
if (isdirsep(*s)) if (isdirsep(*s))
return s; return s;
s++; s = CharNext(s);
} }
return 0; return 0;
} }

14
eval.c
View file

@ -7267,6 +7267,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;
@ -7294,8 +7295,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;
@ -7359,6 +7364,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");
@ -7395,8 +7401,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,5 +7,28 @@ digest.txt.ja
extconf.rb extconf.rb
lib/md5.rb lib/md5.rb
lib/sha1.rb lib/sha1.rb
md5/MANIFEST
md5/extconf.rb
md5/md5.c
md5/md5.h
md5/md5init.c
rmd160/MANIFEST
rmd160/extconf.rb
rmd160/rmd160.c
rmd160/rmd160.h
rmd160/rmd160hl.c
rmd160/rmd160init.c
sha1/MANIFEST
sha1/extconf.rb
sha1/sha1.c
sha1/sha1.h
sha1/sha1hl.c
sha1/sha1init.c
sha2/MANIFEST
sha2/extconf.rb
sha2/sha2.c
sha2/sha2.h
sha2/sha2hl.c
sha2/sha2init.c
test.rb test.rb
test.sh test.sh

2
file.c
View file

@ -2286,7 +2286,7 @@ extern VALUE rb_load_path;
int int
rb_find_file_ext(filep, ext) rb_find_file_ext(filep, ext)
VALUE *filep; VALUE *filep;
const char *const *ext; const char * const *ext;
{ {
char *path, *e, *found; char *path, *e, *found;
char *f = RSTRING(*filep)->ptr; char *f = RSTRING(*filep)->ptr;

View file

@ -48,6 +48,7 @@ class Resolv
def initialize(filename = DefaultFileName) def initialize(filename = DefaultFileName)
@filename = filename @filename = filename
@mutex = Mutex.new @mutex = Mutex.new
@initialized = nil
end end
def lazy_initialize def lazy_initialize
@ -106,6 +107,7 @@ class Resolv
def initialize(config="/etc/resolv.conf") def initialize(config="/etc/resolv.conf")
@mutex = Mutex.new @mutex = Mutex.new
@config = Config.new(config) @config = Config.new(config)
@initialized = nil
end end
def lazy_initialize def lazy_initialize
@ -157,7 +159,7 @@ class Resolv
end end
sender.send sender.send
reply = reply_name = nil reply = reply_name = nil
timeout (tout) { reply, reply_name = q.pop } timeout(tout) { reply, reply_name = q.pop }
case reply.rcode case reply.rcode
when RCode::NoError when RCode::NoError
return extract_resource(reply, reply_name, typeclass) return extract_resource(reply, reply_name, typeclass)
@ -385,6 +387,7 @@ class Resolv
def initialize(filename="/etc/resolv.conf") def initialize(filename="/etc/resolv.conf")
@mutex = Mutex.new @mutex = Mutex.new
@filename = filename @filename = filename
@initialized = nil
end end
def lazy_initialize def lazy_initialize

View file

@ -216,21 +216,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

@ -1112,17 +1112,19 @@ proc_setuid(obj, id)
uid = NUM2INT(id); uid = NUM2INT(id);
#if defined(HAVE_SETRESUID) && !defined(__CHECKER__) #if defined(HAVE_SETRESUID) && !defined(__CHECKER__)
setresuid(uid, -1, -1); if (setresuid(uid, -1, -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETREUID #elif defined HAVE_SETREUID
setreuid(uid, -1); if (setreuid(uid, -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETRUID #elif defined 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
return INT2FIX(uid); return INT2FIX(uid);
@ -1144,17 +1146,19 @@ proc_setgid(obj, id)
gid = NUM2INT(id); gid = NUM2INT(id);
#if defined(HAVE_SETRESGID) && !defined(__CHECKER__) #if defined(HAVE_SETRESGID) && !defined(__CHECKER__)
setresgid(gid, -1, -1); if (setresgid(gid, -1, -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETREGID #elif defined HAVE_SETREGID
setregid(gid, -1); if (setregid(gid, -1) < 0) rb_sys_fail(0);
#elif defined HAS_SETRGID #elif defined HAS_SETRGID
setrgid((GIDTYPE)gid); 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
return INT2FIX(gid); return INT2FIX(gid);
@ -1180,10 +1184,12 @@ proc_seteuid(obj, euid)
if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0); 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
return euid; return euid;
} }
@ -1209,10 +1215,12 @@ proc_setegid(obj, egid)
if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0); 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
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

@ -1967,11 +1967,11 @@ trnext(t)
for (;;) { for (;;) {
if (!t->gen) { if (!t->gen) {
if (t->p == t->pend) return -1; if (t->p == t->pend) return -1;
t->now = *(USTR)t->p++;
if (t->p < t->pend - 1 && *t->p == '\\') { if (t->p < t->pend - 1 && *t->p == '\\') {
t->p++; t->p++;
} }
else if (t->p < t->pend - 1 && *t->p == '-') { t->now = *(USTR)t->p++;
if (t->p < t->pend - 1 && *t->p == '-') {
t->p++; t->p++;
if (t->p < t->pend) { if (t->p < t->pend) {
if (t->now > *(USTR)t->p) { if (t->now > *(USTR)t->p) {

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.1" #define RUBY_VERSION "1.7.1"
#define RUBY_RELEASE_DATE "2001-09-05" #define RUBY_RELEASE_DATE "2001-09-08"
#define RUBY_VERSION_CODE 171 #define RUBY_VERSION_CODE 171
#define RUBY_RELEASE_CODE 20010905 #define RUBY_RELEASE_CODE 20010908