* gc.c (Init_stack): stack region is far smaller than usual if

pthread is used.

* marshal.c (w_extended): singleton methods should not be checked
  when dumping via marshal_dump() or _dump(). [ruby-talk:85909]

* file.c (getcwdofdrv): avoid using getcwd() directly, use
  my_getcwd() instead.

* merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
  <sunshine@sunshineco.com>.  [ruby-core:01596]

* marshal.c (w_object): LINK check earlier than anything else,
  i.e. do not dump TYPE_IVAR for already dumped objects.
  (ruby-bugs PR#1220)

* eval.c (rb_eval): call "inherited" only when a new class is
  generated; not on reopening.

* eval.c (eval): prepend error position in evaluating string to

* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
  had become unbuildable; enhanced --enable-fat-binary option so that
  it accepts a list of desired architectures (rather than assuming a
  fixed list), or defaults to a platform-appropriate list if user does
  not provide an explicit list; made the default list of architectures
  for MAB (fat binary) more comprehensive; now uses -fno-common even
  when building the interpreter (in addition to using it for
  extensions), thus allowing the interpreter to be embedded into a
  plugin module of an external project (in addition to allowing
  embedding directly into an application); added checks for
  <netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
  ensures that -I/usr/local/include is employed when extensions'
  extconf.rb scripts invoke have_header() since extension checks on
  NextStep and OpenStep will fail without it if the desired resource
  resides in the /usr/local tree; fixed formatting of --help message.

* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
  invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
  (see configure's --enable-fat-binary option); added rule for new
  missing/getcwd.c.

* defines.h: fixed endian handling during MAB build (see configure's
  --enable-fat-binary option) to ensure that all portions of the
  project see the correct WORDS_BIGENDIAN value (some extension modules
  were getting the wrong endian setting); added missing constants
  GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
  and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
  define in NeXT section.

* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
  NextStep since, on some installations, this value always resolves
  uselessly to zero.

* dln.c: added error reporting to NextStep extension loader since the
  previous behavior of failing silently was not useful; now ensures
  that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
  for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
  on Rhapsody since this header lacks multiple-include protection,
  which resulted in "redefinition" compilation errors.

* main.c: also create hard reference to objc_msgSend() on NeXT
  platforms (in addition to Apple platforms).

* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
  makefiles so that extensions can be built MAB (see configure's
  --enable-fat-binary option); also utilize XCFLAGS in cc_command()
  (but not cpp_command() because MAB flags are incompatible with
  direct invocation of `cpp').

* ext/curses/extconf.rb: now additionally checks for presence of these
  curses functions which are not present on NextStep or Openstep:
  bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
  setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
  wscrl(), wsetscrreg()

* ext/curses/curses.c: added appropriate #ifdef's for additional set of
  curses functions now checked by extconf.rb; fixed curses_bkgd() and
  window_bkgd() to correctly return boolean result rather than numeric
  result; fixed window_getbkgd() to correctly signal an error by
  returning nil rather than -1.

* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
  pointers before invoking rb_tainted_str_new2() upon fields extracted
  from `struct passwd' and `struct group' since null pointers in some
  fields are common on NextStep/OpenStep (especially so for the
  `pw_comment' field) and rb_tainted_str_new2() throws an exception
  when it receives a null pointer.

* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
  platforms such as NextStep and OpenStep which lack strdup().

* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
  gethostbyaddr(), and gethostbyname() from (const char*) to non-const
  (char*) for older platforms such as NextStep and OpenStep.

* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
  platforms such as NextStep and OpenStep which lack strdup(); include
  <netinet/in_systm.h> if present for NextStep and OpenStep; cast first
  argument of gethostbyaddr() and getservbyname() from (const char*) to
  non-const (char*) for older platforms.

* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
  platforms such as NextStep and OpenStep which lack strdup().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-11-22 04:00:03 +00:00
parent 0125719694
commit 6212cfb9c5
28 changed files with 457 additions and 135 deletions

111
ChangeLog
View File

@ -1,3 +1,8 @@
Sat Nov 22 11:28:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (Init_stack): stack region is far smaller than usual if
pthread is used.
Sat Nov 22 07:30:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org> Sat Nov 22 07:30:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
* lib/test/unit/util/backtracefilter.rb: fixed a bug that occurred * lib/test/unit/util/backtracefilter.rb: fixed a bug that occurred
@ -20,6 +25,11 @@ Fri Nov 21 14:49:42 2003 Minero Aoki <aamine@loveruby.net>
* ruby.1: wrote about ruby related environment variables. * ruby.1: wrote about ruby related environment variables.
Fri Nov 21 12:28:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* marshal.c (w_extended): singleton methods should not be checked
when dumping via marshal_dump() or _dump(). [ruby-talk:85909]
Fri Nov 21 01:40:00 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> Fri Nov 21 01:40:00 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* configure.in: check <pthread.h> * configure.in: check <pthread.h>
@ -154,6 +164,14 @@ Tue Nov 18 14:06:35 2003 Minero Aoki <aamine@loveruby.net>
* test/fileutils/fileasserts.rb: assert_is_directory -> assert_directory. * test/fileutils/fileasserts.rb: assert_is_directory -> assert_directory.
Mon Nov 17 19:38:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* file.c (getcwdofdrv): avoid using getcwd() directly, use
my_getcwd() instead.
* merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
<sunshine@sunshineco.com>. [ruby-core:01596]
Mon Nov 17 10:50:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> Mon Nov 17 10:50:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/optparse.rb (OptionParser::Completion::complete): allow least * lib/optparse.rb (OptionParser::Completion::complete): allow least
@ -176,6 +194,13 @@ Sun Nov 16 18:10:57 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
Sun Nov 16 13:26:07 2003 Yukihiro Matsumoto <matz@ruby-lang.org> Sun Nov 16 13:26:07 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* marshal.c (w_object): LINK check earlier than anything else,
i.e. do not dump TYPE_IVAR for already dumped objects.
(ruby-bugs PR#1220)
* eval.c (rb_eval): call "inherited" only when a new class is
generated; not on reopening.
* eval.c (eval): prepend error position in evaluating string to * eval.c (eval): prepend error position in evaluating string to
"mesg" attribute string only when it's available and is a "mesg" attribute string only when it's available and is a
string. string.
@ -2233,6 +2258,92 @@ Wed Sep 10 22:41:54 2003 Tietew <tietew@tietew.net>
* eval.c (win32_get_exception_list): avoid VC7 warning. * eval.c (win32_get_exception_list): avoid VC7 warning.
[ruby-win32:577] [ruby-win32:577]
Thu Oct 9 12:05:46 2003 Eric Sunshine <sunshine@sunshineco.com>
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
Tue Sep 9 10:39:51 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Sep 9 10:39:51 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (struct tag): dst should be VALUE. * eval.c (struct tag): dst should be VALUE.

View File

@ -121,7 +121,11 @@ $(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) $(SETUP) miniruby$(EXEEXT)
@rm -f $@ @rm -f $@
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@ $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
# We must `rm' the library each time this rule is invoked because "updating" a
# MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
# supported.
$(LIBRUBY_A): $(OBJS) $(DMYEXT) $(LIBRUBY_A): $(OBJS) $(DMYEXT)
@rm -f $@
@AR@ rcu $@ $(OBJS) $(DMYEXT) @AR@ rcu $@ $(OBJS) $(DMYEXT)
@-@RANLIB@ $@ 2> /dev/null || true @-@RANLIB@ $@ 2> /dev/null || true

View File

@ -74,48 +74,57 @@ fi
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
dnl checks for fat-binary dnl checks for fat-binary
fat_binary=no
AC_ARG_ENABLE(fat-binary, AC_ARG_ENABLE(fat-binary,
[ --enable-fat-binary build a NeXT/Apple Multi Architecture Binary. ], [ --enable-fat-binary=ARCHS
[fat_binary=$enableval]) build an Apple/NeXT Multi Architecture Binary (MAB);
if test "$fat_binary" = yes ; then ARCHS is a comma-delimited list of architectures for
which to build; if ARCHS is omitted, then the package
will be built for all architectures supported by the
platform ("ppc" for MacOS/X and Darwin; "ppc,i386"
for Rhapsody; "m68k,i386,sparc" for OpenStep;
"m68k,i386,sparc,hppa" for NextStep); if this option
is disabled or omitted entirely, then the package
will be built only for the target platform],
[fat_binary=$enableval], [fat_binary=no])
if test "$fat_binary" != no; then
AC_MSG_CHECKING(target architecture) AC_MSG_CHECKING([target architectures])
# Respect TARGET_ARCHS setting from environment if available.
if test -z "$TARGET_ARCHS"; then
# Respect ARCH given to --enable-fat-binary if present.
if test "$fat_binary" != yes; then
TARGET_ARCHS=`echo "$fat_binary" | tr ',' ' '`
else
# Choose a default set of architectures based upon platform.
case "$target_os" in
darwin*)
TARGET_ARCHS="ppc"
;;
rhapsody*)
TARGET_ARCHS="ppc i386"
;;
openstep*)
TARGET_ARCHS="m68k i386 sparc"
;;
nextstep*)
TARGET_ARCHS="m68k i386 sparc hppa"
;;
*)
TARGET_ARCHS=`arch`
esac
fi
fi
AC_MSG_RESULT([$TARGET_ARCHS])
case "$target_os" in
rhapsody*)
echo -n "MacOS X Server: "
if test "$TARGET_ARCHS" = "" ; then
TARGET_ARCHS="ppc i386"
fi
;;
nextstep*|openstep*)
echo -n "NeXTSTEP/OPENSTEP: "
if test "$TARGET_ARCHS" = "" ; then
if test `/usr/bin/arch` = "m68k" ; then
TARGET_ARCHS="m68k i486"
else # Black and Native one
TARGET_ARCHS="m68k `/usr/bin/arch`"
fi
fi
# to ensure AC_HEADER_SYS_WAIT works
AC_DEFINE(_POSIX_SOURCE)
;;
macos*|darwin*)
echo -n "MacOS X (Darwin): "
if test "$TARGET_ARCHS" = "" ; then
TARGET_ARCHS="ppc i386"
fi
;;
esac
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS # /usr/lib/arch_tool -archify_list $TARGET_ARCHS
ARCH_FLAG=
for archs in $TARGET_ARCHS for archs in $TARGET_ARCHS
do do
ARCH_FLAG="$ARCH_FLAG -arch $archs " ARCH_FLAG="$ARCH_FLAG -arch $archs"
echo -n " $archs"
done done
AC_DEFINE(NEXT_FAT_BINARY) AC_DEFINE(NEXT_FAT_BINARY)
echo "."
fi fi
case $target_cpu in case $target_cpu in
@ -350,7 +359,7 @@ AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\ AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\ fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \ syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \
sys/mkdev.h sys/utime.h float.h pthread.h) sys/mkdev.h sys/utime.h netinet/in_systm.h float.h pthread.h)
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T AC_TYPE_UID_T
@ -367,7 +376,7 @@ AC_FUNC_MEMCMP
AC_FUNC_FSEEKO AC_FUNC_FSEEKO
AC_CHECK_FUNCS(ftello) AC_CHECK_FUNCS(ftello)
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\ AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\ strchr strstr strtoul getcwd crypt flock vsnprintf\
isinf isnan finite hypot acosh erf) isinf isnan finite hypot acosh erf)
AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync\ AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync\
truncate chsize times utimes fcntl lockf lstat symlink readlink\ truncate chsize times utimes fcntl lockf lstat symlink readlink\
@ -735,9 +744,6 @@ AC_ARG_WITH(dln-a-out,
*) with_dln_a_out=no;; *) with_dln_a_out=no;;
esac], [with_dln_a_out=no]) esac], [with_dln_a_out=no])
AC_SUBST(XCFLAGS)dnl
AC_SUBST(XLDFLAGS)dnl
AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf, AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
[AC_TRY_RUN([ [AC_TRY_RUN([
/* Test for whether ELF binaries are produced */ /* Test for whether ELF binaries are produced */
@ -801,9 +807,9 @@ if test "$with_dln_a_out" != yes; then
AC_MSG_CHECKING(whether OS depend dynamic link works) AC_MSG_CHECKING(whether OS depend dynamic link works)
if test "$GCC" = yes; then if test "$GCC" = yes; then
case "$target_os" in case "$target_os" in
nextstep*) ;; nextstep*) CCDLFLAGS=-fno-common;;
openstep*) ;; openstep*) CCDLFLAGS=-fno-common;;
rhapsody*) ;; rhapsody*) CCDLFLAGS=-fno-common;;
darwin*) CCDLFLAGS=-fno-common;; darwin*) CCDLFLAGS=-fno-common;;
human*) ;; human*) ;;
bsdi*) ;; bsdi*) ;;
@ -1094,7 +1100,7 @@ if test "$prefix" = NONE; then
prefix=$ac_default_prefix prefix=$ac_default_prefix
fi fi
if test "$fat_binary" = yes ; then if test "$fat_binary" != no ; then
XCFLAGS="$ARCH_FLAG" XCFLAGS="$ARCH_FLAG"
fi fi
@ -1225,17 +1231,22 @@ case "$target_os" in
netbsd*) netbsd*)
CFLAGS="$CFLAGS -pipe" CFLAGS="$CFLAGS -pipe"
;; ;;
nextstep*) nextstep*|openstep*)
CFLAGS="$CFLAGS -pipe" # The -fno-common is needed if we wish to embed the Ruby interpreter
;; # into a plugin module of some project (as opposed to embedding it
openstep*) # within the project's application). The -I/usr/local/include is
CFLAGS="$CFLAGS -pipe" # needed because CPP as discovered by configure (cc -E -traditional)
# fails to consult /usr/local/include by default. This causes
# mkmf.rb's have_header() to fail if the desired resource happens to be
# installed in the /usr/local tree.
CFLAGS="$CFLAGS -pipe -fno-common"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
;; ;;
rhapsody*) rhapsody*)
CFLAGS="$CFLAGS -pipe -no-precomp" CFLAGS="$CFLAGS -pipe -no-precomp -fno-common"
;; ;;
darwin*) darwin*)
CFLAGS="$CFLAGS -pipe" CFLAGS="$CFLAGS -pipe -fno-common"
;; ;;
os2-emx) os2-emx)
CFLAGS="$CFLAGS -DOS2 -Zmts" CFLAGS="$CFLAGS -DOS2 -Zmts"
@ -1314,6 +1325,8 @@ case "$build_os" in
*msdosdjgpp*) FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in;; *msdosdjgpp*) FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in;;
esac esac
AC_SUBST(XCFLAGS)dnl
AC_SUBST(XLDFLAGS)dnl
AC_SUBST(LIBRUBY_LDSHARED) AC_SUBST(LIBRUBY_LDSHARED)
AC_SUBST(LIBRUBY_DLDFLAGS) AC_SUBST(LIBRUBY_DLDFLAGS)
AC_SUBST(RUBY_INSTALL_NAME) AC_SUBST(RUBY_INSTALL_NAME)
@ -1390,7 +1403,7 @@ AC_SUBST(sitedir)dnl
configure_args=$ac_configure_args configure_args=$ac_configure_args
AC_SUBST(configure_args)dnl AC_SUBST(configure_args)dnl
if test "$fat_binary" = yes ; then if test "$fat_binary" != no ; then
arch="fat-${target_os}" arch="fat-${target_os}"
AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB, AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,

View File

@ -98,15 +98,23 @@ void xfree _((void*));
#endif #endif
#endif #endif
#ifdef NeXT #ifdef __NeXT__
#define DYNAMIC_ENDIAN /* determine endian at runtime */
#ifndef __APPLE__
#define S_IXUSR _S_IXUSR /* execute/search permission, owner */
#endif
#define S_IXGRP 0000010 /* execute/search permission, group */ #define S_IXGRP 0000010 /* execute/search permission, group */
#define S_IXOTH 0000001 /* execute/search permission, other */ #define S_IXOTH 0000001 /* execute/search permission, other */
#ifndef __APPLE__
#define HAVE_SYS_WAIT_H /* configure fails to find this */ #define S_IXUSR _S_IXUSR /* execute/search permission, owner */
#define GETPGRP_VOID 1
#define WNOHANG 01
#define WUNTRACED 02
#define X_OK 1
typedef int pid_t;
/* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may
result in a different endian. */
#undef WORDS_BIGENDIAN
#ifdef __BIG_ENDIAN__
#define WORDS_BIGENDIAN
#endif
#endif
#endif /* NeXT */ #endif /* NeXT */
#ifdef __CYGWIN__ #ifdef __CYGWIN__

7
dir.c
View File

@ -29,7 +29,12 @@
# define NAMLEN(dirent) strlen((dirent)->d_name) # define NAMLEN(dirent) strlen((dirent)->d_name)
#else #else
# define dirent direct # define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen # if !defined __NeXT__
# define NAMLEN(dirent) (dirent)->d_namlen
# else
# /* On some versions of NextStep, d_namlen is always zero, so avoid it. */
# define NAMLEN(dirent) strlen((dirent)->d_name)
# endif
# if HAVE_SYS_NDIR_H # if HAVE_SYS_NDIR_H
# include <sys/ndir.h> # include <sys/ndir.h>
# endif # endif

