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:
parent
976692f8ae
commit
31c55301e4
16 changed files with 198 additions and 78 deletions
48
ChangeLog
48
ChangeLog
|
@ -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>
|
Thu Mar 9 11:13:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
* regex.c (re_compile_fastmap): fixed embarrassing brace bug.
|
* regex.c (re_compile_fastmap): fixed embarrassing brace bug.
|
||||||
|
|
3
MANIFEST
3
MANIFEST
|
@ -75,6 +75,7 @@ util.c
|
||||||
variable.c
|
variable.c
|
||||||
version.c
|
version.c
|
||||||
version.h
|
version.h
|
||||||
|
beos/GNUmakefile.in
|
||||||
beos/ruby.def.in
|
beos/ruby.def.in
|
||||||
cygwin/GNUmakefile.in
|
cygwin/GNUmakefile.in
|
||||||
ext/Setup
|
ext/Setup
|
||||||
|
@ -125,6 +126,8 @@ lib/mkmf.rb
|
||||||
lib/monitor.rb
|
lib/monitor.rb
|
||||||
lib/mutex_m.rb
|
lib/mutex_m.rb
|
||||||
lib/net/http.rb
|
lib/net/http.rb
|
||||||
|
lib/net/ftp.rb
|
||||||
|
lib/net/http.rb
|
||||||
lib/net/pop.rb
|
lib/net/pop.rb
|
||||||
lib/net/session.rb
|
lib/net/session.rb
|
||||||
lib/net/smtp.rb
|
lib/net/smtp.rb
|
||||||
|
|
3
configure
vendored
3
configure
vendored
|
@ -4827,6 +4827,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FIRSTMAKEFILE=""
|
||||||
LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
|
LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
|
||||||
LIBRUBY='$(LIBRUBY_A)'
|
LIBRUBY='$(LIBRUBY_A)'
|
||||||
LIBRUBYARG='$(LIBRUBY_A)'
|
LIBRUBYARG='$(LIBRUBY_A)'
|
||||||
|
@ -4843,6 +4844,7 @@ if test "$target_os" = "beos"; then
|
||||||
;;
|
;;
|
||||||
i586*)
|
i586*)
|
||||||
LDFLAGS="$LDFLAGS -L."
|
LDFLAGS="$LDFLAGS -L."
|
||||||
|
FIRSTMAKEFILE=GNUmakefile:beos/GNUmakefile.in
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo EXPORTS > ruby.def
|
echo EXPORTS > ruby.def
|
||||||
|
@ -4851,7 +4853,6 @@ if test "$target_os" = "beos"; then
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FIRSTMAKEFILE=""
|
|
||||||
LIBRUBY_LDSHARED=$LDSHARED
|
LIBRUBY_LDSHARED=$LDSHARED
|
||||||
LIBRUBY_DLDFLAGS=$DLDFLAGS
|
LIBRUBY_DLDFLAGS=$DLDFLAGS
|
||||||
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
|
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
|
||||||
|
|
|
@ -671,6 +671,7 @@ fi
|
||||||
AC_SUBST(MINIRUBY)
|
AC_SUBST(MINIRUBY)
|
||||||
AC_SUBST(PREP)
|
AC_SUBST(PREP)
|
||||||
|
|
||||||
|
FIRSTMAKEFILE=""
|
||||||
LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
|
LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
|
||||||
LIBRUBY='$(LIBRUBY_A)'
|
LIBRUBY='$(LIBRUBY_A)'
|
||||||
LIBRUBYARG='$(LIBRUBY_A)'
|
LIBRUBYARG='$(LIBRUBY_A)'
|
||||||
|
@ -687,6 +688,7 @@ if test "$target_os" = "beos"; then
|
||||||
;;
|
;;
|
||||||
i586*)
|
i586*)
|
||||||
LDFLAGS="$LDFLAGS -L."
|
LDFLAGS="$LDFLAGS -L."
|
||||||
|
FIRSTMAKEFILE=GNUmakefile:beos/GNUmakefile.in
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo EXPORTS > ruby.def
|
echo EXPORTS > ruby.def
|
||||||
|
@ -695,7 +697,6 @@ if test "$target_os" = "beos"; then
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FIRSTMAKEFILE=""
|
|
||||||
LIBRUBY_LDSHARED=$LDSHARED
|
LIBRUBY_LDSHARED=$LDSHARED
|
||||||
LIBRUBY_DLDFLAGS=$DLDFLAGS
|
LIBRUBY_DLDFLAGS=$DLDFLAGS
|
||||||
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
|
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
|
||||||
|
|
43
eval.c
43
eval.c
|
@ -3222,6 +3222,8 @@ rb_f_raise(argc, argv)
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
{
|
{
|
||||||
VALUE mesg;
|
VALUE mesg;
|
||||||
|
ID exception;
|
||||||
|
int n;
|
||||||
|
|
||||||
mesg = Qnil;
|
mesg = Qnil;
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
|
@ -3234,17 +3236,24 @@ rb_f_raise(argc, argv)
|
||||||
mesg = rb_exc_new3(rb_eRuntimeError, argv[0]);
|
mesg = rb_exc_new3(rb_eRuntimeError, argv[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mesg = rb_funcall(argv[0], rb_intern("exception"), 0, 0);
|
n = 0;
|
||||||
break;
|
goto exception_call;
|
||||||
case 3:
|
|
||||||
case 2:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!NIL_P(mesg)) {
|
if (argc > 0) {
|
||||||
if (!rb_obj_is_kind_of(mesg, rb_eException))
|
if (!rb_obj_is_kind_of(mesg, rb_eException))
|
||||||
rb_raise(rb_eTypeError, "exception object expected");
|
rb_raise(rb_eTypeError, "exception object expected");
|
||||||
set_backtrace(mesg, (argc>2)?argv[2]:Qnil);
|
set_backtrace(mesg, (argc>2)?argv[2]:Qnil);
|
||||||
|
@ -3739,9 +3748,11 @@ rb_f_missing(argc, argv, obj)
|
||||||
char *file = ruby_sourcefile;
|
char *file = ruby_sourcefile;
|
||||||
int line = ruby_sourceline;
|
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++;
|
argc--; argv++;
|
||||||
|
|
||||||
switch (TYPE(obj)) {
|
switch (TYPE(obj)) {
|
||||||
|
@ -5892,15 +5903,26 @@ block_pass(self, node)
|
||||||
POP_TAG();
|
POP_TAG();
|
||||||
POP_ITER();
|
POP_ITER();
|
||||||
if (_block.tag->dst == state) {
|
if (_block.tag->dst == state) {
|
||||||
|
if (orphan) {
|
||||||
state &= TAG_MASK;
|
state &= TAG_MASK;
|
||||||
orphan = 2;
|
}
|
||||||
|
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_block = old_block;
|
||||||
ruby_safe_level = safe;
|
ruby_safe_level = safe;
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
if (orphan == 2) {/* escape from orphan procedure */
|
switch (state) {/* escape from orphan procedure */
|
||||||
switch (state) {
|
|
||||||
case TAG_BREAK:
|
case TAG_BREAK:
|
||||||
rb_raise(rb_eLocalJumpError, "break from proc-closure");
|
rb_raise(rb_eLocalJumpError, "break from proc-closure");
|
||||||
break;
|
break;
|
||||||
|
@ -5911,7 +5933,6 @@ block_pass(self, node)
|
||||||
rb_raise(rb_eLocalJumpError, "return from proc-closure");
|
rb_raise(rb_eLocalJumpError, "return from proc-closure");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
JUMP_TAG(state);
|
JUMP_TAG(state);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
4
file.c
4
file.c
|
@ -1957,9 +1957,9 @@ path_check_1(path)
|
||||||
char buf[MAXPATHLEN+1];
|
char buf[MAXPATHLEN+1];
|
||||||
|
|
||||||
#ifdef HAVE_GETCWD
|
#ifdef HAVE_GETCWD
|
||||||
if (getcwd(path, sizeof(path)) == 0) return 0;
|
if (getcwd(buf, MAXPATHLEN) == 0) return 0;
|
||||||
#else
|
#else
|
||||||
if (getwd(path) == 0) return 0;
|
if (getwd(buf) == 0) return 0;
|
||||||
#endif
|
#endif
|
||||||
strncat(buf, path, MAXPATHLEN);
|
strncat(buf, path, MAXPATHLEN);
|
||||||
buf[MAXPATHLEN] = '\0';
|
buf[MAXPATHLEN] = '\0';
|
||||||
|
|
14
instruby.rb
14
instruby.rb
|
@ -18,14 +18,14 @@ end
|
||||||
|
|
||||||
ruby_install_name = CONFIG["ruby_install_name"]
|
ruby_install_name = CONFIG["ruby_install_name"]
|
||||||
version = "/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
version = "/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
||||||
arch = version+"/"+CONFIG["arch"]
|
arch = "/"+CONFIG["arch"]
|
||||||
|
|
||||||
bindir = destdir+CONFIG["bindir"]
|
bindir = destdir+CONFIG["bindir"]
|
||||||
libdir = destdir+CONFIG["libdir"]
|
libdir = destdir+CONFIG["libdir"]
|
||||||
scriptdir = destdir+CONFIG["prefix"]+"/lib/ruby"+version
|
rubylibdir = destdir+CONFIG["prefix"]+"/lib/ruby"+version
|
||||||
archlibdir = libdir+"/ruby"+arch
|
archlibdir = rubylibdir+arch
|
||||||
sitelibdir = libdir+"/site_ruby"+version
|
sitelibdir = destdir+CONFIG["prefix"]+"/lib/site_ruby"+version
|
||||||
sitearchlibdir = libdir+"/site_ruby"+arch
|
sitearchlibdir = sitelibdir+arch
|
||||||
mandir = destdir+CONFIG["mandir"] + "/man1"
|
mandir = destdir+CONFIG["mandir"] + "/man1"
|
||||||
wdir = Dir.getwd
|
wdir = Dir.getwd
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ if File.exist? CONFIG["LIBRUBY_SO"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Dir.chdir wdir
|
Dir.chdir wdir
|
||||||
File.makedirs scriptdir, true
|
File.makedirs rubylibdir, true
|
||||||
File.makedirs archlibdir, true
|
File.makedirs archlibdir, true
|
||||||
File.makedirs sitelibdir, true
|
File.makedirs sitelibdir, true
|
||||||
File.makedirs sitearchlibdir, true
|
File.makedirs sitearchlibdir, true
|
||||||
|
@ -71,7 +71,7 @@ Dir.chdir CONFIG["srcdir"]
|
||||||
|
|
||||||
Find.find("lib") do |f|
|
Find.find("lib") do |f|
|
||||||
next unless /\.rb$/ =~ 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.makedirs dir, true unless File.directory? dir
|
||||||
File.install f, dir, 0644, true
|
File.install f, dir, 0644, true
|
||||||
end
|
end
|
||||||
|
|
|
@ -195,10 +195,10 @@ class Date
|
||||||
def once(*ids)
|
def once(*ids)
|
||||||
for id in ids
|
for id in ids
|
||||||
module_eval <<-"end;"
|
module_eval <<-"end;"
|
||||||
alias_method :__#{id}__, #{id}
|
alias_method :__#{id.to_i}__, #{id}
|
||||||
def #{id.id2name}(*args, &block)
|
def #{id.id2name}(*args, &block)
|
||||||
def self.#{id.id2name}(*args, &block); @__#{id}__ end
|
def self.#{id.id2name}(*args, &block); @__#{id.to_i}__ end
|
||||||
@__#{id}__ = __#{id}__(*args, &block)
|
@__#{id.to_i}__ = __#{id.to_i}__(*args, &block)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
6
parse.y
6
parse.y
|
@ -1573,7 +1573,11 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
|
||||||
$$ = NEW_ARGS(0, 0, -1);
|
$$ = 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))
|
if (!is_local_id($1))
|
||||||
yyerror("formal argument must be local variable");
|
yyerror("formal argument must be local variable");
|
||||||
|
|
|
@ -783,7 +783,7 @@ proc_setpgrp(argc, argv)
|
||||||
rb_scan_args(argc, argv, "0");
|
rb_scan_args(argc, argv, "0");
|
||||||
if (setpgrp() < 0) rb_sys_fail(0);
|
if (setpgrp() < 0) rb_sys_fail(0);
|
||||||
#endif
|
#endif
|
||||||
return Qnil;
|
return INT2FIX(0);
|
||||||
#else
|
#else
|
||||||
rb_notimplement();
|
rb_notimplement();
|
||||||
#endif
|
#endif
|
||||||
|
@ -815,7 +815,7 @@ proc_setpgid(obj, pid, pgrp)
|
||||||
ipgrp = NUM2INT(pgrp);
|
ipgrp = NUM2INT(pgrp);
|
||||||
|
|
||||||
if (setpgid(ipid, ipgrp) < 0) rb_sys_fail(0);
|
if (setpgid(ipid, ipgrp) < 0) rb_sys_fail(0);
|
||||||
return Qnil;
|
return INT2FIX(0);
|
||||||
#else
|
#else
|
||||||
rb_notimplement();
|
rb_notimplement();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -143,8 +143,8 @@ while tmp.gets()
|
||||||
gsub!('VT100', 'Vt100')
|
gsub!('VT100', 'Vt100')
|
||||||
redo;
|
redo;
|
||||||
end
|
end
|
||||||
$bad = 1 if /vt100/;
|
$bad = 1 if /vt100/
|
||||||
$bad = 1 if /VT100/;
|
$bad = 1 if /VT100/
|
||||||
end
|
end
|
||||||
ok(tmp.eof? && !$bad)
|
ok(tmp.eof? && !$bad)
|
||||||
tmp.close
|
tmp.close
|
||||||
|
@ -181,6 +181,7 @@ until i>4
|
||||||
end
|
end
|
||||||
ok(i>4)
|
ok(i>4)
|
||||||
|
|
||||||
|
|
||||||
# exception handling
|
# exception handling
|
||||||
check "exception";
|
check "exception";
|
||||||
|
|
||||||
|
|
8
signal.c
8
signal.c
|
@ -202,12 +202,12 @@ rb_f_kill(argc, argv)
|
||||||
switch (TYPE(argv[0])) {
|
switch (TYPE(argv[0])) {
|
||||||
case T_FIXNUM:
|
case T_FIXNUM:
|
||||||
sig = FIX2UINT(argv[0]);
|
sig = FIX2UINT(argv[0]);
|
||||||
if (sig >= NSIG) {
|
break;
|
||||||
s = rb_id2name(sig);
|
|
||||||
|
case T_SYMBOL:
|
||||||
|
s = rb_id2name(SYM2ID(argv[0]));
|
||||||
if (!s) rb_raise(rb_eArgError, "bad signal");
|
if (!s) rb_raise(rb_eArgError, "bad signal");
|
||||||
goto str_signal;
|
goto str_signal;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_STRING:
|
case T_STRING:
|
||||||
{
|
{
|
||||||
|
|
92
string.c
92
string.c
|
@ -106,9 +106,7 @@ rb_str_new4(orig)
|
||||||
str->ptr = RSTRING(orig)->ptr;
|
str->ptr = RSTRING(orig)->ptr;
|
||||||
RSTRING(orig)->orig = (VALUE)str;
|
RSTRING(orig)->orig = (VALUE)str;
|
||||||
str->orig = 0;
|
str->orig = 0;
|
||||||
if (OBJ_TAINTED(orig)) {
|
OBJ_INFECT(str, orig);
|
||||||
OBJ_TAINT(str);
|
|
||||||
}
|
|
||||||
OBJ_FREEZE(str);
|
OBJ_FREEZE(str);
|
||||||
|
|
||||||
return (VALUE)str;
|
return (VALUE)str;
|
||||||
|
@ -162,23 +160,7 @@ rb_obj_as_string(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_str_clone(str)
|
str_dup(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)
|
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE s;
|
VALUE s;
|
||||||
|
@ -190,6 +172,43 @@ rb_str_dup(str)
|
||||||
return s;
|
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
|
static VALUE
|
||||||
rb_str_s_new(argc, argv, klass)
|
rb_str_s_new(argc, argv, klass)
|
||||||
int argc;
|
int argc;
|
||||||
|
@ -1059,6 +1078,7 @@ rb_str_sub_bang(argc, argv, str)
|
||||||
|
|
||||||
pat = get_pat(argv[0]);
|
pat = get_pat(argv[0]);
|
||||||
if (rb_reg_search(pat, str, 0, 0) >= 0) {
|
if (rb_reg_search(pat, str, 0, 0) >= 0) {
|
||||||
|
rb_str_modify(str);
|
||||||
match = rb_backref_get();
|
match = rb_backref_get();
|
||||||
regs = RMATCH(match)->regs;
|
regs = RMATCH(match)->regs;
|
||||||
|
|
||||||
|
@ -1071,7 +1091,6 @@ rb_str_sub_bang(argc, argv, str)
|
||||||
repl = rb_reg_regsub(repl, str, regs);
|
repl = rb_reg_regsub(repl, str, regs);
|
||||||
}
|
}
|
||||||
plen = END(0) - BEG(0);
|
plen = END(0) - BEG(0);
|
||||||
rb_str_modify(str);
|
|
||||||
if (RSTRING(repl)->len > plen) {
|
if (RSTRING(repl)->len > plen) {
|
||||||
REALLOC_N(RSTRING(str)->ptr, char,
|
REALLOC_N(RSTRING(str)->ptr, char,
|
||||||
RSTRING(str)->len + RSTRING(repl)->len - plen + 1);
|
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(repl)->ptr, RSTRING(repl)->len);
|
||||||
RSTRING(str)->len += RSTRING(repl)->len - plen;
|
RSTRING(str)->len += RSTRING(repl)->len - plen;
|
||||||
RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
|
RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
|
||||||
|
OBJ_INFECT(str, repl);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
@ -1102,10 +1122,11 @@ rb_str_sub(argc, argv, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_str_gsub_bang(argc, argv, str)
|
str_gsub(argc, argv, str, bang)
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
|
int bang;
|
||||||
{
|
{
|
||||||
VALUE pat, val, repl, match;
|
VALUE pat, val, repl, match;
|
||||||
struct re_registers *regs;
|
struct re_registers *regs;
|
||||||
|
@ -1129,7 +1150,10 @@ rb_str_gsub_bang(argc, argv, str)
|
||||||
pat = get_pat(argv[0]);
|
pat = get_pat(argv[0]);
|
||||||
offset=0; n=0;
|
offset=0; n=0;
|
||||||
beg = rb_reg_search(pat, str, 0, 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 */
|
blen = RSTRING(str)->len + 30; /* len + margin */
|
||||||
buf = ALLOC_N(char, blen);
|
buf = ALLOC_N(char, blen);
|
||||||
|
@ -1190,25 +1214,39 @@ rb_str_gsub_bang(argc, argv, str)
|
||||||
bp += RSTRING(str)->len - offset;
|
bp += RSTRING(str)->len - offset;
|
||||||
}
|
}
|
||||||
rb_backref_set(match);
|
rb_backref_set(match);
|
||||||
|
if (bang) {
|
||||||
rb_str_modify(str);
|
rb_str_modify(str);
|
||||||
free(RSTRING(str)->ptr);
|
free(RSTRING(str)->ptr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NEWOBJ(dup, struct RString);
|
||||||
|
OBJSETUP(dup, rb_cString, T_STRING);
|
||||||
|
str = (VALUE)dup;
|
||||||
|
}
|
||||||
RSTRING(str)->ptr = buf;
|
RSTRING(str)->ptr = buf;
|
||||||
RSTRING(str)->len = len = bp - buf;
|
RSTRING(str)->len = len = bp - buf;
|
||||||
RSTRING(str)->ptr[len] = '\0';
|
RSTRING(str)->ptr[len] = '\0';
|
||||||
if (tainted) OBJ_TAINT(str);
|
|
||||||
|
|
||||||
|
if (tainted) OBJ_TAINT(str);
|
||||||
return 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
|
static VALUE
|
||||||
rb_str_gsub(argc, argv, str)
|
rb_str_gsub(argc, argv, str)
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
str = rb_str_dup(str);
|
return str_gsub(argc, argv, str, 0);
|
||||||
rb_str_gsub_bang(argc, argv, str);
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
4
struct.c
4
struct.c
|
@ -444,7 +444,7 @@ rb_struct_aref(s, idx)
|
||||||
{
|
{
|
||||||
long i;
|
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));
|
return rb_struct_aref_id(s, rb_to_id(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ rb_struct_aset(s, idx, val)
|
||||||
{
|
{
|
||||||
long i;
|
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);
|
return rb_struct_aset_id(s, rb_to_id(idx), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define RUBY_VERSION "1.5.3"
|
#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_VERSION_CODE 153
|
||||||
#define RUBY_RELEASE_CODE 20000309
|
#define RUBY_RELEASE_CODE 20000313
|
||||||
|
|
|
@ -25,6 +25,7 @@ EXPORTS
|
||||||
rb_eArgError
|
rb_eArgError
|
||||||
rb_eNameError
|
rb_eNameError
|
||||||
rb_eIndexError
|
rb_eIndexError
|
||||||
|
rb_eRangeError
|
||||||
rb_eLoadError
|
rb_eLoadError
|
||||||
rb_eSecurityError
|
rb_eSecurityError
|
||||||
rb_eNotImpError
|
rb_eNotImpError
|
||||||
|
@ -67,6 +68,7 @@ EXPORTS
|
||||||
rb_cNilClass
|
rb_cNilClass
|
||||||
rb_cTrueClass
|
rb_cTrueClass
|
||||||
rb_cFalseClass
|
rb_cFalseClass
|
||||||
|
rb_cSymbol
|
||||||
;prec.c
|
;prec.c
|
||||||
rb_mPrecision
|
rb_mPrecision
|
||||||
;process.c
|
;process.c
|
||||||
|
@ -283,6 +285,7 @@ EXPORTS
|
||||||
rb_funcall
|
rb_funcall
|
||||||
rb_funcall2
|
rb_funcall2
|
||||||
rb_funcall3
|
rb_funcall3
|
||||||
|
rb_call_super
|
||||||
rb_backtrace
|
rb_backtrace
|
||||||
rb_frame_last_func
|
rb_frame_last_func
|
||||||
rb_obj_instance_eval
|
rb_obj_instance_eval
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue