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>
* 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: remove typedef's. INT, UINT, UCHAR, USHORT.

12
array.c
View file

@ -81,12 +81,22 @@ ary_new()
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>
#define va_init_list(a,b) va_start(a)
#endif
VALUE
#ifdef __STDC__
ary_new3(int n, ...)
#else
ary_new3(n, va_alist)
int n;
va_dcl
#endif
{
va_list ar;
VALUE ary;
@ -97,7 +107,7 @@ ary_new3(n, va_alist)
}
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++) {
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);
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) {
len = RBIGNUM(x)->len + 1;

16
class.c
View file

@ -14,6 +14,10 @@
#include "node.h"
#include "st.h"
#ifdef USE_CWGUSI
#include <stdio.h>
#endif
struct st_table *new_idhash();
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);
}
#ifdef __STDC__
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
#include <ctype.h>
int
#ifdef __STDC__
rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
#else
rb_scan_args(argc, argv, fmt, va_alist)
int argc;
VALUE *argv;
char *fmt;
va_dcl
#endif
{
int n, i;
char *p = fmt;
VALUE *var;
va_list vargs;
va_start(vargs);
va_init_list(vargs, fmt);
if (*p == '*') {
var = va_arg(vargs, VALUE*);

9
config.guess vendored
View file

@ -728,6 +728,15 @@ EOF
echo mips-unknown-sysv${UNAME_RELEASE}
fi
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
#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)
;;
-beos)
os=-beos
;;
-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
nextstep*) ;;
human*) ;;
beos*) ;;
*) LIBS="-lm $LIBS";;
esac
AC_CHECK_LIB(crypt, crypt)
@ -87,7 +88,8 @@ AC_HEADER_DIRENT
AC_HEADER_STDC
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\
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.
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\
setruid seteuid setreuid setrgid setegid setregid\
setpgrp2 getpgid getgroups getpriority\
dlopen sigprocmask sigaction _setjmp)
dlopen sigprocmask sigaction _setjmp setpgrp)
if test "$ac_cv_func_strftime" = no; then
AC_STRUCT_TIMEZONE
AC_TRY_LINK([],
@ -207,6 +209,7 @@ fi
if test "$ac_cv_func_getpwent" = yes; then
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_quota, pwd.h, AC_DEFINE(PW_QUOTA))
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=''
LDSHARED=''
LDFLAGS='' ;;
beos*) LDSHARED="mwld -xms"
DLDFLAGS="-f ruby.exp"
rb_cv_dlopen=yes ;;
*) LDSHARED='ld' ;;
esac
AC_MSG_RESULT($rb_cv_dlopen)
@ -451,6 +457,10 @@ if test "$fat_binary" = yes ; then
CFLAGS="$CFLAGS -pipe $ARCH_FLAG"
fi
if test "$host_os" = "beos"; then
CFLAGS="$CFLAGS -relax_pointers"
fi
ri_prefix=
test "$program_prefix" != NONE &&
ri_prefix=$program_prefix

View file

@ -13,7 +13,7 @@
#define RUBY
/* 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
#define SJIS
#else

12
dir.c
View file

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

113
dln.c
View file

@ -36,7 +36,9 @@ void *xrealloc();
#include <stdio.h>
#ifndef NT
#include <sys/file.h>
# ifndef USE_CWGUSI
# include <sys/file.h>
# endif
#else
#include "missing/file.h"
#endif
@ -58,6 +60,16 @@ char *strdup();
char *getenv();
#endif
#ifdef __MACOS__
# include <TextUtils.h>
# include <CodeFragments.h>
# include <Aliases.h>
#endif
#ifdef __BEOS__
# include <image.h>
#endif
int eaccess();
#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT)
@ -81,7 +93,11 @@ init_funcname(buf, file)
/* Load the file as an object one */
for (p = file, slash = p-1; *p; p++) /* Find position of last '/' */
#ifdef __MACOS__
if (*p == ':') slash = p;
#else
if (*p == '/') slash = p;
#endif
sprintf(buf, FUNCNAME_PATTERN, slash + 1);
for (p = buf; *p; p++) { /* Delete suffix it it exists */
@ -1327,6 +1343,93 @@ dln_load(file)
}
#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
rb_notimplement("dynamic link not supported");
#endif
@ -1409,6 +1512,7 @@ dln_find_1(fname, path, exe_flag)
conv_to_posix_path(path, rubypath);
path = rubypath;
#endif
#ifndef __MACOS__
if (fname[0] == '/') return fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
return fname;
@ -1418,6 +1522,7 @@ dln_find_1(fname, path, exe_flag)
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
return fname;
#endif
#endif /* __MACOS__ */
for (dp = path;; dp = ++ep) {
register int l;
@ -1425,7 +1530,7 @@ dln_find_1(fname, path, exe_flag)
int fspace;
/* extract a component */
#if !defined(MSDOS) && !defined(NT) && !defined(__human68k__)
#if !defined(MSDOS) && !defined(NT) && !defined(__human68k__) && !defined(__MACOS__)
ep = strchr(dp, ':');
#else
ep = strchr(dp, ';');
@ -1473,7 +1578,11 @@ dln_find_1(fname, path, exe_flag)
/* add a "/" between directory and filename */
if (ep[-1] != '/')
#ifdef __MACOS__
*bp++ = ':';
#else
*bp++ = '/';
#endif
}
/* now append the file name */

