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

matz - nakada win32 patch

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-08-03 09:50:41 +00:00
parent d65b573aea
commit 5222760bc4
12 changed files with 213 additions and 133 deletions

View file

@ -82,7 +82,7 @@ ext/Setup.dj
ext/Setup.emx
ext/Setup.x68
ext/aix_mksym.rb
ext/mswin32_extmk.rb
ext/configsub.rb
ext/extmk.rb.in
lib/English.rb
lib/Env.rb
@ -127,6 +127,7 @@ lib/mkmf.rb
lib/monitor.rb
lib/mutex_m.rb
lib/net/ftp.rb
lib/net/http.rb
lib/net/pop.rb
lib/net/protocol.rb
lib/net/smtp.rb
@ -231,13 +232,17 @@ sample/time.rb
sample/trojan.rb
sample/tsvr.rb
sample/uumerge.rb
win32/Makefile
win32/config.h
win32/config.status
win32/ntsetup.bat
win32/ruby.def
win32/Makefile.sub
win32/README.win32
win32/config.h.in
win32/config.status.in
win32/configure.bat
win32/mkexports.rb
win32/resource.rb
win32/setup.mak
win32/win32.c
win32/win32.h
win32/winmain.c
x68/fconvert.c
x68/select.c
x68/_dtos18.c

View file