26
dln.c
View File

@ -1139,12 +1139,15 @@ dln_sym(name)
#include <mach-o/rld.h> #include <mach-o/rld.h>
#else #else
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#ifndef NSLINKMODULE_OPTION_BINDNOW
#define NSLINKMODULE_OPTION_BINDNOW 1
#endif #endif
#endif #endif
#else
#ifdef __APPLE__ #ifdef __APPLE__
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#endif #endif
#endif
#if defined _WIN32 && !defined __CYGWIN__ #if defined _WIN32 && !defined __CYGWIN__
#include <windows.h> #include <windows.h>
@ -1389,30 +1392,41 @@ dln_load(file)
Special Thanks... Special Thanks...
Yu tomoak-i@is.aist-nara.ac.jp, Yu tomoak-i@is.aist-nara.ac.jp,
Mi hisho@tasihara.nest.or.jp, Mi hisho@tasihara.nest.or.jp,
sunshine@sunshineco.com,
and... Miss ARAI Akino(^^;) and... Miss ARAI Akino(^^;)
----------------------------------------------------*/ ----------------------------------------------------*/
#if defined(NeXT) && (NS_TARGET_MAJOR < 4)/* NeXTSTEP rld functions */ #if defined(NeXT) && (NS_TARGET_MAJOR < 4)/* NeXTSTEP rld functions */
{ {
NXStream* s;
unsigned long init_address; unsigned long init_address;
char *object_files[2] = {NULL, NULL}; char *object_files[2] = {NULL, NULL};
void (*init_fct)(); void (*init_fct)();
object_files[0] = file; object_files[0] = (char*)file;
s = NXOpenFile(2,NX_WRITEONLY);
/* Load object file, if return value ==0 , load failed*/ /* Load object file, if return value ==0 , load failed*/
if(rld_load(NULL, NULL, object_files, NULL) == 0) { if(rld_load(s, NULL, object_files, NULL) == 0) {
NXFlush(s);
NXClose(s);
rb_loaderror("Failed to load %.200s", file); rb_loaderror("Failed to load %.200s", file);
} }
/* lookup the initial function */ /* lookup the initial function */
if(rld_lookup(NULL, buf, &init_address) == 0) { if(rld_lookup(s, buf, &init_address) == 0) {
NXFlush(s);
NXClose(s);
rb_loaderror("Failed to lookup Init function %.200s", file); rb_loaderror("Failed to lookup Init function %.200s", file);
} }
/* Cannot call *init_address directory, so copy this value to NXFlush(s);
funtion pointer */ NXClose(s);
/* Cannot call *init_address directory, so copy this value to
funtion pointer */
init_fct = (void(*)())init_address; init_fct = (void(*)())init_address;
(*init_fct)(); (*init_fct)();
return (void*)init_address; return (void*)init_address;

11
error.c
View File

@ -363,6 +363,13 @@ exc_to_s(exc)
return mesg; return mesg;
} }
static VALUE
exc_to_str(exc)
VALUE exc;
{
return rb_funcall(exc, rb_intern("to_s"), 0, 0);
}
static VALUE static VALUE
exc_inspect(exc) exc_inspect(exc)
VALUE exc; VALUE exc;
@ -645,8 +652,8 @@ Init_Exception()
rb_define_method(rb_eException, "exception", exc_exception, -1); rb_define_method(rb_eException, "exception", exc_exception, -1);
rb_define_method(rb_eException, "initialize", exc_initialize, -1); rb_define_method(rb_eException, "initialize", exc_initialize, -1);
rb_define_method(rb_eException, "to_s", exc_to_s, 0); rb_define_method(rb_eException, "to_s", exc_to_s, 0);
rb_define_method(rb_eException, "to_str", exc_to_s, 0); rb_define_method(rb_eException, "to_str", exc_to_str, 0);
rb_define_method(rb_eException, "message", exc_to_s, 0); rb_define_method(rb_eException, "message", exc_to_str, 0);
rb_define_method(rb_eException, "inspect", exc_inspect, 0); rb_define_method(rb_eException, "inspect", exc_inspect, 0);
rb_define_method(rb_eException, "backtrace", exc_backtrace, 0); rb_define_method(rb_eException, "backtrace", exc_backtrace, 0);
rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1); rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);

10
eval.c
View File