1
enum.c
View file

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

222
error.c
View file

@ -13,7 +13,18 @@
#include "ruby.h"
#include "env.h"
#include <stdio.h>
#ifdef __STDC__
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#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 int sourceline;
@ -34,28 +45,7 @@ err_sprintf(buf, fmt, args)
}
}
static void
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 err_append _((char*));
static void
err_print(fmt, args)
char *fmt;
@ -68,52 +58,68 @@ err_print(fmt, args)
}
void
#ifdef __STDC__
Error(char *fmt, ...)
#else
Error(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list args;
va_start(args);
va_init_list(args, fmt);
err_print(fmt, args);
va_end(args);
nerrs++;
}
void
#ifdef __STDC__
Error_Append(char *fmt, ...)
#else
Error_Append(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list args;
char buf[BUFSIZ];
va_start(args);
va_init_list(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
err_append(buf);
}
void
#ifdef __STDC__
Warn(char *fmt, ...)
#else
Warn(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
char buf[BUFSIZ];
va_list args;
sprintf(buf, "warning: %s", fmt);
va_start(args);
va_init_list(args, fmt);
err_print(buf, args);
va_end(args);
}
/* Warning() reports only in verbose mode */
void
#ifdef __STDC__
Warning(char *fmt, ...)
#else
Warning(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
char buf[BUFSIZ];
va_list args;
@ -122,15 +128,19 @@ Warning(fmt, va_alist)
sprintf(buf, "warning: %s", fmt);
va_start(args);
va_init_list(args, fmt);
err_print(buf, args);
va_end(args);
}
void
#ifdef __STDC__
Bug(char *fmt, ...)
#else
Bug(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
char buf[BUFSIZ];
va_list args;
@ -138,7 +148,7 @@ Bug(fmt, va_alist)
sprintf(buf, "[BUG] %s", fmt);
rb_in_eval = 0;
va_start(args);
va_init_list(args, fmt);
err_print(buf, args);
va_end(args);
abort();
@ -172,7 +182,9 @@ static struct types {
-1, 0,
};
#ifndef __STDC__
extern void TypeError();
#endif
void
rb_check_type(x, t)
@ -369,7 +381,6 @@ exception(argc, argv)
int argc;
VALUE *argv;
{
void ArgError();
VALUE v = Qnil;
VALUE etype = eStandardError;
int i;
@ -403,7 +414,60 @@ exception(argc, argv)
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;
#endif
#ifndef NT
extern int sys_nerr;
@ -465,64 +529,84 @@ Init_Exception()
rb_define_global_function("Exception", exception, -1);
}
#define RAISE_ERROR(klass) {\
#define RAISE_ERROR(klass,fmt) {\
va_list args;\
char buf[BUFSIZ];\
\
va_start(args);\
vsprintf(buf, fmt, args);\
va_end(args);\
\
va_init_list(args,fmt);\
rb_raise(exc_new2(klass, buf));\
}
void
#ifdef __STDC__
Raise(VALUE exc, char *fmt, ...)
#else
Raise(exc, fmt, va_alist)
VALUE exc;
char *fmt;
va_dcl
#endif
{
RAISE_ERROR(exc);
RAISE_ERROR(exc, fmt);
}
void
#ifdef __STDC__
TypeError(char *fmt, ...)
#else
TypeError(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
RAISE_ERROR(eTypeError);
RAISE_ERROR(eTypeError, fmt);
}
void
#ifdef __STDC__
ArgError(char *fmt, ...)
#else
ArgError(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
RAISE_ERROR(eArgError);
RAISE_ERROR(eArgError, fmt);
}
void
#ifdef __STDC__
NameError(char *fmt, ...)
#else
NameError(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
RAISE_ERROR(eNameError);
RAISE_ERROR(eNameError, fmt);
}
void
#ifdef __STDC__
IndexError(char *fmt, ...)
#else
IndexError(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
RAISE_ERROR(eIndexError);
RAISE_ERROR(eIndexError, fmt);
}
void
#ifdef __STDC__
Fail(char *fmt, ...)
#else
Fail(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
RAISE_ERROR(eRuntimeError);
RAISE_ERROR(eRuntimeError, fmt);
}
void
@ -534,22 +618,30 @@ rb_notimplement()
}
void
#ifdef __STDC__
LoadError(char *fmt, ...)
#else
LoadError(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
RAISE_ERROR(eLoadError);
RAISE_ERROR(eLoadError, fmt);
}
void
#ifdef __STDC__
Fatal(char *fmt, ...)
#else
Fatal(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list args;
char buf[BUFSIZ];
va_start(args);
va_init_list(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
@ -581,6 +673,26 @@ rb_sys_fail(mesg)
}
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]) {
char name[6];
@ -591,6 +703,7 @@ rb_sys_fail(mesg)
ee = syserr_list[n];
}
ee = exc_new2(ee, buf);
#endif
rb_iv_set(ee, "errno", INT2FIX(n));
rb_raise(ee);
}
@ -972,3 +1085,28 @@ init_syserr()
set_syserr(EDQUOT, "EDQUOT");
#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);
}
}

