1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1998-05-13 07:26:47 +00:00
parent ad592443af
commit ae2fe781dd
42 changed files with 953 additions and 364 deletions

View file

@ -1,5 +1,11 @@
Wed May 13 14:56:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp> Wed May 13 14:56:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_19.
* most of the Mac and BeOS patches merged, except path separators.
* error.c (err_append): generated SyntaxError was String.
* ruby.h: xxx2INT, xxx2UINT checks values as int, not long. * ruby.h: xxx2INT, xxx2UINT checks values as int, not long.
* ruby.h: remove typedef's. INT, UINT, UCHAR, USHORT. * ruby.h: remove typedef's. INT, UINT, UCHAR, USHORT.

12
array.c
View file

@ -81,12 +81,22 @@ ary_new()
return ary_new2(ARY_DEFAULT_SIZE); return ary_new2(ARY_DEFAULT_SIZE);
} }
#ifdef __STDC__
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h> #include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
VALUE VALUE
#ifdef __STDC__
ary_new3(int n, ...)
#else
ary_new3(n, va_alist) ary_new3(n, va_alist)
int n; int n;
va_dcl va_dcl
#endif
{ {
va_list ar; va_list ar;
VALUE ary; VALUE ary;
@ -97,7 +107,7 @@ ary_new3(n, va_alist)
} }
ary = ary_new2(n<ARY_DEFAULT_SIZE?ARY_DEFAULT_SIZE:n); ary = ary_new2(n<ARY_DEFAULT_SIZE?ARY_DEFAULT_SIZE:n);
va_start(ar); va_init_list(ar, n);
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
RARRAY(ary)->ptr[i] = va_arg(ar, VALUE); RARRAY(ary)->ptr[i] = va_arg(ar, VALUE);
} }

View file

@ -558,6 +558,18 @@ bigadd(x, y, sign)
if (RBIGNUM(y)->sign == sign) return bigsub(y, x); if (RBIGNUM(y)->sign == sign) return bigsub(y, x);
return bigsub(x, y); return bigsub(x, y);
} }
else if (sign == 0) {
/* x - y */
if ((RBIGNUM(x)->sign == 0) && (RBIGNUM(y)->sign == 1)) {
/* x is negative and y is positive. */
/* return -(abs(x) + y) */
VALUE ret;
RBIGNUM(x)->sign = 1; /* x = abs(x) */
ret = bigadd(x, y, 1); /* ret = x + y (recursive call) */
RBIGNUM(ret)->sign = 0; /* ret = -ret */
return ret;
}
}
if (RBIGNUM(x)->len > RBIGNUM(y)->len) { if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
len = RBIGNUM(x)->len + 1; len = RBIGNUM(x)->len + 1;

16
class.c
View file

@ -14,6 +14,10 @@
#include "node.h" #include "node.h"
#include "st.h" #include "st.h"
#ifdef USE_CWGUSI
#include <stdio.h>
#endif
struct st_table *new_idhash(); struct st_table *new_idhash();
extern st_table *rb_class_tbl; extern st_table *rb_class_tbl;
@ -561,22 +565,32 @@ rb_define_attr(klass, name, read, write)
rb_attr(klass, rb_intern(name), read, write, FALSE); rb_attr(klass, rb_intern(name), read, write, FALSE);
} }
#ifdef __STDC__
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h> #include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
#include <ctype.h> #include <ctype.h>
int int
#ifdef __STDC__
rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
#else
rb_scan_args(argc, argv, fmt, va_alist) rb_scan_args(argc, argv, fmt, va_alist)
int argc; int argc;
VALUE *argv; VALUE *argv;
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
int n, i; int n, i;
char *p = fmt; char *p = fmt;
VALUE *var; VALUE *var;
va_list vargs; va_list vargs;
va_start(vargs); va_init_list(vargs, fmt);
if (*p == '*') { if (*p == '*') {
var = va_arg(vargs, VALUE*); var = va_arg(vargs, VALUE*);

9
config.guess vendored
View file

@ -728,6 +728,15 @@ EOF
echo mips-unknown-sysv${UNAME_RELEASE} echo mips-unknown-sysv${UNAME_RELEASE}
fi fi
exit 0 ;; exit 0 ;;
DS/90*:*:*:V20*)
echo sparc-fujitsu-uxpds
exit 0 ;;
BeBox:BeOS:*:*)
echo powerpc-be-beos
exit 0 ;;
BeMac:BeOS:*:*)
echo powerpc-apple-beos
exit 0 ;;
esac esac
#echo '(No uname command or uname output not recognized.)' 1>&2 #echo '(No uname command or uname output not recognized.)' 1>&2

3
config.sub vendored
View file

@ -783,6 +783,9 @@ case $os in
;; ;;
-human) -human)
;; ;;
-beos)
os=-beos
;;
-none) -none)
;; ;;
*) *)

387
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -76,6 +76,7 @@ dnl Checks for libraries.
case "$host_os" in case "$host_os" in
nextstep*) ;; nextstep*) ;;
human*) ;; human*) ;;
beos*) ;;
*) LIBS="-lm $LIBS";; *) LIBS="-lm $LIBS";;
esac esac
AC_CHECK_LIB(crypt, crypt) AC_CHECK_LIB(crypt, crypt)
@ -87,7 +88,8 @@ AC_HEADER_DIRENT
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS(stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.h \ AC_CHECK_HEADERS(stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.h \
sys/select.h sys/time.h sys/times.h sys/param.h sys/wait.h\ sys/select.h sys/time.h sys/times.h sys/param.h sys/wait.h\
syscall.h a.out.h string.h utime.h memory.h) syscall.h a.out.h string.h utime.h memory.h\
varargs.h stdarg.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
@ -114,7 +116,7 @@ AC_CHECK_FUNCS(fmod killpg random wait4 waitpid syscall getcwd\
truncate chsize times utimes fcntl lockf setitimer\ truncate chsize times utimes fcntl lockf setitimer\
setruid seteuid setreuid setrgid setegid setregid\ setruid seteuid setreuid setrgid setegid setregid\
setpgrp2 getpgid getgroups getpriority\ setpgrp2 getpgid getgroups getpriority\
dlopen sigprocmask sigaction _setjmp) dlopen sigprocmask sigaction _setjmp setpgrp)
if test "$ac_cv_func_strftime" = no; then if test "$ac_cv_func_strftime" = no; then
AC_STRUCT_TIMEZONE AC_STRUCT_TIMEZONE
AC_TRY_LINK([], AC_TRY_LINK([],
@ -207,6 +209,7 @@ fi
if test "$ac_cv_func_getpwent" = yes; then if test "$ac_cv_func_getpwent" = yes; then
AC_MSG_CHECKING(struct passwd) AC_MSG_CHECKING(struct passwd)
AC_EGREP_HEADER(pw_gecos, pwd.h, AC_DEFINE(PW_GECOS))
AC_EGREP_HEADER(pw_change, pwd.h, AC_DEFINE(PW_CHANGE)) AC_EGREP_HEADER(pw_change, pwd.h, AC_DEFINE(PW_CHANGE))
AC_EGREP_HEADER(pw_quota, pwd.h, AC_DEFINE(PW_QUOTA)) AC_EGREP_HEADER(pw_quota, pwd.h, AC_DEFINE(PW_QUOTA))
AC_EGREP_HEADER(pw_age, pwd.h, AC_DEFINE(PW_AGE)) AC_EGREP_HEADER(pw_age, pwd.h, AC_DEFINE(PW_AGE))
@ -316,6 +319,9 @@ if test "$with_dln_a_out" != yes; then
human*) DLDFLAGS='' human*) DLDFLAGS=''
LDSHARED='' LDSHARED=''
LDFLAGS='' ;; LDFLAGS='' ;;
beos*) LDSHARED="mwld -xms"
DLDFLAGS="-f ruby.exp"
rb_cv_dlopen=yes ;;
*) LDSHARED='ld' ;; *) LDSHARED='ld' ;;
esac esac
AC_MSG_RESULT($rb_cv_dlopen) AC_MSG_RESULT($rb_cv_dlopen)
@ -451,6 +457,10 @@ if test "$fat_binary" = yes ; then
CFLAGS="$CFLAGS -pipe $ARCH_FLAG" CFLAGS="$CFLAGS -pipe $ARCH_FLAG"
fi fi
if test "$host_os" = "beos"; then
CFLAGS="$CFLAGS -relax_pointers"
fi
ri_prefix= ri_prefix=
test "$program_prefix" != NONE && test "$program_prefix" != NONE &&
ri_prefix=$program_prefix ri_prefix=$program_prefix

View file

@ -13,7 +13,7 @@
#define RUBY #define RUBY
/* define EUC/SJIS for default kanji-code */ /* define EUC/SJIS for default kanji-code */
#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) #if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__)
#undef EUC #undef EUC
#define SJIS #define SJIS
#else #else

12
dir.c
View file

@ -50,6 +50,10 @@
char *getenv(); char *getenv();
#endif #endif
#ifdef USE_CWGUSI
# include <sys/errno.h>
#endif
static VALUE cDir; static VALUE cDir;
static void static void
@ -144,7 +148,7 @@ dir_tell(dir)
DIR *dirp; DIR *dirp;
int pos; int pos;
#if !defined(__CYGWIN32__) #if !defined(__CYGWIN32__) && !defined(__BEOS__)
GetDIR(dir, dirp); GetDIR(dir, dirp);
pos = telldir(dirp); pos = telldir(dirp);
return int2inum(pos); return int2inum(pos);
@ -159,7 +163,7 @@ dir_seek(dir, pos)
{ {
DIR *dirp; DIR *dirp;
#if !defined(__CYGWIN32__) #if !defined(__CYGWIN32__) && !defined(__BEOS__)
GetDIR(dir, dirp); GetDIR(dir, dirp);
seekdir(dirp, NUM2INT(pos)); seekdir(dirp, NUM2INT(pos));
return dir; return dir;
@ -241,7 +245,7 @@ static VALUE
dir_s_chroot(dir, path) dir_s_chroot(dir, path)
VALUE dir, path; VALUE dir, path;
{ {
#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) #if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__)
rb_secure(2); rb_secure(2);
Check_SafeStr(path); Check_SafeStr(path);
@ -272,7 +276,7 @@ dir_s_mkdir(argc, argv, obj)
} }
Check_SafeStr(path); Check_SafeStr(path);
#ifndef NT #if !defined(NT) && !defined(USE_CWGUSI)
if (mkdir(RSTRING(path)->ptr, mode) == -1) if (mkdir(RSTRING(path)->ptr, mode) == -1)
rb_sys_fail(RSTRING(path)->ptr); rb_sys_fail(RSTRING(path)->ptr);
#else #else

111
dln.c
View file

@ -36,7 +36,9 @@ void *xrealloc();
#include <stdio.h> #include <stdio.h>
#ifndef NT #ifndef NT
# ifndef USE_CWGUSI
# include <sys/file.h> # include <sys/file.h>
# endif
#else #else
#include "missing/file.h" #include "missing/file.h"
#endif #endif
@ -58,6 +60,16 @@ char *strdup();
char *getenv(); char *getenv();
#endif #endif
#ifdef __MACOS__
# include <TextUtils.h>
# include <CodeFragments.h>
# include <Aliases.h>
#endif
#ifdef __BEOS__
# include <image.h>
#endif
int eaccess(); int eaccess();
#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) #if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT)
@ -81,7 +93,11 @@ init_funcname(buf, file)
/* Load the file as an object one */ /* Load the file as an object one */
for (p = file, slash = p-1; *p; p++) /* Find position of last '/' */ for (p = file, slash = p-1; *p; p++) /* Find position of last '/' */
#ifdef __MACOS__
if (*p == ':') slash = p;
#else
if (*p == '/') slash = p; if (*p == '/') slash = p;
#endif
sprintf(buf, FUNCNAME_PATTERN, slash + 1); sprintf(buf, FUNCNAME_PATTERN, slash + 1);
for (p = buf; *p; p++) { /* Delete suffix it it exists */ for (p = buf; *p; p++) { /* Delete suffix it it exists */
@ -1327,6 +1343,93 @@ dln_load(file)
} }
#endif #endif
#ifdef __BEOS__
# define DLN_DEFINED
{
status_t err_stat; /* BeOS error status code */
image_id img_id; /* extention module unique id */
void (*init_fct)(); /* initialize function for extention module */
/* load extention module */
img_id = load_add_on(file);
if (img_id <= 0) {
LoadError("Failed to load %.200s", file);
}
/* find symbol for module initialize function. */
/* The Be Book KernelKit Images section described to use
B_SYMBOL_TYPE_TEXT for symbol of function, not
B_SYMBOL_TYPE_CODE. Why ? */
/* strcat(init_fct_symname, "__Fv"); */ /* parameter nothing. */
/* "__Fv" dont need! The Be Book Bug ? */
err_stat = get_image_symbol(img_id, buf,
B_SYMBOL_TYPE_TEXT, &init_fct);
if ((B_BAD_IMAGE_ID == err_stat) || (B_BAD_INDEX == err_stat)) {
unload_add_on(img_id);
LoadError("Failed to lookup Init function %.200s", file);
}
else if (B_NO_ERROR != err_stat) {
char errmsg[] = "Internal of BeOS version. %.200s (symbol_name = %s)";
unload_add_on(img_id);
LoadError(errmsg, strerror(err_stat), buf);
}
/* call module initialize function. */
(*init_fct)();
return;
}
#endif /* __BEOS__*/
#ifdef __MACOS__
# define DLN_DEFINED
{
OSErr err;
FSSpec libspec;
CFragConnectionID connID;
Ptr mainAddr;
char errMessage[1024];
Boolean isfolder, didsomething;
Str63 fragname;
Ptr symAddr;
CFragSymbolClass class;
void (*init_fct)();
char fullpath[MAXPATHLEN];
extern LoadError();
strcpy(fullpath, file);
/* resolve any aliases to find the real file */
c2pstr(fullpath);
(void)FSMakeFSSpec(0, 0, fullpath, &libspec);
err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething);
if ( err ) {
LoadError("Unresolved Alias - %s", file);
}
/* Load the fragment (or return the connID if it is already loaded */
fragname[0] = 0;
err = GetDiskFragment(&libspec, 0, 0, fragname,
kLoadCFrag, &connID, &mainAddr,
errMessage);
if ( err ) {
p2cstr(errMessage);
LoadError("%s - %s",errMessage , file);
}
/* Locate the address of the correct init function */
c2pstr(buf);
err = FindSymbol(connID, buf, &symAddr, &class);
if ( err ) {
LoadError("Unresolved symbols - %s" , file);
}
init_fct = (void (*)())symAddr;
(*init_fct)();
return;
}
#endif /* __MACOS__ */
#ifndef DLN_DEFINED #ifndef DLN_DEFINED
rb_notimplement("dynamic link not supported"); rb_notimplement("dynamic link not supported");
#endif #endif
@ -1409,6 +1512,7 @@ dln_find_1(fname, path, exe_flag)
conv_to_posix_path(path, rubypath); conv_to_posix_path(path, rubypath);
path = rubypath; path = rubypath;
#endif #endif
#ifndef __MACOS__
if (fname[0] == '/') return fname; if (fname[0] == '/') return fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0) if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
return fname; return fname;
@ -1418,6 +1522,7 @@ dln_find_1(fname, path, exe_flag)
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0) if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
return fname; return fname;
#endif #endif
#endif /* __MACOS__ */
for (dp = path;; dp = ++ep) { for (dp = path;; dp = ++ep) {
register int l; register int l;
@ -1425,7 +1530,7 @@ dln_find_1(fname, path, exe_flag)
int fspace; int fspace;
/* extract a component */ /* extract a component */
#if !defined(MSDOS) && !defined(NT) && !defined(__human68k__) #if !defined(MSDOS) && !defined(NT) && !defined(__human68k__) && !defined(__MACOS__)
ep = strchr(dp, ':'); ep = strchr(dp, ':');
#else #else
ep = strchr(dp, ';'); ep = strchr(dp, ';');
@ -1473,7 +1578,11 @@ dln_find_1(fname, path, exe_flag)
/* add a "/" between directory and filename */ /* add a "/" between directory and filename */
if (ep[-1] != '/') if (ep[-1] != '/')
#ifdef __MACOS__
*bp++ = ':';
#else
*bp++ = '/'; *bp++ = '/';
#endif
} }
/* now append the file name */ /* now append the file name */

1
enum.c
View file

@ -356,6 +356,7 @@ enum_length(obj)
return INT2FIX(length); return INT2FIX(length);
} }
static VALUE
each_with_index_i(val, indexp) each_with_index_i(val, indexp)
VALUE val; VALUE val;
int *indexp; int *indexp;

222
error.c
View file

@ -13,7 +13,18 @@
#include "ruby.h" #include "ruby.h"
#include "env.h" #include "env.h"
#include <stdio.h> #include <stdio.h>
#ifdef __STDC__
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h> #include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
#ifdef USE_CWGUSI
#include <sys/errno.h>
int sys_nerr = 256;
#endif
extern char *sourcefile; extern char *sourcefile;
extern int sourceline; extern int sourceline;
@ -34,28 +45,7 @@ err_sprintf(buf, fmt, args)
} }
} }
static void static void err_append _((char*));
err_append(s)
char *s;
{
extern VALUE errinfo;
if (rb_in_eval) {
if (NIL_P(errinfo)) {
errinfo = str_new2(s);
}
else {
str_cat(errinfo, "\n", 1);
str_cat(errinfo, s, strlen(s));
}
}
else {
fputs(s, stderr);
fputs("\n", stderr);
fflush(stderr);
}
}
static void static void
err_print(fmt, args) err_print(fmt, args)
char *fmt; char *fmt;
@ -68,52 +58,68 @@ err_print(fmt, args)
} }
void void
#ifdef __STDC__
Error(char *fmt, ...)
#else
Error(fmt, va_alist) Error(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
va_list args; va_list args;
va_start(args); va_init_list(args, fmt);
err_print(fmt, args); err_print(fmt, args);
va_end(args); va_end(args);
nerrs++; nerrs++;
} }
void void
#ifdef __STDC__
Error_Append(char *fmt, ...)
#else
Error_Append(fmt, va_alist) Error_Append(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
va_list args; va_list args;
char buf[BUFSIZ]; char buf[BUFSIZ];
va_start(args); va_init_list(args, fmt);
vsprintf(buf, fmt, args); vsprintf(buf, fmt, args);
va_end(args); va_end(args);
err_append(buf); err_append(buf);
} }
void void
#ifdef __STDC__
Warn(char *fmt, ...)
#else
Warn(fmt, va_alist) Warn(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
va_list args; va_list args;
sprintf(buf, "warning: %s", fmt); sprintf(buf, "warning: %s", fmt);
va_start(args); va_init_list(args, fmt);
err_print(buf, args); err_print(buf, args);
va_end(args); va_end(args);
} }
/* Warning() reports only in verbose mode */ /* Warning() reports only in verbose mode */
void void
#ifdef __STDC__
Warning(char *fmt, ...)
#else
Warning(fmt, va_alist) Warning(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
va_list args; va_list args;
@ -122,15 +128,19 @@ Warning(fmt, va_alist)
sprintf(buf, "warning: %s", fmt); sprintf(buf, "warning: %s", fmt);
va_start(args); va_init_list(args, fmt);
err_print(buf, args); err_print(buf, args);
va_end(args); va_end(args);
} }
void void
#ifdef __STDC__
Bug(char *fmt, ...)
#else
Bug(fmt, va_alist) Bug(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
va_list args; va_list args;
@ -138,7 +148,7 @@ Bug(fmt, va_alist)
sprintf(buf, "[BUG] %s", fmt); sprintf(buf, "[BUG] %s", fmt);
rb_in_eval = 0; rb_in_eval = 0;
va_start(args); va_init_list(args, fmt);
err_print(buf, args); err_print(buf, args);
va_end(args); va_end(args);
abort(); abort();
@ -172,7 +182,9 @@ static struct types {
-1, 0, -1, 0,
}; };
#ifndef __STDC__
extern void TypeError(); extern void TypeError();
#endif
void void
rb_check_type(x, t) rb_check_type(x, t)
@ -369,7 +381,6 @@ exception(argc, argv)
int argc; int argc;
VALUE *argv; VALUE *argv;
{ {
void ArgError();
VALUE v = Qnil; VALUE v = Qnil;
VALUE etype = eStandardError; VALUE etype = eStandardError;
int i; int i;
@ -403,7 +414,60 @@ exception(argc, argv)
return v; return v;
} }
#ifdef __BEOS__
typedef struct {
VALUE *list;
size_t n;
} syserr_list_entry;
typedef struct {
int ix;
size_t n;
} syserr_index_entry;
static VALUE syserr_list_b_general[16+1];
static VALUE syserr_list_b_os0[2+1];
static VALUE syserr_list_b_os1[5+1];
static VALUE syserr_list_b_os2[2+1];
static VALUE syserr_list_b_os3[3+1];
static VALUE syserr_list_b_os4[1+1];
static VALUE syserr_list_b_app[15+1];
static VALUE syserr_list_b_interface[0+1];
static VALUE syserr_list_b_media[8+1];
static VALUE syserr_list_b_midi[0+1];
static VALUE syserr_list_b_storage[15+1];
static VALUE syserr_list_b_posix[38+1];
static VALUE syserr_list_b_mail[8+1];
static VALUE syserr_list_b_print[1+1];
static VALUE syserr_list_b_device[14+1];
# define SYSERR_LIST_B(n) {(n), sizeof(n)/sizeof(VALUE)}
static const syserr_list_entry syserr_list[] = {
SYSERR_LIST_B(syserr_list_b_general),
SYSERR_LIST_B(syserr_list_b_os0),
SYSERR_LIST_B(syserr_list_b_os1),
SYSERR_LIST_B(syserr_list_b_os2),
SYSERR_LIST_B(syserr_list_b_os3),
SYSERR_LIST_B(syserr_list_b_os4),
SYSERR_LIST_B(syserr_list_b_app),
SYSERR_LIST_B(syserr_list_b_interface),
SYSERR_LIST_B(syserr_list_b_media),
SYSERR_LIST_B(syserr_list_b_midi),
SYSERR_LIST_B(syserr_list_b_storage),
SYSERR_LIST_B(syserr_list_b_posix),
SYSERR_LIST_B(syserr_list_b_mail),
SYSERR_LIST_B(syserr_list_b_print),
SYSERR_LIST_B(syserr_list_b_device),
};
# undef SYSERR_LIST_B
static const syserr_index_entry syserr_index[]= {
{0, 1}, {1, 5}, {6, 1}, {7, 1}, {8, 1}, {9, 1}, {10, 1}, {11, 1},
{12, 1}, {13, 1}, {14, 1}, {0, 0},
};
#else
static VALUE *syserr_list; static VALUE *syserr_list;
#endif
#ifndef NT #ifndef NT
extern int sys_nerr; extern int sys_nerr;
@ -465,64 +529,84 @@ Init_Exception()
rb_define_global_function("Exception", exception, -1); rb_define_global_function("Exception", exception, -1);
} }
#define RAISE_ERROR(klass) {\ #define RAISE_ERROR(klass,fmt) {\
va_list args;\ va_list args;\
char buf[BUFSIZ];\ char buf[BUFSIZ];\
\ va_init_list(args,fmt);\
va_start(args);\
vsprintf(buf, fmt, args);\
va_end(args);\
\
rb_raise(exc_new2(klass, buf));\ rb_raise(exc_new2(klass, buf));\
} }
void void
#ifdef __STDC__
Raise(VALUE exc, char *fmt, ...)
#else
Raise(exc, fmt, va_alist) Raise(exc, fmt, va_alist)
VALUE exc; VALUE exc;
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
RAISE_ERROR(exc); RAISE_ERROR(exc, fmt);
} }
void void
#ifdef __STDC__
TypeError(char *fmt, ...)
#else
TypeError(fmt, va_alist) TypeError(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
RAISE_ERROR(eTypeError); RAISE_ERROR(eTypeError, fmt);
} }
void void
#ifdef __STDC__
ArgError(char *fmt, ...)
#else
ArgError(fmt, va_alist) ArgError(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
RAISE_ERROR(eArgError); RAISE_ERROR(eArgError, fmt);
} }
void void
#ifdef __STDC__
NameError(char *fmt, ...)
#else
NameError(fmt, va_alist) NameError(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
RAISE_ERROR(eNameError); RAISE_ERROR(eNameError, fmt);
} }
void void
#ifdef __STDC__
IndexError(char *fmt, ...)
#else
IndexError(fmt, va_alist) IndexError(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
RAISE_ERROR(eIndexError); RAISE_ERROR(eIndexError, fmt);
} }
void void
#ifdef __STDC__
Fail(char *fmt, ...)
#else
Fail(fmt, va_alist) Fail(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
RAISE_ERROR(eRuntimeError); RAISE_ERROR(eRuntimeError, fmt);
} }
void void
@ -534,22 +618,30 @@ rb_notimplement()
} }
void void
#ifdef __STDC__
LoadError(char *fmt, ...)
#else
LoadError(fmt, va_alist) LoadError(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
RAISE_ERROR(eLoadError); RAISE_ERROR(eLoadError, fmt);
} }
void void
#ifdef __STDC__
Fatal(char *fmt, ...)
#else
Fatal(fmt, va_alist) Fatal(fmt, va_alist)
char *fmt; char *fmt;
va_dcl va_dcl
#endif
{ {
va_list args; va_list args;
char buf[BUFSIZ]; char buf[BUFSIZ];
va_start(args); va_init_list(args, fmt);
vsprintf(buf, fmt, args); vsprintf(buf, fmt, args);
va_end(args); va_end(args);
@ -581,6 +673,26 @@ rb_sys_fail(mesg)
} }
errno = 0; errno = 0;
#ifdef __BEOS__
ee = get_syserr(n);
if (!ee) {
char name[6];
sprintf(name, "E%03d", n);
ee = set_syserr(n, name);
}
#else
# ifdef USE_CWGUSI
if (n < 0) {
int macoserr_index = sys_nerr - 1;
if (!syserr_list[macoserr_index]) {
char name[6];
sprintf(name, "E%03d", macoserr_index);
ee = set_syserr(macoserr_index, name);
}
}
else
#endif /* USE_CWGUSI */
if (n > sys_nerr || !syserr_list[n]) { if (n > sys_nerr || !syserr_list[n]) {
char name[6]; char name[6];
@ -591,6 +703,7 @@ rb_sys_fail(mesg)
ee = syserr_list[n]; ee = syserr_list[n];
} }
ee = exc_new2(ee, buf); ee = exc_new2(ee, buf);
#endif
rb_iv_set(ee, "errno", INT2FIX(n)); rb_iv_set(ee, "errno", INT2FIX(n));
rb_raise(ee); rb_raise(ee);
} }
@ -972,3 +1085,28 @@ init_syserr()
set_syserr(EDQUOT, "EDQUOT"); set_syserr(EDQUOT, "EDQUOT");
#endif #endif
} }
static void
err_append(s)
char *s;
{
extern VALUE errinfo;
if (rb_in_eval) {
if (NIL_P(errinfo)) {
errinfo = exc_new2(eSyntaxError, s);
}
else {
VALUE str = str_to_str(errinfo);
str_cat(str, "\n", 1);
str_cat(str, s, strlen(s));
errinfo = exc_new3(eSyntaxError, str);
}
}
else {
fputs(s, stderr);
fputs("\n", stderr);
fflush(stderr);
}
}