@ -3,7 +3,7 @@ SHELL = /bin/sh
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@:@srcdir@/missing
VPATH = $(srcdir):$(srcdir)/missing
CC = @CC@
YACC = @YACC@
@ -13,7 +13,7 @@ AUTOCONF = autoconf
prefix = @prefix@
CFLAGS = @CFLAGS@
CPPFLAGS = -I. -I@srcdir@ -I@includedir@
CPPFLAGS = -I. -I$(srcdir) -I@includedir@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
XLDFLAGS = @XLDFLAGS@
EXTLIBS =
@ -148,7 +148,7 @@ $(srcdir)/configure: $(srcdir)/configure.in
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
lex.c: keywords
gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ @srcdir@/keywords > lex.c
gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $(srcdir)/keywords > lex.c
parse.c: parse.y
$(YACC) $<
@ -156,80 +156,80 @@ parse.c: parse.y
parse.@OBJEXT@: parse.c
alloca.@OBJEXT@: @srcdir@/missing/alloca.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/alloca.c
alloca.@OBJEXT@: $(srcdir)/missing/alloca.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/alloca.c
crypt.@OBJEXT@: @srcdir@/missing/crypt.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/crypt.c
crypt.@OBJEXT@: $(srcdir)/missing/crypt.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/crypt.c
dup2.@OBJEXT@: @srcdir@/missing/dup2.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/dup2.c
dup2.@OBJEXT@: $(srcdir)/missing/dup2.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/dup2.c
finite.@OBJEXT@: @srcdir@/missing/finite.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/finite.c
finite.@OBJEXT@: $(srcdir)/missing/finite.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/finite.c
flock.@OBJEXT@: @srcdir@/missing/flock.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/flock.c
flock.@OBJEXT@: $(srcdir)/missing/flock.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/flock.c
isinf.@OBJEXT@: @srcdir@/missing/isinf.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/isinf.c
isinf.@OBJEXT@: $(srcdir)/missing/isinf.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/isinf.c
isnan.@OBJEXT@: @srcdir@/missing/isnan.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/isnan.c
isnan.@OBJEXT@: $(srcdir)/missing/isnan.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/isnan.c
fnmatch.@OBJEXT@: @srcdir@/missing/fnmatch.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/fnmatch.c
fnmatch.@OBJEXT@: $(srcdir)/missing/fnmatch.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/fnmatch.c
memcmp.@OBJEXT@: @srcdir@/missing/memcmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memcmp.c
memcmp.@OBJEXT@: $(srcdir)/missing/memcmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/memcmp.c
memmove.@OBJEXT@: @srcdir@/missing/memmove.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memmove.c
memmove.@OBJEXT@: $(srcdir)/missing/memmove.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/memmove.c
mkdir.@OBJEXT@: @srcdir@/missing/mkdir.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/mkdir.c
mkdir.@OBJEXT@: $(srcdir)/missing/mkdir.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/mkdir.c
vsnprintf.@OBJEXT@: @srcdir@/missing/vsnprintf.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/vsnprintf.c
vsnprintf.@OBJEXT@: $(srcdir)/missing/vsnprintf.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/vsnprintf.c
strcasecmp.@OBJEXT@: @srcdir@/missing/strcasecmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strcasecmp.c
strcasecmp.@OBJEXT@: $(srcdir)/missing/strcasecmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strcasecmp.c
strncasecmp.@OBJEXT@: @srcdir@/missing/strncasecmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strncasecmp.c
strncasecmp.@OBJEXT@: $(srcdir)/missing/strncasecmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strncasecmp.c
strchr.@OBJEXT@: @srcdir@/missing/strchr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strchr.c
strchr.@OBJEXT@: $(srcdir)/missing/strchr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strchr.c
strerror.@OBJEXT@: @srcdir@/missing/strerror.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strerror.c
strerror.@OBJEXT@: $(srcdir)/missing/strerror.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strerror.c
strftime.@OBJEXT@: @srcdir@/missing/strftime.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strftime.c
strftime.@OBJEXT@: $(srcdir)/missing/strftime.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strftime.c
strstr.@OBJEXT@: @srcdir@/missing/strstr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strstr.c
strstr.@OBJEXT@: $(srcdir)/missing/strstr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strstr.c
strtod.@OBJEXT@: @srcdir@/missing/strtod.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtod.c
strtod.@OBJEXT@: $(srcdir)/missing/strtod.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtod.c
strtol.@OBJEXT@: @srcdir@/missing/strtol.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtol.c
strtol.@OBJEXT@: $(srcdir)/missing/strtol.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtol.c
strtoul.@OBJEXT@: @srcdir@/missing/strtoul.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtoul.c
strtoul.@OBJEXT@: $(srcdir)/missing/strtoul.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtoul.c
x68.@OBJEXT@: @srcdir@/missing/x68.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/x68.c
x68.@OBJEXT@: $(srcdir)/missing/x68.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/x68.c
os2.@OBJEXT@: @srcdir@/missing/os2.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/os2.c
os2.@OBJEXT@: $(srcdir)/missing/os2.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/os2.c
dl_os2.@OBJEXT@: @srcdir@/missing/dl_os2.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/dl_os2.c
dl_os2.@OBJEXT@: $(srcdir)/missing/dl_os2.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/dl_os2.c
win32.@OBJEXT@: @srcdir@/win32/win32.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/win32/win32.c
win32.@OBJEXT@: $(srcdir)/win32/win32.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/win32/win32.c
# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:

View file

@ -89,6 +89,7 @@ case "$target_os" in
AC_CHECK_TOOL(DLLWRAP, dllwrap)
AC_CHECK_TOOL(AS, as)
AC_CHECK_TOOL(DLLTOOL, dlltool)
AC_CHECK_TOOL(WINDRES, windres)
;;
esac
@ -878,13 +879,22 @@ test "$program_suffix" != NONE &&
ri_suffix=$program_suffix
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
RUBY_LIB_PREFIX="${prefix}/lib/ruby"
case "$target_os" in
cygwin*|mingw*|*djgpp*)
RUBY_LIB_PREFIX="/lib/ruby"
SITEDIR='/lib/ruby/site_ruby'
;;
*)
RUBY_LIB_PREFIX="${prefix}/lib/ruby"
SITEDIR='${prefix}/lib/ruby/site_ruby'
;;
esac
RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
sitedir='${prefix}/lib/ruby/site_ruby'
AC_ARG_WITH(sitedir,
[--with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
[sitedir=$withval])
RUBY_SITE_LIB_PATH=`eval "echo ${sitedir}"`
RUBY_SITE_LIB_PATH=`eval "echo ${SITEDIR}"`
RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}"
AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")