@ -3589,6 +3589,7 @@ rb_eval(self, n)
{ {
VALUE super, klass, tmp, cbase; VALUE super, klass, tmp, cbase;
ID cname; ID cname;
int gen = Qfalse;
if (NIL_P(ruby_cbase)) { if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no outer class/module"); rb_raise(rb_eTypeError, "no outer class/module");
@ -3625,12 +3626,15 @@ rb_eval(self, n)
klass = rb_define_class_id(cname, super); klass = rb_define_class_id(cname, super);
rb_set_class_path(klass, cbase, rb_id2name(cname)); rb_set_class_path(klass, cbase, rb_id2name(cname));
rb_const_set(cbase, cname, klass); rb_const_set(cbase, cname, klass);
gen = Qtrue;
} }
if (ruby_wrapper) { if (ruby_wrapper) {
rb_extend_object(klass, ruby_wrapper); rb_extend_object(klass, ruby_wrapper);
rb_include_module(klass, ruby_wrapper); rb_include_module(klass, ruby_wrapper);
} }
if (super) rb_class_inherited(super, klass); if (super && gen) {
rb_class_inherited(super, klass);
}
result = module_setup(klass, node); result = module_setup(klass, node);
} }
break; break;
@ -5596,12 +5600,12 @@ eval(self, src, scope, file, line)
if (strcmp(file, "(eval)") == 0) { if (strcmp(file, "(eval)") == 0) {
VALUE mesg, errat; VALUE mesg, errat;
errat = get_backtrace(ruby_errinfo);
mesg = rb_attr_get(ruby_errinfo, rb_intern("mesg")); mesg = rb_attr_get(ruby_errinfo, rb_intern("mesg"));
if (!NIL_P(mesg) && TYPE(mesg) == T_STRING) { if (!NIL_P(mesg) && TYPE(mesg) == T_STRING) {
errat = get_backtrace(ruby_errinfo);
rb_str_update(mesg, 0, 0, RARRAY(errat)->ptr[0]); rb_str_update(mesg, 0, 0, RARRAY(errat)->ptr[0]);
RARRAY(errat)->ptr[0] = RARRAY(backtrace(-2))->ptr[0];
} }
RARRAY(errat)->ptr[0] = RARRAY(backtrace(-2))->ptr[0];
} }
rb_exc_raise(ruby_errinfo); rb_exc_raise(ruby_errinfo);
} }

View File