49
eval.c
View file

@ -28,6 +28,16 @@ char *strrchr _((char*,char));
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef __BEOS__
#include <net/socket.h>
#endif
#ifdef USE_CWGUSI
#include <sys/stat.h>
#include <sys/errno.h>
#include <compat.h>
#endif
#ifndef setjmp #ifndef setjmp
#ifdef HAVE__SETJMP #ifdef HAVE__SETJMP
#define setjmp(env) _setjmp(env) #define setjmp(env) _setjmp(env)
@ -35,6 +45,12 @@ char *strrchr _((char*,char));
#endif #endif
#endif #endif
#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__MACOS__)
#define RUBY_LIB_SEP ";"
#else
#define RUBY_LIB_SEP ":"
#endif
VALUE cProc; VALUE cProc;
static VALUE cBinding; static VALUE cBinding;
static VALUE proc_call _((VALUE,VALUE)); static VALUE proc_call _((VALUE,VALUE));
@ -800,7 +816,7 @@ error_print()
} }
} }
#ifndef NT #if !defined(NT) && !defined(__MACOS__)
extern char **environ; extern char **environ;
#endif #endif
char **origenviron; char **origenviron;
@ -821,7 +837,11 @@ ruby_init()
the_frame = top_frame = &frame; the_frame = top_frame = &frame;
the_iter = &iter; the_iter = &iter;
#ifdef __MACOS__
origenviron = 0;
#else
origenviron = environ; origenviron = environ;
#endif
init_heap(); init_heap();
PUSH_SCOPE(); PUSH_SCOPE();
@ -2664,10 +2684,6 @@ rb_iter_break()
JUMP_TAG(TAG_BREAK); JUMP_TAG(TAG_BREAK);
} }
#ifdef __GNUC__
static volatile voidfn rb_longjmp;
#endif
static VALUE make_backtrace _((void)); static VALUE make_backtrace _((void));
static void static void
@ -3085,7 +3101,7 @@ rb_rescue(b_proc, data1, r_proc, data2)
VALUE VALUE
rb_ensure(b_proc, data1, e_proc, data2) rb_ensure(b_proc, data1, e_proc, data2)
VALUE (*b_proc)(); VALUE (*b_proc)();
void (*e_proc)(); VALUE (*e_proc)();
VALUE data1, data2; VALUE data1, data2;
{ {
int state; int state;
@ -3589,14 +3605,24 @@ f_send(argc, argv, recv)
} }
#ifdef __STDC__
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h> #include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
VALUE VALUE
#ifdef __STDC__
rb_funcall(VALUE recv, ID mid, int n, ...)
#else
rb_funcall(recv, mid, n, va_alist) rb_funcall(recv, mid, n, va_alist)
VALUE recv; VALUE recv;
ID mid; ID mid;
int n; int n;
va_dcl va_dcl
#endif
{ {
va_list ar; va_list ar;
VALUE *argv; VALUE *argv;
@ -3606,7 +3632,7 @@ rb_funcall(recv, mid, n, va_alist)
argv = ALLOCA_N(VALUE, n); argv = ALLOCA_N(VALUE, n);
va_start(ar); va_init_list(ar, n);
for (i=0;i<n;i++) { for (i=0;i<n;i++) {
argv[i] = va_arg(ar, VALUE); argv[i] = va_arg(ar, VALUE);
} }
@ -4023,11 +4049,7 @@ find_file(file)
for (i=0;i<RARRAY(rb_load_path)->len;i++) { for (i=0;i<RARRAY(rb_load_path)->len;i++) {
Check_SafeStr(RARRAY(rb_load_path)->ptr[i]); Check_SafeStr(RARRAY(rb_load_path)->ptr[i]);
} }
#if !defined(MSDOS) && !defined(NT) && !defined(__human68k__) vpath = ary_join(rb_load_path, str_new2(RUBY_LIB_SEP));
vpath = ary_join(rb_load_path, str_new2(":"));
#else
vpath = ary_join(rb_load_path, str_new2(";"));
#endif
Check_SafeStr(vpath); Check_SafeStr(vpath);
path = RSTRING(vpath)->ptr; path = RSTRING(vpath)->ptr;
} }
@ -4048,9 +4070,11 @@ f_load(obj, fname)
TMP_PROTECT; TMP_PROTECT;
Check_SafeStr(fname); Check_SafeStr(fname);
#ifndef __MACOS__
if (RSTRING(fname)->ptr[0] == '~') { if (RSTRING(fname)->ptr[0] == '~') {
fname = file_s_expand_path(0, fname); fname = file_s_expand_path(0, fname);
} }
#endif
file = find_file(RSTRING(fname)->ptr); file = find_file(RSTRING(fname)->ptr);
if (!file) LoadError("No such file to load -- %s", RSTRING(fname)->ptr); if (!file) LoadError("No such file to load -- %s", RSTRING(fname)->ptr);
@ -6498,3 +6522,4 @@ return_check()
} }
#endif #endif
} }

View file

@ -15,6 +15,9 @@
#include <ndbm.h> #include <ndbm.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#ifdef USE_CWGUSI
# include <sys/errno.h>
#endif
VALUE cDBM; VALUE cDBM;
@ -331,7 +334,7 @@ fdbm_store(obj, keystr, valstr)
#ifdef HAVE_DBM_CLAERERR #ifdef HAVE_DBM_CLAERERR
dbm_clearerr(dbm); dbm_clearerr(dbm);
#endif #endif
if (errno == EPERM) rb_sys_fail(Qnil); if (errno == EPERM) rb_sys_fail(0);
Fail("dbm_store failed"); Fail("dbm_store failed");
} }

View file

@ -52,7 +52,9 @@ setup_passwd(pwd)
str_new2(pwd->pw_passwd), str_new2(pwd->pw_passwd),
INT2FIX(pwd->pw_uid), INT2FIX(pwd->pw_uid),
INT2FIX(pwd->pw_gid), INT2FIX(pwd->pw_gid),
#ifdef PW_GECOS
str_new2(pwd->pw_gecos), str_new2(pwd->pw_gecos),
#endif
str_new2(pwd->pw_dir), str_new2(pwd->pw_dir),
str_new2(pwd->pw_shell), str_new2(pwd->pw_shell),
#ifdef PW_CHANGE #ifdef PW_CHANGE