View file

@ -7,11 +7,34 @@ ifneq (,$(findstring no, $(ENABLE_SHARED)))
LIBRUBYARG = $(LIBRUBY_A)
endif
ifneq (,$(findstring ruby, $(RUBY_INSTALL_NAME)))
RUBYW_INSTALL_NAME = $(subst ruby,rubyw,$(RUBY_INSTALL_NAME))
else
RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME)w
endif
WPROGRAM = $(RUBYW_INSTALL_NAME)$(EXEEXT)
RUBYDEF = $(RUBY_INSTALL_NAME).def
SOLIBS := $(RUBY_INSTALL_NAME).dll.res.o $(SOLIBS)
EXTOBJS += $(@:$(EXEEXT)=.res.o)
$(LIBRUBY_SO): $(RUBYDEF)
$(LIBRUBY_SO): $(RUBYDEF) $(RUBY_INSTALL_NAME).dll.res.o
$(LIBRUBY): $(LIBRUBY_SO)
%.res.o: %.rc
@WINDRES@ --include-dir . --include-dir $(<D) --include-dir $(srcdir)/win32 $< $@
$(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_INSTALL_NAME).dll.rc: rbconfig.rb
@@MINIRUBY@ $(srcdir)/win32/resource.rb \
-ruby_name=$(RUBY_INSTALL_NAME) -rubyw_name=$(RUBYW_INSTALL_NAME) \
-so_name=$(RUBY_INSTALL_NAME).dll \
. $(icondirs) $(srcdir)/win32
$(PROGRAM): $(RUBY_INSTALL_NAME).res.o
$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.o
@rm -f $@
$(PURIFY) $(CC) -mwindows -e _mainCRTStartup $(LDFLAGS) $(XLDFLAGS) \
$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
$(RUBYDEF): $(LIBRUBY_A)
echo EXPORTS > $(RUBYDEF)
@NM@ --extern-only --defined-only $(LIBRUBY_A) | \

6
eval.c
View file

@ -8111,13 +8111,13 @@ rb_cont_call(argc, argv, cont)
rb_raise(rb_eRuntimeError, "continuation called across threads");
}
switch (argc) {
case 0:
case 0:
th->result = Qnil;
break;
case 1:
case 1:
th->result = *argv;
break;
default:
default:
th->result = rb_ary_new4(argc, argv);
break;
}

View file

@ -374,7 +374,8 @@ DESTDIR =
CC = @CC@
CFLAGS = %s -I$(topdir) -I$(hdrdir) #{CFLAGS} #$CFLAGS -I@includedir@ %s
CFLAGS = %s #{CFLAGS} #$CFLAGS
CPPFLAGS = -I$(topdir) -I$(hdrdir) -I@includedir@ %s
DLDFLAGS = #$DLDFLAGS #$LDFLAGS
LDSHARED = @LDSHARED@ #{defflag}
", if $static then "" else "@CCDLFLAGS@" end, $defs.join(" ")
@ -382,6 +383,7 @@ LDSHARED = @LDSHARED@ #{defflag}
mfile.printf "\
RUBY_INSTALL_NAME = @RUBY_INSTALL_NAME@
RUBY_SO_NAME = @RUBY_SO_NAME@
prefix = @prefix@
exec_prefix = @exec_prefix@
@ -455,6 +457,16 @@ EOS
install_rb(mfile, $srcdir)
mfile.printf "\n"
if /mswin32/ =~ RUBY_PLATFORM
mfile.puts "
.c.obj:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
{$(srcdir)}.c{}.obj:
$(CC) -I. -I$(<D) $(CFLAGS) $(CPPFLAGS) -c $(<:/=\\)
"
end
if $static
if "@AR@" =~ /^lib\b/i
mfile.printf "\
@ -490,6 +502,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
mfile.printf "%s", line.gsub('\$\(hdrdir\)/config.h', '$(topdir)/config.h')
end
dfile.close
@ -515,7 +528,7 @@ def extmake(target)
$local_flags = ""
if /mswin32/ =~ RUBY_PLATFORM
$LIBEXT = "lib"
$local_flags = "$(topdir)/rubymw.lib -link /EXPORT:Init_$(TARGET)"
$local_flags = "$(topdir)/$(RUBY_SO_NAME).lib -link /EXPORT:Init_$(TARGET)"
end
$LOCAL_LIBS = "" # to be assigned in extconf.rb
dir = with_config("opt-dir")
@ -536,7 +549,7 @@ def extmake(target)
$LDFLAGS = ldir || ""
begin
system "mkdir", target unless File.directory?(target)
Dir.mkdir target unless File.directory?(target)
Dir.chdir target
$target = target
$mdir = target