@ -477,22 +477,34 @@ curses_cols()
static VALUE static VALUE
curses_curs_set(VALUE obj, VALUE visibility) curses_curs_set(VALUE obj, VALUE visibility)
{ {
#ifdef HAVE_CURS_SET
int n; int n;
return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil; return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil;
#else
return Qnil;
#endif
} }
static VALUE static VALUE
curses_scrl(VALUE obj, VALUE n) curses_scrl(VALUE obj, VALUE n)
{ {
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
#ifdef HAVE_SCRL
return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse; return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
} }
static VALUE static VALUE
curses_setscrreg(VALUE obj, VALUE top, VALUE bottom) curses_setscrreg(VALUE obj, VALUE top, VALUE bottom)
{ {
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
#ifdef HAVE_SETSCRREG
return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse; return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
} }
static VALUE static VALUE
@ -519,14 +531,20 @@ curses_attrset(VALUE obj, VALUE attrs)
static VALUE static VALUE
curses_bkgdset(VALUE obj, VALUE ch) curses_bkgdset(VALUE obj, VALUE ch)
{ {
#ifdef HAVE_BKGDSET
bkgdset(NUM2CHR(ch)); bkgdset(NUM2CHR(ch));
#endif
return Qnil; return Qnil;
} }
static VALUE static VALUE
curses_bkgd(VALUE obj, VALUE ch) curses_bkgd(VALUE obj, VALUE ch)
{ {
return CHR2FIX(bkgd(NUM2CHR(ch))); #ifdef HAVE_BKGD
return (bkgd(NUM2CHR(ch)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
} }
static VALUE static VALUE
@ -679,6 +697,37 @@ DEFINE_MOUSE_GET_MEMBER(curs_mouse_bstate, bstate)
#undef define_curs_mouse_member #undef define_curs_mouse_member
#endif /* USE_MOUSE */ #endif /* USE_MOUSE */
static VALUE
curses_timeout(VALUE obj, VALUE delay)
{
#ifdef HAVE_TIMEOUT
timeout(NUM2INT(delay));
return Qnil;
#else
rb_notimplement();
#endif
}
static VALUE
curses_def_prog_mode(VALUE obj)
{
#ifdef HAVE_DEF_PROG_MODE
return def_prog_mode() == OK ? Qtrue : Qfalse;
#else
rb_notimplement();
#endif
}
static VALUE
curses_reset_prog_mode(VALUE obj)
{
#ifdef HAVE_RESET_PROG_MODE
return reset_prog_mode() == OK ? Qtrue : Qfalse;
#else
rb_notimplement();
#endif
}
/*-------------------------- class Window --------------------------*/ /*-------------------------- class Window --------------------------*/
/* def self.allocate */ /* def self.allocate */
@ -1125,6 +1174,7 @@ window_idlok(VALUE obj, VALUE bf)
static VALUE static VALUE
window_setscrreg(VALUE obj, VALUE top, VALUE bottom) window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
{ {
#ifdef HAVE_WSETSCRREG
struct windata *winp; struct windata *winp;
int res; int res;
@ -1132,6 +1182,9 @@ window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
res = wsetscrreg(winp->window, NUM2INT(top), NUM2INT(bottom)); res = wsetscrreg(winp->window, NUM2INT(top), NUM2INT(bottom));
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (res == OK) ? Qtrue : Qfalse; return (res == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
} }
static VALUE static VALUE
@ -1147,25 +1200,34 @@ window_scroll(VALUE obj)
static VALUE static VALUE
window_scrl(VALUE obj, VALUE n) window_scrl(VALUE obj, VALUE n)
{ {
#ifdef HAVE_WSCRL
struct windata *winp; struct windata *winp;
GetWINDOW(obj, winp); GetWINDOW(obj, winp);
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (wscrl(winp->window,NUM2INT(n)) == OK) ? Qtrue : Qfalse; return (wscrl(winp->window,NUM2INT(n)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
} }
static VALUE static VALUE
window_attroff(VALUE obj, VALUE attrs) window_attroff(VALUE obj, VALUE attrs)
{ {
#ifdef HAVE_WATTROFF
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return INT2FIX(wattroff(winp->window,NUM2INT(attrs))); return INT2FIX(wattroff(winp->window,NUM2INT(attrs)));
#else
return Qtrue;
#endif
} }
static VALUE static VALUE
window_attron(VALUE obj, VALUE attrs) window_attron(VALUE obj, VALUE attrs)
{ {
#ifdef HAVE_WATTRON
struct windata *winp; struct windata *winp;
VALUE val; VALUE val;
@ -1179,43 +1241,61 @@ window_attron(VALUE obj, VALUE attrs)
else{ else{
return val; return val;
} }
#else
return Qtrue;
#endif
} }
static VALUE static VALUE
window_attrset(VALUE obj, VALUE attrs) window_attrset(VALUE obj, VALUE attrs)
{ {
#ifdef HAVE_WATTRSET
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return INT2FIX(wattrset(winp->window,NUM2INT(attrs))); return INT2FIX(wattrset(winp->window,NUM2INT(attrs)));
#else
return Qtrue;
#endif
} }
static VALUE static VALUE
window_bkgdset(VALUE obj, VALUE ch) window_bkgdset(VALUE obj, VALUE ch)
{ {
#ifdef HAVE_WBKGDSET
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
wbkgdset(winp->window, NUM2CHR(ch)); wbkgdset(winp->window, NUM2CHR(ch));
#endif
return Qnil; return Qnil;
} }
static VALUE static VALUE
window_bkgd(VALUE obj, VALUE ch) window_bkgd(VALUE obj, VALUE ch)
{ {
#ifdef HAVE_WBKGD
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return CHR2FIX(wbkgd(winp->window, NUM2CHR(ch))); return (wbkgd(winp->window, NUM2CHR(ch)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
} }
static VALUE static VALUE
window_getbkgd(VALUE obj) window_getbkgd(VALUE obj)
{ {
#ifdef HAVE_WGETBKGD
char c;
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return CHR2FIX(getbkgd(winp->window)); return (c = getbkgd(winp->window) != ERR) ? CHR2FIX(c) : Qnil;
#else
return Qnil;
#endif
} }
static VALUE static VALUE
@ -1232,10 +1312,10 @@ window_resize(VALUE obj, VALUE lin, VALUE col)
} }
#ifdef HAVE_KEYPAD
static VALUE static VALUE
window_keypad(VALUE obj, VALUE val) window_keypad(VALUE obj, VALUE val)
{ {
#ifdef HAVE_KEYPAD
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
@ -1248,8 +1328,37 @@ window_keypad(VALUE obj, VALUE val)
return (keypad(winp->window,RTEST(val) ? TRUE : FALSE)) == OK ? return (keypad(winp->window,RTEST(val) ? TRUE : FALSE)) == OK ?
Qtrue : Qfalse; Qtrue : Qfalse;
#endif #endif
} #else
rb_notimplement();
#endif /* HAVE_KEYPAD */ #endif /* HAVE_KEYPAD */
}
static VALUE
window_nodelay(VALUE obj, VALUE val)
{
#ifdef HAVE_NODELAY
struct windata *winp;
GetWINDOW(obj,winp);
return nodelay(winp->window,RTEST(val) ? TRUE : FALSE) == OK ? Qtrue : Qfalse;
#else
rb_notimplement();
#endif
}
static VALUE
window_timeout(VALUE obj, VALUE delay)
{
#ifdef HAVE_WTIMEOUT
struct windata *winp;
GetWINDOW(obj,winp);
wtimeout(winp->window,NUM2INT(delay));
return Qnil;
#else
rb_notimplement();
#endif
}
/*------------------------- Initialization -------------------------*/ /*------------------------- Initialization -------------------------*/
void void
@ -1333,6 +1442,10 @@ Init_curses()
rb_define_module_function(mCurses, "mousemask", curses_mousemask, 1); rb_define_module_function(mCurses, "mousemask", curses_mousemask, 1);
#endif /* USE_MOUSE */ #endif /* USE_MOUSE */
rb_define_module_function(mCurses, "timeout=", curses_timeout, 1);
rb_define_module_function(mCurses, "def_prog_mode", curses_def_prog_mode, 0);
rb_define_module_function(mCurses, "reset_prog_mode", curses_reset_prog_mode, 0);
cWindow = rb_define_class_under(mCurses, "Window", rb_cData); cWindow = rb_define_class_under(mCurses, "Window", rb_cData);
rb_define_alloc_func(cWindow, window_s_allocate); rb_define_alloc_func(cWindow, window_s_allocate);
rb_define_method(cWindow, "initialize", window_initialize, 4); rb_define_method(cWindow, "initialize", window_initialize, 4);
@ -1367,10 +1480,9 @@ Init_curses()
rb_define_method(cWindow, "setscrreg", window_setscrreg, 2); rb_define_method(cWindow, "setscrreg", window_setscrreg, 2);
rb_define_method(cWindow, "scrl", window_scrl, 1); rb_define_method(cWindow, "scrl", window_scrl, 1);
rb_define_method(cWindow, "resize", window_resize, 2); rb_define_method(cWindow, "resize", window_resize, 2);
#ifdef HAVE_KEYPAD
rb_define_method(cWindow, "keypad", window_keypad, 1); rb_define_method(cWindow, "keypad", window_keypad, 1);
rb_define_method(cWindow, "keypad=", window_keypad, 1); rb_define_method(cWindow, "keypad=", window_keypad, 1);
#endif
#ifdef USE_COLOR #ifdef USE_COLOR
rb_define_method(cWindow, "attroff", window_attroff, 1); rb_define_method(cWindow, "attroff", window_attroff, 1);
rb_define_method(cWindow, "attron", window_attron, 1); rb_define_method(cWindow, "attron", window_attron, 1);
@ -1380,6 +1492,8 @@ Init_curses()
rb_define_method(cWindow, "getbkgd", window_getbkgd, 0); rb_define_method(cWindow, "getbkgd", window_getbkgd, 0);
#endif /* USE_COLOR */ #endif /* USE_COLOR */
rb_define_method(cWindow, "nodelay=", window_nodelay, 1);
rb_define_method(cWindow, "timeout=", window_timeout, 1);
#define rb_curses_define_const(c) rb_define_const(mCurses,#c,UINT2NUM(c)) #define rb_curses_define_const(c) rb_define_const(mCurses,#c,UINT2NUM(c))

View File

@ -19,7 +19,7 @@ elsif have_header(*curses=%w"curses.h") and have_library("curses", "initscr")
end end
if make if make
for f in %w(isendwin ungetch beep getnstr wgetnstr doupdate flash deleteln wdeleteln keypad keyname init_color wresize resizeterm) for f in %w(beep bkgd bkgdset color curs deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay)
have_func(f) have_func(f)
end end
flag = "-D_XOPEN_SOURCE_EXTENDED" flag = "-D_XOPEN_SOURCE_EXTENDED"

View File

@ -49,6 +49,16 @@ etc_getlogin(obj)
return Qnil; return Qnil;
} }
#if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
static VALUE
safe_setup_str(str)
const char *str;
{
if (str == 0) str = "";
return rb_tainted_str_new2(str);
}
#endif
#ifdef HAVE_GETPWENT #ifdef HAVE_GETPWENT
static VALUE static VALUE
setup_passwd(pwd) setup_passwd(pwd)
@ -56,15 +66,15 @@ setup_passwd(pwd)
{ {
if (pwd == 0) rb_sys_fail("/etc/passwd"); if (pwd == 0) rb_sys_fail("/etc/passwd");
return rb_struct_new(sPasswd, return rb_struct_new(sPasswd,
rb_tainted_str_new2(pwd->pw_name), safe_setup_str(pwd->pw_name),
rb_tainted_str_new2(pwd->pw_passwd), safe_setup_str(pwd->pw_passwd),
INT2FIX(pwd->pw_uid), INT2FIX(pwd->pw_uid),
INT2FIX(pwd->pw_gid), INT2FIX(pwd->pw_gid),
#ifdef HAVE_ST_PW_GECOS #ifdef HAVE_ST_PW_GECOS
rb_tainted_str_new2(pwd->pw_gecos), safe_setup_str(pwd->pw_gecos),
#endif #endif
rb_tainted_str_new2(pwd->pw_dir), safe_setup_str(pwd->pw_dir),
rb_tainted_str_new2(pwd->pw_shell), safe_setup_str(pwd->pw_shell),
#ifdef HAVE_ST_PW_CHANGE #ifdef HAVE_ST_PW_CHANGE
INT2FIX(pwd->pw_change), INT2FIX(pwd->pw_change),
#endif #endif
@ -75,10 +85,10 @@ setup_passwd(pwd)
INT2FIX(pwd->pw_age), INT2FIX(pwd->pw_age),
#endif #endif
#ifdef HAVE_ST_PW_CLASS #ifdef HAVE_ST_PW_CLASS
rb_tainted_str_new2(pwd->pw_class), safe_setup_str(pwd->pw_class),
#endif #endif
#ifdef HAVE_ST_PW_COMMENT #ifdef HAVE_ST_PW_COMMENT
rb_tainted_str_new2(pwd->pw_comment), safe_setup_str(pwd->pw_comment),
#endif #endif
#ifdef HAVE_ST_PW_EXPIRE #ifdef HAVE_ST_PW_EXPIRE
INT2FIX(pwd->pw_expire), INT2FIX(pwd->pw_expire),
@ -220,12 +230,12 @@ setup_group(grp)
mem = rb_ary_new(); mem = rb_ary_new();
tbl = grp->gr_mem; tbl = grp->gr_mem;
while (*tbl) { while (*tbl) {
rb_ary_push(mem, rb_tainted_str_new2(*tbl)); rb_ary_push(mem, safe_setup_str(*tbl));
tbl++; tbl++;
} }
return rb_struct_new(sGroup, return rb_struct_new(sGroup,
rb_tainted_str_new2(grp->gr_name), safe_setup_str(grp->gr_name),
rb_tainted_str_new2(grp->gr_passwd), safe_setup_str(grp->gr_passwd),
INT2FIX(grp->gr_gid), INT2FIX(grp->gr_gid),
mem); mem);
} }

View File

@ -24,6 +24,7 @@
#include "ruby.h" #include "ruby.h"
#include "rubyio.h" #include "rubyio.h"
#include "util.h"
#include <signal.h> #include <signal.h>
#ifdef HAVE_SYS_STROPTS_H #ifdef HAVE_SYS_STROPTS_H

View File

@ -397,7 +397,7 @@ getaddrinfo(hostname, servname, hints, res)
fprintf(stderr, "panic!\n"); fprintf(stderr, "panic!\n");
break; break;
} }
if ((sp = getservbyname(servname, proto)) == NULL) if ((sp = getservbyname((char*)servname, proto)) == NULL)
ERR(EAI_SERVICE); ERR(EAI_SERVICE);
port = sp->s_port; port = sp->s_port;
if (pai->ai_socktype == ANY) if (pai->ai_socktype == ANY)
@ -554,7 +554,7 @@ get_name(addr, afd, res, numaddr, pai, port0)
#ifdef INET6 #ifdef INET6
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
#else #else
hp = gethostbyaddr(addr, afd->a_addrlen, AF_INET); hp = gethostbyaddr((char*)addr, afd->a_addrlen, AF_INET);
#endif #endif
if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
GET_AI(cur, afd, hp->h_addr_list[0], port); GET_AI(cur, afd, hp->h_addr_list[0], port);
@ -606,7 +606,7 @@ get_addr(hostname, af, res, pai, port0)
} else } else
hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error); hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error);
#else #else
hp = gethostbyname(hostname); hp = gethostbyname((char*)hostname);
h_error = h_errno; h_error = h_errno;
#endif #endif
if (hp == NULL) { if (hp == NULL) {

View File

@ -13,6 +13,7 @@
#include "ruby.h" #include "ruby.h"
#include "rubyio.h" #include "rubyio.h"
#include "rubysig.h" #include "rubysig.h"
#include "util.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
@ -31,6 +32,9 @@
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#include <netinet/in.h> #include <netinet/in.h>
#ifdef HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#ifdef HAVE_NETINET_TCP_H #ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h> # include <netinet/tcp.h>
#endif #endif
@ -2016,7 +2020,7 @@ sock_s_gethostbyaddr(argc, argv)
t = AF_INET6; t = AF_INET6;
} }
#endif #endif
h = gethostbyaddr(RSTRING(addr)->ptr, RSTRING(addr)->len, t); h = gethostbyaddr((char*)RSTRING(addr)->ptr, RSTRING(addr)->len, t);
if (h == NULL) { if (h == NULL) {
#ifdef HAVE_HSTRERROR #ifdef HAVE_HSTRERROR
extern int h_errno; extern int h_errno;
@ -2061,7 +2065,7 @@ sock_s_getservbyaname(argc, argv)
else proto = StringValuePtr(protocol); else proto = StringValuePtr(protocol);
StringValue(service); StringValue(service);
sp = getservbyname(RSTRING(service)->ptr, proto); sp = getservbyname((char*)RSTRING(service)->ptr, proto);
if (sp) { if (sp) {
port = ntohs(sp->s_port); port = ntohs(sp->s_port);
} }

View File

@ -8,6 +8,7 @@
*/ */
#include "ruby.h" #include "ruby.h"
#include "util.h"
#include <syslog.h> #include <syslog.h>
/* Syslog class */ /* Syslog class */

24
file.c
View File

@ -1419,14 +1419,12 @@ has_drive_letter(buf)
} }
} }
static void static char*
getcwdofdrv(drv, buf, len) getcwdofdrv(drv)
int drv; int drv;
char *buf;
int len;
{ {
char drive[4]; char drive[4];
char oldcwd[MAXPATHLEN+1]; char *drvcwd, *oldcwd;
drive[0] = drv; drive[0] = drv;
drive[1] = ':'; drive[1] = ':';
@ -1436,15 +1434,17 @@ getcwdofdrv(drv, buf, len)
of a particular drive is to change chdir() to that drive, of a particular drive is to change chdir() to that drive,
so save the old cwd before chdir() so save the old cwd before chdir()
*/ */
getcwd(oldcwd, MAXPATHLEN); oldcwd = my_getcwd();
if (chdir(drive) == 0) { if (chdir(drive) == 0) {
getcwd(buf, len); drvcwd = my_getcwd();
chdir(oldcwd); chdir(oldcwd);
free(oldcwd);
} }
else { else {
/* perhaps the drive is not exist. we return only drive letter */ /* perhaps the drive is not exist. we return only drive letter */
strncpy(buf, drive, len); drvcwd = strdup(drive);
} }
return drvcwd;
} }
#endif #endif
@ -1630,9 +1630,13 @@ file_expand_path(fname, dname, result)
} }
} }
if (!same) { if (!same) {
BUFCHECK(buflen < MAXPATHLEN); char *dir = getcwdofdrv(*s);
getcwdofdrv(*s, buf, MAXPATHLEN);
tainted = 1; tainted = 1;
dirlen = strlen(dir);
BUFCHECK(dirlen > buflen);
strcpy(buf, dir);
free(dir);
} }
p = chompdirsep(skiproot(buf)); p = chompdirsep(skiproot(buf));
s += 2; s += 2;