View file

@ -61,6 +61,9 @@ md5_clone(obj)
static VALUE static VALUE
md5_new(argc, argv, class) md5_new(argc, argv, class)
int argc;
VALUE* argv;
VALUE class;
{ {
int i; int i;
VALUE arg, obj; VALUE arg, obj;

View file

@ -22,6 +22,13 @@
#include <sys/un.h> #include <sys/un.h>
#endif #endif
#ifdef USE_CWGUSI
extern int fileno(FILE *stream); /* <unix.mac.h> */
extern int thread_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /* thread.c */
# include <sys/errno.h>
# include <GUSI.h>
#endif
#if defined(THREAD) && defined(HAVE_FCNTL) #if defined(THREAD) && defined(HAVE_FCNTL)
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
#include <sys/select.h> #include <sys/select.h>
@ -168,6 +175,7 @@ static VALUE
bsock_getsockopt(sock, lev, optname) bsock_getsockopt(sock, lev, optname)
VALUE sock, lev, optname; VALUE sock, lev, optname;
{ {
#if !defined(__BEOS__)
int level, option, len; int level, option, len;
char *buf; char *buf;
OpenFile *fptr; OpenFile *fptr;
@ -182,6 +190,9 @@ bsock_getsockopt(sock, lev, optname)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
return str_new(buf, len); return str_new(buf, len);
#else
rb_notimplement();
#endif
} }
static VALUE static VALUE
@ -401,7 +412,11 @@ thread_connect(fd, sockaddr, len, type)
#endif #endif
FD_ZERO(&fds); FD_ZERO(&fds);
FD_SET(fd, &fds); FD_SET(fd, &fds);
#ifndef USE_CWGUSI
thread_select(fd+1, 0, &fds, 0, 0, 0); thread_select(fd+1, 0, &fds, 0, 0, 0);
#else
thread_select(fd+1, 0, &fds, 0, 0);
#endif
continue; continue;
#endif #endif
@ -446,7 +461,11 @@ open_inet(class, h, serv, type)
host = RSTRING(h)->ptr; host = RSTRING(h)->ptr;
hostent = gethostbyname(host); hostent = gethostbyname(host);
if (hostent == NULL) { if (hostent == NULL) {
#ifndef USE_CWGUSI
hostaddr = inet_addr(host); hostaddr = inet_addr(host);
#else
hostaddr = inet_addr(host).s_addr;
#endif
if (hostaddr == -1) { if (hostaddr == -1) {
if (type == INET_SERVER && !strlen(host)) if (type == INET_SERVER && !strlen(host))
hostaddr = INADDR_ANY; hostaddr = INADDR_ANY;
@ -484,12 +503,16 @@ open_inet(class, h, serv, type)
_servent.s_proto = "tcp"; _servent.s_proto = "tcp";
servent = &_servent; servent = &_servent;
} }
#ifdef __BEOS__
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
#else
protoent = getprotobyname(servent->s_proto); protoent = getprotobyname(servent->s_proto);
if (protoent == NULL) { if (protoent == NULL) {
Raise(eSocket, "no such proto %s", servent->s_proto); Raise(eSocket, "no such proto %s", servent->s_proto);
} }
fd = socket(AF_INET, SOCK_STREAM, protoent->p_proto); fd = socket(AF_INET, SOCK_STREAM, protoent->p_proto);
#endif
memset(&sockaddr, 0, sizeof(sockaddr)); memset(&sockaddr, 0, sizeof(sockaddr));
sockaddr.sin_family = AF_INET; sockaddr.sin_family = AF_INET;
@ -1060,8 +1083,10 @@ setup_domain_and_type(domain, dv, type, tv)
else if (strcmp(ptr, "AF_IMPLINK") == 0) else if (strcmp(ptr, "AF_IMPLINK") == 0)
*dv = AF_IMPLINK; *dv = AF_IMPLINK;
#endif #endif
#ifdef PF_INET
else if (strcmp(ptr, "PF_INET") == 0) else if (strcmp(ptr, "PF_INET") == 0)
*dv = PF_INET; *dv = PF_INET;
#endif
#ifdef PF_UNIX #ifdef PF_UNIX
else if (strcmp(ptr, "PF_UNIX") == 0) else if (strcmp(ptr, "PF_UNIX") == 0)
*dv = PF_UNIX; *dv = PF_UNIX;
@ -1474,7 +1499,9 @@ Init_socket()
mConst = rb_define_module_under(cSocket, "Constants"); mConst = rb_define_module_under(cSocket, "Constants");
sock_define_const("SOCK_STREAM", SOCK_STREAM); sock_define_const("SOCK_STREAM", SOCK_STREAM);
sock_define_const("SOCK_DGRAM", SOCK_DGRAM); sock_define_const("SOCK_DGRAM", SOCK_DGRAM);
#ifdef SOCK_RAW
sock_define_const("SOCK_RAW", SOCK_RAW); sock_define_const("SOCK_RAW", SOCK_RAW);
#endif
#ifdef SOCK_RDM #ifdef SOCK_RDM
sock_define_const("SOCK_RDM", SOCK_RDM); sock_define_const("SOCK_RDM", SOCK_RDM);
#endif #endif
@ -1486,7 +1513,9 @@ Init_socket()
#endif #endif
sock_define_const("AF_INET", AF_INET); sock_define_const("AF_INET", AF_INET);
#ifdef PF_INET
sock_define_const("PF_INET", PF_INET); sock_define_const("PF_INET", PF_INET);
#endif
#ifdef AF_UNIX #ifdef AF_UNIX
sock_define_const("AF_UNIX", AF_UNIX); sock_define_const("AF_UNIX", AF_UNIX);
sock_define_const("PF_UNIX", PF_UNIX); sock_define_const("PF_UNIX", PF_UNIX);
@ -1505,8 +1534,12 @@ Init_socket()
#endif #endif
sock_define_const("MSG_OOB", MSG_OOB); sock_define_const("MSG_OOB", MSG_OOB);
#ifdef MSG_PEEK
sock_define_const("MSG_PEEK", MSG_PEEK); sock_define_const("MSG_PEEK", MSG_PEEK);
#endif
#ifdef MSG_DONTROUTE
sock_define_const("MSG_DONTROUTE", MSG_DONTROUTE); sock_define_const("MSG_DONTROUTE", MSG_DONTROUTE);
#endif
sock_define_const("SOL_SOCKET", SOL_SOCKET); sock_define_const("SOL_SOCKET", SOL_SOCKET);
#ifdef SOL_IP #ifdef SOL_IP
@ -1550,7 +1583,9 @@ Init_socket()
#ifdef SO_RCVBUF #ifdef SO_RCVBUF
sock_define_const("SO_RCVBUF", SO_RCVBUF); sock_define_const("SO_RCVBUF", SO_RCVBUF);
#endif #endif
#ifdef SO_KEEPALIVE
sock_define_const("SO_KEEPALIVE", SO_KEEPALIVE); sock_define_const("SO_KEEPALIVE", SO_KEEPALIVE);
#endif
#ifdef SO_OOBINLINE #ifdef SO_OOBINLINE
sock_define_const("SO_OOBINLINE", SO_OOBINLINE); sock_define_const("SO_OOBINLINE", SO_OOBINLINE);
#endif #endif
@ -1560,7 +1595,9 @@ Init_socket()
#ifdef SO_PRIORITY #ifdef SO_PRIORITY
sock_define_const("SO_PRIORITY", SO_PRIORITY); sock_define_const("SO_PRIORITY", SO_PRIORITY);
#endif #endif
#ifdef SO_LINGER
sock_define_const("SO_LINGER", SO_LINGER); sock_define_const("SO_LINGER", SO_LINGER);
#endif
#ifdef SOPRI_INTERACTIVE #ifdef SOPRI_INTERACTIVE
sock_define_const("SOPRI_INTERACTIVE", SOPRI_INTERACTIVE); sock_define_const("SOPRI_INTERACTIVE", SOPRI_INTERACTIVE);

View file

@ -11,6 +11,11 @@
#include <tcl.h> #include <tcl.h>
#include <tk.h> #include <tk.h>
#ifdef __MACOS__
# include <tkMac.h>
# include <Quickdraw.h>
#endif
/* for debug */ /* for debug */
#define DUMP1(ARG1) if (debug) { fprintf(stderr, "tcltklib: %s\n", ARG1);} #define DUMP1(ARG1) if (debug) { fprintf(stderr, "tcltklib: %s\n", ARG1);}
@ -112,7 +117,7 @@ ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
DUMP2("rb_eval_string(%s)", argv[1]); DUMP2("rb_eval_string(%s)", argv[1]);
old_trapflg = trap_immediate; old_trapflg = trap_immediate;
trap_immediate = 0; trap_immediate = 0;
res = rb_rescue(rb_eval_string, argv[1], ip_eval_rescue, &failed); res = rb_rescue(rb_eval_string, (VALUE)argv[1], ip_eval_rescue, (VALUE)&failed);
trap_immediate = old_trapflg; trap_immediate = old_trapflg;
if (failed) { if (failed) {
@ -253,6 +258,15 @@ ip_retval(VALUE self)
return (INT2FIX(ptr->return_value)); return (INT2FIX(ptr->return_value));
} }
#ifdef __MACOS__
static void
_macinit()
{
tcl_macQdPtr = &qd; /* setup QuickDraw globals */
Tcl_MacSetEventProc(TkMacConvertEvent); /* setup event handler */
}
#endif
/*---- initialization ----*/ /*---- initialization ----*/
void Init_tcltklib() void Init_tcltklib()
{ {
@ -269,6 +283,10 @@ void Init_tcltklib()
rb_define_method(ip, "_return_value", ip_retval, 0); rb_define_method(ip, "_return_value", ip_retval, 0);
rb_define_method(ip, "mainloop", lib_mainloop, 0); rb_define_method(ip, "mainloop", lib_mainloop, 0);
#ifdef __MACOS__
_macinit();
#endif
/*---- initialize tcl/tk libraries ----*/ /*---- initialize tcl/tk libraries ----*/
/* from Tk_Main() */ /* from Tk_Main() */
DUMP1("Tcl_FindExecutable"); DUMP1("Tcl_FindExecutable");

26
file.c
View file

@ -54,6 +54,12 @@ char *strdup();
char *getenv(); char *getenv();
#endif #endif
#ifdef USE_CWGUSI
#include "macruby_missing.h"
extern int fileno(FILE *stream);
extern int utimes();
#endif
extern VALUE cIO; extern VALUE cIO;
VALUE cFile; VALUE cFile;
VALUE mFileTest; VALUE mFileTest;
@ -190,7 +196,9 @@ file_path(obj)
} }
#ifndef NT #ifndef NT
# ifndef USE_CWGUSI
# include <sys/file.h> # include <sys/file.h>
# endif
#else #else
#include "missing/file.h" #include "missing/file.h"
#endif #endif
@ -309,7 +317,7 @@ static int
group_member(gid) group_member(gid)
GETGROUPS_T gid; GETGROUPS_T gid;
{ {
#ifndef NT #if !defined(NT) && !defined(USE_CWGUSI)
if (getgid() == gid || getegid() == gid) if (getgid() == gid || getegid() == gid)
return TRUE; return TRUE;
@ -853,7 +861,7 @@ file_chmod(obj, vmode)
mode = NUM2INT(vmode); mode = NUM2INT(vmode);
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
#if defined(DJGPP) || defined(NT) #if defined(DJGPP) || defined(NT) || defined(USE_CWGUSI) || defined(__BEOS__)
if (chmod(fptr->path, mode) == -1) if (chmod(fptr->path, mode) == -1)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
#else #else
@ -912,7 +920,7 @@ file_chown(obj, owner, group)
rb_secure(2); rb_secure(2);
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
#if defined(DJGPP) || defined(__CYGWIN32__) || defined(NT) #if defined(DJGPP) || defined(__CYGWIN32__) || defined(NT) || defined(USE_CWGUSI)
if (chown(fptr->path, NUM2INT(owner), NUM2INT(group)) == -1) if (chown(fptr->path, NUM2INT(owner), NUM2INT(group)) == -1)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
#else #else
@ -1004,12 +1012,16 @@ static VALUE
file_s_link(obj, from, to) file_s_link(obj, from, to)
VALUE obj, from, to; VALUE obj, from, to;
{ {
#if defined(USE_CWGUSI)
rb_notimplement();
#else
Check_SafeStr(from); Check_SafeStr(from);
Check_SafeStr(to); Check_SafeStr(to);
if (link(RSTRING(from)->ptr, RSTRING(to)->ptr) < 0) if (link(RSTRING(from)->ptr, RSTRING(to)->ptr) < 0)
rb_sys_fail(RSTRING(from)->ptr); rb_sys_fail(RSTRING(from)->ptr);
return INT2FIX(0); return INT2FIX(0);
#endif /* USE_CWGUSI */
} }
static VALUE static VALUE
@ -1083,6 +1095,9 @@ file_s_umask(argc, argv)
int argc; int argc;
VALUE *argv; VALUE *argv;
{ {
#ifdef USE_CWGUSI
rb_notimplement();
#else
int omask = 0; int omask = 0;
if (argc == 0) { if (argc == 0) {
@ -1096,6 +1111,7 @@ file_s_umask(argc, argv)
ArgError("wrong # of argument"); ArgError("wrong # of argument");
} }
return INT2FIX(omask); return INT2FIX(omask);
#endif /* USE_CWGUSI */
} }
VALUE VALUE
@ -1378,6 +1394,9 @@ file_flock(obj, operation)
VALUE obj; VALUE obj;
VALUE operation; VALUE operation;
{ {
#ifdef USE_CWGUSI
rb_notimplement();
#else
OpenFile *fptr; OpenFile *fptr;
rb_secure(2); rb_secure(2);
@ -1392,6 +1411,7 @@ file_flock(obj, operation)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
} }
return INT2FIX(0); return INT2FIX(0);
#endif /* USE_CWGUSI */
} }
#undef flock #undef flock

View file

@ -20,6 +20,10 @@ Cambridge, MA 02139, USA. */
#include <errno.h> #include <errno.h>
#include "fnmatch.h" #include "fnmatch.h"
#ifdef USE_CWGUSI
#include <sys/errno.h>
#endif
#if !defined (__GNU_LIBRARY__) && !defined (STDC_HEADERS) #if !defined (__GNU_LIBRARY__) && !defined (STDC_HEADERS)
# if !defined (errno) # if !defined (errno)
extern int errno; extern int errno;

3
gc.c
View file

@ -19,6 +19,9 @@
#include <stdio.h> #include <stdio.h>
#include <setjmp.h> #include <setjmp.h>
void re_free_registers _((struct re_registers*));
void io_fptr_finalize _((struct OpenFile*));
#ifndef setjmp #ifndef setjmp
#ifdef HAVE__SETJMP #ifdef HAVE__SETJMP
#define setjmp(env) _setjmp(env) #define setjmp(env) _setjmp(env)

2
glob.c
View file

@ -52,7 +52,7 @@
# endif /* !USG */ # endif /* !USG */
#endif /* !HAVE_DIRENT_H */ #endif /* !HAVE_DIRENT_H */
#if defined (_POSIX_SOURCE) || defined(DJGPP) #if defined (_POSIX_SOURCE) || defined(DJGPP) || defined(USE_CWGUSI)
/* Posix does not require that the d_ino field be present, and some /* Posix does not require that the d_ino field be present, and some
systems do not provide it. */ systems do not provide it. */
# define REAL_DIR_ENTRY(dp) 1 # define REAL_DIR_ENTRY(dp) 1

11
hash.c
View file

@ -156,7 +156,7 @@ hash_delete_nil(key, value)
return ST_CONTINUE; return ST_CONTINUE;
} }
static void static VALUE
hash_foreach_ensure(hash) hash_foreach_ensure(hash)
VALUE hash; VALUE hash;
{ {
@ -774,6 +774,8 @@ hash_update(hash1, hash2)
return hash1; return hash1;
} }
#ifndef __MACOS__ /* environment variables nothing on MacOS. */
int env_path_tainted(); int env_path_tainted();
static int path_tainted = -1; static int path_tainted = -1;
@ -1131,6 +1133,8 @@ env_to_hash(obj)
return hash; return hash;
} }
#endif /* ifndef __MACOS__ environment variables nothing on MacOS. */
void void
Init_Hash() Init_Hash()
{ {
@ -1188,6 +1192,7 @@ Init_Hash()
rb_define_method(cHash,"key?", hash_has_key, 1); rb_define_method(cHash,"key?", hash_has_key, 1);
rb_define_method(cHash,"value?", hash_has_value, 1); rb_define_method(cHash,"value?", hash_has_value, 1);
#ifndef __MACOS__ /* environment variables nothing on MacOS. */
envtbl = obj_alloc(cObject); envtbl = obj_alloc(cObject);
rb_extend_object(envtbl, mEnumerable); rb_extend_object(envtbl, mEnumerable);
@ -1216,4 +1221,8 @@ Init_Hash()
rb_define_singleton_method(envtbl,"to_hash", env_to_hash, 0); rb_define_singleton_method(envtbl,"to_hash", env_to_hash, 0);
rb_define_global_const("ENV", envtbl); rb_define_global_const("ENV", envtbl);
#else /* __MACOS__ */
envtbl = hash_s_new(0, NULL, cHash);
rb_define_global_const("ENV", envtbl);
#endif /* ifndef __MACOS__ environment variables nothing on MacOS. */
} }