View file

@ -86,8 +86,8 @@ end
if RUBY_PLATFORM =~ /mswin32|mingw/
File.makedirs archlibdir + "/win32", true
File.install "win32/win32.h", archlibdir + "/win32", 0644, true
if File.exist? wdir+'/rubymw.lib'
File.install wdir+'/rubymw.lib', archlibdir, 0644, true
if File.exist? wdir+'/'+CONFIG["LIBRUBY"]
File.install wdir+'/'+CONFIG["LIBRUBY"], archlibdir, 0644, true
end
end
File.install wdir+'/'+CONFIG['LIBRUBY_A'], archlibdir, 0644, true

View file

@ -385,12 +385,14 @@ hdrdir = #{$hdrdir}
CC = #{CONFIG["CC"]}
CFLAGS = #{CONFIG["CCDLFLAGS"]} -I$(hdrdir) #{CFLAGS} #{$CFLAGS} -I#{CONFIG["includedir"]} #{$defs.join(" ")}
CFLAGS = #{CONFIG["CCDLFLAGS"]} #{CFLAGS} #{$CFLAGS}
CPPFLAGS = -I$(hdrdir) -I#{CONFIG["includedir"]} #{$defs.join(" ")}
CXXFLAGS = $(CFLAGS)
DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS}
LDSHARED = #{CONFIG["LDSHARED"]} #{defflag}
RUBY_INSTALL_NAME = #{CONFIG["RUBY_INSTALL_NAME"]}
RUBY_SO_NAME = #{CONFIG["RUBY_SO_NAME"]}
DESTDIR =
prefix = $(DESTDIR)#{CONFIG["prefix"]}
@ -444,11 +446,23 @@ EOMF
install_rb(mfile, "$(sitelibdir)")
mfile.printf "\n"
if /mswin32/ =~ RUBY_PLATFORM
mfile.print "
.c.obj:
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
{$(srcdir)}.c.obj:
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
"
end
if CONFIG["DLEXT"] != $OBJEXT
mfile.printf <<EOMF
$(DLLIB): $(OBJS)
$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
EOMF
mfile.print "$(DLLIB): $(OBJS)\n"
if /mswin32/ =~ RUBY_PLATFORM
mfile.print "\tset LIB=$(topdir:/=\\);$(LIB)\n"
end
mfile.print "\t$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n"
elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc")
mfile.print "$(DLLIB): $(OBJS)\n"
case RUBY_PLATFORM
@ -476,7 +490,7 @@ $libs = CONFIG["DLDLIBS"]
$local_flags = ""
case RUBY_PLATFORM
when /mswin32/
$local_flags = "rubymw.lib -link /LIBPATH:$(topdir) /EXPORT:Init_$(TARGET)"
$local_flags = "$(RUBY_SO_NAME).lib -link /EXPORT:Init_$(TARGET)"
end
$LOCAL_LIBS = ""
$defs = []

View file

