diff --git a/ChangeLog b/ChangeLog index 9fda8fc114b211..27cd88650d512c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Oct 15 18:08:37 1997 Yukihiro Matsumoto + + * version 1.0-971015 + Fri Oct 3 10:51:10 1997 Yukihiro Matsumoto * version 1.0-971003 diff --git a/MANIFEST b/MANIFEST index a1129f908ae8f2..1ae2adcd41aaea 100644 --- a/MANIFEST +++ b/MANIFEST @@ -124,8 +124,8 @@ missing/strftime.c missing/strstr.c missing/strtol.c missing/strtoul.c +missing/x68.c sample/biorhythm.rb -sample/cbreak.rb sample/clnt.rb sample/dbmtest.rb sample/dir.rb diff --git a/config.guess b/config.guess index ea28434e584e24..91dad5ee6a616e 100755 --- a/config.guess +++ b/config.guess @@ -333,6 +333,9 @@ EOF *:NetBSD:*:*) echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; *:*:*BOW*:*) echo i386-pc-bow exit 0 ;; @@ -572,7 +575,7 @@ main () } EOF -${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy.x dummy && exit 0 +${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm -f dummy.c dummy.x dummy && exit 0 rm -f dummy.c dummy.x dummy # Apollos put the system type in the environment. diff --git a/config.sub b/config.sub index 9dec8e3c136eb2..002d4088120e14 100755 --- a/config.sub +++ b/config.sub @@ -686,7 +686,7 @@ case $os in | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \ | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \ | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ diff --git a/configure.in b/configure.in index 699ca1eed37172..9a59f42e0f3642 100644 --- a/configure.in +++ b/configure.in @@ -28,6 +28,35 @@ if test $rb_thread = yes; then fi AC_CANONICAL_HOST + + +dnl checks for fat-binary +fat_binary=no +AC_ARG_ENABLE( fat-binary, + [--enable-fat-binary build a NeXT Multi Architecture Binary. ], + [ fat_binary=$enableval ] ) +if test "$fat_binary" = yes ; then + + AC_MSG_CHECKING( target architecture ) + + if test "$TARGET_ARCHS" = "" ; then + if test `/usr/bin/arch` = "m68k" ; then + TARGET_ARCHS="m68k i486" + else + TARGET_ARCHS="m68k `/usr/bin/arch`" + fi + fi + # /usr/lib/arch_tool -archify_list $TARGET_ARCHS + for archs in $TARGET_ARCHS + do + ARCH_FLAG="$ARCH_FLAG -arch $archs " + echo -n " $archs" + done + AC_DEFINE( NEXT_FAT_BINARY ) + echo "." +fi + + AC_ARG_PROGRAM dnl Checks for programs. @@ -75,7 +104,7 @@ AC_TYPE_SIGNAL AC_FUNC_ALLOCA AC_FUNC_VFORK AC_REPLACE_FUNCS(dup2 setenv memmove mkdir strcasecmp strerror strftime\ - strstr strtoul strdup strcasecmp crypt flock) + strstr strtoul strdup crypt flock) AC_CHECK_FUNCS(fmod killpg random wait4 waitpid syscall getcwd\ truncate chsize times utimes fcntl lockf setitimer\ setruid seteuid setreuid setrgid setegid setregid\ @@ -269,8 +298,11 @@ if test "$with_dln_a_out" != yes; then rb_cv_dlopen=yes ;; netbsd*) LDSHARED="ld -Bshareable" rb_cv_dlopen=yes ;; - nextstep*) LDSHARED='ld' + openbsd*) LDSHARED="ld -Bshareable" + rb_cv_dlopen=yes ;; + nextstep*) LDSHARED='cc -r' LDFLAGS="-u libsys_s" + DLDFLAGS="$ARCH_FLAG" rb_cv_dlopen=yes ;; aix*) LDSHARED='../../miniruby ../aix_ld.rb $(TARGET)' rb_cv_dlopen=yes ;; @@ -407,11 +439,27 @@ AC_SUBST(setup) if test "$prefix" = NONE; then prefix=$ac_default_prefix fi + +if test "$fat_binary" = yes ; then + CFLAGS="$CFLAGS -pipe $ARCH_FLAG" +fi + AC_DEFINE_UNQUOTED(RUBY_LIB, "${prefix}/lib/ruby") AC_SUBST(arch)dnl -arch="${host_cpu}-${host_os}" -AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/ruby/${host_cpu}-${host_os}") -AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "$arch") + +if test "$fat_binary" = yes ; then + arch="fat-${host_os}" + + AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB, + "${prefix}/lib/ruby/" __ARCHITECTURE__ "-${host_os}" ) + + AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/ruby/${arch}") + AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${host_os}" ) +else + arch="${host_cpu}-${host_os}" + AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/ruby/${arch}") + AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}") +fi echo "creating config.h" cat confdefs.h > config.h diff --git a/error.c b/error.c index 5291d9ea76f3be..3427310f289434 100644 --- a/error.c +++ b/error.c @@ -313,7 +313,7 @@ void Init_Exception() { eGlobalExit = rb_define_class("GlobalExit", cString); - rb_define_method(eGlobalExit, "new", exc_s_new, -1); + rb_define_singleton_method(eGlobalExit, "new", exc_s_new, -1); rb_define_method(eGlobalExit, "inspect", exc_inspect, 0); eSystemExit = rb_define_class("SystemExit", eGlobalExit); diff --git a/eval.c b/eval.c index fdc338b50470d1..8d48a2bf192369 100644 --- a/eval.c +++ b/eval.c @@ -685,7 +685,10 @@ ruby_options(argc, argv) eval_tree = save; } POP_TAG(); - if (state) error_print(); + if (state) { + error_print(); + exit(1); + } } static VALUE diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index 80e2a3c9d19b5c..c6405aa6f7f29b 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -287,6 +287,11 @@ $(TARGET): $(OBJS) mfile.printf "\ $(TARGET): $(OBJS) ar cru $(TARGET) $(OBJS) +" + elsif PLATFORM =~ "-nextstep" + mfile.printf "\ +$(TARGET): $(OBJS) + cc -r $(CFLAGS) -o $(TARGET) $(OBJS) " else mfile.printf "\ diff --git a/io.c b/io.c index 8d3fb7b8798ad3..b836469c47a4aa 100644 --- a/io.c +++ b/io.c @@ -1760,11 +1760,12 @@ io_ctl(io, req, arg, io_p) #endif str_modify(arg); - if (arg->len < len) { - str_resize(arg, len+1); - arg->ptr[len] = 17; /* a little sanity check here */ - narg = (long)arg->ptr; + if (len < arg->len) { + len = arg->len; } + str_resize(arg, len+1); + arg->ptr[len] = 17; /* a little sanity check here */ + narg = (long)arg->ptr; } fd = fileno(fptr->f); #ifdef HAVE_FCNTL diff --git a/main.c b/main.c index f3c1c31455bc6c..473b51d02893f8 100644 --- a/main.c +++ b/main.c @@ -23,7 +23,7 @@ __declspec(dllexport) void __stdcall ruby_run(void); __declspec(dllexport) void __stdcall NtInitialize(int *, char ***); #endif -void +int main(argc, argv, envp) int argc; char **argv, **envp; diff --git a/missing/mkdir.c b/missing/mkdir.c index b581a5e46797c0..ed1476db9ac7d3 100644 --- a/missing/mkdir.c +++ b/missing/mkdir.c @@ -1,4 +1,4 @@ -* +/* * Written by Robert Rother, Mariah Corporation, August 1985. * * If you want it, it's yours. All I ask in return is that if you @@ -14,6 +14,7 @@ */ #include +#include /* * Make a directory. */ diff --git a/missing/nt.c b/missing/nt.c index 6674f09207cf1d..58736ae241931a 100644 --- a/missing/nt.c +++ b/missing/nt.c @@ -46,6 +46,109 @@ static char *str_grow(struct RString *str, size_t new_size); char *NTLoginName; +DWORD Win32System = (DWORD)-1; + +static DWORD +IdOS(void) +{ + static OSVERSIONINFO osver; + + if (osver.dwPlatformId != Win32System) { + memset(&osver, 0, sizeof(OSVERSIONINFO)); + osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osver); + Win32System = osver.dwPlatformId; + } + return (Win32System); +} + +static int +IsWin95(void) { + return (IdOS() == VER_PLATFORM_WIN32_WINDOWS); +} + +static int +IsWinNT(void) { + return (IdOS() == VER_PLATFORM_WIN32_NT); +} + + +/* simulate flock by locking a range on the file */ + + +#define LK_ERR(f,i) ((f) ? (i = 0) : (errno = GetLastError())) +#define LK_LEN 0xffff0000 + +int +flock(int fd, int oper) +{ + OVERLAPPED o; + int i = -1; + HANDLE fh; + + fh = (HANDLE)_get_osfhandle(fd); + memset(&o, 0, sizeof(o)); + + if(IsWinNT()) { + switch(oper) { + case LOCK_SH: /* shared lock */ + LK_ERR(LockFileEx(fh, 0, 0, LK_LEN, 0, &o),i); + break; + case LOCK_EX: /* exclusive lock */ + LK_ERR(LockFileEx(fh, LOCKFILE_EXCLUSIVE_LOCK, 0, LK_LEN, 0, &o),i); + break; + case LOCK_SH|LOCK_NB: /* non-blocking shared lock */ + LK_ERR(LockFileEx(fh, LOCKFILE_FAIL_IMMEDIATELY, 0, LK_LEN, 0, &o),i); + break; + case LOCK_EX|LOCK_NB: /* non-blocking exclusive lock */ + LK_ERR(LockFileEx(fh, + LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, + 0, LK_LEN, 0, &o),i); + if(errno == EDOM) errno = EWOULDBLOCK; + break; + case LOCK_UN: /* unlock lock */ + if (UnlockFileEx(fh, 0, LK_LEN, 0, &o)) { + i = 0; + } + else { + /* GetLastError() must returns `ERROR_NOT_LOCKED' */ + errno = EWOULDBLOCK; + } + if(errno == EDOM) errno = EWOULDBLOCK; + break; + default: /* unknown */ + errno = EINVAL; + break; + } + } + else if(IsWin95()) { + switch(oper) { + case LOCK_EX: + while(i == -1) { + LK_ERR(LockFile(fh, 0, 0, LK_LEN, 0), i); + if(errno != EDOM && i == -1) break; + } + break; + case LOCK_EX | LOCK_NB: + LK_ERR(LockFile(fh, 0, 0, LK_LEN, 0), i); + if(errno == EDOM) errno = EWOULDBLOCK; + break; + case LOCK_UN: + LK_ERR(UnlockFile(fh, 0, 0, LK_LEN, 0), i); + if(errno == EDOM) errno = EWOULDBLOCK; + break; + default: + errno = EINVAL; + break; + } + } + return i; +} + +#undef LK_ERR +#undef LK_LEN + + #undef const FILE *fdopen(int, const char *); @@ -467,7 +570,7 @@ mypopen (char *cmd, char *mode) fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode)); CloseHandle(hInFile); DuplicateHandle(GetCurrentProcess(), hStdin, - GetCurrentProcess(), &hDummy, + GetCurrentProcess(), &hDummy, 0, TRUE, (DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE) ); } diff --git a/missing/nt.h b/missing/nt.h index cf9f4cb00a8c01..70132b4577211b 100644 --- a/missing/nt.h +++ b/missing/nt.h @@ -147,6 +147,7 @@ extern int NtMakeCmdVector(char *, char ***, int); extern char *NtGetLib(void); extern char *NtGetBin(void); extern FILE *mypopen(char *, char *); +extern int flock(int fd, int oper); // // define this so we can do inplace editing @@ -190,6 +191,14 @@ extern char *mystrerror(int); #define HAVE_WAITPID 1 #define HAVE_GETCWD 1 +#define LOCK_SH 1 +#define LOCK_EX 2 +#define LOCK_NB 4 +#define LOCK_UN 8 +#ifndef EWOULDBLOCK +#define EWOULDBLOCK 10035 /* EBASEERR + 35 (winsock.h) */ +#endif + #ifdef popen #undef popen #define popen mypopen diff --git a/missing/x68.c b/missing/x68.c new file mode 100644 index 00000000000000..8fd9c3e879dbad --- /dev/null +++ b/missing/x68.c @@ -0,0 +1,12 @@ +#include "config.h" + +#if !HAVE_SELECT +#include "x68/select.c" +#endif +#if MISSING__DTOS18 +#include "x68/_dtos18.c" +#endif +#if MISSING_FCONVERT +#include "x68/_round.c" +#include "x68/fconvert.c" +#endif diff --git a/ruby.1 b/ruby.1 index b0668047164b40..fe1e76007a2131 100644 --- a/ruby.1 +++ b/ruby.1 @@ -191,6 +191,7 @@ mode, ruby executes .ne 1 \& $F = $_.split at beginning of each loop. +.fi .TP .B -c causes ruby to check the syntax of the script and exit without @@ -225,6 +226,7 @@ example: \& MATZ \& % cat /tmp/junk.bak \& matz +.fi .TP .B -I directory used to tell ruby where to load the library scripts. Directory @@ -244,6 +246,7 @@ sed -n or awk. \& while gets \& ... \& end +.fi .TP .B -p acts mostly same as -n switch, but print the value of variable @@ -253,6 +256,7 @@ example: .ne 2 \& % echo matz | ruby -p -e '$_.tr! "a-z", "A-Z"' \& MATZ +.fi .TP .B -r filename causes ruby to load the file using [4]require. It is useful @@ -269,6 +273,7 @@ example: \& #! /usr/local/bin/ruby -s \& # prints "true" if invoked with `-xyz' switch. \& print "true\n" if $xyz +.fi .TP .B -S makes ruby uses the PATH environment variable to search for @@ -278,8 +283,9 @@ manner: .nf .ne 2 \& #! /usr/local/bin/ruby -\& # This line makes the next one a comment in ruby \ +\& # This line makes the next one a comment in ruby \\ \& exec /usr/local/bin/ruby -S $0 $* +.fi On some systems $0 does not always contain the full pathname, so you need -S switch to tell ruby to search for the script if necessary. diff --git a/ruby.c b/ruby.c index 33522f8b4da7d2..ab08fd8c760b83 100644 --- a/ruby.c +++ b/ruby.c @@ -595,6 +595,11 @@ ruby_prog_init() if (rb_safe_level() == 0) { addpath(getenv("RUBYLIB")); } + +#ifdef RUBY_THIN_ARCHLIB + addpath(RUBY_THIN_ARCHLIB); +#endif + #ifdef RUBY_ARCHLIB addpath(RUBY_ARCHLIB); #endif diff --git a/sample/cbreak.rb b/sample/cbreak.rb deleted file mode 100644 index cbb15d2f4191fb..00000000000000 --- a/sample/cbreak.rb +++ /dev/null @@ -1,36 +0,0 @@ -# ioctl example works on Sun - -CBREAK = 0x00000002 -ECHO = 0x00000008 -TIOCGETP = 0x40067408 -TIOCSETP = 0x80067409 - -def cbreak () - set_cbreak(TRUE) -end - -def cooked () - set_cbreak(FALSE) -end - -def set_cbreak (on) - tty = "\0" * 256 - STDIN.ioctl(TIOCGETP, tty) - ttys = tty.unpack("C4 S") - if on - ttys[4] |= CBREAK - ttys[4] &= ~ECHO - else - ttys[4] &= ~CBREAK - ttys[4] |= ECHO - end - tty = ttys.pack("C4 S") - STDIN.ioctl(TIOCSETP, tty) -end -cbreak(); - -print("this is no-echo line: "); -readline().print -cooked(); -print("this is echo line: "); -readline() diff --git a/version.h b/version.h index 5d53852146c2eb..37f5eac467d6f4 100644 --- a/version.h +++ b/version.h @@ -1,2 +1,2 @@ -#define RUBY_VERSION "1.0-971003" -#define VERSION_DATE "97/10/03" +#define RUBY_VERSION "1.0-971015" +#define VERSION_DATE "97/10/15" diff --git a/win32/Makefile b/win32/Makefile index 4927e05631a6d8..b5a9d140cf5168 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -20,7 +20,7 @@ PURIFY = CFLAGS = -nologo -DNT=1 -Zi -MD LDFLAGS = $(CFLAGS) -Fm -MD LIBS = $(EXTLIBS) advapi32.lib wsock32.lib -MISSING = crypt.obj flock.obj setenv.obj alloca.obj nt.obj +MISSING = crypt.obj setenv.obj alloca.obj nt.obj prefix = binprefix = diff --git a/win32/config.h b/win32/config.h index d43cfdb53554f0..cf5cb332bfb6dc 100644 --- a/win32/config.h +++ b/win32/config.h @@ -51,7 +51,7 @@ #define S_IREAD _S_IREAD #define S_IWRITE _S_IWRITE #define S_IEXEC _S_IEXEC -#define S_ISFIFO _S_ISFIFO +#define S_IFIFO _S_IFIFO #define UIDTYPE int #define GIDTYPE int