3
gc.c
View File

@ -1358,6 +1358,9 @@ Init_stack(addr)
if (STACK_LEVEL_MAX > IA64_MAGIC_STACK_LIMIT) if (STACK_LEVEL_MAX > IA64_MAGIC_STACK_LIMIT)
STACK_LEVEL_MAX = IA64_MAGIC_STACK_LIMIT; STACK_LEVEL_MAX = IA64_MAGIC_STACK_LIMIT;
#endif #endif
#ifdef _THREAD_SAFE
STACK_LEVEL_MAX /= 4;
#endif
#endif #endif
} }

View File

@ -1036,7 +1036,7 @@ class CGI
eval <<-END eval <<-END
def body.local_path def body.local_path
#{body.path.dump} #{(body.class == StringIO)? "" : body.path.dump}
end end
END END

View File

@ -751,7 +751,7 @@ module FileUtils
end end
def have_st_ino? def have_st_ino?
/mswin|mingw|bccwin|wince|emx/ !~ RUBY_PLATFORM /djgpp|mswin|mingw|bccwin|wince|emx/ !~ RUBY_PLATFORM
end end
def fu_stream_blksize( *streams ) def fu_stream_blksize( *streams )

View File

@ -215,6 +215,7 @@ def link_command(ldflags, opt="", libpath=$LIBPATH)
'INCFLAGS' => $INCFLAGS, 'INCFLAGS' => $INCFLAGS,
'CPPFLAGS' => $CPPFLAGS, 'CPPFLAGS' => $CPPFLAGS,
'CFLAGS' => "#$CFLAGS", 'CFLAGS' => "#$CFLAGS",
'XCFLAGS' => "#$XCFLAGS",
'LDFLAGS' => "#$LDFLAGS #{ldflags}", 'LDFLAGS' => "#$LDFLAGS #{ldflags}",
'LIBPATH' => libpathflag(libpath), 'LIBPATH' => libpathflag(libpath),
'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs", 'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
@ -223,7 +224,7 @@ end
def cc_command(opt="") def cc_command(opt="")
"$(CC) -c #$INCFLAGS -I#{$hdrdir} " \ "$(CC) -c #$INCFLAGS -I#{$hdrdir} " \
"#$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C}" "#$CPPFLAGS #$CFLAGS #$XCFLAGS #{opt} #{CONFTEST_C}"
end end
def cpp_command(outfile, opt="") def cpp_command(outfile, opt="")
@ -720,7 +721,7 @@ LIBRUBY_A = #{CONFIG['LIBRUBY_A']}
LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED
LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #{CONFIG['XCFLAGS']} #$CFLAGS
CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{$CPPFLAGS} CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{$CPPFLAGS}
CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']} CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
DLDFLAGS = #$LDFLAGS #{CONFIG['DLDFLAGS']} #$DLDFLAGS DLDFLAGS = #$LDFLAGS #{CONFIG['DLDFLAGS']} #$DLDFLAGS
@ -943,6 +944,7 @@ def init_mkmf(config = CONFIG)
$enable_shared = config['ENABLE_SHARED'] == 'yes' $enable_shared = config['ENABLE_SHARED'] == 'yes'
$defs = [] $defs = []
$CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup $CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup
$XCFLAGS = config['XCFLAGS'].dup
$CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup $CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup
$LDFLAGS = (with_config("ldflags") || "").dup $LDFLAGS = (with_config("ldflags") || "").dup
$INCFLAGS = "-I#{$topdir}" $INCFLAGS = "-I#{$topdir}"

