summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-05-10 08:22:50 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-05-10 08:22:50 +0000
commit27e948fd458b06c3a018d46f04599a874f43fd92 (patch)
treee369ed2a78f4d5393074804b71f136c84e9dfca5
parent192463c7a5525008a7bf95065261877eff79cf74 (diff)
regexp,range,squeeze
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog37
-rw-r--r--MANIFEST1
-rw-r--r--dir.c43
-rw-r--r--ext/extmk.rb.in25
-rw-r--r--ext/extmk.rb.nt403
-rw-r--r--ext/socket/addrinfo.h8
-rw-r--r--ext/socket/extconf.rb30
-rw-r--r--ext/socket/getaddrinfo.c2
-rw-r--r--ext/socket/getnameinfo.c2
-rw-r--r--ext/socket/socket.c207
-rw-r--r--instruby.rb8
-rw-r--r--lib/jcode.rb5
-rw-r--r--lib/mkmf.rb48
-rw-r--r--range.c12
-rw-r--r--regex.c45
-rw-r--r--regex.h4
-rw-r--r--signal.c3
-rw-r--r--string.c50
-rw-r--r--win32/Makefile78
19 files changed, 574 insertions, 437 deletions
diff --git a/ChangeLog b/ChangeLog
index 6af4cde242b..e8751cbe2a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+Mon May 10 00:59:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/jcode.rb: forgot to squeeze on reverse (complement) case.
+
+ * string.c (tr_squeeze): should not set modify flag to be honest,
+ if the string is not modified.
+
+ * signal.c (Init_signal): SIGTERM should not be handled.
+
+ * regex.c (re_match): seeking for longest match is now optional,
+ which can be set using RE_OPTION_POSIXMATCH. This satisfies
+ POSIX longest match as much as Emacs's posix-* functions, which
+ are known to be incomplete.
+
+Sun May 9 13:04:01 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/socket.c (sock_s_getaddrinfo): conversion from
+ Fixnums to C integers needed.
+
+Sun May 9 11:51:43 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * range.c (range_eqq): reverse condition.
+
+ * range.c (range_s_new): default should be end inclusive.
+
+Sat May 8 03:27:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (thread_connect): replace nasty
+ rb_thread_fd_writable() with rb_thread_select().
+
+Fri May 7 20:49:00 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/getaddrinfo.c (inet_pton): wrong parameter to
+ inet_aton().
+
+ * ext/socket/addrinfo.h (__P): silly cut and paste typo.
+
Fri May 7 17:03:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* dir.c (glob): removed GPL'ed glob.c completely.
diff --git a/MANIFEST b/MANIFEST
index 7821f5f5fb9..2b333c5c5c0 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -153,6 +153,7 @@ missing/memmove.c
missing/mkdir.c
missing/os2.c
missing/strcasecmp.c
+missing/strncasecmp.c
missing/strchr.c
missing/strdup.c
missing/strerror.c
diff --git a/dir.c b/dir.c
index c12fd542bc9..3ddcc8fdf99 100644
--- a/dir.c
+++ b/dir.c
@@ -345,12 +345,6 @@ has_magic(s, send)
return Qfalse;
}
-struct glob1_arg {
- void (*func)();
- char *basename;
- VALUE arg;
-};
-
static char*
extract_path(p, pend)
char *p, *pend;
@@ -412,6 +406,11 @@ glob(path, func, arg)
DIR *dirp;
struct dirent *dp;
+ struct d_link {
+ char *path;
+ struct d_link *next;
+ } *tmp, *link = 0;
+
base = extract_path(path, p);
if (path == p) dir = ".";
else dir = base;
@@ -424,27 +423,39 @@ glob(path, func, arg)
magic = extract_elem(p);
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if (fnmatch(magic, dp->d_name, FNM_PERIOD|FNM_PATHNAME) == 0) {
- char *fix = ALLOC_N(char, strlen(base)+strlen(dp->d_name)+2);
+ char *fix = ALLOC_N(char, strlen(base)+NAMLEN(dp)+2);
- sprintf(fix, "%s%s%s", base, (p==path)?"":"/", dp->d_name);
+ sprintf(fix, "%s%s%s", base, (*base)?"/":"", dp->d_name);
if (!m) {
(*func)(fix, arg);
free(fix);
continue;
}
- stat(fix, &st); /* should success */
- if (S_ISDIR(st.st_mode)) {
- char *t = ALLOC_N(char, strlen(fix)+strlen(m)+2);
- sprintf(t, "%s%s", fix, m);
- glob(t, func, arg);
- free(t);
- }
- free(fix);
+ tmp = ALLOC(struct d_link);
+ tmp->path = fix;
+ tmp->next = link;
+ link = tmp;
}
}
closedir(dirp);
free(base);
free(magic);
+ while (link) {
+ stat(link->path, &st); /* should success */
+ if (S_ISDIR(st.st_mode)) {
+ int len = strlen(link->path);
+ int mlen = strlen(m);
+ char *t = ALLOC_N(char, len+mlen+1);
+
+ sprintf(t, "%s%s", link->path, m);
+ glob(t, func, arg);
+ free(t);
+ }
+ tmp = link;
+ link = link->next;
+ free(tmp->path);
+ free(tmp);
+ }
}
p = m;
}
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index db34b4252d7..f98ca4dc2b5 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -71,8 +71,8 @@ CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
else
CFLAGS = "@CFLAGS@"
end
-LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s %s conftest.c @LIBS@ %s"
-CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s conftest.c"
+LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} @LDFLAGS@ %s %s conftest.c %s %s @LIBS@"
+CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s %s conftest.c"
if /cygwin|mswin32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ PLATFORM
$null = open("nul", "w")
@@ -98,7 +98,7 @@ def try_link0(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+ xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
end
def try_link(src, opt="")
@@ -109,23 +109,23 @@ def try_link(src, opt="")
end
end
-def try_cpp(src, opt=$CFLAGS)
+def try_cpp(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
begin
- xsystem(format(CPP, opt))
+ xsystem(format(CPP, $CFLAGS, opt))
ensure
system "rm -f conftest*"
end
end
-def egrep_cpp(pat, src, opt=$CFLAGS)
+def egrep_cpp(pat, src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
begin
- xsystem(format(CPP+"|egrep #{pat}", opt))
+ xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
ensure
system "rm -f conftest*"
end
@@ -268,7 +268,7 @@ def arg_config(config, default=nil)
if /=/ =~ arg
$configure_args[$`] = $'
else
- $configure_args[arg] = default
+ $configure_args[arg] = true
end
end
end
@@ -283,7 +283,7 @@ def with_config(config, default=nil)
end
def enable_config(config, default=nil)
- if arg_config("--enable-"+config, true)
+ if arg_config("--enable-"+config, default)
true
elsif arg_config("--disable-"+config, false)
false
@@ -335,6 +335,7 @@ srcdir = #{$srcdir}
VPATH = #{$srcdir}
hdrdir = #{$topdir}
+DESTDIR =
CC = @CC@
@@ -360,7 +361,7 @@ ruby_inc = #{$ruby_inc}
#### End of system configuration section. ####
"
- mfile.printf "LOCAL_LIBS = %s\n", $local_libs unless $local_libs == ""
+ mfile.printf "LOCAL_LIBS = %s\n", $LOCAL_LIBS unless $LOCAL_LIBS == ""
mfile.printf "LIBS = %s\n", $libs
mfile.printf "OBJS = "
if !$objs then
@@ -472,7 +473,7 @@ def extmake(target)
$objs = nil
$libs = PLATFORM =~ /cygwin|beos|openstep|nextstep|rhapsody/ ? nil : "-lc"
- $local_libs = "" # to be assigned in extconf.rb
+ $LOCAL_LIBS = "" # to be assigned in extconf.rb
$CFLAGS = ""
$LDFLAGS = ""
@@ -509,7 +510,7 @@ def extmake(target)
$extlibs ||= ""
$extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
$extlibs += " " + $libs if $libs
- $extlibs += " " + $local_libs unless $local_libs == ""
+ $extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
end
ensure
system "rm -f conftest*"
diff --git a/ext/extmk.rb.nt b/ext/extmk.rb.nt
index 81bbb3e4dd3..b5aa4592c22 100644
--- a/ext/extmk.rb.nt
+++ b/ext/extmk.rb.nt
@@ -3,39 +3,39 @@
$".push 'mkmf.rb'
if ARGV[0] == 'static'
- $force_static = TRUE
+ $force_static = true
ARGV.shift
elsif ARGV[0] == 'install'
- $install = TRUE
+ $install = true
$destdir = ARGV[1] || ''
ARGV.shift
elsif ARGV[0] == 'clean'
- $clean = TRUE
+ $clean = true
ARGV.shift
end
$extlist = []
-$cache_mod = FALSE;
+$cache_mod = false;
$lib_cache = {}
$func_cache = {}
$hdr_cache = {}
-$top_srcdir = ".."
-if $top_srcdir !~ "^/"
- # get absolute path
- $top_srcdir = File.expand_path($top_srcdir)
-end
+
+$top_srcdir = File.expand_path("..")
$topdir = File.expand_path("..")
$topdir = File.expand_path($topdir)
$ruby_inc = $top_srcdir
load "#{$top_srcdir}/lib/find.rb"
+#$dllopt = '-MD'
+$dllopt = ''
+
if File.exist?("config.cache") then
f = open("config.cache", "r")
while f.gets
case $_
- when /^lib: (.+) (yes|no)/
+ when /^lib: ([\w_]+) (yes|no)/
$lib_cache[$1] = $2
when /^func: ([\w_]+) (yes|no)/
$func_cache[$1] = $2
@@ -59,11 +59,11 @@ def older(file1, file2)
return false
end
-CFLAGS = "-g -O2"
-LINK = "gcc -o conftest -I#$topdir -I#$top_srcdir -I${prefix}/include #{CFLAGS} %s %s conftest.c -ldl -lcrypt -lm %s"
-CPP = "gcc -E -I#$topdir -I#$top_srcdir -I${prefix}/include #{CFLAGS} %s conftest.c"
-
+#LINK = "cl -o conftest.exe -I../.. -Zi -O -I. %s conftest.c %s > nul"
+LINK = "cl -o conftest.exe -Zi -O %s conftest.c %s > nul"
+CPP = "cl -E -I../.. -I../../missing -I../../win32 -I. -Zi -O %s conftest.c > nul"
$null = open("nul", "w")
+
$orgerr = $stderr.dup
$orgout = $stdout.dup
def xsystem command
@@ -78,12 +78,18 @@ def xsystem command
return r
end
-def try_link(src, opt="")
+def try_link0(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
+ xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+end
+
+def try_link(src, opt="")
begin
- xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+ try_link0(src, opt)
+ ensure
+ system "rm -f conftest*"
end
end
@@ -91,19 +97,27 @@ def try_cpp(src, opt=$CFLAGS)
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(CPP, opt))
+ begin
+ xsystem(format(CPP, opt))
+ ensure
+ system "rm -f conftest*"
+ end
end
def egrep_cpp(pat, src, opt=$CFLAGS)
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(CPP+"|egrep #{pat}", opt))
+ begin
+ xsystem(format(CPP+"|egrep #{pat}", opt))
+ ensure
+ system "rm -f conftest*"
+ end
end
def try_run(src, opt="")
begin
- if try_link(src, opt)
+ if try_link0(src, opt)
if xsystem("./conftest")
true
else
@@ -112,6 +126,8 @@ def try_run(src, opt="")
else
nil
end
+ ensure
+ system "rm -f conftest*"
end
end
@@ -134,73 +150,84 @@ def install_rb(mfile)
end
def have_library(lib, func="main")
+ #print format("have_library(%s, %s)\n", lib, func)
if $lib_cache[lib]
if $lib_cache[lib] == "yes"
if $libs
- $libs = "-l" + lib + " " + $libs
+ $libs = lib + ".lib " + $libs
else
- $libs = "-l" + lib
+ $libs = lib + ".lib "
end
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
if func && func != ""
if $libs
- libs = "-l" + lib + " " + $libs
+ libs = lib + ".lib " + $libs
else
- libs = "-l" + lib
+ libs = lib + ".lib"
end
+ #print "libs=#{libs}\n"
unless try_link(<<"SRC", libs)
+#include <windows.h>
+#include <winsock.h>
+//char #{func}();
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
+ #print "fail : #{libs}\n"
$lib_cache[lib] = 'no'
- $cache_mod = TRUE
- return FALSE
- end
- else
- if $libs
- libs = "-l" + lib + " " + $libs
- else
- libs = "-l" + lib
+ $cache_mod = true
+ return false
end
end
$libs = libs
$lib_cache[lib] = 'yes'
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def have_func(func)
if $func_cache[func]
if $func_cache[func] == "yes"
$defs.push(format("-DHAVE_%s", func.upcase))
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
+ cfile = open("conftest.c", "w")
+ cfile.printf "\
+#include <windows.h>
+#include <winsock.h>
+//char %s();
+int main() { return 0; }
+int t() { %s(); return 0; }
+", func, func
+ cfile.close
+
libs = $libs
libs = "" if libs == nil
- unless try_link(<<"SRC", libs)
-char #{func}();
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
- $func_cache[func] = 'no'
- $cache_mod = TRUE
- return FALSE
+ begin
+ #print "libs=#{libs}\n"
+ unless try_link(libs)
+ $func_cache[func] = 'no'
+ $cache_mod = true
+ return false
+ end
+ ensure
+ system "rm -f conftest*"
end
$defs.push(format("-DHAVE_%s", func.upcase))
$func_cache[func] = 'yes'
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def have_header(header)
@@ -208,9 +235,9 @@ def have_header(header)
if $hdr_cache[header] == "yes"
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
@@ -218,25 +245,25 @@ def have_header(header)
#include <#{header}>
SRC
$hdr_cache[header] = 'no'
- $cache_mod = TRUE
- return FALSE
+ $cache_mod = true
+ return false
end
$hdr_cache[header] = 'yes'
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def arg_config(config, default=nil)
unless defined? $configure_args
$configure_args = {}
- for arg in " --prefix=/usr --with-dbm-include=/usr/include/db1".split
+ for arg in ENV["CONFIGURE_ARGS"].split
next unless /^--/ =~ arg
if /=/ =~ arg
$configure_args[$`] = $'
else
- $configure_args[arg] = default
+ $configure_args[arg] = true
end
end
end
@@ -273,121 +300,96 @@ end
def create_makefile(target)
- if $libs and "so" == "o"
+ if $libs
libs = $libs.split
for lib in libs
- lib.sub!(/-l(.*)/, '"lib\1.a"')
+ lib.sub!(/(.*)/, '"\1.lib"') if /.lib$/ !~ lib
end
$defs.push(format("-DEXTLIB='%s'", libs.join(",")))
end
+ $libs = "" unless $libs
- $DLDFLAGS = ''
-
- if PLATFORM =~ /beos/
- if $libs
- $libs = $libs + " -lruby"
- else
- $libs = "-lruby"
- end
- $DLDFLAGS = $DLDFLAGS + " -L" + $topdir
- end
-
- $srcdir = $top_srcdir + "/ext/" + $mdir
mfile = open("Makefile", "w")
mfile.printf "\
-SHELL = /bin/sh
+SHELL = $(COMPSEC)
#### Start of system configuration section. ####
-srcdir = #{$srcdir}
+srcdir = .
+VPATH = .
-hdrdir = #{$topdir}
+CC = cl
-CC = gcc
+CFLAGS = %s -I../.. -I../../missing -I../../win32 -I. -O -DNT %s #{CFLAGS} #$CFLAGS %s
-prefix = /usr
-CFLAGS = %s -I#{$topdir} -I#{$top_srcdir} -I${prefix}/include #{CFLAGS} #$CFLAGS %s
-DLDFLAGS = #$DLDFLAGS #$LDFLAGS
-LDSHARED = gcc -shared
-", if $static then "" else "-fPIC" end, $defs.join(" ")
+RUBYLIB = ../../ruby.lib
+DLDFLAGS = /DLL
+LDSHARED =
+", if $static then "" else "-fpic" end, $dllopt, $defs.join(" ")
- mfile.printf "\
+ if $force_static
+ print "static\n"
+ else
+ print "non static\n"
+ end
-RUBY_INSTALL_NAME = ruby
+ mfile.printf "\
-prefix = /usr
-exec_prefix = ${prefix}
-libdir = ${exec_prefix}/lib
-pkglibdir = $(libdir)/ruby/1.3
-archdir = $(pkglibdir)/i586-linux
-ruby_inc = #{$ruby_inc}
+libdir = /usr/local/lib/ruby/i386-mswin32
#### End of system configuration section. ####
-
"
- mfile.printf "LOCAL_LIBS = %s\n", $local_libs unless $local_libs == ""
+ mfile.printf "LOCAL_LIBS = %s\n", $LOCAL_LIBS unless $LOCAL_LIBS == ""
mfile.printf "LIBS = %s\n", $libs
mfile.printf "OBJS = "
if !$objs then
- $objs = []
- for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{c,cc}"]
- f = File.basename(f)
- f.sub!(/\.(c|cc)$/, ".o")
- $objs.push f
+ $objs = Dir["*.{c,cc}"]
+ for f in $objs
+ f.sub!(/\.(c|cc)$/, ".obj")
end
end
mfile.printf $objs.join(" ")
mfile.printf "\n"
- mfile.printf <<EOS
-TARGET = #{target}
-DLLIB = $(TARGET).#{$static ? "a" : "so"}
-
-INSTALL = /usr/bin/install -c
-INSTALL_DATA = ${INSTALL} -m 644
-
-binsuffix =
+ mfile.printf "\
+TARGET = %s
+DLLIB = $(TARGET).%s
+INSTALL = ginstall -c
+DEFFILE = %s.def
-all: $(DLLIB)
+all: $(DLLIB)
-clean:; @rm -f *.o *.a *.so *.sl *.a
+clean:; @rm -f *.obj *.lib *.exp vc*.pdb *.bak *.def
@rm -f Makefile extconf.h conftest.*
- @rm -f core ruby$(binsuffix) *~
-realclean: clean
-EOS
-
- mfile.printf <<EOS
+realclean: clean
install:
@test -d $(DESTDIR)$(libdir) || mkdir $(DESTDIR)$(libdir)
@test -d $(DESTDIR)$(pkglibdir) || mkdir $(DESTDIR)$(pkglibdir)
@test -d $(DESTDIR)$(archdir) || mkdir $(DESTDIR)$(archdir)
-EOS
+", target,
+ if $force_static then "lib" else "dll" end, target
+
if !$static
mfile.printf "\
- $(INSTALL) $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)
+ $(INSTALL) $(DLLIB) $(libdir)/$(DLLIB)
"
end
- install_rb(mfile)
- mfile.printf "\n"
- if $static
- mfile.printf "\
-$(DLLIB): $(OBJS)
- ar cru $(DLLIB) $(OBJS)
- @-ranlib $(DLLIB) 2> /dev/null || true
-"
- else
+ if $force_static
mfile.printf "\
$(DLLIB): $(OBJS)
- $(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
+ lib /OUT:$(DLLIB) $(OBJS)
"
- elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc")
+ else
mfile.printf "\
-$(DLLIB): $(OBJS)
- ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)
+$(DEFFILE):
+ echo $(DEFFILE)
+
+$(DLLIB): $(OBJS) $(DEFFILE)
+ cl -DLL -o$(DLLIB) $(OBJS) $(RUBYLIB) -link /DEF:$(DEFFILE)
"
end
@@ -400,99 +402,120 @@ $(DLLIB): $(OBJS)
dfile.close
end
mfile.close
-
+ if $static
+ #printf format("push %s,%s\n", $static, target); ##debug print##
+ $extlist.push [$static,target]
+ end
+end
+
+#template of .def file.
+def create_def(basename)
+ defname = sprintf("%s.def", basename)
+ f = open(defname, "w")
+ f.printf "\
+LIBRARY %s.dll
+CODE LOADONCALL
+DATA LOADONCALL
+DESCRIPTION 'win32 %s.dll'
+EXPORTS
+
+ Init_%s
+", basename, basename, basename
+ f.close
+
end
def extmake(target)
if $force_static or $static_ext[target]
$static = target
else
- $static = FALSE
+ $static = false
end
return if $nodynamic and not $static
- $objs = nil
- $libs = "-lc"
- $local_libs = "" # to be assigned in extconf.rb
+ $CFLAGS = nil
+ $LDFLAGS = nil
+ $LOCAL_LIBS = "" # to be assigned in extconf.rb
$CFLAGS = ""
$LDFLAGS = ""
begin
- system "mkdir", target unless File.directory?(target)
Dir.chdir target
- $mdir = target
if $static_ext.size > 0 ||
!File.exist?("./Makefile") ||
- older("./Makefile", "#{$top_srcdir}/ext/Setup") ||
+ older("./Makefile", "../Setup") ||
older("./Makefile", "../extmk.rb") ||
- older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb")
+ older("./Makefile", "./extconf.rb")
then
$defs = []
- if File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb")
- load "#{$top_srcdir}/ext/#{target}/extconf.rb"
+ if File.exist?("extconf.rb")
+ load "extconf.rb"
else
create_makefile(target);
end
end
+
+ if !File.exist?("#{target}.def")
+ create_def(target)
+ end
+
if File.exist?("./Makefile")
- if $static
- $extlist.push [$static,target]
- end
if $install
- system "make install DESTDIR=#{$destdir}"
+ system "nmake install DESTDIR=#{$destdir}"
+ if File.directory? "./lib"
+ for i in Dir["./lib/*.rb"]
+ system "ginstall -c #{i} /usr/local/lib/ruby/i386-mswin32"
+ end
+ end
elsif $clean
- system "make clean"
+ system "nmake clean"
else
- system "make all" or exit
+ #print "!!!make!!!\n"
+ system "nmake all"
end
end
if $static
- $extlibs ||= ""
+ $extlibs = " "
$extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
$extlibs += " " + $libs if $libs
- $extlibs += " " + $local_libs unless $local_libs == ""
+ $extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
end
ensure
- system "rm -f conftest*"
Dir.chdir ".."
end
end
# get static-link modules
$static_ext = {}
-for setup in ["Setup", "#{$top_srcdir}/ext/Setup"]
- if File.file? setup
- f = open(setup)
- while f.gets()
- $_.chomp!
- sub!(/#.*$/, '')
- next if /^\s*$/
- if /^option +nodynamic/
- $nodynamic = TRUE
- next
- end
- $static_ext[$_.split[0]] = TRUE
+if File.file? "./Setup"
+ f = open("./Setup")
+ while f.gets()
+ $_.chop!
+ sub!(/#.*$/, '')
+ next if /^\s*$/
+ #print $_, "\n"
+
+ if /^option +nodynamic/
+ $nodynamic = true
+ next
end
- f.close
- break
+ $static_ext[$_.split[0]] = true
end
+ f.close
end
-for d in Dir["#{$top_srcdir}/ext/*"]
+for d in Dir["*"]
File.directory?(d) || next
File.file?(d + "/MANIFEST") || next
- d = File.basename(d)
+ d = $1 if d =~ /\/([\/]*)$/
if $install
print "installing ", d, "\n"
elsif $clean
print "cleaning ", d, "\n"
else
print "compiling ", d, "\n"
- if PLATFORM =~ /-aix/ and older("../ruby.imp", "../miniruby")
- load "#{$top_srcdir}/ext/aix_mksym.rb"
- end
end
extmake(d)
end
@@ -512,64 +535,62 @@ if $cache_mod
end
exit if $install or $clean
-$extinit = "" unless $extinit
-
-ruby = "ruby"
-miniruby = "miniruby"
-
+$extinit = " " unless $extinit
+$extobjs = ""
if $extlist.size > 0
for s,t in $extlist
- f = format("%s/%s.a", s, t)
- if File.exist?(f)
+ #for s,t in $static_ext
+ #f = format("%s/%s.obj", s, t)
+ #f = format("%s/%s.obj", s, s)
+ l = format("%s/%s.lib", s, s)
+ if File.exist?(l)
$extinit += format("\
\tInit_%s();\n\
\trb_provide(\"%s.so\");\n\
-", t, t)
- $extobjs = "" unless $extobjs
+", s, s)
$extobjs += "ext/"
- $extobjs += f
+ #$extobjs += f # *.obj
+ $extobjs += l # *.lib
$extobjs += " "
else
- FALSE
+ false
end
end
- if older("extinit.c", "#{$top_srcdir}/ext/Setup")
+ if older("extinit.c", "Setup")
f = open("extinit.c", "w")
f.printf "void Init_ext() {\n"
f.printf $extinit
f.printf "}\n"
f.close
end
- if older("extinit.o", "extinit.c")
- cmd = "gcc " + CFLAGS + " -c extinit.c"
+ if older("extinit.obj", "extinit.c")
+ cmd = "cl -Zi -O -I. -c extinit.c"
print cmd, "\n"
system cmd or exit 1
end
Dir.chdir ".."
- if older(ruby, "#{$top_srcdir}/ext/Setup") or older(ruby, miniruby)
- system("rm -f #{ruby}")
+ if older("ruby.exe", "ext/Setup") or older("ruby.exe", "miniruby.exe")
+ `rm -f ruby.exe`
end
- if $extobjs
- $extobjs = "ext/extinit.o " + $extobjs
- else
- $extobjs = "ext/extinit.o "
- end
- if PLATFORM =~ /m68k-human|beos/
- $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
- end
- system format(%[make #{ruby} EXTOBJS="%s" EXTLIBS="%s"], $extobjs, $extlibs)
+ $extobjs = "ext/extinit.obj " + $extobjs
+ #$extlibs = ""
+ #print "EXTLIBS=#{$extlibs}\n"
+ $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
+ $extlibs.gsub!(" +", " ") if $extlibs
+ #print "EXTLIBS=#{$extlibs}\n"
+
+ system format('nmake ruby.exe EXTOBJS="%s" EXTLIBS="%s"', $extobjs, $extlibs)
else
Dir.chdir ".."
- if older(ruby, miniruby)
- system("rm -f #{ruby}")
- system("make #{ruby}")
+ if older("ruby.exe", "miniruby.exe")
+ `rm -f ruby.exe`
+ `cp miniruby.exe ruby.exe`
end
end
-
#Local variables:
# mode: ruby
#end:
diff --git a/ext/socket/addrinfo.h b/ext/socket/addrinfo.h
index 1236437897b..5d2c7dea45c 100644
--- a/ext/socket/addrinfo.h
+++ b/ext/socket/addrinfo.h
@@ -66,7 +66,7 @@
#define freeaddrinfo freeaddrinfo__compat
#ifndef __P
-# ifdef HAVE_PROTOTYPES 1
+# ifdef HAVE_PROTOTYPES
# define __P(args) args
# else
# define __P(args)
@@ -136,12 +136,6 @@ struct addrinfo {
struct addrinfo *ai_next; /* next structure in linked list */
};
-struct sockaddr_storage {
- u_int8_t __ss_len;
- u_int8_t __ss_family;
- u_int8_t fill[126];
-};
-
extern int getaddrinfo __P((
const char *hostname, const char *servname,
const struct addrinfo *hints,
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 12b24667b47..0526e319ec7 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -21,17 +21,13 @@ else
end
$ipv6 = false
-if enable_config("ipv6", true)
- if try_run(<<EOF)
+if enable_config("ipv6", false)
+ if try_link(<<EOF)
#include <sys/types.h>
#include <sys/socket.h>
main()
{
- exit(0);
- if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
- exit(1);
- else
- exit(0);
+ socket(AF_INET6, SOCK_STREAM, 0);
}
EOF
$CFLAGS+=" -DENABLE_IPV6"
@@ -39,7 +35,6 @@ EOF
end
end
-
$ipv6type = nil
$ipv6lib = nil
$ipv6libdir = nil
@@ -101,9 +96,10 @@ EOF
if $ipv6lib
if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a"
- $LDFLAGS += " -L#$ipv6libdir -l#$ipv6lib"
+ $LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib"
else
print <<EOS
+
Fatal: no #$ipv6lib library found. cannot continue.
You need to fetch lib#{$ipv6lib}.a from appropriate
ipv6 kit and compile beforehand.
@@ -235,13 +231,21 @@ main()
EOF
$getaddr_info_ok = true
end
+if $ipv6 and not $getaddr_info_ok
+ print <<EOS
+
+Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
+But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
+you cannot compile IPv6 socket classes with broken these functions.
+EOS
+ exit
+end
+
$objs = ["socket.o"]
-if $getaddr_info_ok
- if have_func("getaddrinfo") and have_func("getnameinfo")
- have_getaddrinfo = true
- end
+if $getaddr_info_ok and have_func("getaddrinfo") and have_func("getnameinfo")
+ have_getaddrinfo = true
end
if have_getaddrinfo
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index 64d29b17ab8..cdc3de52e4a 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -221,7 +221,7 @@ inet_pton(af, hostname, pton)
struct in_addr in;
#ifdef HAVE_INET_ATON
- if (!inet_aton(hostname, &in.s_addr))
+ if (!inet_aton(hostname, &in))
return 0;
#else
int d1, d2, d3, d4;
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index e4a57c65545..89245d324fd 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -93,7 +93,7 @@ inet_ntop(af, addr, numaddr, numaddr_len)
#ifdef HAVE_INET_NTOA
struct in_addr in;
memcpy(&in.s_addr, addr, sizeof(in.s_addr));
- strncpy(numaddr, numaddr_len, inet_ntoa(in));
+ snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in));
#else
unsigned long x = ntohl(*(unsigned long*)addr);
snprintf(numaddr, numaddr_len, "%d.%d.%d.%d",
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 6126ddf2b99..875f6f33d36 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -309,11 +309,13 @@ bsock_send(argc, argv, sock)
if (n < 0) {
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ rb_thread_fd_writable(fd);
goto retry;
}
rb_sys_fail("send(2)");
@@ -367,11 +369,14 @@ s_recv(sock, argc, argv, from)
if (RSTRING(str)->len < 0) {
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
+
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ rb_thread_wait_fd(fd);
goto retry;
}
rb_sys_fail("recvfrom(2)");
@@ -422,7 +427,7 @@ mkipaddr(addr)
error = getnameinfo(addr, SA_LEN(addr), buf, sizeof(buf), NULL, 0,
NI_NUMERICHOST);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
return rb_str_new2(buf);
}
@@ -453,13 +458,13 @@ ipaddr(sockaddr)
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
NULL, 0, 0);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
addr1 = rb_str_new2(hbuf);
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
addr2 = rb_str_new2(hbuf);
port = INT2FIX(atoi(pbuf));
@@ -479,7 +484,7 @@ setipaddr(name, addr)
sin = (struct sockaddr_in *)addr;
if (name[0] == 0) {
- memset(sin, 0, sizeof(*sin));
+ MEMZERO(sin, struct sockaddr_in, 1);
sin->sin_family = AF_INET;
SET_SIN_LEN(sin, sizeof(*sin));
sin->sin_addr.s_addr = INADDR_ANY;
@@ -490,11 +495,11 @@ setipaddr(name, addr)
sin->sin_addr.s_addr = INADDR_BROADCAST;
}
else {
- memset(&hints, 0, sizeof(hints));
+ MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = PF_UNSPEC;
error = getaddrinfo(name, NULL, &hints, &res);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
/* just take the first one */
memcpy(addr, res->ai_addr, res->ai_addrlen);
@@ -502,17 +507,27 @@ setipaddr(name, addr)
}
}
+static void
+thread_write_select(fd)
+ int fd;
+{
+ fd_set fds;
+
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ rb_thread_select(fd+1, 0, &fds, 0, 0);
+}
+
#if defined(HAVE_FCNTL)
static int
-thread_connect(fd, sockaddr, len, type)
+ruby_connect(fd, sockaddr, len, socks)
int fd;
struct sockaddr *sockaddr;
int len;
- int type;
+ int socks;
{
int status;
int mode;
- fd_set fds;
mode = fcntl(fd, F_GETFL, 0);
@@ -528,7 +543,7 @@ thread_connect(fd, sockaddr, len, type)
fcntl(fd, F_SETFL, mode|NONBLOCKING);
for (;;) {
#ifdef SOCKS
- if (type == INET_SOCKS) {
+ if (socks) {
status = Rconnect(fd, sockaddr, len);
}
else
@@ -538,22 +553,15 @@ thread_connect(fd, sockaddr, len, type)
}
if (status < 0) {
switch (errno) {
-#ifdef EAGAIN
case EAGAIN:
#ifdef EINPROGRESS
case EINPROGRESS:
#endif
- rb_thread_fd_writable(fd);
+ thread_write_select(fd);
continue;
-#endif
#ifdef EISCONN
case EISCONN:
-#endif
-#ifdef EALREADY
- case EALREADY:
-#endif
-#if defined(EISCONN) || defined(EALREADY)
status = 0;
errno = 0;
break;
@@ -565,6 +573,29 @@ thread_connect(fd, sockaddr, len, type)
return status;
}
}
+
+#else
+
+#ifdef SOCKS
+static int
+ruby_connect(fd, sockaddr, len, socks)
+ int fd;
+ struct sockaddr *sockaddr;
+ int len;
+ int socks;
+{
+ if (socks) {
+ return Rconnect(fd, sockaddr, len);
+ }
+ else {
+ return connect(fd, sockaddr, len);
+ }
+}
+#else
+
+#define ruby_connect(fd, sockaddr, len, socks) connect(fd, sockaddr, len)
+
+#endif /* SOCKS */
#endif
static VALUE
@@ -595,7 +626,7 @@ open_inet(class, h, serv, type)
strcpy(pbuf, STR2CSTR(serv));
portp = pbuf;
}
- memset(&hints, 0, sizeof(hints));
+ MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if (type == INET_SERVER) {
@@ -603,7 +634,7 @@ open_inet(class, h, serv, type)
}
error = getaddrinfo(host, portp, &hints, &res0);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
fd = -1;
@@ -621,19 +652,8 @@ open_inet(class, h, serv, type)
syscall = "bind(2)";
}
else {
-#if defined(HAVE_FCNTL)
- status = thread_connect(fd, res->ai_addr, res->ai_addrlen, type);
-#else
-#ifdef SOCKS
- if (type == INET_SOCKS) {
- status = Rconnect(fd, res->ai_addr, res->ai_addrlen);
- }
- else
-#endif
- {
- status = connect(fd, res->ai_addr, res->ai_addrlen);
- }
-#endif
+ status = ruby_connect(fd, res->ai_addr, res->ai_addrlen,
+ (type == INET_SOCKS));
syscall = "connect(2)";
}
@@ -698,10 +718,10 @@ tcp_s_gethostbyname(obj, host)
VALUE ary, names;
if (rb_obj_is_kind_of(host, rb_cInteger)) {
- int i = NUM2INT(host);
+ long i = NUM2LONG(host);
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&addr;
- memset(sin, 0, sizeof(*sin));
+ MEMZERO(sin, struct sockaddr_in, 1);
sin->sin_family = AF_INET;
SET_SIN_LEN(sin, sizeof(*sin));
sin->sin_addr.s_addr = htonl(i);
@@ -737,7 +757,7 @@ tcp_s_gethostbyname(obj, host)
if (h == NULL) {
#ifdef HAVE_HSTERROR
extern int h_errno;
- rb_raise(rb_eSocket, (char *)hsterror(h_errno));
+ rb_raise(rb_eSocket, "%s", (char *)hsterror(h_errno));
#else
rb_raise(rb_eSocket, "host not found");
#endif
@@ -756,7 +776,7 @@ tcp_s_gethostbyname(obj, host)
case AF_INET:
{
struct sockaddr_in sin;
- memset(&sin, 0, sizeof(sin));
+ MEMZERO(&sin, struct sockaddr_in, 1);
sin.sin_family = AF_INET;
SET_SIN_LEN(&sin, sizeof(sin));
memcpy((char *) &sin.sin_addr, *pch, h->h_length);
@@ -770,7 +790,7 @@ tcp_s_gethostbyname(obj, host)
case AF_INET6:
{
struct sockaddr_in6 sin6;
- memset(&sin6, 0, sizeof(sin6));
+ MEMZERO(&sin6, struct sockaddr_in6, 1);
sin6.sin6_family = AF_INET;
sin6.sin6_len = sizeof(sin6);
memcpy((char *) &sin6.sin6_addr, *pch, h->h_length);
@@ -824,11 +844,14 @@ s_accept(class, fd, sockaddr, len)
if (fd2 < 0) {
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
+
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ rb_thread_wait_fd(fd);
goto retry;
}
rb_sys_fail(0);
@@ -875,7 +898,7 @@ open_unix(class, path, server)
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) rb_sys_fail("socket(2)");
- memset(&sockaddr, 0, sizeof(sockaddr));
+ MEMZERO(&sockaddr, struct sockaddr_un, 1);
sockaddr.sun_family = AF_UNIX;
strncpy(sockaddr.sun_path, path->ptr, sizeof(sockaddr.sun_path)-1);
sockaddr.sun_path[sizeof(sockaddr.sun_path)-1] = '\0';
@@ -884,7 +907,7 @@ open_unix(class, path, server)
status = bind(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
}
else {
- status = connect(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
+ status = ruby_connect(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr), 0);
}
if (status < 0) {
@@ -939,10 +962,10 @@ ip_s_getaddress(obj, host)
struct sockaddr addr;
if (rb_obj_is_kind_of(host, rb_cInteger)) {
- int i = NUM2INT(host);
+ long i = NUM2LONG(host);
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&addr;
- memset(sin, 0, sizeof(*sin));
+ MEMZERO(sin, struct sockaddr_in, 1);
sin->sin_family = AF_INET;
SET_SIN_LEN(sin, sizeof(*sin));
sin->sin_addr.s_addr = htonl(i);
@@ -961,18 +984,12 @@ udp_s_open(argc, argv, class)
VALUE class;
{
VALUE arg;
+ int socktype = AF_INET;
if (rb_scan_args(argc, argv, "01", &arg) == 1) {
- if (rb_obj_is_kind_of(arg, rb_cInteger)) {
- return sock_new(class, socket(NUM2INT(arg), SOCK_DGRAM, 0));
- }
- else {
- rb_raise(rb_eSocket, "argument must be Integer");
- }
- }
- else {
- return sock_new(class, socket(AF_INET, SOCK_DGRAM, 0));
+ socktype = NUM2INT(arg);
}
+ return sock_new(class, socket(socktype, SOCK_DGRAM, 0));
}
static struct addrinfo *
@@ -990,15 +1007,15 @@ udp_addrsetup(fptr, host, port)
}
else if (rb_obj_is_kind_of(host, rb_cInteger)) {
struct sockaddr_in sin;
- int i = NUM2INT(host);
- memset(&sin, 0, sizeof(sin));
+ long i = NUM2LONG(host);
+ MEMZERO(&sin, struct sockaddr_in, 1);
sin.sin_family = AF_INET;
SET_SIN_LEN(&sin, sizeof(sin));
sin.sin_addr.s_addr = htonl(i);
error = getnameinfo((struct sockaddr *)&sin, SIN_LEN(&sin),
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
hostp = hbuf;
}
@@ -1014,12 +1031,12 @@ udp_addrsetup(fptr, host, port)
portp = STR2CSTR(port);
}
- memset(&hints, 0, sizeof(hints));
+ MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
error = getaddrinfo(hostp, portp, &hints, &res);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
return res;
@@ -1030,23 +1047,28 @@ udp_connect(sock, host, port)
VALUE sock, host, port;
{
OpenFile *fptr;
+ int fd;
struct addrinfo *res0, *res;
GetOpenFile(sock, fptr);
+ fd = fileno(fptr->f);
res0 = udp_addrsetup(fptr, host, port);
for (res = res0; res; res = res->ai_next) {
retry:
- if (connect(fileno(fptr->f), res->ai_addr, res->ai_addrlen) >= 0) {
+ if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) {
freeaddrinfo(res0);
return INT2FIX(0);
}
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
+
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ thread_write_select(fd);
goto retry;
}
}
@@ -1111,11 +1133,14 @@ udp_send(argc, argv, sock)
}
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
+
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ thread_write_select(fileno(f));
goto retry;
}
}
@@ -1354,20 +1379,24 @@ sock_connect(sock, addr)
VALUE sock, addr;
{
OpenFile *fptr;
+ int fd;
Check_Type(addr, T_STRING);
rb_str_modify(addr);
GetOpenFile(sock, fptr);
+ fd = fileno(fptr->f);
retry:
- if (connect(fileno(fptr->f), (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len) < 0) {
+ if (ruby_connect(fd, (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len, 0) < 0) {
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ thread_write_select(fd);
goto retry;
}
rb_sys_fail("connect(2)");
@@ -1476,7 +1505,7 @@ mkhostent(h)
if (h == NULL) {
#ifdef HAVE_HSTRERROR
extern int h_errno;
- rb_raise(rb_eSocket, (char *)hstrerror(h_errno));
+ rb_raise(rb_eSocket, "%s", (char *)hstrerror(h_errno));
#else
rb_raise(rb_eSocket, "host not found");
#endif
@@ -1534,10 +1563,10 @@ sock_s_gethostbyname(obj, host)
struct hostent *h;
if (rb_obj_is_kind_of(host, rb_cInteger)) {
- int i = NUM2INT(host);
+ long i = NUM2LONG(host);
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&addr;
- memset(sin, 0, sizeof(*sin));
+ MEMZERO(sin, struct sockaddr_in, 1);
sin->sin_family = AF_INET;
SET_SIN_LEN(sin, sizeof(*sin));
sin->sin_addr.s_addr = htonl(i);
@@ -1642,7 +1671,7 @@ sock_s_getaddrinfo(argc, argv)
host = port = family = socktype = protocol = flags = Qnil;
rb_scan_args(argc, argv, "24", &host, &port, &family, &socktype, &protocol,
- &flags);
+ &flags);
if (NIL_P(host)) {
hptr = NULL;
}
@@ -1654,7 +1683,7 @@ sock_s_getaddrinfo(argc, argv)
if (NIL_P(port)) {
pptr = NULL;
}
- else if (rb_obj_is_kind_of(port, rb_cInteger)) {
+ else if (FIXNUM_P(port)) {
snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
pptr = pbuf;
}
@@ -1664,25 +1693,25 @@ sock_s_getaddrinfo(argc, argv)
pptr = pbuf;
}
- memset(&hints, 0, sizeof(hints));
- if (!NIL_P(family) && rb_obj_is_kind_of(family, rb_cInteger)) {
- hints.ai_family = FIX2INT(family);
+ MEMZERO(&hints, struct addrinfo, 1);
+ if (!NIL_P(family)) {
+ hints.ai_family = NUM2INT(family);
}
else {
hints.ai_family = PF_UNSPEC;
}
- if (!NIL_P(socktype) && rb_obj_is_kind_of(socktype, rb_cInteger)) {
- hints.ai_socktype = socktype;
+ if (!NIL_P(socktype)) {
+ hints.ai_socktype = NUM2INT(socktype);
}
- if (!NIL_P(protocol) && rb_obj_is_kind_of(protocol, rb_cInteger)) {
- hints.ai_protocol = protocol;
+ if (!NIL_P(protocol)) {
+ hints.ai_protocol = NUM2INT(protocol);
}
- if (!NIL_P(flags) && rb_obj_is_kind_of(flags, rb_cInteger)) {
- hints.ai_flags = flags;
+ if (!NIL_P(flags)) {
+ hints.ai_flags = NUM2INT(flags);
}
error = getaddrinfo(hptr, pptr, &hints, &res);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
ret = mkaddrinfo(res);
@@ -1743,8 +1772,8 @@ sock_s_getnameinfo(argc, argv)
strcpy(pbuf, "0");
pptr = NULL;
}
- else if (rb_obj_is_kind_of(port, rb_cInteger)) {
- snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
+ else if (!NIL_P(port)) {
+ snprintf(pbuf, sizeof(pbuf), "%d", NUM2INT(port));
pptr = pbuf;
}
else {
@@ -1752,21 +1781,21 @@ sock_s_getnameinfo(argc, argv)
pbuf[sizeof(pbuf) - 1] = '\0';
pptr = pbuf;
}
- memset(&hints, 0, sizeof(hints));
+ MEMZERO(&hints, struct addrinfo, 1);
if (strcmp(STR2CSTR(af), "AF_INET") == 0) {
hints.ai_family = PF_INET;
}
- #ifdef INET6
+#ifdef INET6
else if (strcmp(STR2CSTR(af), "AF_INET6") == 0) {
hints.ai_family = PF_INET6;
}
- #endif
+#endif
else {
hints.ai_family = PF_UNSPEC;
}
error = getaddrinfo(hptr, pptr, &hints, &res);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
sap = res->ai_addr;
}
@@ -1775,15 +1804,15 @@ sock_s_getnameinfo(argc, argv)
}
fl = 0;
- if (!NIL_P(flags) && rb_obj_is_kind_of(flags, rb_cInteger)) {
- fl = FIX2INT(flags);
+ if (!NIL_P(flags)) {
+ fl = NUM2INT(flags);
}
-gotsap:
+ gotsap:
error = getnameinfo(sap, SA_LEN(sap), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), fl);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
if (res)
freeaddrinfo(res);
diff --git a/instruby.rb b/instruby.rb
index 2c182b23f7b..338ec566fc7 100644
--- a/instruby.rb
+++ b/instruby.rb
@@ -49,6 +49,11 @@ end
Dir.chdir wdir
File.makedirs pkglibdir, true
File.makedirs archdir, true
+
+if PLATFORM =~ /-aix/
+ File.install "ruby.imp", archdir, 0644, true
+end
+
Dir.chdir "ext"
system "../miniruby#{binsuffix} extmk.rb install #{destdir}"
Dir.chdir CONFIG["srcdir"]
@@ -60,9 +65,6 @@ Find.find("lib") do |f|
File.install f, dir, 0644, true
end
-if PLATFORM =~ /-aix/
- File.install "ruby.imp", archdir, 0644, true
-end
for f in Dir["*.h"]
File.install f, archdir, 0644, true
end
diff --git a/lib/jcode.rb b/lib/jcode.rb
index 50b7beee9de..1ed82327b85 100644
--- a/lib/jcode.rb
+++ b/lib/jcode.rb
@@ -172,8 +172,11 @@ class String
self.gsub!(/(.|\n)/) do |c|
if comp
unless afrom.include?(c)
- ato[-1]
+ c = ato[-1]
+ next if c == last
+ last = c
else
+ last = nil
c
end
elsif i = afrom.index(c)
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index c697ade2710..7ebef9fd8d8 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -59,8 +59,8 @@ if /win32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ PLATFORM
else
$null = open("/dev/null", "w")
end
-LINK = "#{CONFIG['CC']} -o conftest -I#{$hdrdir} -I#{CONFIG['includedir']} #{CFLAGS} %s #{CONFIG['LDFLAGS']} %s conftest.c #{CONFIG['LIBS']} %s"
-CPP = "#{CONFIG['CPP']} -E -I#{$hdrdir} -I#{CONFIG['includedir']} #{CFLAGS} %s conftest.c"
+LINK = "#{CONFIG['CC']} -o conftest -I#{$hdrdir} -I#{CONFIG['includedir']} #{CFLAGS} %s #{CONFIG['LDFLAGS']} %s conftest.c %s %s #{CONFIG['LIBS']}"
+CPP = "#{CONFIG['CPP']} -E -I#{$hdrdir} -I#{CONFIG['includedir']} #{CFLAGS} %s %s conftest.c"
$orgerr = $stderr.dup
$orgout = $stdout.dup
@@ -81,7 +81,7 @@ def try_link0(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+ xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
end
def try_link(src, opt="")
@@ -92,23 +92,41 @@ def try_link(src, opt="")
end
end
-def try_cpp(src, opt=$CFLAGS)
+def try_cpp(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(CPP, opt))
+ begin
+ xsystem(format(CPP, $CFLAGS, opt))
+ ensure
+ system "rm -f conftest*"
+ end
end
-def egrep_cpp(pat, src, opt=$CFLAGS)
+def egrep_cpp(pat, src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(CPP+"|egrep #{pat}", opt))
+ begin
+ xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
+ ensure
+ system "rm -f conftest*"
+ end
end
def try_run(src, opt="")
- if try_link0(src, opt)
- xsystem("./conftest")
+ begin
+ if try_link0(src, opt)
+ if xsystem("./conftest")
+ true
+ else
+ false
+ end
+ else
+ nil
+ end
+ ensure
+ system "rm -f conftest*"
end
end
@@ -250,7 +268,7 @@ SRC
return TRUE
end
-def arg_config(config, default="yes")
+def arg_config(config, default=nil)
unless defined? $configure_args
$configure_args = {}
for arg in CONFIG["configure_args"].split + ARGV
@@ -258,14 +276,14 @@ def arg_config(config, default="yes")
if /=/ =~ arg
$configure_args[$`] = $'
else
- $configure_args[arg] = default
+ $configure_args[arg] = true
end
end
end
$configure_args.fetch(config, default)
end
-def with_config(config, default="yes")
+def with_config(config, default=nil)
unless /^--with-/ =~ config
config = '--with-' + config
end
@@ -273,7 +291,7 @@ def with_config(config, default="yes")
end
def enable_config(config, default=nil)
- if arg_config("--enable-"+config, true)
+ if arg_config("--enable-"+config, default)
true
elsif arg_config("--disable-"+config, false)
false
@@ -346,7 +364,7 @@ ruby_inc = #{$ruby_inc}
#### End of system configuration section. ####
-LOCAL_LIBS = #{$local_libs}
+LOCAL_LIBS = #{$LOCAL_LIBS}
LIBS = #{$libs}
OBJS = #{$objs}
@@ -440,7 +458,7 @@ end
$libs = PLATFORM =~ /cygwin32|beos/ ? nil : "-lc"
$objs = nil
-$local_libs = ""
+$LOCAL_LIBS = ""
$CFLAGS = ""
$LDFLAGS = ""
$defs = []
diff --git a/range.c b/range.c
index dd023cc23b3..d2ce1f00585 100644
--- a/range.c
+++ b/range.c
@@ -74,7 +74,6 @@ range_s_new(argc, argv, klass)
VALUE beg, end, flag, range;
rb_scan_args(argc, argv, "21", &beg, &end, &flag);
- if (argc == 2) flag = Qfalse;
return range_new(klass, beg, end, RTEST(flag));
}
@@ -82,7 +81,7 @@ static VALUE
range_exclude_end_p(range)
VALUE range;
{
- return EXCL(range)?Qtrue:Qfalse;;
+ return EXCL(range)?Qtrue:Qfalse;
}
static VALUE
@@ -97,23 +96,22 @@ range_eqq(range, obj)
if (FIXNUM_P(beg) && FIXNUM_P(obj) && FIXNUM_P(end)) {
if (FIX2INT(beg) <= FIX2INT(obj)) {
if (EXCL(range)) {
- if (FIX2INT(obj) <= FIX2INT(end)) return Qtrue;
+ if (FIX2INT(obj) < FIX2INT(end)) return Qtrue;
}
else {
- if (FIX2INT(obj) < FIX2INT(end)) return Qtrue;
+ if (FIX2INT(obj) <= FIX2INT(end)) return Qtrue;
}
}
return Qfalse;
}
else if (RTEST(rb_funcall(beg, rb_intern("<="), 1, obj))) {
if (EXCL(range)) {
- if (RTEST(rb_funcall(end, rb_intern(">="), 1, obj)))
+ if (RTEST(rb_funcall(end, rb_intern(">"), 1, obj)))
return Qtrue;
}
else {
- if (RTEST(rb_funcall(end, rb_intern(">"), 1, obj)))
+ if (RTEST(rb_funcall(end, rb_intern(">="), 1, obj)))
return Qtrue;
- if (FIX2INT(obj) < FIX2INT(end)) return Qtrue;
}
}
return Qfalse;
diff --git a/regex.c b/regex.c
index 530701b2d55..31d0c879d73 100644
--- a/regex.c
+++ b/regex.c
@@ -332,6 +332,7 @@ enum regexpcode
set_number_at, /* Set the following relative location to the
subsequent number. */
anychar, /* Matches any (more or less) one character excluding newlines. */
+ anychar_repeat, /* Matches sequence of characters excluding newlines. */
charset, /* Matches any one char belonging to specified set.
First following byte is number of bitmap bytes.
Then come bytes for a bitmap saying which chars are in.
@@ -784,6 +785,10 @@ print_partial_compiled_pattern(start, end)
printf("/anychar");
break;
+ case anychar_repeat:
+ printf("/anychar_repeat");
+ break;
+
case charset:
case charset_not:
{
@@ -982,12 +987,11 @@ calculate_must_string(start, end)
case casefold_on:
case casefold_off:
- case posix_on:
- case posix_off:
return 0; /* should not check must_string */
case pop_and_fail:
case anychar:
+ case anychar_repeat:
case begline:
case endline:
case wordbound:
@@ -1001,6 +1005,8 @@ calculate_must_string(start, end)
case endbuf2:
case push_dummy_failure:
case stop_paren:
+ case posix_on:
+ case posix_off:
break;
case charset:
@@ -1228,6 +1234,12 @@ re_compile_pattern(pattern, size, bufp)
if (!laststart)
break;
+ if (greedy && *laststart == anychar && b - laststart < 2) {
+ if (b[-1] == stop_paren)
+ b--;
+ *laststart = anychar_repeat;
+ break;
+ }
/* Now we know whether or not zero matches is allowed
and also whether or not two or more matches is allowed. */
if (many_times_ok) {
@@ -2152,7 +2164,10 @@ re_compile_pattern(pattern, size, bufp)
if (*laststart == start_memory) laststart += 3;
if (*laststart == dummy_failure_jump) laststart += 3;
else if (*laststart == try_next) laststart += 3;
- if (*laststart == on_failure_jump) {
+ if (*laststart == anychar_repeat) {
+ bufp->options |= RE_OPTIMIZE_ANCHOR;
+ }
+ else if (*laststart == on_failure_jump) {
int mcnt;
laststart++;
@@ -2675,6 +2690,7 @@ re_compile_fastmap(bufp)
case duplicate:
bufp->can_be_null = 1;
fastmap['\n'] = 1;
+ case anychar_repeat:
case anychar:
for (j = 0; j < (1 << BYTEWIDTH); j++) {
if (j != '\n' || (options & RE_OPTION_POSIXLINE))
@@ -3359,7 +3375,9 @@ re_match(bufp, string_arg, size, pos, regs)
/* End of pattern means we might have succeeded. */
if (p == pend) {
/* If not end of string, try backtracking. Otherwise done. */
- if (d != dend) {
+ if ((bufp->options & RE_OPTION_POSIXMATCH) && d != dend) {
+ if (best_regs_set) /* non-greedy, no need to backtrack */
+ goto restore_best_regs;
while (stackp != stackb && stackp[-1] == NON_GREEDY) {
if (best_regs_set) /* non-greedy, no need to backtrack */
goto restore_best_regs;
@@ -3599,6 +3617,25 @@ re_match(bufp, string_arg, size, pos, regs)
d++;
break;
+ case anychar_repeat:
+ for (;;) {
+ PUSH_FAILURE_POINT(p, d);
+ PREFETCH;
+ if (ismbchar(*d)) {
+ if (d + mbclen(*d) > dend)
+ goto fail;
+ SET_REGS_MATCHED;
+ d += mbclen(*d);
+ break;
+ }
+ if (!(options&RE_OPTION_POSIXLINE) &&
+ (TRANSLATE_P() ? translate[*d] : *d) == '\n')
+ goto fail;
+ SET_REGS_MATCHED;
+ d++;
+ }
+ break;
+
case charset:
case charset_not:
{
diff --git a/regex.h b/regex.h
index e116f63c9f6..e03331b1b8f 100644
--- a/regex.h
+++ b/regex.h
@@ -65,8 +65,10 @@
#define RE_OPTION_EXTENDED (RE_OPTION_IGNORECASE<<1)
/* newline will be included for . and invert charclass matches */
#define RE_OPTION_POSIXLINE (RE_OPTION_EXTENDED<<1)
+/* search for longest match, in accord with POSIX regexp */
+#define RE_OPTION_POSIXMATCH (RE_OPTION_POSIXLINE<<1)
-#define RE_MAY_IGNORECASE (RE_OPTION_POSIXLINE<<1)
+#define RE_MAY_IGNORECASE (RE_OPTION_POSIXMATCH<<1)
#define RE_OPTIMIZE_ANCHOR (RE_MAY_IGNORECASE<<1)
#define RE_OPTIMIZE_EXACTN (RE_OPTIMIZE_ANCHOR<<1)
#define RE_OPTIMIZE_NO_BM (RE_OPTIMIZE_EXACTN<<1)
diff --git a/signal.c b/signal.c
index 3e5bed47992..0fbf1585230 100644
--- a/signal.c
+++ b/signal.c
@@ -312,7 +312,6 @@ signal_exec(sig)
break;
#ifndef NT
case SIGHUP:
- case SIGTERM:
#endif
#ifdef SIGPIPE
case SIGPIPE:
@@ -497,7 +496,6 @@ trap(arg)
case SIGINT:
#ifndef NT
case SIGHUP:
- case SIGTERM:
#endif
#ifdef SIGQUIT
case SIGQUIT:
@@ -615,7 +613,6 @@ Init_signal()
ruby_signal(SIGINT, sighandle);
#ifndef NT
ruby_signal(SIGHUP, sighandle);
- ruby_signal(SIGTERM, sighandle);
#endif
#ifdef SIGPIPE
ruby_signal(SIGPIPE, sighandle);
diff --git a/string.c b/string.c
index 7b8a55aa944..37321306aee 100644
--- a/string.c
+++ b/string.c
@@ -1332,10 +1332,12 @@ rb_str_inspect(str)
*b++ = *p++;
}
}
+#if 0
else if ((c & 0x80) && rb_kcode() != MBCTYPE_EUC) {
CHECK(1);
*b++ = c;
}
+#endif
else if (c == '"'|| c == '\\') {
CHECK(2);
*b++ = '\\';
@@ -1671,13 +1673,13 @@ tr_trans(str, src, repl, sflag)
struct tr trsrc, trrepl;
int cflag = 0;
char trans[256];
- int i, c, c0, modify = 0;
+ int i, c, modify = 0;
char *s, *send;
rb_str_modify(str);
if (TYPE(src) != T_STRING) src = rb_str_to_str(src);
trsrc.p = RSTRING(src)->ptr; trsrc.pend = trsrc.p + RSTRING(src)->len;
- if (RSTRING(src)->len > 2 && RSTRING(src)->ptr[0] == '^') {
+ if (RSTRING(src)->len >= 2 && RSTRING(src)->ptr[0] == '^') {
cflag++;
trsrc.p++;
}
@@ -1696,18 +1698,11 @@ tr_trans(str, src, repl, sflag)
while ((c = trnext(&trsrc)) >= 0) {
trans[c & 0xff] = 0;
}
+ while ((c = trnext(&trrepl)) >= 0)
+ /* retrieve last replacer */;
for (i=0; i<256; i++) {
- if (trans[i] == 0) {
- trans[i] = i;
- }
- else {
- c = trnext(&trrepl);
- if (c == -1) {
- trans[i] = trrepl.now;
- }
- else {
- trans[i] = c;
- }
+ if (trans[i] != 0) {
+ trans[i] = trrepl.now;
}
}
}
@@ -1715,7 +1710,7 @@ tr_trans(str, src, repl, sflag)
char r;
for (i=0; i<256; i++) {
- trans[i] = i;
+ trans[i] = 0;
}
while ((c = trnext(&trsrc)) >= 0) {
r = trnext(&trrepl);
@@ -1725,19 +1720,21 @@ tr_trans(str, src, repl, sflag)
}
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
- c0 = -1;
if (sflag) {
char *t = s;
+ int c0, last = -1;
while (s < send) {
- c = trans[*s++ & 0xff] & 0xff;
- if (s[-1] == c || c != c0) {
- c0 = (s[-1] == c)?-1:c;
- if (*t != c) {
- *t = c;
- modify = 1;
- }
+ c0 = *s++;
+ if ((c = trans[c0 & 0xff] & 0xff) != 0) {
+ if (last == c) continue;
+ last = c;
*t++ = c;
+ modify = 1;
+ }
+ else {
+ last = -1;
+ *t++ = c0;
}
}
if (RSTRING(str)->len > (t - RSTRING(str)->ptr)) {
@@ -1748,8 +1745,7 @@ tr_trans(str, src, repl, sflag)
}
else {
while (s < send) {
- c = trans[*s & 0xff] & 0xff;
- if (*s != c) {
+ if ((c = trans[*s & 0xff] & 0xff) != 0) {
*s = c;
modify = 1;
}
@@ -1869,11 +1865,13 @@ tr_squeeze(str1, str2)
c = *s++ & 0xff;
if (c != save || !squeez[c & 0xff]) {
*t++ = save = c;
- modify = 1;
}
}
*t = '\0';
- RSTRING(str1)->len = t - RSTRING(str1)->ptr;
+ if (t - RSTRING(str1)->ptr != RSTRING(str1)->len) {
+ RSTRING(str1)->len = t - RSTRING(str1)->ptr;
+ modify = 1;
+ }
if (modify) return str1;
return Qnil;
diff --git a/win32/Makefile b/win32/Makefile
index b0d6ffe723a..89a51004fbf 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -23,10 +23,9 @@ LIBS = $(EXTLIBS) advapi32.lib wsock32.lib
MISSING = crypt.obj alloca.obj win32.obj fnmatch.obj isinf.obj isnan.obj
prefix =
-binprefix =
-exec_prefix =
-bindir =
-libdir =
+RUBY_INSTALL_NAME=ruby
+binsuffix = .exe
+PROGRAM=$(RUBY_INSTALL_NAME)$(binsuffix)
STACK = 0x200000
ORGLIBPATH = $(LIB)
@@ -51,7 +50,6 @@ OBJS = array.obj \
eval.obj \
file.obj \
gc.obj \
- glob.obj \
hash.obj \
inits.obj \
io.obj \
@@ -79,61 +77,48 @@ OBJS = array.obj \
version.obj \
$(MISSING)
-all: miniruby.exe ext/Setup $(MISCLIBS)
- cd ext
+all: miniruby$(binsuffix) rbconfig.rb ext/Setup $(MISCLIBS)
set LIB=..\..\win32;$(ORGLIBPATH)
- ..\miniruby .\extmk.rb static
-# ..\miniruby .\extmk.rb
- cd ..
+ @./miniruby$(binsuffix) -Xext extmk.rb static
-miniruby.exe: $(OBJS) $(MAINOBJ) $(EXTOBJS)
+miniruby$(binsuffix): $(OBJS) $(MAINOBJ) $(EXTOBJS)
@echo $(EXTOBJS)
@echo $(LIBS)
- @rm -f miniruby.exe
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(LIBS) -o miniruby.exe
+ @rm -f miniruby$(binsuffix)
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $(LIBS) -o $@
-ruby.exe: $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) rubymw.dll
- @rm -f ruby.exe
-# $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY) $(LIBS) -o ruby.exe
- $(CC) $(LDFLAGS) $(MAINOBJ) -o ruby.exe rubymw.lib -link /STACK:$(STACK)
+$(PROGRAM): $(LIBRUBY) $(MAINOBJ) rubymw.dll
+ @rm -f $(PROGRAM)
+ $(CC) $(LDFLAGS) $(MAINOBJ) -o $(PROGRAM) rubymw.lib -link /STACK:$(STACK)
rubymw.dll: $(LIBRUBY) $(EXTOBJS)
set LIB=.\win32;$(ORGLIBPATH)
@rm -f rubymw.dll
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY) $(LIBS) -o rubymw.dll -link /DLL /DEF:ruby.def
+ $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY) $(LIBS) -o rubymw.dll -link /DLL /DEF:ruby.def
@mv rubymw.map rubydll.map
$(LIBRUBY): $(OBJS)
lib /OUT:$(LIBRUBY) $(OBJS)
-install:; $(INSTALL_PROGRAM) ruby.exe $(bindir)/ruby.exe
- @-strip $(bindir)/ruby
- @test -d $(libdir) || mkdir $(libdir)
- cd ext; ../miniruby ./extmk.rb install
- @for rb in `grep '^lib/' MANIFEST`; do \
- $(INSTALL_DATA) $$rb $(libdir); \
- done
-
-clean:; @rm -f $(OBJS) $(LIBRUBY) main.obj dmyext.obj *.pdb *.map *.exp
- @rm -f ext/extinit.c ext/extinit.obj
- cd ext
- ..\miniruby .\extmk.rb clean
- cd ..
-
-realclean: clean
- @rm -f Makefile ext/extmk.rb
- @rm -f config.cache config.h config.log config.status
- @rm -f core ruby miniruby *~
-
-test:; @-./ruby sample/test.rb > ./ruby_test 2>&1; \
- if grep '^end of test' ./ruby_test > /dev/null; then \
- echo "test succeeded"; \
- else \
- grep '^sample/test.rb' ./ruby_test; \
- grep '^not' ./ruby_test; \
- echo "test failed";\
- fi;\
- rm -f ./ruby_test
+install: rbconfig.rb
+ ./miniruby.exe $(srcdir)/instruby.rb $(DESTDIR)
+
+clean:; @rm -f $(OBJS) $(LIBRUBY) rbconfig.rb
+ @rm -f ext/extinit.c ext/extinit.obj *.obj
+ @-./miniruby$(binsuffix) -Xext extmk.rb clean 2> /dev/null || true
+
+distclean: clean
+ @rm -f Makefile ext/extmk.rb config.h
+ @rm -f ext/config.cache config.cache config.log config.status
+ @rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp
+ @rm -f $(PROGRAM) miniruby$(binsuffix)
+
+realclean: distclean
+ @rm -f parse.c
+ @rm -f lex.c
+
+test: miniruby$(binsuffix)
+ @./miniruby$(binsuffix) $(srcdir)/rubytest.rb
.c.obj:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
@@ -211,7 +196,6 @@ error.obj: error.c ruby.h config.h defines.h env.h
eval.obj: eval.c ruby.h config.h defines.h env.h node.h rubysig.h st.h dln.h
file.obj: file.c ruby.h config.h defines.h rubyio.h rubysig.h
gc.obj: gc.c ruby.h config.h defines.h env.h rubysig.h st.h node.h re.h regex.h
-glob.obj: glob.c config.h missing/fnmatch.h
hash.obj: hash.c ruby.h config.h defines.h st.h
inits.obj: inits.c ruby.h config.h defines.h
io.obj: io.c ruby.h config.h defines.h rubyio.h rubysig.h