Skip to content

Commit

Permalink
matz
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Dec 22, 2000
1 parent 31c53aa commit 0e47c13
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 141 deletions.
24 changes: 24 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@ Thu Dec 21 13:01:46 2000 Tanaka Akira <akr@m17n.org>

* lib/net/ftp.rb (makeport): don't use TCPsocket.getaddress.

Wed Dec 20 12:00:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* bignum.c (rb_big_lshift): should cast up to BDIGIT_DBL.

* parse.y (yylex): disallow trailin '_' for numeric litrals.

* bignum.c (rb_cstr2inum): allow `_' within converting string.

* eval.c (specific_eval): should take no argument if block is
supplied.

Tue Dec 19 13:44:50 2000 K.Kosako <kosako@sofnec.co.jp>

* io.c (rb_f_p): should flush rb_defout, not stdout.

Tue Dec 19 00:57:10 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* time.c (time_minus): usec might overflow (ruby-bugs-ja:#PR#35).

* eval.c (rb_obj_extend): Object#extend should take at least one
argument.

* parse.y (mrhs_basic): should check value_expr($3), not $1.

Mon Dec 18 23:18:39 2000 WATANABE Hirofumi <eban@ruby-lang.org>

* util.c (mblen, __crt0_glob_function): add for multibyte
Expand Down
12 changes: 10 additions & 2 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ rb_cstr2inum(str, base)
}
}
if (base == 8) {
while (str[0] == '0') str++;
while (*str == '0') str++;
if (!*str) return INT2FIX(0);
while (*str == '_') str++;
len = 3*strlen(str)*sizeof(char);
}
else { /* base == 10, 2 or 16 */
Expand All @@ -249,6 +251,7 @@ rb_cstr2inum(str, base)
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
unsigned long val = strtoul((char*)str, &end, base);

if (*end == '_') goto bigparse;
if (badcheck) {
if (end == str) goto bad; /* no number */
while (*end && ISSPACE(*end)) end++;
Expand All @@ -271,7 +274,9 @@ rb_cstr2inum(str, base)
return big;
}
}
bigparse:
len = (len/BITSPERDIG)+1;
if (badcheck && *str == '_') goto bad;

z = bignew(len, sign);
zds = BDIGITS(z);
Expand All @@ -290,6 +295,8 @@ rb_cstr2inum(str, base)
case 'D': case 'E': case 'F':
c = c - 'A' + 10;
break;
case '_':
continue;
default:
if (badcheck) {
if (ISSPACE(c)) {
Expand Down Expand Up @@ -317,6 +324,7 @@ rb_cstr2inum(str, base)
break;
}
}
if (badcheck && s+2 < str && str[-2] == '_') goto bad;

return bignorm(z);
}
Expand Down Expand Up @@ -1252,7 +1260,7 @@ rb_big_lshift(x, y)
}
xds = BDIGITS(x);
for (i=0; i<len; i++) {
num = num | *xds++<<s2;
num = num | (BDIGIT_DBL)*xds++<<s2;
*zds++ = BIGLO(num);
num = BIGDN(num);
}
Expand Down
50 changes: 27 additions & 23 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4943,33 +4943,34 @@ specific_eval(argc, argv, klass, self)
VALUE *argv;
VALUE klass, self;
{
char *file = "(eval)";
int line = 1;
int iter = rb_block_given_p();

if (argc > 0) {
if (ruby_safe_level >= 4) {
Check_Type(argv[0], T_STRING);
if (rb_block_given_p()) {
if (argc > 0) {
rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
}
else {
Check_SafeStr(argv[0]);
}
if (argc > 3) {
rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
rb_id2name(ruby_frame->last_func),
rb_id2name(ruby_frame->last_func));
}
if (argc > 1) file = STR2CSTR(argv[1]);
if (argc > 2) line = NUM2INT(argv[2]);
}
else if (!iter) {
rb_raise(rb_eArgError, "block not supplied");
}

if (iter) {
return yield_under(klass, self);
}
else {
char *file = "(eval)";
int line = 1;

if (argc == 0) {
rb_raise(rb_eArgError, "block not supplied");
}
else {
if (ruby_safe_level >= 4) {
Check_Type(argv[0], T_STRING);
}
else {
Check_SafeStr(argv[0]);
}
if (argc > 3) {
rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
rb_id2name(ruby_frame->last_func),
rb_id2name(ruby_frame->last_func));
}
if (argc > 1) file = STR2CSTR(argv[1]);
if (argc > 2) line = NUM2INT(argv[2]);
}
return eval_under(klass, self, argv[0], file, line);
}
}
Expand Down Expand Up @@ -5551,6 +5552,9 @@ rb_obj_extend(argc, argv, obj)
{
int i;

if (argc == 0) {
rb_raise(rb_eArgError, "wrong # of arguments(0 for 1)");
}
for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE);
for (i=0; i<argc; i++) {
rb_funcall(argv[i], rb_intern("extend_object"), 1, obj);
Expand Down
93 changes: 62 additions & 31 deletions ext/extmk.rb.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#! /usr/local/bin/ruby
# -*- ruby -*-

$".push 'mkmf.rb'
ORIG_LIBPATH = ENV['LIB']

if ARGV[0] == 'static'
$force_static = true
Expand Down Expand Up @@ -90,7 +92,19 @@ def try_link0(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
xsystem(format(LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
ldflags = $LDFLAGS
if /mswin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty?
ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';')
else
$LDFLAGS = ldflags.dup
$LIBPATH.each {|d| $LDFLAGS << " -L" + d}
end
begin
xsystem(format(LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
ensure
$LDFLAGS = ldflags
ENV['LIB'] = ORIG_LIBPATH if /mswin32/ =~ RUBY_PLATFORM
end
end

def try_link(src, opt="")
Expand Down Expand Up @@ -205,17 +219,17 @@ SRC
end

def find_library(lib, func, *paths)
ldflags = $LDFLAGS
libpath = $LIBPATH
libs = append_library($libs, lib)
until try_link(<<"SRC", libs)
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
if paths.size == 0
$LDFLAGS = ldflags
$LIBPATH = libpath
return false
end
$LDFLAGS = ldflags + " -L"+paths.shift
$LIBPATH = libpath | [paths.shift]
end
$libs = libs
return true
Expand Down Expand Up @@ -270,7 +284,7 @@ def arg_config(config, default=nil)
$configure_args = {}
args = "@configure_args@"
if /mswin32|mingw/ =~ RUBY_PLATFORM and ENV["CONFIGURE_ARGS"]
args = args + " " + ENV["CONFIGURE_ARGS"]
args << " " << ENV["CONFIGURE_ARGS"]
end
for arg in args.split
next unless /^--/ =~ arg
Expand Down Expand Up @@ -321,19 +335,18 @@ def dir_config(target, idefault=nil, ldefault=nil)
dir = with_config("%s-dir"%target, default)
if dir
idir = " -I"+dir+"/include"
ldir = " -L"+dir+"/lib"
ldir = dir+"/lib"
end
unless idir
dir = with_config("%s-include"%target, idefault)
idir = " -I"+dir if dir
end
unless ldir
dir = with_config("%s-lib"%target, ldefault)
ldir = " -L"+dir if dir
ldir = with_config("%s-lib"%target, ldefault)
end

$CFLAGS += idir if idir
$LDFLAGS += ldir if ldir
$CPPFLAGS += idir if idir
$LIBPATH |= [ldir] if ldir
end

def create_makefile(target)
Expand All @@ -355,9 +368,9 @@ def create_makefile(target)

$DLDFLAGS = '@DLDFLAGS@'

if $configure_args['--enable-shared'] or /cygwin|mingw/ === RUBY_PLATFORM
if $configure_args['--enable-shared'] or "@LIBRUBY@" != "@LIBRUBY_A@"
$libs = "@LIBRUBYARG@ " + $libs
$DLDFLAGS = $DLDFLAGS + " -L" + $topdir
$LIBPATH |= [$topdir]
end

defflag = ''
Expand All @@ -368,6 +381,12 @@ def create_makefile(target)
defflag = "--def=" + target + ".def"
end

if RUBY_PLATFORM =~ /mswin32/
libpath = $LIBPATH.join(';')
else
$LIBPATH.each {|d| $DLDFLAGS << " -L" << d}
end

$srcdir = $top_srcdir + "/ext/" + $mdir
mfile = open("Makefile", "w")
mfile.binmode if /mingw/ =~ RUBY_PLATFORM
Expand All @@ -389,6 +408,9 @@ CPPFLAGS = -I$(topdir) -I$(hdrdir) -I@includedir@ %s #$CPPFLAGS
DLDFLAGS = #$DLDFLAGS #$LDFLAGS
LDSHARED = @LDSHARED@ #{defflag}
", if $static then "" else "@CCDLFLAGS@" end, $defs.join(" ")
mfile.puts "LIBPATH = #{libpath}" if libpath

mfile.puts ".SUFFIXES: .@OBJEXT@" unless "@OBJEXT@" == "o"

mfile.printf "\
Expand Down Expand Up @@ -425,9 +447,8 @@ archdir = $(pkglibdir)/@arch@
mfile.printf "\n"

ruby_interpreter = "$(topdir)/miniruby@EXEEXT@"
if /mswin32/ =~ RUBY_PLATFORM
ruby_interpreter = $topdir + "/miniruby@EXEEXT@"
ruby_interpreter.gsub!("/", "\\")
if /nmake/i =~ $make
ruby_interpreter = '$(topdir:/=\)\miniruby@EXEEXT@'
end
if defined? CROSS_COMPILING
ruby_interpreter = "@MINIRUBY@"
Expand Down Expand Up @@ -467,18 +488,23 @@ EOS
install_rb(mfile, $srcdir)
mfile.printf "\n"

if /mswin32/ =~ RUBY_PLATFORM
if /mswin32/ !~ RUBY_PLATFORM
mfile.puts "
.c.obj:
.c.@OBJEXT@:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
{$(srcdir)}.c{}.obj:
$(CC) -I. -I$(<D) $(CFLAGS) $(CPPFLAGS) -c $(<:/=\\)
"
elsif /nmake/i =~ $make
mfile.print "
{$(srcdir)}.c{}.@OBJEXT@:
$(CC) -I. -I$(<D) $(CFLAGS) $(CPPFLAGS) -c $(<:/=\\)
.c.@OBJEXT@:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(<:/=\\)
"
else
mfile.puts "
mfile.print "
.c.@OBJEXT@:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
"
end

Expand All @@ -496,10 +522,15 @@ $(DLLIB): $(OBJS)
"
end
elsif "@DLEXT@" != $OBJEXT
mfile.printf "\
$(DLLIB): $(OBJS)
$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
"
mfile.print "$(DLLIB): $(OBJS)\n"
if /mswin32/ =~ RUBY_PLATFORM
if /nmake/i =~ $make
mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n"
else
mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n"
end
end
mfile.print "\t$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n"
elsif RUBY_PLATFORM == "m68k-human"
mfile.printf "\
$(DLLIB): $(OBJS)
Expand All @@ -517,7 +548,7 @@ $(DLLIB): $(OBJS)
mfile.printf "###\n"
while line = dfile.gets()
line.gsub!(/\.o\b/, ".#{$OBJEXT}")
line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1$(srcdir)/\2') if /mswin32/ =~ RUBY_PLATFORM
line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1$(srcdir)/\2') if /nmake/i =~ $make
mfile.printf "%s", line.gsub('\$\(hdrdir\)/config.h', '$(topdir)/config.h')
end
dfile.close
Expand All @@ -543,26 +574,26 @@ def extmake(target)
$local_flags = ""
if /mswin32/ =~ RUBY_PLATFORM
$LIBEXT = "lib"
$local_flags = "$(topdir)/$(RUBY_SO_NAME).lib -link /EXPORT:Init_$(TARGET)"
$local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)"
end
$LOCAL_LIBS = "" # to be assigned in extconf.rb
dir = with_config("opt-dir")
if dir
idir = "-I"+dir+"/include"
ldir = "-L"+dir+"/lib"
ldir = dir+"/lib"
end
unless idir
dir = with_config("opt-include")
idir = "-I"+dir if dir
end
unless ldir
dir = with_config("opt-lib")
ldir = "-L"+dir if dir
ldir = with_config("opt-lib")
end

$CFLAGS = ""
$CPPFLAGS = idir || ""
$LDFLAGS = ldir || ""
$LDFLAGS = ""
$LIBPATH = [ldir].compact

begin
Dir.mkdir target unless File.directory?(target)
Expand Down
5 changes: 3 additions & 2 deletions ext/socket/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'mkmf'
$LDFLAGS += " -L/usr/local/lib" if File.directory?("/usr/local/lib")
$CFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len"

$LIBPATH << "/usr/local/lib" if File.directory?("/usr/local/lib")
$CPPFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len"

case RUBY_PLATFORM
when /mswin32|mingw/
Expand Down
1 change: 0 additions & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ rb_gc_mark(ptr)
register RVALUE *obj = RANY(ptr);

Top:
if (FIXNUM_P(obj)) return; /* fixnum not marked */
if (rb_special_const_p((VALUE)obj)) return; /* special const not marked */
if (obj->as.basic.flags == 0) return; /* free cell */
if (obj->as.basic.flags & FL_MARK) return; /* already marked */
Expand Down
Loading

0 comments on commit 0e47c13

Please sign in to comment.