View File

@ -41,7 +41,7 @@ public
EncodingConvertMap[['UTF8', 'EUC' ]] = Proc.new { |str| IconvCharset.safe_iconv("euc-jp", "utf-8", str) } EncodingConvertMap[['UTF8', 'EUC' ]] = Proc.new { |str| IconvCharset.safe_iconv("euc-jp", "utf-8", str) }
EncodingConvertMap[['EUC' , 'UTF8']] = Proc.new { |str| IconvCharset.safe_iconv("utf-8", "euc-jp", str) } EncodingConvertMap[['EUC' , 'UTF8']] = Proc.new { |str| IconvCharset.safe_iconv("utf-8", "euc-jp", str) }
EncodingConvertMap[['EUC' , 'SJIS']] = Proc.new { |str| IconvCharset.safe_iconv("shift-jis", "euc-jp", str) } EncodingConvertMap[['EUC' , 'SJIS']] = Proc.new { |str| IconvCharset.safe_iconv("shift-jis", "euc-jp", str) }
if /(mswin|bccwin|mingw|cygwin)/ =~ RUBY_PLATFORM if /(mswin|bccwin|mingw|cygwin|emx)/ =~ RUBY_PLATFORM
EncodingConvertMap[['UTF8', 'SJIS']] = Proc.new { |str| IconvCharset.safe_iconv("cp932", "utf-8", str) } EncodingConvertMap[['UTF8', 'SJIS']] = Proc.new { |str| IconvCharset.safe_iconv("cp932", "utf-8", str) }
EncodingConvertMap[['SJIS', 'UTF8']] = Proc.new { |str| IconvCharset.safe_iconv("utf-8", "cp932", str) } EncodingConvertMap[['SJIS', 'UTF8']] = Proc.new { |str| IconvCharset.safe_iconv("utf-8", "cp932", str) }
EncodingConvertMap[['SJIS', 'EUC' ]] = Proc.new { |str| IconvCharset.safe_iconv("euc-jp", "cp932", str) } EncodingConvertMap[['SJIS', 'EUC' ]] = Proc.new { |str| IconvCharset.safe_iconv("euc-jp", "cp932", str) }

2
main.c
View File

@ -29,7 +29,7 @@ int _CRT_glob = 0;
#endif #endif
/* to link startup code with ObjC support */ /* to link startup code with ObjC support */
#if defined(__APPLE__) && defined(__MACH__) #if (defined(__APPLE__) || defined(__NeXT__)) && defined(__MACH__)
static void objcdummyfunction( void ) { objc_msgSend(); } static void objcdummyfunction( void ) { objc_msgSend(); }
#endif #endif

View File