View file

@ -7,9 +7,10 @@ void memclear _((register VALUE*, register int));
VALUE assoc_new _((VALUE, VALUE)); VALUE assoc_new _((VALUE, VALUE));
VALUE ary_new _((void)); VALUE ary_new _((void));
VALUE ary_new2 _((int)); VALUE ary_new2 _((int));
VALUE ary_new3(); VALUE ary_new3 _((int,...));
VALUE ary_new4 _((int, VALUE *)); VALUE ary_new4 _((int, VALUE *));
VALUE ary_freeze _((VALUE)); VALUE ary_freeze _((VALUE));
VALUE ary_aref(int, VALUE*, VALUE);
void ary_store _((VALUE, int, VALUE)); void ary_store _((VALUE, int, VALUE));
VALUE ary_push _((VALUE, VALUE)); VALUE ary_push _((VALUE, VALUE));
VALUE ary_pop _((VALUE)); VALUE ary_pop _((VALUE));
@ -83,19 +84,11 @@ VALUE enum_length _((VALUE));
VALUE exc_new _((VALUE, char*, unsigned int)); VALUE exc_new _((VALUE, char*, unsigned int));
VALUE exc_new2 _((VALUE, char*)); VALUE exc_new2 _((VALUE, char*));
VALUE exc_new3 _((VALUE, VALUE)); VALUE exc_new3 _((VALUE, VALUE));
#ifdef __GNUC__ void TypeError _((char*, ...));
volatile voidfn TypeError; void ArgError _((char*, ...));
volatile voidfn ArgError; void NameError _((char*, ...));
volatile voidfn NameError; void IndexError _((char*, ...));
volatile voidfn IndexError; void LoadError _((char*, ...));
volatile voidfn LoadError;
#else
void TypeError();
void ArgError();
void NameError();
void IndexError();
void LoadError();
#endif
/* eval.c */ /* eval.c */
void rb_remove_method _((VALUE, char*)); void rb_remove_method _((VALUE, char*));
void rb_disable_super _((VALUE, char*)); void rb_disable_super _((VALUE, char*));
@ -267,8 +260,8 @@ VALUE str_upto _((VALUE, VALUE));
VALUE str_inspect _((VALUE)); VALUE str_inspect _((VALUE));
VALUE str_split _((VALUE, char*)); VALUE str_split _((VALUE, char*));
/* struct.c */ /* struct.c */
VALUE struct_new(); VALUE struct_new _((VALUE, ...));
VALUE struct_define(); VALUE struct_define _((char*, ...));
VALUE struct_alloc _((VALUE, VALUE)); VALUE struct_alloc _((VALUE, VALUE));
VALUE struct_aref _((VALUE, VALUE)); VALUE struct_aref _((VALUE, VALUE));
VALUE struct_aset _((VALUE, VALUE, VALUE)); VALUE struct_aset _((VALUE, VALUE, VALUE));

50
io.c
View file