53
eval.c
View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,6 +11,11 @@
#include <tcl.h>
#include <tk.h>
#ifdef __MACOS__
# include <tkMac.h>
# include <Quickdraw.h>
#endif
/* for debug */
#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]);
old_trapflg = trap_immediate;
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;
if (failed) {
@ -253,6 +258,15 @@ ip_retval(VALUE self)
return (INT2FIX(ptr->return_value));
}
#ifdef __MACOS__
static void
_macinit()
{
tcl_macQdPtr = &qd; /* setup QuickDraw globals */
Tcl_MacSetEventProc(TkMacConvertEvent); /* setup event handler */
}
#endif
/*---- initialization ----*/
void Init_tcltklib()
{
@ -269,6 +283,10 @@ void Init_tcltklib()
rb_define_method(ip, "_return_value", ip_retval, 0);
rb_define_method(ip, "mainloop", lib_mainloop, 0);
#ifdef __MACOS__
_macinit();
#endif
/*---- initialize tcl/tk libraries ----*/
/* from Tk_Main() */
DUMP1("Tcl_FindExecutable");

28
file.c
View file

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

View file

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

3
gc.c
View file

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

2
glob.c
View file

@ -52,7 +52,7 @@
# endif /* !USG */
#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
systems do not provide it. */
# define REAL_DIR_ENTRY(dp) 1

11
hash.c
View file

@ -156,7 +156,7 @@ hash_delete_nil(key, value)
return ST_CONTINUE;
}
static void
static VALUE
hash_foreach_ensure(hash)
VALUE hash;
{
@ -774,6 +774,8 @@ hash_update(hash1, hash2)
return hash1;
}
#ifndef __MACOS__ /* environment variables nothing on MacOS. */
int env_path_tainted();
static int path_tainted = -1;
@ -1131,6 +1133,8 @@ env_to_hash(obj)
return hash;
}
#endif /* ifndef __MACOS__ environment variables nothing on MacOS. */
void
Init_Hash()
{
@ -1188,6 +1192,7 @@ Init_Hash()
rb_define_method(cHash,"key?", hash_has_key, 1);
rb_define_method(cHash,"value?", hash_has_value, 1);
#ifndef __MACOS__ /* environment variables nothing on MacOS. */
envtbl = obj_alloc(cObject);
rb_extend_object(envtbl, mEnumerable);
@ -1216,4 +1221,8 @@ Init_Hash()
rb_define_singleton_method(envtbl,"to_hash", env_to_hash, 0);
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 ary_new _((void));
VALUE ary_new2 _((int));
VALUE ary_new3();
VALUE ary_new4 _((int, VALUE*));
VALUE ary_new3 _((int,...));
VALUE ary_new4 _((int, VALUE *));
VALUE ary_freeze _((VALUE));
VALUE ary_aref(int, VALUE*, VALUE);
void ary_store _((VALUE, int, VALUE));
VALUE ary_push _((VALUE, VALUE));
VALUE ary_pop _((VALUE));
@ -83,19 +84,11 @@ VALUE enum_length _((VALUE));
VALUE exc_new _((VALUE, char*, unsigned int));
VALUE exc_new2 _((VALUE, char*));
VALUE exc_new3 _((VALUE, VALUE));
#ifdef __GNUC__
volatile voidfn TypeError;
volatile voidfn ArgError;
volatile voidfn NameError;
volatile voidfn IndexError;
volatile voidfn LoadError;
#else
void TypeError();
void ArgError();
void NameError();
void IndexError();
void LoadError();
#endif
void TypeError _((char*, ...));
void ArgError _((char*, ...));
void NameError _((char*, ...));
void IndexError _((char*, ...));
void LoadError _((char*, ...));
/* eval.c */
void rb_remove_method _((VALUE, char*));
void rb_disable_super _((VALUE, char*));
@ -267,8 +260,8 @@ VALUE str_upto _((VALUE, VALUE));
VALUE str_inspect _((VALUE));
VALUE str_split _((VALUE, char*));
/* struct.c */
VALUE struct_new();
VALUE struct_define();
VALUE struct_new _((VALUE, ...));
VALUE struct_define _((char*, ...));
VALUE struct_alloc _((VALUE, VALUE));
VALUE struct_aref _((VALUE, VALUE));
VALUE struct_aset _((VALUE, VALUE, VALUE));

50
io.c
View file

@ -53,6 +53,17 @@ struct timeval {
#include <unistd.h>
#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 cIO;
@ -87,8 +98,14 @@ struct timeval time_timeval();
# ifdef FILE_COUNT
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
# 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() */
extern int ReadDataPending();
# endif
# define READ_DATA_PENDING(fp) ReadDataPending(fp)
# endif
#endif
@ -354,7 +371,12 @@ read_all(port)
GetOpenFile(port, 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)) {
#endif
if (st.st_size == 0) return Qnil;
else {
int pos = ftell(fptr->f);
@ -866,7 +888,7 @@ VALUE
io_binmode(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;
GetOpenFile(io, fptr);
@ -876,10 +898,17 @@ io_binmode(io)
if (fptr->f2)
fmode(fptr->f2, _IOBIN);
#else
# ifndef USE_CWGUSI
if (fptr->f && setmode(fileno(fptr->f), O_BINARY) == -1)
rb_sys_fail(fptr->path);
if (fptr->f2 && setmode(fileno(fptr->f2), O_BINARY) == -1)
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
fptr->mode |= FMODE_BINMODE;
@ -1046,6 +1075,7 @@ static VALUE
pipe_open(pname, mode)
char *pname, *mode;
{
#ifndef USE_CWGUSI
int modef = io_mode_flags(mode);
OpenFile *fptr;
@ -1159,6 +1189,9 @@ pipe_open(pname, mode)
}
}
#endif
#else /* USE_CWGUSI */
rb_notimplement();
#endif
}
static VALUE
@ -1717,16 +1750,17 @@ next_argv()
#endif
}
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);
fchmod(fileno(fw), st.st_mode);
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
fchown(fileno(fw), st.st_uid, st.st_gid);
}
#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 {
@ -2107,7 +2141,11 @@ io_ctl(io, req, arg, io_p)
}
fd = fileno(fptr->f);
#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);
# endif
#else
if (!io_p) {
rb_notimplement();
@ -2306,7 +2344,7 @@ io_s_foreach(argc, argv, io)
arg.argc = argc - 1;
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
@ -2337,7 +2375,7 @@ io_s_readlines(argc, argv, io)
arg.argc = argc - 1;
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

View file

@ -445,7 +445,7 @@ marshal_dump(argc, argv)
w_byte(MARSHAL_MAJOR, &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;
}
@ -846,7 +846,7 @@ marshal_load(argc, argv)
arg.data = st_init_numtable();
if (NIL_P(proc)) arg.proc = 0;
else arg.proc = proc;
v = rb_ensure(load, &arg, load_ensure, &arg);
v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
}
else {
TypeError("Old marshal file format (can't read)");

View file

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

View file

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

View file

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

View file

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

View file

@ -39,7 +39,7 @@ range_s_new(klass, first, last)
VALUE args[2];
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);
@ -111,7 +111,7 @@ range_each(obj)
data.first = b;
data.last = e;
rb_iterate(range_upto, &data, rb_yield, 0);
rb_iterate(range_upto, (VALUE)&data, rb_yield, 0);
}
return Qnil;

View file

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

18
ruby.c
View file

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

88
ruby.h
View file

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

View file

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

View file

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

View file

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

5
time.c
View file

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

View file

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

View file

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