@ -345,14 +345,15 @@ hash_each(key, value, arg)
} }
static void static void
w_extended(klass, arg) w_extended(klass, arg, check)
VALUE klass; VALUE klass;
struct dump_arg *arg; struct dump_arg *arg;
int check;
{ {
char *path; char *path;
if (FL_TEST(klass, FL_SINGLETON)) { if (FL_TEST(klass, FL_SINGLETON)) {
if (RCLASS(klass)->m_tbl->num_entries || if (check && RCLASS(klass)->m_tbl->num_entries ||
(RCLASS(klass)->iv_tbl && RCLASS(klass)->iv_tbl->num_entries > 1)) { (RCLASS(klass)->iv_tbl && RCLASS(klass)->iv_tbl->num_entries > 1)) {
rb_raise(rb_eTypeError, "singleton can't be dumped"); rb_raise(rb_eTypeError, "singleton can't be dumped");
} }
@ -367,15 +368,16 @@ w_extended(klass, arg)
} }
static void static void
w_class(type, obj, arg) w_class(type, obj, arg, check)
int type; int type;
VALUE obj; VALUE obj;
struct dump_arg *arg; struct dump_arg *arg;
int check;
{ {
char *path; char *path;
VALUE klass = CLASS_OF(obj); VALUE klass = CLASS_OF(obj);
w_extended(klass, arg); w_extended(klass, arg, check);
w_byte(type, arg); w_byte(type, arg);
path = rb_class2name(klass); path = rb_class2name(klass);
w_unique(path, arg); w_unique(path, arg);
@ -388,7 +390,7 @@ w_uclass(obj, base_klass, arg)
{ {
VALUE klass = CLASS_OF(obj); VALUE klass = CLASS_OF(obj);
w_extended(klass, arg); w_extended(klass, arg, Qtrue);
klass = rb_class_real(klass); klass = rb_class_real(klass);
if (klass != base_klass) { if (klass != base_klass) {
w_byte(TYPE_UCLASS, arg); w_byte(TYPE_UCLASS, arg);
@ -429,6 +431,7 @@ w_object(obj, arg, limit)
{ {
struct dump_call_arg c_arg; struct dump_call_arg c_arg;
st_table *ivtbl = 0; st_table *ivtbl = 0;
st_data_t num;
if (limit == 0) { if (limit == 0) {
rb_raise(rb_eArgError, "exceed depth limit"); rb_raise(rb_eArgError, "exceed depth limit");
@ -438,6 +441,12 @@ w_object(obj, arg, limit)
c_arg.limit = limit; c_arg.limit = limit;
c_arg.arg = arg; c_arg.arg = arg;
if (st_lookup(arg->data, obj, &num)) {
w_byte(TYPE_LINK, arg);
w_long((long)num, arg);
return;
}
if (ivtbl = rb_generic_ivar_table(obj)) { if (ivtbl = rb_generic_ivar_table(obj)) {
w_byte(TYPE_IVAR, arg); w_byte(TYPE_IVAR, arg);
} }
@ -468,14 +477,6 @@ w_object(obj, arg, limit)
w_symbol(SYM2ID(obj), arg); w_symbol(SYM2ID(obj), arg);
} }
else { else {
st_data_t num;
if (st_lookup(arg->data, obj, &num)) {
w_byte(TYPE_LINK, arg);
w_long((long)num, arg);
return;
}
if (OBJ_TAINTED(obj)) arg->taint = Qtrue; if (OBJ_TAINTED(obj)) arg->taint = Qtrue;
st_add_direct(arg->data, obj, arg->data->num_entries); st_add_direct(arg->data, obj, arg->data->num_entries);
@ -483,7 +484,7 @@ w_object(obj, arg, limit)
VALUE v; VALUE v;
v = rb_funcall(obj, s_mdump, 0, 0); v = rb_funcall(obj, s_mdump, 0, 0);
w_class(TYPE_USRMARSHAL, obj, arg); w_class(TYPE_USRMARSHAL, obj, arg, Qfalse);
w_object(v, arg, limit); w_object(v, arg, limit);
if (ivtbl) w_ivar(0, &c_arg); if (ivtbl) w_ivar(0, &c_arg);
return; return;
@ -498,7 +499,7 @@ w_object(obj, arg, limit)
if (!ivtbl && (ivtbl = rb_generic_ivar_table(v))) { if (!ivtbl && (ivtbl = rb_generic_ivar_table(v))) {
w_byte(TYPE_IVAR, arg); w_byte(TYPE_IVAR, arg);
} }
w_class(TYPE_USERDEF, obj, arg); w_class(TYPE_USERDEF, obj, arg, Qfalse);
w_bytes(RSTRING(v)->ptr, RSTRING(v)->len, arg); w_bytes(RSTRING(v)->ptr, RSTRING(v)->len, arg);
if (ivtbl) { if (ivtbl) {
w_ivar(ivtbl, &c_arg); w_ivar(ivtbl, &c_arg);
@ -614,7 +615,7 @@ w_object(obj, arg, limit)
break; break;
case T_STRUCT: case T_STRUCT:
w_class(TYPE_STRUCT, obj, arg); w_class(TYPE_STRUCT, obj, arg, Qtrue);
{ {
long len = RSTRUCT(obj)->len; long len = RSTRUCT(obj)->len;
VALUE mem; VALUE mem;
@ -633,7 +634,7 @@ w_object(obj, arg, limit)
break; break;
case T_OBJECT: case T_OBJECT:
w_class(TYPE_OBJECT, obj, arg); w_class(TYPE_OBJECT, obj, arg, Qtrue);
w_ivar(ROBJECT(obj)->iv_tbl, &c_arg); w_ivar(ROBJECT(obj)->iv_tbl, &c_arg);
break; break;
@ -641,10 +642,10 @@ w_object(obj, arg, limit)
{ {
VALUE v; VALUE v;
w_class(TYPE_DATA, obj, arg); w_class(TYPE_DATA, obj, arg, Qtrue);
if (!rb_respond_to(obj, s_dump_data)) { if (!rb_respond_to(obj, s_dump_data)) {
rb_raise(rb_eTypeError, rb_raise(rb_eTypeError,
"class %s needs to have instance method `_dump_data'", "no marshal_dump is defined for class %s",
rb_obj_classname(obj)); rb_obj_classname(obj));
} }
v = rb_funcall(obj, s_dump_data, 0); v = rb_funcall(obj, s_dump_data, 0);

View File

@ -1,5 +1,4 @@
require 'test/unit/testsuite' require 'test/unit'
require 'test/unit/testcase'
require 'tempfile' require 'tempfile'
require 'fileutils' require 'fileutils'

View File

@ -13,7 +13,7 @@ class TestFile < Test::Unit::TestCase
w.close w.close
r = File.open(filename, "r") r = File.open(filename, "r")
begin begin
if /(mswin|bccwin|mingw)/ =~ RUBY_PLATFORM if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
begin begin
File.unlink(filename) File.unlink(filename)
assert(false) assert(false)

View File

@ -1,8 +1,7 @@
# vim:sw=4:ts=4 # vim:sw=4:ts=4
# $Id$ # $Id$
# #
require 'test/unit/testsuite' require 'test/unit'
require 'test/unit/testcase'
require 'yaml' require 'yaml'
class YAML_Unit_Tests < Test::Unit::TestCase class YAML_Unit_Tests < Test::Unit::TestCase

13
util.c
View File

@ -636,14 +636,25 @@ ruby_strdup(str)
char * char *
ruby_getcwd() ruby_getcwd()
{ {
#ifdef HAVE_GETCWD
int size = 200; int size = 200;
char *buf = xmalloc(size); char *buf = xmalloc(size);
while (!getcwd(buf, size)) { while (!getcwd(buf, size)) {
if (errno != ERANGE) rb_sys_fail(0); if (errno != ERANGE) rb_sys_fail("getcwd");
size *= 2; size *= 2;
buf = xrealloc(buf, size); buf = xrealloc(buf, size);
} }
#else
# ifndef PATH_MAX
# define PATH_MAX 8192
# endif
char *buf = xmalloc(PATH_MAX+1);
if (!getwd(buf)) {
rb_sys_fail("getwd");
}
#endif
return buf; return buf;
} }

View File

@ -1493,7 +1493,14 @@ mod_av_set(klass, id, val, isconst)
if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4) if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest); rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest);
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); if (OBJ_FROZEN(klass)) {
if (BUILTIN_TYPE(klass) == T_MODULE) {
rb_error_frozen("module");
}
else {
rb_error_frozen("class");
}
}
if (!RCLASS(klass)->iv_tbl) { if (!RCLASS(klass)->iv_tbl) {
RCLASS(klass)->iv_tbl = st_init_numtable(); RCLASS(klass)->iv_tbl = st_init_numtable();
} }