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

2000-03-13

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-03-13 07:18:45 +00:00
parent 976692f8ae
commit 31c55301e4
16 changed files with 198 additions and 78 deletions

View file

@ -1,3 +1,51 @@
Mon Mar 13 16:12:13 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (block_pass): distinguish real orphan block and still
on-stack block passed by block argument.
Mon Mar 13 00:20:25 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (f_norm_arg): proper error message when constant comes
in formal argument list. this message is suggested by Muvaw
Pnazte <bugathlon@yahoo.com>.
* eval.c (rb_f_raise): proper error message when the first
argument is not an exception class/object.
* string.c (rb_str_dup): dup now postpone buffer copy as long as
possible. performance improved by lazy copying.
Sun Mar 12 13:58:52 2000 Koji Arai <JCA02266@nifty.ne.jp>
* signal.c (rb_f_kill): should treat some symbols as the signal.
Sat Mar 11 22:03:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (rb_str_gsub): performance tune by avoiding buffer copy.
* eval.c (rb_f_missing): check if argv[0] is ID.
Sat Mar 11 15:49:41 2000 Tadayoshi Funaba <tadf@kt.rim.or.jp>
* struct.c (rb_struct_aref): struct aref by symbol.
Sat Mar 11 05:07:11 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* process.c (proc_setpriority): should return 0, not nil.
* process.c (proc_setpgid): ditto.
Fri Mar 10 18:14:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* file.c (path_check_1): confusing buf and path. this bug found
by <decoux@moulon.inra.fr>.
Fri Mar 10 09:37:49 JST 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* MANIFEST: add beos/GNUmakefile.in.
* configure.in: support BeOS R4.5.2 (Intel).
* beos/GNUmakefile.in: new file to support BeOS R4.5.2 (Intel).
Thu Mar 9 11:13:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_compile_fastmap): fixed embarrassing brace bug.

View file

@ -75,6 +75,7 @@ util.c
variable.c
version.c
version.h
beos/GNUmakefile.in
beos/ruby.def.in
cygwin/GNUmakefile.in
ext/Setup
@ -125,6 +126,8 @@ lib/mkmf.rb
lib/monitor.rb
lib/mutex_m.rb
lib/net/http.rb
lib/net/ftp.rb
lib/net/http.rb
lib/net/pop.rb
lib/net/session.rb
lib/net/smtp.rb

3
configure vendored
View file

@ -4827,6 +4827,7 @@ fi
FIRSTMAKEFILE=""
LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
LIBRUBY='$(LIBRUBY_A)'
LIBRUBYARG='$(LIBRUBY_A)'
@ -4843,6 +4844,7 @@ if test "$target_os" = "beos"; then
;;
i586*)
LDFLAGS="$LDFLAGS -L."
FIRSTMAKEFILE=GNUmakefile:beos/GNUmakefile.in
;;
*)
echo EXPORTS > ruby.def
@ -4851,7 +4853,6 @@ if test "$target_os" = "beos"; then
esac
fi
FIRSTMAKEFILE=""
LIBRUBY_LDSHARED=$LDSHARED
LIBRUBY_DLDFLAGS=$DLDFLAGS
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'

View file

@ -671,6 +671,7 @@ fi
AC_SUBST(MINIRUBY)
AC_SUBST(PREP)
FIRSTMAKEFILE=""
LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
LIBRUBY='$(LIBRUBY_A)'
LIBRUBYARG='$(LIBRUBY_A)'
@ -687,6 +688,7 @@ if test "$target_os" = "beos"; then
;;
i586*)
LDFLAGS="$LDFLAGS -L."
FIRSTMAKEFILE=GNUmakefile:beos/GNUmakefile.in
;;
*)
echo EXPORTS > ruby.def
@ -695,7 +697,6 @@ if test "$target_os" = "beos"; then
esac
fi
FIRSTMAKEFILE=""
LIBRUBY_LDSHARED=$LDSHARED
LIBRUBY_DLDFLAGS=$DLDFLAGS
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'

63
eval.c
View file