@ -53,6 +53,17 @@ struct timeval {
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef USE_CWGUSI
#include <sys/errno.h>
#include <unix.mac.h>
#include <compat.h>
extern void Init_File();
#endif
#ifdef __BEOS__
#include <net/socket.h>
#endif
VALUE rb_ad_string(); VALUE rb_ad_string();
VALUE cIO; VALUE cIO;
@ -87,8 +98,14 @@ struct timeval time_timeval();
# ifdef FILE_COUNT # ifdef FILE_COUNT
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0) # define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
# else # else
# if defined(__BEOS__)
# define ReadDataPending(fp) (fp->state._eof == 0)
# elif defined(USE_CWGUSI)
# define ReadDataPending(fp) (fp->state.eof == 0)
# else
/* requires systems own version of the ReadDataPending() */ /* requires systems own version of the ReadDataPending() */
extern int ReadDataPending(); extern int ReadDataPending();
# endif
# define READ_DATA_PENDING(fp) ReadDataPending(fp) # define READ_DATA_PENDING(fp) ReadDataPending(fp)
# endif # endif
#endif #endif
@ -354,7 +371,12 @@ read_all(port)
GetOpenFile(port, fptr); GetOpenFile(port, fptr);
io_readable(fptr); io_readable(fptr);
#ifdef __BEOS__
if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode)
&& (st.st_dev > 3)) {
#else
if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode)) { if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode)) {
#endif
if (st.st_size == 0) return Qnil; if (st.st_size == 0) return Qnil;
else { else {
int pos = ftell(fptr->f); int pos = ftell(fptr->f);
@ -866,7 +888,7 @@ VALUE
io_binmode(io) io_binmode(io)
VALUE io; VALUE io;
{ {
#if defined(NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__) #if defined(NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__) || defined(USE_CWGUSI)
OpenFile *fptr; OpenFile *fptr;
GetOpenFile(io, fptr); GetOpenFile(io, fptr);
@ -876,10 +898,17 @@ io_binmode(io)
if (fptr->f2) if (fptr->f2)
fmode(fptr->f2, _IOBIN); fmode(fptr->f2, _IOBIN);
#else #else
# ifndef USE_CWGUSI
if (fptr->f && setmode(fileno(fptr->f), O_BINARY) == -1) if (fptr->f && setmode(fileno(fptr->f), O_BINARY) == -1)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
if (fptr->f2 && setmode(fileno(fptr->f2), O_BINARY) == -1) if (fptr->f2 && setmode(fileno(fptr->f2), O_BINARY) == -1)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
# else /* USE_CWGUSI */
if (fptr->f)
fptr->f->mode.binary_io = 1;
if (fptr->f2)
fptr->f2->mode.binary_io = 1;
# endif /* USE_CWGUSI */
#endif #endif
fptr->mode |= FMODE_BINMODE; fptr->mode |= FMODE_BINMODE;
@ -1046,6 +1075,7 @@ static VALUE
pipe_open(pname, mode) pipe_open(pname, mode)
char *pname, *mode; char *pname, *mode;
{ {
#ifndef USE_CWGUSI
int modef = io_mode_flags(mode); int modef = io_mode_flags(mode);
OpenFile *fptr; OpenFile *fptr;
@ -1159,6 +1189,9 @@ pipe_open(pname, mode)
} }
} }
#endif #endif
#else /* USE_CWGUSI */
rb_notimplement();
#endif
} }
static VALUE static VALUE
@ -1717,16 +1750,17 @@ next_argv()
#endif #endif
} }
fw = rb_fopen(fn, "w"); fw = rb_fopen(fn, "w");
#if !defined(MSDOS) && !defined(__CYGWIN32__) && !(NT) && !defined(__human68k__) #if !defined(MSDOS) && !defined(__CYGWIN32__) && !(NT) && !defined(__human68k__)\
&& !defined(USE_CWGUSI) && !defined(__BEOS__)
fstat(fileno(fw), &st2); fstat(fileno(fw), &st2);
fchmod(fileno(fw), st.st_mode); fchmod(fileno(fw), st.st_mode);
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) { if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
fchown(fileno(fw), st.st_uid, st.st_gid); fchown(fileno(fw), st.st_uid, st.st_gid);
} }
#endif #endif
rb_defout = prep_stdio(fw, FMODE_WRITABLE, cIO); rb_defout = prep_stdio(fw, FMODE_WRITABLE, cFile);
} }
file = prep_stdio(fr, FMODE_READABLE, cIO); file = prep_stdio(fr, FMODE_READABLE, cFile);
} }
} }
else { else {
@ -2107,7 +2141,11 @@ io_ctl(io, req, arg, io_p)
} }
fd = fileno(fptr->f); fd = fileno(fptr->f);
#ifdef HAVE_FCNTL #ifdef HAVE_FCNTL
# ifdef USE_CWGUSI
retval = io_p?ioctl(fd, cmd, (void*) narg):fcntl(fd, cmd, narg);
# else
retval = io_p?ioctl(fd, cmd, narg):fcntl(fd, cmd, narg); retval = io_p?ioctl(fd, cmd, narg):fcntl(fd, cmd, narg);
# endif
#else #else
if (!io_p) { if (!io_p) {
rb_notimplement(); rb_notimplement();
@ -2306,7 +2344,7 @@ io_s_foreach(argc, argv, io)
arg.argc = argc - 1; arg.argc = argc - 1;
arg.io = io_open(RSTRING(fname)->ptr, "r"); arg.io = io_open(RSTRING(fname)->ptr, "r");
return rb_ensure(io_foreach_line, &arg, io_close, arg.io); return rb_ensure(io_foreach_line, (VALUE)&arg, io_close, arg.io);
} }
static VALUE static VALUE
@ -2337,7 +2375,7 @@ io_s_readlines(argc, argv, io)
arg.argc = argc - 1; arg.argc = argc - 1;
arg.io = io_open(RSTRING(fname)->ptr, "r"); arg.io = io_open(RSTRING(fname)->ptr, "r");
return rb_ensure(io_readline_line, &arg, io_close, arg.io); return rb_ensure(io_readline_line, (VALUE)&arg, io_close, arg.io);
} }
static VALUE static VALUE

View file

@ -445,7 +445,7 @@ marshal_dump(argc, argv)
w_byte(MARSHAL_MAJOR, &arg); w_byte(MARSHAL_MAJOR, &arg);
w_byte(MARSHAL_MINOR, &arg); w_byte(MARSHAL_MINOR, &arg);
rb_ensure(dump, &c_arg, dump_ensure, &arg); rb_ensure(dump, (VALUE)&c_arg, dump_ensure, (VALUE)&arg);
return port; return port;
} }
@ -846,7 +846,7 @@ marshal_load(argc, argv)
arg.data = st_init_numtable(); arg.data = st_init_numtable();
if (NIL_P(proc)) arg.proc = 0; if (NIL_P(proc)) arg.proc = 0;
else arg.proc = proc; else arg.proc = proc;
v = rb_ensure(load, &arg, load_ensure, &arg); v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
} }
else { else {
TypeError("Old marshal file format (can't read)"); TypeError("Old marshal file format (can't read)");

View file

@ -12,6 +12,7 @@
#include "ruby.h" #include "ruby.h"
#include <math.h> #include <math.h>
#include <stdio.h>
static ID coerce; static ID coerce;
static ID to_i; static ID to_i;
@ -42,12 +43,14 @@ num_coerce(x, y)
return assoc_new(rb_Float(x), rb_Float(y)); return assoc_new(rb_Float(x), rb_Float(y));
} }
static VALUE
coerce_body(x) coerce_body(x)
VALUE *x; VALUE *x;
{ {
return rb_funcall(x[1], coerce, 1, x[0]); return rb_funcall(x[1], coerce, 1, x[0]);
} }
static VALUE
coerce_rescue(x) coerce_rescue(x)
VALUE *x; VALUE *x;
{ {
@ -66,7 +69,7 @@ do_coerce(x, y)
VALUE a[2]; VALUE a[2];
a[0] = *x; a[1] = *y; a[0] = *x; a[1] = *y;
ary = rb_rescue(coerce_body, a, coerce_rescue, a); ary = rb_rescue(coerce_body, (VALUE)a, coerce_rescue, (VALUE)a);
if (TYPE(ary) != T_ARRAY || RARRAY(ary)->len != 2) { if (TYPE(ary) != T_ARRAY || RARRAY(ary)->len != 2) {
TypeError("coerce must return [x, y]"); TypeError("coerce must return [x, y]");
} }

View file

@ -15,7 +15,11 @@
#include <stdio.h> #include <stdio.h>
VALUE mKernel; VALUE mKernel;
#ifdef __MACOS__ /* name conflict AERegistory.h */
VALUE cRubyObject;
#else
VALUE cObject; VALUE cObject;
#endif
VALUE cModule; VALUE cModule;
VALUE cClass; VALUE cClass;
extern VALUE cFixnum; extern VALUE cFixnum;
@ -776,7 +780,7 @@ rb_convert_type(val, type, tname, method)
arg1.val = arg2.val = val; arg1.val = arg2.val = val;
arg1.s = method; arg1.s = method;
arg2.s = tname; arg2.s = tname;
val = rb_rescue(to_type, &arg1, fail_to_type, &arg2); val = rb_rescue(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2);
Check_Type(val, type); Check_Type(val, type);
return val; return val;
} }

View file

@ -1545,6 +1545,7 @@ yyerror(msg)
{ {
UCHAR *p, *pe, *buf; UCHAR *p, *pe, *buf;
int len, i; int len, i;
void Error_Append();
Error("%s", msg); Error("%s", msg);
p = lex_p; p = lex_p;

View file

@ -43,6 +43,11 @@ struct timeval time_timeval();
#endif #endif
#include "st.h" #include "st.h"
#ifdef USE_CWGUSI
# include <sys/errno.h>
# include "macruby_missing.h"
#endif
static VALUE static VALUE
get_pid() get_pid()
{ {
@ -256,9 +261,11 @@ security(str)
extern VALUE eSecurityError; extern VALUE eSecurityError;
if (rb_safe_level() > 0) { if (rb_safe_level() > 0) {
#ifndef USE_CWGUSI
if (env_path_tainted()) { if (env_path_tainted()) {
Raise(eSecurityError, "Insecure PATH - %s", str); Raise(eSecurityError, "Insecure PATH - %s", str);
} }
#endif
} }
} }
@ -267,6 +274,7 @@ proc_exec_v(argv, prog)
char **argv; char **argv;
char *prog; char *prog;
{ {
#ifndef USE_CWGUSI
if (prog) { if (prog) {
security(prog); security(prog);
} }
@ -315,6 +323,9 @@ proc_exec_v(argv, prog)
execv(prog, argv); execv(prog, argv);
after_exec(); after_exec();
return -1; return -1;
#else /* USE_CWGUSI */
rb_notimplement();
#endif /* USE_CWGUSI */
} }
static int static int
@ -347,6 +358,7 @@ int
rb_proc_exec(str) rb_proc_exec(str)
char *str; char *str;
{ {
#ifndef USE_CWGUSI
char *s = str, *t; char *s = str, *t;
char **argv, **a; char **argv, **a;
@ -395,6 +407,9 @@ rb_proc_exec(str)
} }
errno = ENOENT; errno = ENOENT;
return -1; return -1;
#else /* USE_CWGUSI */
rb_notimplement();
#endif /* USE_CWGUSI */
} }
#if defined(__human68k__) #if defined(__human68k__)
@ -568,7 +583,11 @@ f_exit_bang(obj, status)
code = INT2FIX(status); code = INT2FIX(status);
} }
#ifdef USE_CWGUSI
exit(code);
#else
_exit(code); _exit(code);
#endif
/* not reached */ /* not reached */
} }
@ -772,7 +791,7 @@ f_sleep(argc, argv)
return INT2FIX(end); return INT2FIX(end);
} }
#if !defined(NT) && !defined(DJGPP) && !defined(__human68k__) #if !defined(NT) && !defined(DJGPP) && !defined(__human68k__) && !defined(USE_CWGUSI)
static VALUE static VALUE
proc_getpgrp(argc, argv) proc_getpgrp(argc, argv)
int argc; int argc;
@ -794,6 +813,7 @@ proc_getpgrp(argc, argv)
return INT2FIX(pgrp); return INT2FIX(pgrp);
} }
#ifdef HAVE_SETPGRP
static VALUE static VALUE
proc_setpgrp(argc, argv) proc_setpgrp(argc, argv)
int argc; int argc;
@ -814,6 +834,7 @@ proc_setpgrp(argc, argv)
#endif #endif
return Qnil; return Qnil;
} }
#endif
#ifdef HAVE_SETPGID #ifdef HAVE_SETPGID
static VALUE static VALUE
@ -995,14 +1016,20 @@ extern VALUE f_kill();
void void
Init_process() Init_process()
{ {
#ifndef USE_CWGUSI
rb_define_virtual_variable("$$", get_pid, 0); rb_define_virtual_variable("$$", get_pid, 0);
#endif
rb_define_readonly_variable("$?", &last_status); rb_define_readonly_variable("$?", &last_status);
#ifndef USE_CWGUSI
rb_define_global_function("exec", f_exec, -1); rb_define_global_function("exec", f_exec, -1);
#ifndef NT #endif
#if !defined(NT) && !defined(USE_CWGUSI)
rb_define_global_function("fork", f_fork, 0); rb_define_global_function("fork", f_fork, 0);
#endif #endif
rb_define_global_function("exit!", f_exit_bang, 1); rb_define_global_function("exit!", f_exit_bang, 1);
#ifndef USE_CWGUSI
rb_define_global_function("system", f_system, -1); rb_define_global_function("system", f_system, -1);
#endif
rb_define_global_function("sleep", f_sleep, -1); rb_define_global_function("sleep", f_sleep, -1);
mProcess = rb_define_module("Process"); mProcess = rb_define_module("Process");
@ -1020,22 +1047,28 @@ Init_process()
#endif #endif
#endif #endif
#ifndef NT #if !defined(NT) && !defined(USE_CWGUSI)
rb_define_singleton_method(mProcess, "fork", f_fork, 0); rb_define_singleton_method(mProcess, "fork", f_fork, 0);
#endif #endif
rb_define_singleton_method(mProcess, "exit!", f_exit_bang, 1); rb_define_singleton_method(mProcess, "exit!", f_exit_bang, 1);
#ifndef USE_CWGUSI
rb_define_module_function(mProcess, "kill", f_kill, -1); rb_define_module_function(mProcess, "kill", f_kill, -1);
#endif
#ifndef NT #ifndef NT
rb_define_module_function(mProcess, "wait", f_wait, 0); rb_define_module_function(mProcess, "wait", f_wait, 0);
rb_define_module_function(mProcess, "waitpid", f_waitpid, 2); rb_define_module_function(mProcess, "waitpid", f_waitpid, 2);
#ifndef USE_CWGUSI
rb_define_module_function(mProcess, "pid", get_pid, 0); rb_define_module_function(mProcess, "pid", get_pid, 0);
rb_define_module_function(mProcess, "ppid", get_ppid, 0); rb_define_module_function(mProcess, "ppid", get_ppid, 0);
#endif #endif /* ifndef USE_CWGUSI */
#endif /* ifndef NT */
#if !defined(NT) && !defined(DJGPP) && !defined(__human68k__) #if !defined(NT) && !defined(DJGPP) && !defined(__human68k__) && !defined(USE_CWGUSI)
rb_define_module_function(mProcess, "getpgrp", proc_getpgrp, -1); rb_define_module_function(mProcess, "getpgrp", proc_getpgrp, -1);
#ifdef HAVE_SETPGRP
rb_define_module_function(mProcess, "setpgrp", proc_setpgrp, -1); rb_define_module_function(mProcess, "setpgrp", proc_setpgrp, -1);
#endif
#ifdef HAVE_SETPGID #ifdef HAVE_SETPGID
rb_define_module_function(mProcess, "setpgid", proc_setpgid, 2); rb_define_module_function(mProcess, "setpgid", proc_setpgid, 2);
#endif #endif

View file

@ -39,7 +39,7 @@ range_s_new(klass, first, last)
VALUE args[2]; VALUE args[2];
args[0] = first; args[1] = last; args[0] = first; args[1] = last;
rb_rescue(range_check, args, range_failed, 0); rb_rescue(range_check, (VALUE)args, range_failed, 0);
obj = obj_alloc(klass); obj = obj_alloc(klass);
@ -111,7 +111,7 @@ range_each(obj)
data.first = b; data.first = b;
data.last = e; data.last = e;
rb_iterate(range_upto, &data, rb_yield, 0); rb_iterate(range_upto, (VALUE)&data, rb_yield, 0);
} }
return Qnil; return Qnil;