@ -1,15 +1,16 @@
#!./miniruby
#!./miniruby -s
require File.dirname($0)+"/lib/ftools"
rbconfig_rb = ARGV[0] || 'rbconfig.rb'
srcdir = $srcdir if $srcdir
File.makedirs(File.dirname(rbconfig_rb), true)
version = VERSION
config = open(rbconfig_rb, "w")
$stdout.reopen(config)
fast = {'prefix'=>TRUE, 'INSTALL'=>TRUE, 'EXEEXT'=>TRUE}
fast = {'prefix'=>TRUE, 'ruby_install_name'=>TRUE, 'INSTALL'=>TRUE, 'EXEEXT'=>TRUE}
print %[
module Config
@ -23,16 +24,20 @@ module Config
print " DESTDIR = '' if not defined? DESTDIR\n CONFIG = {}\n"
v_fast = []
v_others = []
has_srcdir = false
has_version = false
File.foreach "config.status" do |$_|
next if /^#/
if /^s%@program_transform_name@%s,(.*)%g$/
next if $install_name
ptn = $1.sub(/\$\$/, '$').split(/,/) #'
v_fast << " CONFIG[\"ruby_install_name\"] = \"" + "ruby".sub(ptn[0],ptn[1]) + "\"\n"
elsif /^s%@(\w+)@%(.*)%g/
name = $1
val = $2 || ""
next if name =~ /^(INSTALL|DEFS|configure_input|srcdir|top_srcdir)$/
next if $install_name and name =~ /^RUBY_INSTALL_NAME$/
next if $so_name and name =~ /^RUBY_SO_NAME$/
v = " CONFIG[\"" + name + "\"] = " +
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?([^(){}]+)\}?/) {
"\#{CONFIG[\\\"#{$1}\\\"]}"
@ -58,12 +63,17 @@ File.foreach "config.status" do |$_|
end
elsif /^ac_given_srcdir=(.*)/
v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path($1) + "\"\n"
has_srcdir = true
elsif /^ac_given_INSTALL=(.*)/
v_fast << " CONFIG[\"INSTALL\"] = " + $1 + "\n"
end
# break if /^CEOF/
end
if not has_srcdir
v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path(srcdir) + "\"\n"
end
if not has_version
VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) {
print " CONFIG[\"MAJOR\"] = \"" + $1 + "\"\n"
@ -74,12 +84,22 @@ end
v_fast.collect! do |x|
if /"prefix"/ === x
x.sub(/= /, '= DESTDIR + ')
prefix = Regexp.quote('/lib/ruby/' + RUBY_VERSION.sub(/\.\d+$/, '') + '/' + RUBY_PLATFORM)
puts " TOPDIR = File.dirname(__FILE__).sub!(%r'#{prefix}\\Z', '')"
x.sub(/= (.*)/, '= (TOPDIR || DESTDIR + \1)')
else
x
end
end
if $install_name
v_fast << " CONFIG[\"ruby_install_name\"] = \"" + $install_name + "\"\n"
v_fast << " CONFIG[\"RUBY_INSTALL_NAME\"] = \"" + $install_name + "\"\n"
end
if $so_name
v_fast << " CONFIG[\"RUBY_SO_NAME\"] = \"" + $so_name + "\"\n"
end
print v_fast, v_others
print <<EOS
CONFIG["compile_dir"] = "#{Dir.pwd}"

View file

@ -71,7 +71,7 @@ void srand48 _((long));
#endif /* HAVE_RANDOM */
/* 0 <= RANDOM_NUMBER <= 1 */
/* 0 <= RANDOM_NUMBER < 1 */
#define RANDOM_NUMBER (((double)RANDOM())/((double)RANDOM_MAX+1))
#endif /* not HAVE_DRAND48 */

95
ruby.c
View file

@ -206,30 +206,64 @@ ruby_incpush(path)
void
ruby_init_loadpath()
{
#if defined(_WIN32) || defined(DJGPP)
char libpath[FILENAME_MAX+1];
char *p;
size_t rest;
#if defined(_WIN32)
GetModuleFileName(NULL, libpath, sizeof libpath);
#elif defined(DJGPP)
extern char *__dos_argv0;
strncpy(libpath, __dos_argv0, FILENAME_MAX);
#endif
p = strrchr(libpath, '\\');
if (p) {
*p = 0;
if (p-libpath > 3 && !strcasecmp(p-4, "\\bin")) {
p -= 4;
*p = 0;
}
} else {
strcpy(libpath, ".");
p = libpath + 1;
}
#if !defined(__CYGWIN32__)
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
#define CharNext(p) ((p) + 1)
#endif
for (p = libpath; *p; p = CharNext(p))
if (*p == '\\')
*p = '/';
#endif
rest = FILENAME_MAX - (p - libpath);
#define RUBY_RELATIVE(path) (strncpy(p, (path), rest), libpath)
#else
#define RUBY_RELATIVE(path) (path)
#endif
if (rb_safe_level() == 0) {
ruby_incpush(getenv("RUBYLIB"));
}
#ifdef RUBY_SEARCH_PATH
ruby_incpush(RUBY_SEARCH_PATH);
ruby_incpush(RUBY_RELATIVE(RUBY_SEARCH_PATH));
#endif
#ifdef RUBY_SITE_THIN_ARCHLIB
ruby_incpush(RUBY_SITE_THIN_ARCHLIB);
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_THIN_ARCHLIB));
#endif
ruby_incpush(RUBY_SITE_ARCHLIB);
ruby_incpush(RUBY_SITE_LIB2);
ruby_incpush(RUBY_SITE_LIB);
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_ARCHLIB));
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB2));
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB));
#ifdef RUBY_THIN_ARCHLIB
ruby_incpush(RUBY_THIN_ARCHLIB);
ruby_incpush(RUBY_RELATIVE(RUBY_THIN_ARCHLIB));
#endif
ruby_incpush(RUBY_ARCHLIB);
ruby_incpush(RUBY_RELATIVE(RUBY_ARCHLIB));
ruby_incpush(RUBY_LIB);
#if defined(_WIN32) || defined(DJGPP)
ruby_incpush(ruby_libpath());
#endif
ruby_incpush(RUBY_RELATIVE(RUBY_LIB));
if (rb_safe_level() == 0) {
ruby_incpush(".");
@ -904,45 +938,6 @@ forbid_setid(s)
rb_raise(rb_eSecurityError, "No %s allowed in tainted mode", s);
}
#if defined(_WIN32) || defined(DJGPP)
static char *
ruby_libpath()
{
static char libpath[FILENAME_MAX+1];
char *p;
#if defined(_WIN32)
GetModuleFileName(NULL, libpath, sizeof libpath);
#elif defined(DJGPP)
extern char *__dos_argv0;
strcpy(libpath, __dos_argv0);
#endif
p = strrchr(libpath, '\\');
if (p) {
*p = 0;
if (!strcasecmp(p-4, "\\bin"))
p -= 4;
} else {
strcpy(libpath, ".");
p = libpath + 1;
}
strcpy(p, "\\lib");
#if defined(__CYGWIN32__)
p = (char *)malloc(strlen(libpath)+10);
if (!p)
return 0;
cygwin32_conv_to_posix_path(libpath, p);
strcpy(libpath, p);
free(p);
#else
for (p = libpath; *p; p++)
if (*p == '\\')
*p = '/';
#endif
return libpath;
}
#endif
void
ruby_prog_init()
{

View file

@ -1,6 +1,6 @@
#! ./miniruby -I.
#! ./miniruby
require 'rbconfig'
load './rbconfig.rb'
include Config
unless File.exist? "./#{CONFIG['ruby_install_name']}#{CONFIG['EXEEXT']}"
@ -32,7 +32,7 @@ end
$stderr.reopen($stdout)
error = ''
`./#{CONFIG["ruby_install_name"]} #{CONFIG["srcdir"]}/sample/test.rb`.each do |line|
`./#{CONFIG["ruby_install_name"]}#{CONFIG["EXEEXT"]} #{CONFIG["srcdir"]}/sample/test.rb`.each do |line|
if line =~ /^end of test/
print "test succeeded\n"
exit 0