@ -3222,6 +3222,8 @@ rb_f_raise(argc, argv)
VALUE *argv;
{
VALUE mesg;
ID exception;
int n;
mesg = Qnil;
switch (argc) {
@ -3234,17 +3236,24 @@ rb_f_raise(argc, argv)
mesg = rb_exc_new3(rb_eRuntimeError, argv[0]);
break;
}
mesg = rb_funcall(argv[0], rb_intern("exception"), 0, 0);
break;
case 3:
n = 0;
goto exception_call;
case 2:
mesg = rb_funcall(argv[0], rb_intern("exception"), 1, argv[1]);
case 3:
n = 1;
exception_call:
exception = rb_intern("exception");
if (!rb_respond_to(argv[0], exception)) {
rb_raise(rb_eTypeError, "exception class/object expected");
}
mesg = rb_funcall(argv[0], exception, n, argv[1]);
break;
default:
rb_raise(rb_eArgError, "wrong # of arguments");
break;
}
if (!NIL_P(mesg)) {
if (argc > 0) {
if (!rb_obj_is_kind_of(mesg, rb_eException))
rb_raise(rb_eTypeError, "exception object expected");
set_backtrace(mesg, (argc>2)?argv[2]:Qnil);
@ -3739,9 +3748,11 @@ rb_f_missing(argc, argv, obj)
char *file = ruby_sourcefile;
int line = ruby_sourceline;
if (argc == 0) rb_raise(rb_eArgError, "no id given");
if (argc == 0 || !SYMBOL_P(argv[0])) {
rb_raise(rb_eArgError, "no id given");
}
id = NUM2INT(argv[0]);
id = SYM2ID(argv[0]);
argc--; argv++;
switch (TYPE(obj)) {
@ -5892,25 +5903,35 @@ block_pass(self, node)
POP_TAG();
POP_ITER();
if (_block.tag->dst == state) {
state &= TAG_MASK;
orphan = 2;
if (orphan) {
state &= TAG_MASK;
}
else {
struct BLOCK *ptr = old_block;
while (ptr) {
if (ptr->scope == _block.scope) {
ptr->tag->dst = state;
break;
}
ptr = ptr->prev;
}
}
}
ruby_block = old_block;
ruby_safe_level = safe;
if (state) {
if (orphan == 2) {/* escape from orphan procedure */
switch (state) {
case TAG_BREAK:
rb_raise(rb_eLocalJumpError, "break from proc-closure");
break;
case TAG_RETRY:
rb_raise(rb_eLocalJumpError, "retry from proc-closure");
break;
case TAG_RETURN:
rb_raise(rb_eLocalJumpError, "return from proc-closure");
break;
}
switch (state) {/* escape from orphan procedure */
case TAG_BREAK:
rb_raise(rb_eLocalJumpError, "break from proc-closure");
break;
case TAG_RETRY:
rb_raise(rb_eLocalJumpError, "retry from proc-closure");
break;
case TAG_RETURN:
rb_raise(rb_eLocalJumpError, "return from proc-closure");
break;
}
JUMP_TAG(state);
}

4
file.c
View file

@ -1957,9 +1957,9 @@ path_check_1(path)
char buf[MAXPATHLEN+1];
#ifdef HAVE_GETCWD
if (getcwd(path, sizeof(path)) == 0) return 0;
if (getcwd(buf, MAXPATHLEN) == 0) return 0;
#else
if (getwd(path) == 0) return 0;
if (getwd(buf) == 0) return 0;
#endif
strncat(buf, path, MAXPATHLEN);
buf[MAXPATHLEN] = '\0';

View file

@ -18,14 +18,14 @@ end
ruby_install_name = CONFIG["ruby_install_name"]
version = "/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
arch = version+"/"+CONFIG["arch"]
arch = "/"+CONFIG["arch"]
bindir = destdir+CONFIG["bindir"]
libdir = destdir+CONFIG["libdir"]
scriptdir = destdir+CONFIG["prefix"]+"/lib/ruby"+version
archlibdir = libdir+"/ruby"+arch
sitelibdir = libdir+"/site_ruby"+version
sitearchlibdir = libdir+"/site_ruby"+arch
rubylibdir = destdir+CONFIG["prefix"]+"/lib/ruby"+version
archlibdir = rubylibdir+arch
sitelibdir = destdir+CONFIG["prefix"]+"/lib/site_ruby"+version
sitearchlibdir = sitelibdir+arch
mandir = destdir+CONFIG["mandir"] + "/man1"
wdir = Dir.getwd
@ -52,7 +52,7 @@ if File.exist? CONFIG["LIBRUBY_SO"]
end
end
Dir.chdir wdir
File.makedirs scriptdir, true
File.makedirs rubylibdir, true
File.makedirs archlibdir, true
File.makedirs sitelibdir, true
File.makedirs sitearchlibdir, true
@ -71,7 +71,7 @@ Dir.chdir CONFIG["srcdir"]
Find.find("lib") do |f|
next unless /\.rb$/ =~ f
dir = scriptdir+"/"+File.dirname(f[4..-1])
dir = rubylibdir+"/"+File.dirname(f[4..-1])
File.makedirs dir, true unless File.directory? dir
File.install f, dir, 0644, true
end

View file

@ -195,10 +195,10 @@ class Date
def once(*ids)
for id in ids
module_eval <<-"end;"
alias_method :__#{id}__, #{id}
alias_method :__#{id.to_i}__, #{id}
def #{id.id2name}(*args, &block)
def self.#{id.id2name}(*args, &block); @__#{id}__ end
@__#{id}__ = __#{id}__(*args, &block)
def self.#{id.id2name}(*args, &block); @__#{id.to_i}__ end
@__#{id.to_i}__ = __#{id.to_i}__(*args, &block)
end
end;
end

View file

@ -1573,7 +1573,11 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
$$ = NEW_ARGS(0, 0, -1);
}
f_norm_arg : tIDENTIFIER
f_norm_arg : tCONSTANT
{
yyerror("formal argument must not be constant");
}
| tIDENTIFIER
{
if (!is_local_id($1))
yyerror("formal argument must be local variable");

View file

@ -783,7 +783,7 @@ proc_setpgrp(argc, argv)
rb_scan_args(argc, argv, "0");
if (setpgrp() < 0) rb_sys_fail(0);
#endif
return Qnil;
return INT2FIX(0);
#else
rb_notimplement();
#endif
@ -815,7 +815,7 @@ proc_setpgid(obj, pid, pgrp)
ipgrp = NUM2INT(pgrp);
if (setpgid(ipid, ipgrp) < 0) rb_sys_fail(0);
return Qnil;
return INT2FIX(0);
#else
rb_notimplement();
#endif

View file

@ -143,8 +143,8 @@ while tmp.gets()
gsub!('VT100', 'Vt100')
redo;
end
$bad = 1 if /vt100/;
$bad = 1 if /VT100/;
$bad = 1 if /vt100/
$bad = 1 if /VT100/
end
ok(tmp.eof? && !$bad)
tmp.close
@ -181,6 +181,7 @@ until i>4
end
ok(i>4)
# exception handling
check "exception";

View file

@ -202,13 +202,13 @@ rb_f_kill(argc, argv)
switch (TYPE(argv[0])) {
case T_FIXNUM:
sig = FIX2UINT(argv[0]);
if (sig >= NSIG) {
s = rb_id2name(sig);
if (!s) rb_raise(rb_eArgError, "bad signal");
goto str_signal;
}
break;
case T_SYMBOL:
s = rb_id2name(SYM2ID(argv[0]));
if (!s) rb_raise(rb_eArgError, "bad signal");
goto str_signal;
case T_STRING:
{
s = RSTRING(argv[0])->ptr;

View file

@ -106,9 +106,7 @@ rb_str_new4(orig)
str->ptr = RSTRING(orig)->ptr;
RSTRING(orig)->orig = (VALUE)str;
str->orig = 0;
if (OBJ_TAINTED(orig)) {
OBJ_TAINT(str);
}
OBJ_INFECT(str, orig);
OBJ_FREEZE(str);
return (VALUE)str;
@ -162,23 +160,7 @@ rb_obj_as_string(obj)
}
static VALUE
rb_str_clone(str)
VALUE str;
{
VALUE clone;
if (RSTRING(str)->orig && !FL_TEST(str, STR_NO_ORIG))
clone = rb_str_new3(RSTRING(str)->orig);
else
clone = rb_str_new(RSTRING(str)->ptr, RSTRING(str)->len);
if (RSTRING(str)->orig && FL_TEST(str, STR_NO_ORIG))
RSTRING(str)->orig = RSTRING(str)->orig;
CLONESETUP(clone, str);
return clone;
}
VALUE
rb_str_dup(str)
str_dup(str)
VALUE str;
{
VALUE s;
@ -190,6 +172,43 @@ rb_str_dup(str)
return s;
}
VALUE
rb_str_dup(str)
VALUE str;
{
if (TYPE(str) != T_STRING) str = rb_str_to_str(str);
if (OBJ_FROZEN(str)) return rb_str_new3(str);
if (FL_TEST(str, STR_NO_ORIG)) return str_dup(str);
if (RSTRING(str)->orig) return rb_str_new3(RSTRING(str)->orig);
else {
VALUE shadow;
NEWOBJ(dup, struct RString);
OBJSETUP(dup, rb_cString, T_STRING);
shadow = rb_str_new4(str);
dup->len = RSTRING(shadow)->len;
dup->ptr = RSTRING(shadow)->ptr;
dup->orig = shadow;
OBJ_INFECT(dup, str);
return (VALUE)dup;
}
}
static VALUE
rb_str_clone(str)
VALUE str;
{
VALUE clone = rb_str_dup(str);
if (FL_TEST(str, STR_NO_ORIG))
RSTRING(str)->orig = RSTRING(str)->orig;
CLONESETUP(clone, str);
return clone;
}
static VALUE
rb_str_s_new(argc, argv, klass)
int argc;
@ -1059,6 +1078,7 @@ rb_str_sub_bang(argc, argv, str)
pat = get_pat(argv[0]);
if (rb_reg_search(pat, str, 0, 0) >= 0) {
rb_str_modify(str);
match = rb_backref_get();
regs = RMATCH(match)->regs;
@ -1071,7 +1091,6 @@ rb_str_sub_bang(argc, argv, str)
repl = rb_reg_regsub(repl, str, regs);
}
plen = END(0) - BEG(0);
rb_str_modify(str);
if (RSTRING(repl)->len > plen) {
REALLOC_N(RSTRING(str)->ptr, char,
RSTRING(str)->len + RSTRING(repl)->len - plen + 1);
@ -1085,6 +1104,7 @@ rb_str_sub_bang(argc, argv, str)
RSTRING(repl)->ptr, RSTRING(repl)->len);
RSTRING(str)->len += RSTRING(repl)->len - plen;
RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
OBJ_INFECT(str, repl);
return str;
}
return Qnil;
@ -1102,10 +1122,11 @@ rb_str_sub(argc, argv, str)
}
static VALUE
rb_str_gsub_bang(argc, argv, str)
str_gsub(argc, argv, str, bang)
int argc;
VALUE *argv;
VALUE str;
int bang;
{
VALUE pat, val, repl, match;
struct re_registers *regs;
@ -1129,7 +1150,10 @@ rb_str_gsub_bang(argc, argv, str)
pat = get_pat(argv[0]);
offset=0; n=0;
beg = rb_reg_search(pat, str, 0, 0);
if (beg < 0) return Qnil; /* no match, no substitution */
if (beg < 0) {
if (bang) return Qnil; /* no match, no substitution */
return rb_str_dup(str);
}
blen = RSTRING(str)->len + 30; /* len + margin */
buf = ALLOC_N(char, blen);
@ -1190,25 +1214,39 @@ rb_str_gsub_bang(argc, argv, str)
bp += RSTRING(str)->len - offset;
}
rb_backref_set(match);
rb_str_modify(str);
free(RSTRING(str)->ptr);
if (bang) {
rb_str_modify(str);
free(RSTRING(str)->ptr);
}
else {
NEWOBJ(dup, struct RString);
OBJSETUP(dup, rb_cString, T_STRING);
str = (VALUE)dup;
}
RSTRING(str)->ptr = buf;
RSTRING(str)->len = len = bp - buf;
RSTRING(str)->ptr[len] = '\0';
if (tainted) OBJ_TAINT(str);
if (tainted) OBJ_TAINT(str);
return str;
}
static VALUE
rb_str_gsub_bang(argc, argv, str)
int argc;
VALUE *argv;
VALUE str;
{
return str_gsub(argc, argv, str, 1);
}
static VALUE
rb_str_gsub(argc, argv, str)
int argc;
VALUE *argv;
VALUE str;
{
str = rb_str_dup(str);
rb_str_gsub_bang(argc, argv, str);
return str;
return str_gsub(argc, argv, str, 0);
}
static VALUE

View file

@ -444,7 +444,7 @@ rb_struct_aref(s, idx)
{
long i;
if (TYPE(idx) == T_STRING) {
if (TYPE(idx) == T_STRING || TYPE(idx) == T_SYMBOL) {
return rb_struct_aref_id(s, rb_to_id(idx));
}
@ -489,7 +489,7 @@ rb_struct_aset(s, idx, val)
{
long i;
if (TYPE(idx) == T_STRING) {
if (TYPE(idx) == T_STRING || TYPE(idx) == T_SYMBOL) {
return rb_struct_aset_id(s, rb_to_id(idx), val);
}

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.3"
#define RUBY_RELEASE_DATE "2000-03-09"
#define RUBY_RELEASE_DATE "2000-03-13"
#define RUBY_VERSION_CODE 153
#define RUBY_RELEASE_CODE 20000309
#define RUBY_RELEASE_CODE 20000313

View file

@ -25,6 +25,7 @@ EXPORTS
rb_eArgError
rb_eNameError
rb_eIndexError
rb_eRangeError
rb_eLoadError
rb_eSecurityError
rb_eNotImpError
@ -67,6 +68,7 @@ EXPORTS
rb_cNilClass
rb_cTrueClass
rb_cFalseClass
rb_cSymbol
;prec.c
rb_mPrecision
;process.c
@ -283,6 +285,7 @@ EXPORTS
rb_funcall
rb_funcall2
rb_funcall3
rb_call_super
rb_backtrace
rb_frame_last_func
rb_obj_instance_eval