View file

@ -32,6 +32,10 @@
#include <ctype.h> #include <ctype.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef __MWERKS__
#include "ruby.h"
#endif
#include "config.h" #include "config.h"
#include "defines.h" #include "defines.h"

18
ruby.c
View file

@ -23,6 +23,17 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef __MWERKS__
#include "node.h"
void show_version();
void show_copyright();
#endif
#ifdef USE_CWGUSI
#include "macruby_missing.h"
#endif
#ifndef HAVE_STRING_H #ifndef HAVE_STRING_H
char *strchr(); char *strchr();
char *strrchr(); char *strrchr();
@ -73,7 +84,7 @@ extern char *sourcefile;
#define RUBY_SITE_LIB "/usr/local/lib/site_ruby" #define RUBY_SITE_LIB "/usr/local/lib/site_ruby"
#endif #endif
#if defined(MSDOS) || defined(NT) #if defined(MSDOS) || defined(NT) || defined(__MACOS__)
#define RUBY_LIB_SEP ';' #define RUBY_LIB_SEP ';'
#else #else
#define RUBY_LIB_SEP ':' #define RUBY_LIB_SEP ':'
@ -529,7 +540,9 @@ load_file(fname, script)
argv = origargv; argv = origargv;
} }
argv[0] = path; argv[0] = path;
#ifndef USE_CWGUSI
execv(path, argv); execv(path, argv);
#endif
sourcefile = fname; sourcefile = fname;
sourceline = 1; sourceline = 1;
Fatal("Can't exec %s", path); Fatal("Can't exec %s", path);
@ -722,6 +735,9 @@ ruby_prog_init()
#if defined(_WIN32) || defined(DJGPP) #if defined(_WIN32) || defined(DJGPP)
addpath(ruby_libpath()); addpath(ruby_libpath());
#endif #endif
#ifdef __MACOS__
setup_macruby_libpath();
#endif
#ifdef RUBY_ARCHLIB #ifdef RUBY_ARCHLIB
addpath(RUBY_ARCHLIB); addpath(RUBY_ARCHLIB);

78
ruby.h
View file

@ -13,6 +13,10 @@
#ifndef RUBY_H #ifndef RUBY_H
#define RUBY_H #define RUBY_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "config.h" #include "config.h"
#include "defines.h" #include "defines.h"
@ -27,6 +31,10 @@
# include <strings.h> # include <strings.h>
#endif #endif
#if defined(__MWERKS__) && defined(__cplusplus)
# define NEED_PROTO
#endif
#ifndef __STDC__ #ifndef __STDC__
# define volatile # define volatile
# ifdef __GNUC__ # ifdef __GNUC__
@ -34,9 +42,13 @@
# else # else
# define const # define const
# endif # endif
# define _(args) ()
#else #else
# define NEED_PROTO
#endif
#ifdef NEED_PROTO
# define _(args) args # define _(args) args
#else
# define _(args) ()
#endif #endif
#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__) #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
@ -102,11 +114,13 @@ VALUE int2inum _((long));
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f)) #define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
/* special contants - i.e. non-zero and non-fixnum constants */ /* special contants - i.e. non-zero and non-fixnum constants */
#ifndef MACRUBY_PUBLIC_INTERFACE
# undef FALSE # undef FALSE
# undef TRUE # undef TRUE
# define FALSE 0 # define FALSE 0
# define TRUE 2 # define TRUE 2
# define NIL 4 # define NIL 4
#endif
#define Qfalse 0 #define Qfalse 0
#define Qtrue 2 #define Qtrue 2
#define Qnil 4 #define Qnil 4
@ -114,7 +128,11 @@ VALUE int2inum _((long));
# define RTEST(v) rb_test_false_or_nil((VALUE)(v)) # define RTEST(v) rb_test_false_or_nil((VALUE)(v))
#define NIL_P(v) ((VALUE)(v) == Qnil) #define NIL_P(v) ((VALUE)(v) == Qnil)
#ifdef __MACOS__ /* name conflict, AERegistory.h */
extern VALUE cRubyObject;
#else
extern VALUE cObject; extern VALUE cObject;
#endif
VALUE rb_class_of _((VALUE)); VALUE rb_class_of _((VALUE));
#define CLASS_OF(v) rb_class_of((VALUE)(v)) #define CLASS_OF(v) rb_class_of((VALUE)(v))
@ -334,22 +352,36 @@ rb_type(VALUE obj)
{ {
if (FIXNUM_P(obj)) return T_FIXNUM; if (FIXNUM_P(obj)) return T_FIXNUM;
if (obj == Qnil) return T_NIL; if (obj == Qnil) return T_NIL;
#ifdef MACRUBY_PUBLIC_INTERFACE
if (obj == RubyFALSE) return T_FALSE;
if (obj == RubyTRUE) return T_TRUE;
#else
if (obj == FALSE) return T_FALSE; if (obj == FALSE) return T_FALSE;
if (obj == TRUE) return T_TRUE; if (obj == TRUE) return T_TRUE;
#endif
return BUILTIN_TYPE(obj); return BUILTIN_TYPE(obj);
} }
extern __inline__ int extern __inline__ int
rb_special_const_p(VALUE obj) rb_special_const_p(VALUE obj)
{ {
#ifdef MACRUBY_PUBLIC_INTERFACE
return (FIXNUM_P(obj)||obj == Qnil||obj == RubyFALSE||obj == RubyTRUE)?RubyTRUE:RubyFALSE;
#else
return (FIXNUM_P(obj)||obj == Qnil||obj == FALSE||obj == TRUE)?TRUE:FALSE; return (FIXNUM_P(obj)||obj == Qnil||obj == FALSE||obj == TRUE)?TRUE:FALSE;
#endif
} }
extern __inline__ int extern __inline__ int
rb_test_false_or_nil(VALUE v) rb_test_false_or_nil(VALUE v)
{ {
#ifdef MACRUBY_PUBLIC_INTERFACE
return (v != Qnil) && (v != RubyFALSE);
return (v != Qnil) && (v != RubyFALSE);
#else
return (v != Qnil) && (v != FALSE); return (v != Qnil) && (v != FALSE);
return (v != Qnil) && (v != FALSE);
#endif
} }
#else #else
int rb_type _((VALUE)); int rb_type _((VALUE));
@ -403,8 +435,8 @@ char *rb_class2name _((VALUE));
void rb_p _((VALUE)); void rb_p _((VALUE));
VALUE rb_eval_string _((char*)); VALUE rb_eval_string _((char*));
VALUE rb_funcall(); VALUE rb_funcall _((VALUE, ID, int, ...));
int rb_scan_args(); int rb_scan_args _((int, VALUE*, char*, ...));
VALUE rb_iv_get _((VALUE, char *)); VALUE rb_iv_get _((VALUE, char *));
VALUE rb_iv_set _((VALUE, char *, VALUE)); VALUE rb_iv_set _((VALUE, char *, VALUE));
@ -419,41 +451,27 @@ extern VALUE verbose, debug;
int rb_safe_level _((void)); int rb_safe_level _((void));
void rb_set_safe_level _((int)); void rb_set_safe_level _((int));
#ifdef __GNUC__ void Raise _((VALUE, char*, ...));
typedef void voidfn (); void Fail _((char*, ...));
volatile voidfn Raise; void Fatal _((char*, ...));
volatile voidfn Fail; void Bug _((char*, ...));
volatile voidfn Fatal;
volatile voidfn Bug;
volatile voidfn rb_sys_fail;
volatile voidfn rb_iter_break;
volatile voidfn rb_exit;
volatile voidfn rb_fatal;
volatile voidfn rb_raise;
volatile voidfn rb_notimplement;
#else
void Raise();
void Fail();
void Fatal();
void Bug();
void rb_sys_fail _((char *)); void rb_sys_fail _((char *));
void rb_iter_break _((void)); void rb_iter_break _((void));
void rb_exit _((int)); void rb_exit _((int));
void rb_raise _((VALUE)); void rb_raise _((VALUE));
void rb_fatal _((VALUE)); void rb_fatal _((VALUE));
void rb_notimplement _((void)); void rb_notimplement _((void));
#endif
void Error(); void Error _((char*, ...));
void Warn(); void Warn _((char*, ...));
void Warning(); /* reports if `-w' specified */ void Warning _((char*, ...)); /* reports if `-w' specified */
VALUE rb_each _((VALUE)); VALUE rb_each _((VALUE));
VALUE rb_yield _((VALUE)); VALUE rb_yield _((VALUE));
int iterator_p _((void)); int iterator_p _((void));
VALUE rb_iterate(); VALUE rb_iterate _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
VALUE rb_rescue(); VALUE rb_rescue _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
VALUE rb_ensure(); VALUE rb_ensure _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
#include "intern.h" #include "intern.h"
@ -463,3 +481,7 @@ static char *libs_to_be_linked[] = { EXTLIB, 0 };
#endif #endif
#endif #endif
#if defined(__cplusplus)
} /* extern "C" { */
#endif

View file

@ -13,6 +13,10 @@
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#ifdef __BEOS__
#undef SIGBUS
#endif
#ifndef NSIG #ifndef NSIG
# ifdef DJGPP # ifdef DJGPP
# define NSIG SIGMAX # define NSIG SIGMAX
@ -21,6 +25,11 @@
# endif # endif
#endif #endif
#ifdef USE_CWGUSI
# undef NSIG
# define NSIG __signal_max
#endif
static struct signals { static struct signals {
char *signm; char *signm;
int signo; int signo;
@ -175,6 +184,9 @@ f_kill(argc, argv)
int argc; int argc;
VALUE *argv; VALUE *argv;
{ {
#ifdef USE_CWGUSI
rb_notimplement();
#else
int sig; int sig;
int i; int i;
char *s; char *s;
@ -237,6 +249,7 @@ f_kill(argc, argv)
} }
} }
return INT2FIX(i-1); return INT2FIX(i-1);
#endif /* USE_CWGUSI */
} }
static VALUE trap_list[NSIG]; static VALUE trap_list[NSIG];
@ -248,12 +261,14 @@ int prohibit_interrupt;
void void
gc_mark_trap_list() gc_mark_trap_list()
{ {
#ifndef MACOS_UNUSE_SIGNAL
int i; int i;
for (i=0; i<NSIG; i++) { for (i=0; i<NSIG; i++) {
if (trap_list[i]) if (trap_list[i])
gc_mark(trap_list[i]); gc_mark(trap_list[i]);
} }
#endif /* MACOS_UNUSE_SIGNAL */
} }
#ifdef POSIX_SIGNAL #ifdef POSIX_SIGNAL
@ -322,13 +337,16 @@ sigsegv(sig)
void void
rb_trap_exit() rb_trap_exit()
{ {
#ifndef MACOS_UNUSE_SIGNAL
if (trap_list[0]) if (trap_list[0])
rb_eval_cmd(trap_list[0], ary_new3(1, INT2FIX(0))); rb_eval_cmd(trap_list[0], ary_new3(1, INT2FIX(0)));
#endif
} }
void void
rb_trap_exec() rb_trap_exec()
{ {
#ifndef MACOS_UNUSE_SIGNAL
int i; int i;
for (i=0; i<NSIG; i++) { for (i=0; i<NSIG; i++) {
@ -341,11 +359,12 @@ rb_trap_exec()
rb_trap_eval(trap_list[i], i); rb_trap_eval(trap_list[i], i);
} }
} }
#endif /* MACOS_UNUSE_SIGNAL */
trap_pending = 0; trap_pending = 0;
} }
struct trap_arg { struct trap_arg {
#ifndef NT #if !defined(NT) && !defined(USE_CWGUSI)
# ifdef HAVE_SIGPROCMASK # ifdef HAVE_SIGPROCMASK
sigset_t mask; sigset_t mask;
# else # else
@ -458,7 +477,7 @@ trap(arg)
trap_list[sig] = command; trap_list[sig] = command;
/* enable at least specified signal. */ /* enable at least specified signal. */
#ifndef NT #if !defined(NT) && !defined(USE_CWGUSI)
#ifdef HAVE_SIGPROCMASK #ifdef HAVE_SIGPROCMASK
sigdelset(&arg->mask, sig); sigdelset(&arg->mask, sig);
#else #else
@ -468,8 +487,8 @@ trap(arg)
return old; return old;
} }
#ifndef NT #if !defined(NT) && !defined(USE_CWGUSI)
static void static VALUE
trap_ensure(arg) trap_ensure(arg)
struct trap_arg *arg; struct trap_arg *arg;
{ {
@ -515,7 +534,7 @@ f_trap(argc, argv)
arg.cmd = argv[1]; arg.cmd = argv[1];
} }
#ifndef NT #if !defined(NT) && !defined(USE_CWGUSI)
/* disable interrupt */ /* disable interrupt */
# ifdef HAVE_SIGPROCMASK # ifdef HAVE_SIGPROCMASK
sigfillset(&arg.mask); sigfillset(&arg.mask);
@ -524,7 +543,7 @@ f_trap(argc, argv)
arg.mask = sigblock(~0); arg.mask = sigblock(~0);
# endif # endif
return rb_ensure(trap, &arg, trap_ensure, &arg); return rb_ensure(trap, (VALUE)&arg, trap_ensure, (VALUE)&arg);
#else #else
return trap(&arg); return trap(&arg);
#endif #endif
@ -533,6 +552,7 @@ f_trap(argc, argv)
void void
Init_signal() Init_signal()
{ {
#ifndef MACOS_UNUSE_SIGNAL
extern VALUE mKernel; extern VALUE mKernel;
rb_define_global_function("trap", f_trap, -1); rb_define_global_function("trap", f_trap, -1);
@ -547,4 +567,5 @@ Init_signal()
#ifdef SIGSEGV #ifdef SIGSEGV
signal(SIGSEGV, sigsegv); signal(SIGSEGV, sigsegv);
#endif #endif
#endif /* MACOS_UNUSE_SIGNAL */
} }

4
st.c
View file

@ -6,6 +6,10 @@ static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible";
#include <stdio.h> #include <stdio.h>
#include "st.h" #include "st.h"
#ifdef USE_CWGUSI
#include <stdlib.h>
#endif
#define ST_DEFAULT_MAX_DENSITY 5 #define ST_DEFAULT_MAX_DENSITY 5
#define ST_DEFAULT_INIT_TABLE_SIZE 11 #define ST_DEFAULT_INIT_TABLE_SIZE 11

View file

@ -29,8 +29,6 @@ VALUE cString;
#define STR_FREEZE FL_USER1 #define STR_FREEZE FL_USER1
#define STR_TAINT FL_USER2 #define STR_TAINT FL_USER2
#define STR_NO_ORIG FL_USER3 #define STR_NO_ORIG FL_USER3
void reg_prepare_re _((VALUE));
void kcode_reset_option _((void));
extern VALUE RS; extern VALUE RS;

View file

@ -10,6 +10,10 @@
#include "ruby.h" #include "ruby.h"
#ifdef USE_CWGUSI
#include <stdio.h>
#endif
ID rb_frame_last_func(); ID rb_frame_last_func();
VALUE cStruct; VALUE cStruct;
extern VALUE mEnumerable; extern VALUE mEnumerable;
@ -161,12 +165,22 @@ make_struct(name, member, klass)
return nstr; return nstr;
} }
#ifdef __STDC__
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h> #include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
VALUE VALUE
#ifdef __STDC__
struct_define(char *name, ...)
#else
struct_define(name, va_alist) struct_define(name, va_alist)
char *name; char *name;
va_dcl va_dcl
#endif
{ {
va_list ar; va_list ar;
VALUE nm, ary; VALUE nm, ary;
@ -175,7 +189,7 @@ struct_define(name, va_alist)
nm = str_new2(name); nm = str_new2(name);
ary = ary_new(); ary = ary_new();
va_start(ar); va_init_list(ar, name);
while (mem = va_arg(ar, char*)) { while (mem = va_arg(ar, char*)) {
ID slot = rb_intern(mem); ID slot = rb_intern(mem);
ary_push(ary, INT2FIX(slot)); ary_push(ary, INT2FIX(slot));
@ -235,9 +249,13 @@ struct_alloc(klass, values)
} }
VALUE VALUE
#ifdef __STDC__
struct_new(VALUE klass, ...)
#else
struct_new(klass, va_alist) struct_new(klass, va_alist)
VALUE klass; VALUE klass;
va_dcl va_dcl
#endif
{ {
VALUE val, mem; VALUE val, mem;
int size; int size;
@ -246,7 +264,7 @@ struct_new(klass, va_alist)
val = rb_iv_get(klass, "__size__"); val = rb_iv_get(klass, "__size__");
size = FIX2INT(val); size = FIX2INT(val);
mem = ary_new(); mem = ary_new();
va_start(args); va_init_list(args, klass);
while (size--) { while (size--) {
val = va_arg(args, VALUE); val = va_arg(args, VALUE);
ary_push(mem, val); ary_push(mem, val);

5
time.c
View file

@ -13,6 +13,11 @@
#include "ruby.h" #include "ruby.h"
#include <sys/types.h> #include <sys/types.h>
#ifdef USE_CWGUSI
int gettimeofday(struct timeval*, struct timezone*);
int strcasecmp(char*, char*);
#endif
#include <time.h> #include <time.h>
#ifndef NT #ifndef NT
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H

View file

@ -13,6 +13,10 @@
#include "node.h" #include "node.h"
#include "st.h" #include "st.h"
#ifdef USE_CWGUSI
char* strdup(char*);
#endif
static st_table *rb_global_tbl; static st_table *rb_global_tbl;
st_table *rb_class_tbl; st_table *rb_class_tbl;
#define global_tbl rb_global_tbl #define global_tbl rb_global_tbl
@ -590,7 +594,7 @@ struct trace_data {
VALUE val; VALUE val;
}; };
static void static VALUE
trace_ev(data) trace_ev(data)
struct trace_data *data; struct trace_data *data;
{ {
@ -602,7 +606,7 @@ trace_ev(data)
} }
} }
static void static VALUE
trace_en(entry) trace_en(entry)
struct global_entry *entry; struct global_entry *entry;
{ {
@ -627,7 +631,7 @@ rb_gvar_set(entry, val)
entry->block_trace = 1; entry->block_trace = 1;
trace.trace = entry->trace; trace.trace = entry->trace;
trace.val = val; trace.val = val;
rb_ensure(trace_ev, &trace, trace_en, entry); rb_ensure(trace_ev, (VALUE)&trace, trace_en, (VALUE)entry);
} }
return val; return val;
} }

View file

@ -1,2 +1,2 @@
#define RUBY_VERSION "1.1b9_18" #define RUBY_VERSION "1.1b9_19"
#define VERSION_DATE "98/05/12" #define VERSION_DATE "98/05/13"