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

2000-02-17

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-02-17 07:11:22 +00:00
parent 7dd3853eac
commit 96b40dff45
27 changed files with 286 additions and 171 deletions

View file

@ -1,3 +1,58 @@
Wed Feb 16 00:32:49 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (method_arity): nd_rest is -1 for no rest argument.
* process.c (proc_waitpid): returns nil when waitpid(2) returns 0.
Tue Feb 15 01:47:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* process.c (rb_f_waitpid): pid_t should be signed.
Mon Feb 14 13:59:01 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (yylex): yylex yields wrong token for `:foo=~expr'.
* ruby.c (load_file): exit if reading file is empty.
Mon Feb 14 03:34:52 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (yylex): `foo.bar=' should be <foo><.><bar><=>.
* eval.c (rb_thread_restore_context): process according to
RESTORE_* is moved after longjmp().
* eval.c (thread_switch): new function to process RESTORE_*.
Sun Feb 13 16:19:49 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* ruby.c (require_libraries): don't access freed memory.
* ruby.c (add_modules): ditto.
Fri Feb 11 12:06:22 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (parse_quotedwords): %w() need to split not only by mere
spaces, but by all whitespaces.
Thu Feb 10 02:12:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (rb_str_index_m): did not support negative offset.
Wed Feb 9 21:54:26 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* ext/socket/getaddrinfo.c: gcc --traditional support.
Rearrange headers to work AC_C_CONST.
* ext/socket/getnameinfo.c: ditto.
* ext/socket/socket.c: mswin32: use double instead of long long.
Wed Feb 9 16:30:41 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* numeric.c (num_coerce): should return [y, x].
Wed Feb 9 11:07:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* ruby.c (ruby_prog_init): loadpath structure changed.
Tue Feb 8 02:07:33 2000 Yukihiro Matsumoto <matz@netlab.co.jp> Tue Feb 8 02:07:33 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_search): optimize for \G at top. * regex.c (re_search): optimize for \G at top.

View file

@ -51,6 +51,13 @@ rb_ary_modify(ary)
rb_raise(rb_eSecurityError, "Insecure: can't modify array"); rb_raise(rb_eSecurityError, "Insecure: can't modify array");
} }
VALUE
rb_ary_freeze(ary)
VALUE ary;
{
return rb_obj_freeze(ary);
}
static VALUE static VALUE
rb_ary_frozen_p(ary) rb_ary_frozen_p(ary)
VALUE ary; VALUE ary;

15
configure vendored
View file

@ -4966,16 +4966,24 @@ test "$program_suffix" != NONE &&
ri_suffix=$program_suffix ri_suffix=$program_suffix
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}" RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
RUBY_LIB_PATH="${prefix}/lib/ruby/${MAJOR}.${MINOR}" RUBY_LIB_PREFIX="${prefix}/lib/ruby"
RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
RUBY_SITE_LIB_PATH="${RUBY_LIB_PREFIX}/site_ruby"
RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}"
cat >> confdefs.h <<EOF cat >> confdefs.h <<EOF
#define RUBY_LIB "${RUBY_LIB_PATH}" #define RUBY_LIB "${RUBY_LIB_PATH}"
EOF EOF
RUBY_SITE_LIB_PATH="${RUBY_LIB_PATH}/site_ruby"
cat >> confdefs.h <<EOF cat >> confdefs.h <<EOF
#define RUBY_SITE_LIB "${RUBY_SITE_LIB_PATH}" #define RUBY_SITE_LIB "${RUBY_SITE_LIB_PATH}"
EOF EOF
cat >> confdefs.h <<EOF
#define RUBY_SITE_LIB2 "${RUBY_SITE_LIB_PATH2}"
EOF
configure_args=$ac_configure_args configure_args=$ac_configure_args
@ -5002,12 +5010,13 @@ else
EOF EOF
fi fi
cat >> confdefs.h <<EOF cat >> confdefs.h <<EOF
#define RUBY_ARCHLIB "${RUBY_LIB_PATH}/${arch}" #define RUBY_ARCHLIB "${RUBY_LIB_PATH}/${arch}"
EOF EOF
cat >> confdefs.h <<EOF cat >> confdefs.h <<EOF
#define RUBY_SITE_ARCHLIB "${RUBY_SITE_LIB_PATH}/${arch}" #define RUBY_SITE_ARCHLIB "${RUBY_SITE_LIB_PATH2}/${arch}"
EOF EOF

View file

@ -798,10 +798,15 @@ test "$program_suffix" != NONE &&
ri_suffix=$program_suffix ri_suffix=$program_suffix
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}" RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
RUBY_LIB_PATH="${prefix}/lib/ruby/${MAJOR}.${MINOR}" RUBY_LIB_PREFIX="${prefix}/lib/ruby"
RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
RUBY_SITE_LIB_PATH="${RUBY_LIB_PREFIX}/site_ruby"
RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}"
AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}") AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
RUBY_SITE_LIB_PATH="${RUBY_LIB_PATH}/site_ruby"
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}") AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
AC_SUBST(arch)dnl AC_SUBST(arch)dnl
configure_args=$ac_configure_args configure_args=$ac_configure_args
@ -820,8 +825,9 @@ else
arch="${target_cpu}-${target_os}" arch="${target_cpu}-${target_os}"
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}") AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
fi fi
AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}") AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH}/${arch}") AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${arch}")
AC_ARG_WITH(search-path, AC_ARG_WITH(search-path,
[--with-search-path specify the additional search path], [--with-search-path specify the additional search path],

View file

@ -50,6 +50,8 @@
#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(OS2) #if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(OS2)
#define PATH_SEP ";" #define PATH_SEP ";"
#elif defined(riscos)
#define PATH_SEP ","
#else #else
#define PATH_SEP ":" #define PATH_SEP ":"
#endif #endif

2
dir.c
View file

@ -412,7 +412,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__) && !defined(USE_CWGUSI) && !defined(__BEOS__) && !defined(__EMX__) #if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__) && !defined(__EMX__) && !defined(riscos)
rb_secure(2); rb_secure(2);
Check_SafeStr(path); Check_SafeStr(path);

154
eval.c
View file

@ -3359,7 +3359,7 @@ rb_yield_0(val, self, klass, acheck)
rb_gc_force_recycle((VALUE)vars); rb_gc_force_recycle((VALUE)vars);
vars = vars->next; vars = vars->next;
} }
if (ruby_dyna_vars->id == 0) { if (ruby_dyna_vars && ruby_dyna_vars->id == 0) {
rb_gc_force_recycle((VALUE)ruby_dyna_vars); rb_gc_force_recycle((VALUE)ruby_dyna_vars);
} }
} }
@ -3720,7 +3720,7 @@ rb_f_missing(argc, argv, obj)
if (argc == 0) rb_raise(rb_eArgError, "no id given"); if (argc == 0) rb_raise(rb_eArgError, "no id given");
id = FIX2INT(argv[0]); id = NUM2INT(argv[0]);
argc--; argv++; argc--; argv++;
switch (TYPE(obj)) { switch (TYPE(obj)) {
@ -5789,7 +5789,7 @@ proc_arity(proc)
int n; int n;
Data_Get_Struct(proc, struct BLOCK, data); Data_Get_Struct(proc, struct BLOCK, data);
if (data->var == 0) return FIX2INT(-1); if (data->var == 0) return INT2FIX(-1);
switch (nd_type(data->var)) { switch (nd_type(data->var)) {
default: default:
return INT2FIX(-2); return INT2FIX(-2);
@ -5986,7 +5986,7 @@ method_arity(method)
body = body->nd_head; body = body->nd_head;
if (!body) return INT2FIX(0); if (!body) return INT2FIX(0);
n = body->nd_cnt; n = body->nd_cnt;
if (body->nd_rest) n = -n-1; if (body->nd_rest >= 0) n = -n-1;
return INT2FIX(n); return INT2FIX(n);
} }
} }
@ -6261,13 +6261,30 @@ rb_thread_check(data)
return (thread_t)RDATA(data)->data; return (thread_t)RDATA(data)->data;
} }
static int th_raise_argc;
static VALUE th_raise_argv[2];
static char *th_raise_file;
static int th_raise_line;
static VALUE th_cmd;
static int th_sig;
static char *th_signm;
#define RESTORE_NORMAL 1
#define RESTORE_FATAL 2
#define RESTORE_INTERRUPT 3
#define RESTORE_TRAP 4
#define RESTORE_RAISE 5
#define RESTORE_SIGNAL 6
static void static void
rb_thread_save_context(th) rb_thread_save_context(th)
thread_t th; thread_t th;
{ {
VALUE v; VALUE v;
int len = stack_length(); int len;
len = stack_length();
th->stk_len = 0; th->stk_len = 0;
th->stk_pos = (rb_gc_stack_start<(VALUE*)&v)?rb_gc_stack_start th->stk_pos = (rb_gc_stack_start<(VALUE*)&v)?rb_gc_stack_start
:rb_gc_stack_start - len; :rb_gc_stack_start - len;
@ -6299,6 +6316,41 @@ rb_thread_save_context(th)
th->line = ruby_sourceline; th->line = ruby_sourceline;
} }
static int
thread_switch(n)
int n;
{
switch (n) {
case 0:
return 0;
case RESTORE_FATAL:
JUMP_TAG(TAG_FATAL);
break;
case RESTORE_INTERRUPT:
rb_interrupt();
break;
case RESTORE_TRAP:
rb_trap_eval(th_cmd, th_sig);
errno = EINTR;
break;
case RESTORE_RAISE:
ruby_frame->last_func = 0;
ruby_sourcefile = th_raise_file;
ruby_sourceline = th_raise_line;
rb_f_raise(th_raise_argc, th_raise_argv);
break;
case RESTORE_SIGNAL:
rb_raise(rb_eSignal, "SIG%s", th_signm);
break;
case RESTORE_NORMAL:
default:
return 1;
}
}
#define THREAD_SAVE_CONTEXT(th) \
(rb_thread_save_context(th),thread_switch(setjmp((th)->context)))
static void rb_thread_restore_context _((thread_t,int)); static void rb_thread_restore_context _((thread_t,int));
static void static void
@ -6312,21 +6364,6 @@ stack_extend(th, exit)
rb_thread_restore_context(th, exit); rb_thread_restore_context(th, exit);
} }
static int th_raise_argc;
static VALUE th_raise_argv[2];
static char *th_raise_file;
static int th_raise_line;
static VALUE th_cmd;
static int th_sig;
static char *th_signm;
#define RESTORE_NORMAL 0
#define RESTORE_FATAL 1
#define RESTORE_INTERRUPT 2
#define RESTORE_TRAP 3
#define RESTORE_RAISE 4
#define RESTORE_SIGNAL 5
static void static void
rb_thread_restore_context(th, exit) rb_thread_restore_context(th, exit)
thread_t th; thread_t th;
@ -6373,35 +6410,7 @@ rb_thread_restore_context(th, exit)
rb_lastline_set(tmp->last_line); rb_lastline_set(tmp->last_line);
rb_backref_set(tmp->last_match); rb_backref_set(tmp->last_match);
switch (ex) { longjmp(tmp->context, ex);
case RESTORE_FATAL:
JUMP_TAG(TAG_FATAL);
break;
case RESTORE_INTERRUPT:
rb_interrupt();
break;
case RESTORE_TRAP:
rb_trap_eval(th_cmd, th_sig);
errno = EINTR;
break;
case RESTORE_SIGNAL:
rb_raise(rb_eSignal, "SIG%s", th_signm);
break;
case RESTORE_RAISE:
ruby_frame->last_func = 0;
ruby_sourcefile = th_raise_file;
ruby_sourceline = th_raise_line;
rb_f_raise(th_raise_argc, th_raise_argv);
break;
case RESTORE_NORMAL:
default:
longjmp(tmp->context, 1);
}
} }
static void static void
@ -6639,8 +6648,7 @@ rb_thread_schedule()
/* context switch */ /* context switch */
if (curr == curr_thread) { if (curr == curr_thread) {
rb_thread_save_context(curr); if (THREAD_SAVE_CONTEXT(curr)) {
if (setjmp(curr->context)) {
return; return;
} }
} }
@ -7209,15 +7217,13 @@ rb_thread_create_0(fn, arg, klass)
scope_dup(ruby_scope); scope_dup(ruby_scope);
FL_SET(ruby_scope, SCOPE_SHARED); FL_SET(ruby_scope, SCOPE_SHARED);
rb_thread_save_context(curr_thread); if (THREAD_SAVE_CONTEXT(curr_thread)) {
if (setjmp(curr_thread->context)) {
return thread; return thread;
} }
PUSH_TAG(PROT_THREAD); PUSH_TAG(PROT_THREAD);
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
rb_thread_save_context(th); if (THREAD_SAVE_CONTEXT(th) == 0) {
if (setjmp(th->context) == 0) {
curr_thread = th; curr_thread = th;
th->result = (*fn)(arg, th); th->result = (*fn)(arg, th);
} }
@ -7384,8 +7390,7 @@ rb_thread_interrupt()
if (curr_thread == main_thread) { if (curr_thread == main_thread) {
rb_interrupt(); rb_interrupt();
} }
rb_thread_save_context(curr_thread); if (THREAD_SAVE_CONTEXT(curr_thread)) {
if (setjmp(curr_thread->context)) {
return; return;
} }
curr_thread = main_thread; curr_thread = main_thread;
@ -7403,8 +7408,7 @@ rb_thread_signal_raise(sig)
rb_raise(rb_eSignal, "SIG%s", sig); rb_raise(rb_eSignal, "SIG%s", sig);
} }
rb_thread_ready(main_thread); rb_thread_ready(main_thread);
rb_thread_save_context(curr_thread); if (THREAD_SAVE_CONTEXT(curr_thread)) {
if (setjmp(curr_thread->context)) {
return; return;
} }
th_signm = sig; th_signm = sig;
@ -7417,6 +7421,7 @@ rb_thread_trap_eval(cmd, sig)
VALUE cmd; VALUE cmd;
int sig; int sig;
{ {
#if 0
rb_thread_critical = 0; rb_thread_critical = 0;
if (!rb_thread_dead(curr_thread)) { if (!rb_thread_dead(curr_thread)) {
rb_thread_ready(curr_thread); rb_thread_ready(curr_thread);
@ -7424,14 +7429,26 @@ rb_thread_trap_eval(cmd, sig)
return; return;
} }
rb_thread_ready(main_thread); rb_thread_ready(main_thread);
rb_thread_save_context(curr_thread); if (THREAD_SAVE_CONTEXT(curr_thread)) {
if (setjmp(curr_thread->context)) {
return; return;
} }
th_cmd = cmd; th_cmd = cmd;
th_sig = sig; th_sig = sig;
curr_thread = main_thread; curr_thread = main_thread;
rb_thread_restore_context(curr_thread, RESTORE_TRAP); rb_thread_restore_context(curr_thread, RESTORE_TRAP);
#else
rb_thread_critical = 0;
if (!rb_thread_dead(curr_thread)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) {
return;
}
}
rb_thread_ready(main_thread);
th_cmd = cmd;
th_sig = sig;
curr_thread = main_thread;
rb_thread_restore_context(curr_thread, RESTORE_TRAP);
#endif
} }
static VALUE static VALUE
@ -7442,17 +7459,15 @@ rb_thread_raise(argc, argv, thread)
{ {
thread_t th = rb_thread_check(thread); thread_t th = rb_thread_check(thread);
if (rb_thread_dead(th)) return thread; if (rb_thread_dead(th)) return Qnil;
if (curr_thread == th) { if (curr_thread == th) {
rb_f_raise(argc, argv); rb_f_raise(argc, argv);
} }
if (th->safe < 4) { if (ruby_safe_level > th->safe) {
rb_secure(4); rb_secure(4);
} }
if (curr_thread->status != THREAD_KILLED) if (THREAD_SAVE_CONTEXT(curr_thread)) {
rb_thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
return thread; return thread;
} }
@ -7613,8 +7628,7 @@ rb_callcc(self)
for (tag=prot_tag; tag; tag=tag->prev) { for (tag=prot_tag; tag; tag=tag->prev) {
scope_dup(tag->scope); scope_dup(tag->scope);
} }
rb_thread_save_context(th); if (THREAD_SAVE_CONTEXT(th)) {
if (setjmp(th->context)) {
return th->result; return th->result;
} }
else { else {
@ -7793,7 +7807,7 @@ static VALUE
catch_i(tag) catch_i(tag)
ID tag; ID tag;
{ {
return rb_funcall(Qnil, rb_intern("catch"), 0, FIX2INT(tag)); return rb_funcall(Qnil, rb_intern("catch"), 0, INT2FIX(tag));
} }
VALUE VALUE
@ -7846,7 +7860,7 @@ rb_throw(tag, val)
VALUE argv[2]; VALUE argv[2];
ID t = rb_intern(tag); ID t = rb_intern(tag);
argv[0] = FIX2INT(t); argv[0] = INT2FIX(t);
argv[1] = val; argv[1] = val;
rb_f_throw(2, argv); rb_f_throw(2, argv);
} }

View file

@ -38,6 +38,7 @@
* - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag. * - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag.
*/ */
#include "config.h"
#include <sys/types.h> #include <sys/types.h>
#ifndef NT #ifndef NT
#include <sys/param.h> #include <sys/param.h>
@ -66,7 +67,6 @@
#include <socks.h> #include <socks.h>
#endif #endif
#include "config.h"
#include "addrinfo.h" #include "addrinfo.h"
#include "sockport.h" #include "sockport.h"

View file

@ -34,6 +34,7 @@
* but INRIA implementation returns EAI_xxx defined for getaddrinfo(). * but INRIA implementation returns EAI_xxx defined for getaddrinfo().
*/ */
#include "config.h"
#include <sys/types.h> #include <sys/types.h>
#ifndef NT #ifndef NT
#include <sys/socket.h> #include <sys/socket.h>
@ -60,7 +61,6 @@
#include <socks.h> #include <socks.h>
#endif #endif
#include "config.h"
#include "addrinfo.h" #include "addrinfo.h"
#include "sockport.h" #include "sockport.h"

View file

@ -86,7 +86,7 @@ int Rconnect();
* RFC 2553: protocol-independent placeholder for socket addresses * RFC 2553: protocol-independent placeholder for socket addresses
*/ */
#define _SS_MAXSIZE 128 #define _SS_MAXSIZE 128
#define _SS_ALIGNSIZE (sizeof(long long)) #define _SS_ALIGNSIZE (sizeof(double))
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2) #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \ #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
_SS_PAD1SIZE - _SS_ALIGNSIZE) _SS_PAD1SIZE - _SS_ALIGNSIZE)
@ -99,7 +99,7 @@ struct sockaddr_storage {
unsigned short ss_family; unsigned short ss_family;
#endif #endif
char __ss_pad1[_SS_PAD1SIZE]; char __ss_pad1[_SS_PAD1SIZE];
long long __ss_align; /* force desired structure storage alignment */ double __ss_align; /* force desired structure storage alignment */
char __ss_pad2[_SS_PAD2SIZE]; char __ss_pad2[_SS_PAD2SIZE];
}; };
#endif #endif

8
file.c
View file

@ -1077,7 +1077,7 @@ static VALUE
rb_file_s_symlink(obj, from, to) rb_file_s_symlink(obj, from, to)
VALUE obj, from, to; VALUE obj, from, to;
{ {
#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__) #if !defined(MSDOS) && !defined(NT) && !defined(__EMX__) && !defined(riscos)
Check_SafeStr(from); Check_SafeStr(from);
Check_SafeStr(to); Check_SafeStr(to);
@ -1094,7 +1094,7 @@ static VALUE
rb_file_s_readlink(obj, path) rb_file_s_readlink(obj, path)
VALUE obj, path; VALUE obj, path;
{ {
#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__) #if !defined(MSDOS) && !defined(NT) && !defined(__EMX__) && !defined(riscos)
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
int cc; int cc;
@ -2026,7 +2026,7 @@ rb_path_check(path)
return 1; return 1;
} }
#ifdef __MACOS__ #if defined(__MACOS__) || defined(riscos)
static int static int
is_macos_native_path(path) is_macos_native_path(path)
const char *path; const char *path;
@ -2045,7 +2045,7 @@ rb_find_file(file)
VALUE fname; VALUE fname;
char *path; char *path;
#ifdef __MACOS__ #if defined(__MACOS__) || defined(riscos)
if (is_macos_native_path(file)) { if (is_macos_native_path(file)) {
FILE *f; FILE *f;

7
hash.c
View file

@ -34,6 +34,13 @@ rb_hash_modify(hash)
rb_raise(rb_eSecurityError, "Insecure: can't modify hash"); rb_raise(rb_eSecurityError, "Insecure: can't modify hash");
} }
VALUE
rb_hash_freeze(hash)
VALUE hash;
{
return rb_obj_freeze(hash);
}
VALUE rb_cHash; VALUE rb_cHash;
static VALUE envtbl; static VALUE envtbl;

View file

@ -15,12 +15,17 @@ if ENV["prefix"]
else else
prefix = CONFIG["prefix"] prefix = CONFIG["prefix"]
end end
ruby_install_name = CONFIG["ruby_install_name"] ruby_install_name = CONFIG["ruby_install_name"]
version = "/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
arch = version+"/"+CONFIG["arch"]
bindir = destdir+CONFIG["bindir"] bindir = destdir+CONFIG["bindir"]
libdir = destdir+CONFIG["libdir"] libdir = destdir+CONFIG["libdir"]
#pkglibdir = libdir + "/" + ruby_install_name+"/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"] rubydir = libdir+"/ruby"
pkglibdir = libdir + "/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"] rubylibdir = rubydir+version
archdir = pkglibdir + "/" + CONFIG["arch"] archlibdir = rubydir+arch
sitelibdir = rubydir+"/site_ruby"+version
mandir = destdir+CONFIG["mandir"] + "/man1" mandir = destdir+CONFIG["mandir"] + "/man1"
wdir = Dir.getwd wdir = Dir.getwd
@ -47,17 +52,16 @@ if File.exist? CONFIG["LIBRUBY_SO"]
end end
end end
Dir.chdir wdir Dir.chdir wdir
File.makedirs pkglibdir, true File.makedirs rubylibdir, true
File.makedirs archdir, true File.makedirs archlibdir, true
File.makedirs pkglibdir+"/site_ruby", true File.makedirs sitelibdir, true
File.makedirs pkglibdir+"/site_ruby/"+CONFIG["arch"], true
if RUBY_PLATFORM =~ /cygwin/ and File.exist? "import.h" if RUBY_PLATFORM =~ /cygwin/ and File.exist? "import.h"
File.install "import.h", archdir, 0644, true File.install "import.h", archlibdir, 0644, true
end end
if RUBY_PLATFORM =~ /-aix/ if RUBY_PLATFORM =~ /-aix/
File.install "ruby.imp", archdir, 0644, true File.install "ruby.imp", archlibdir, 0644, true
end end
Dir.chdir "ext" Dir.chdir "ext"
@ -72,20 +76,20 @@ Find.find("lib") do |f|
end end
for f in Dir["*.h"] for f in Dir["*.h"]
File.install f, archdir, 0644, true File.install f, archlibdir, 0644, true
end end
if RUBY_PLATFORM =~ /mswin32/ if RUBY_PLATFORM =~ /mswin32/
File.makedirs archdir + "/win32", true File.makedirs archlibdir + "/win32", true
File.install "win32/win32.h", archdir + "/win32", 0644, true File.install "win32/win32.h", archlibdir + "/win32", 0644, true
if File.exist? wdir+'/rubymw.lib' if File.exist? wdir+'/rubymw.lib'
File.install wdir+'/rubymw.lib', archdir, 0644, true File.install wdir+'/rubymw.lib', archlibdir, 0644, true
end end
end end
File.install wdir+'/'+CONFIG['LIBRUBY_A'], archdir, 0644, true File.install wdir+'/'+CONFIG['LIBRUBY_A'], archlibdir, 0644, true
File.makedirs mandir, true File.makedirs mandir, true
File.install "ruby.1", mandir, 0644, true File.install "ruby.1", mandir, 0644, true
Dir.chdir wdir Dir.chdir wdir
File.install "config.h", archdir, 0644, true File.install "config.h", archlibdir, 0644, true
File.install "rbconfig.rb", archdir, 0644, true File.install "rbconfig.rb", archlibdir, 0644, true
# vi:set sw=2: # vi:set sw=2:

10
io.c
View file

@ -1608,8 +1608,8 @@ rb_file_s_open(argc, argv, klass)
path = RSTRING(fname)->ptr; path = RSTRING(fname)->ptr;
if (FIXNUM_P(vmode)) { if (FIXNUM_P(vmode)) {
int flags = FIX2INT(vmode); int flags = NUM2INT(vmode);
int fmode = NIL_P(perm) ? 0666 : FIX2INT(perm); int fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
file = rb_file_sysopen_internal(klass, path, flags, fmode); file = rb_file_sysopen_internal(klass, path, flags, fmode);
} }
@ -1649,7 +1649,7 @@ rb_f_open(argc, argv)
mode = "r"; mode = "r";
} }
else if (FIXNUM_P(pmode)) { else if (FIXNUM_P(pmode)) {
mode = rb_io_flags_mode(FIX2INT(pmode)); mode = rb_io_flags_mode(NUM2INT(pmode));
} }
else { else {
int len; int len;
@ -1661,6 +1661,7 @@ rb_f_open(argc, argv)
} }
port = pipe_open(RSTRING(pname)->ptr+1, mode); port = pipe_open(RSTRING(pname)->ptr+1, mode);
if (!rb_iterator_p()) return port;
if (NIL_P(port)) { if (NIL_P(port)) {
rb_yield(port); rb_yield(port);
} }
@ -3396,4 +3397,7 @@ Init_IO()
#ifdef O_BINARY #ifdef O_BINARY
rb_file_const("BINARY", INT2FIX(O_BINARY)); rb_file_const("BINARY", INT2FIX(O_BINARY));
#endif #endif
#ifdef O_SYNC
rb_file_const("BINARY", INT2FIX(O_SYNC));
#endif
} }

View file

@ -16,7 +16,7 @@ module Find
d = Dir.open(file) d = Dir.open(file)
begin begin
for f in d for f in d
next if f =~ /^\.\.?$/ next if f =~ /\A\.\.?\z/
if File::ALT_SEPARATOR and file =~ /^([\/\\]|[A-Za-z]:[\/\\]?)$/ then if File::ALT_SEPARATOR and file =~ /^([\/\\]|[A-Za-z]:[\/\\]?)$/ then
f = file + f f = file + f
elsif file == "/" then elsif file == "/" then

6
math.c
View file

@ -22,11 +22,11 @@ VALUE rb_mMath;
} }
static VALUE static VALUE
math_atan2(obj, x, y) math_atan2(obj, y, x)
VALUE obj, x, y; VALUE obj, x, y;
{ {
Need_Float2(x, y); Need_Float2(y, x);
return rb_float_new(atan2(RFLOAT(x)->value, RFLOAT(y)->value)); return rb_float_new(atan2(RFLOAT(y)->value, RFLOAT(x)->value));
} }
static VALUE static VALUE

View file

@ -1,31 +1,23 @@
/* This is file FILE.H */ /* This is file FILE.H */
/*
** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
**
** This file is distributed under the terms listed in the document
** "copying.dj", available from DJ Delorie at the address above.
** A copy of "copying.dj" should accompany this file; if not, a copy
** should be available from where this file was obtained. This file
** may not be distributed without a verbatim copy of "copying.dj".
**
** This file is distributed WITHOUT ANY WARRANTY; without even the implied
** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef _FILE_H_ #ifndef _FILE_H_
#define _FILE_H_ #define _FILE_H_
#include <fcntl.h> #include <fcntl.h>
#define L_SET 0 #ifndef L_SET
#define L_CURR 1 # define L_SET 0 /* seek from beginning. */
#define L_INCR 1 # define L_CURR 1 /* seek from current position. */
#define L_XTND 2 # define L_INCR 1 /* ditto. */
# define L_XTND 2 /* seek from end. */
#endif
# ifndef R_OK
#define F_OK 0 /* does file exist */ # define R_OK 4 /* test whether readable. */
#define X_OK 1 /* is it executable by caller */ # define W_OK 2 /* test whether writable. */
#define W_OK 2 /* is it writable by caller */ # define X_OK 1 /* test whether execubale. */
#define R_OK 4 /* is it readable by caller */ # define F_OK 0 /* test whether exist. */
# endif
#endif
#endif #endif

View file

@ -6,8 +6,13 @@
* Copyright (c) 1988-1993 The Regents of the University of California. * Copyright (c) 1988-1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc. * Copyright (c) 1994 Sun Microsystems, Inc.
* *
* See the file "license.terms" for information on usage and redistribution * Permission to use, copy, modify, and distribute this
* of this file, and for a DISCLAIMER OF ALL WARRANTIES. * software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
* *
* RCS: @(#) $Id$ * RCS: @(#) $Id$
*/ */

View file

@ -43,8 +43,8 @@ num_coerce(x, y)
VALUE x, y; VALUE x, y;
{ {
if (CLASS_OF(x) == CLASS_OF(y)) if (CLASS_OF(x) == CLASS_OF(y))
return rb_assoc_new(x, y); return rb_assoc_new(y, x);
return rb_assoc_new(rb_Float(x), rb_Float(y)); return rb_assoc_new(rb_Float(y), rb_Float(x));
} }
static VALUE static VALUE

17
parse.y
View file

@ -2430,7 +2430,7 @@ parse_quotedwords(term, paren)
strstart = ruby_sourceline; strstart = ruby_sourceline;
newtok(); newtok();
while ((c = nextc()) == ' ') while (c = nextc(),ISSPACE(c))
; /* skip preceding spaces */ ; /* skip preceding spaces */
pushback(c); pushback(c);
while ((c = nextc()) != term || nest > 0) { while ((c = nextc()) != term || nest > 0) {
@ -2455,14 +2455,13 @@ parse_quotedwords(term, paren)
case '\\': case '\\':
c = '\\'; c = '\\';
break; break;
case ' ':
tokadd(' ');
break;
default: default:
tokadd('\\'); if (ISSPACE(c))
tokadd('\\');
tokadd(c);
} }
} }
else if (c == ' ') { else if (ISSPACE(c)) {
NODE *str; NODE *str;
tokfix(); tokfix();
@ -2470,7 +2469,7 @@ parse_quotedwords(term, paren)
newtok(); newtok();
if (!qwords) qwords = NEW_LIST(str); if (!qwords) qwords = NEW_LIST(str);
else list_append(qwords, str); else list_append(qwords, str);
while ((c = nextc()) == ' ') while (c = nextc(),ISSPACE(c))
; /* skip continuous spaces */ ; /* skip continuous spaces */
pushback(c); pushback(c);
continue; continue;
@ -3414,8 +3413,8 @@ yylex()
result = tFID; result = tFID;
} }
else { else {
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) { if (lex_state == EXPR_FNAME) {
if ((c = nextc()) == '=' && !peek('=')) { if ((c = nextc()) == '=' && !peek('=') && !peek('~')) {
result = tIDENTIFIER; result = tIDENTIFIER;
tokadd(c); tokadd(c);
} }

View file

@ -160,7 +160,7 @@ wait_each(key, value, data)
#endif #endif
static VALUE static VALUE
rb_f_wait() proc_wait()
{ {
int pid, state; int pid, state;
#ifdef NO_WAITPID #ifdef NO_WAITPID
@ -189,16 +189,17 @@ rb_f_wait()
} }
static VALUE static VALUE
rb_f_waitpid(obj, vpid, vflags) proc_waitpid(obj, vpid, vflags)
VALUE obj, vpid, vflags; VALUE obj, vpid, vflags;
{ {
int pid, flags, status; int pid, flags, status;
if (NIL_P(vflags)) flags = 0; if (NIL_P(vflags)) flags = 0;
else flags = FIX2UINT(vflags); else flags = NUM2UINT(vflags);
if ((pid = rb_waitpid(FIX2UINT(vpid), flags, &status)) < 0) if ((pid = rb_waitpid(NUM2INT(vpid), flags, &status)) < 0)
rb_sys_fail(0); rb_sys_fail(0);
if (pid == 0) return Qnil;
return INT2FIX(pid); return INT2FIX(pid);
} }
@ -1056,8 +1057,8 @@ Init_process()
rb_define_module_function(rb_mProcess, "kill", rb_f_kill, -1); rb_define_module_function(rb_mProcess, "kill", rb_f_kill, -1);
#endif #endif
#ifndef NT #ifndef NT
rb_define_module_function(rb_mProcess, "wait", rb_f_wait, 0); rb_define_module_function(rb_mProcess, "wait", proc_wait, 0);
rb_define_module_function(rb_mProcess, "waitpid", rb_f_waitpid, 2); rb_define_module_function(rb_mProcess, "waitpid", proc_waitpid, 2);
#ifndef USE_CWGUSI #ifndef USE_CWGUSI
rb_define_module_function(rb_mProcess, "pid", get_pid, 0); rb_define_module_function(rb_mProcess, "pid", get_pid, 0);

View file

@ -3721,12 +3721,12 @@ re_match(bufp, string_arg, size, pos, regs)
cc = c = (unsigned char)translate[c]; cc = c = (unsigned char)translate[c];
not = is_in_list(c, p); not = is_in_list(c, p);
if (!not && cc != c) {
part = not = is_in_list(cc, p);
}
if (*(p - 1) == (unsigned char)charset_not) { if (*(p - 1) == (unsigned char)charset_not) {
not = !not; not = !not;
} }
else if (!not && cc != c) {
part = not = is_in_list(cc, p);
}
if (!not) goto fail; if (!not) goto fail;
p += 1 + *p + 2 + EXTRACT_UNSIGNED(&p[1 + *p])*8; p += 1 + *p + 2 + EXTRACT_UNSIGNED(&p[1 + *p])*8;

24
ruby.c
View file

@ -108,13 +108,6 @@ NULL
printf("\n %s", *p++); printf("\n %s", *p++);
} }
#ifndef RUBY_LIB
#define RUBY_LIB "/usr/local/lib/ruby"
#endif
#ifndef RUBY_SITE_LIB
#define RUBY_SITE_LIB "/usr/local/lib/site_ruby"
#endif
extern VALUE rb_load_path; extern VALUE rb_load_path;
#define STATIC_FILE_LENGTH 255 #define STATIC_FILE_LENGTH 255
@ -215,7 +208,7 @@ addpath(path)
} }
struct req_list { struct req_list {
const char *name; char *name;
struct req_list *next; struct req_list *next;
} req_list_head; } req_list_head;
struct req_list *req_list_last = &req_list_head; struct req_list *req_list_last = &req_list_head;
@ -227,7 +220,8 @@ add_modules(mod)
struct req_list *list; struct req_list *list;
list = ALLOC(struct req_list); list = ALLOC(struct req_list);
list->name = mod; list->name = ALLOC_N(char, strlen(mod)+1);
strcpy(list->name, mod);
list->next = 0; list->next = 0;
req_list_last->next = list; req_list_last->next = list;
req_list_last = list; req_list_last = list;
@ -248,6 +242,7 @@ require_libraries()
while (list) { while (list) {
rb_require(list->name); rb_require(list->name);
tmp = list->next; tmp = list->next;
free(list->name);
free(list); free(list);
list = tmp; list = tmp;
} }
@ -745,7 +740,11 @@ load_file(fname, script)
} }
} }
} }
else if (!NIL_P(c)) { else if (NIL_P(c)) {
rb_io_close(f);
return;
}
else {
rb_io_ungetc(f, c); rb_io_ungetc(f, c);
} }
} }
@ -930,17 +929,14 @@ ruby_prog_init()
addpath(ruby_libpath()); addpath(ruby_libpath());
#endif #endif
#ifdef RUBY_ARCHLIB
addpath(RUBY_ARCHLIB); addpath(RUBY_ARCHLIB);
#endif
#ifdef RUBY_THIN_ARCHLIB #ifdef RUBY_THIN_ARCHLIB
addpath(RUBY_THIN_ARCHLIB); addpath(RUBY_THIN_ARCHLIB);
#endif #endif
addpath(RUBY_SITE_LIB); addpath(RUBY_SITE_LIB);
#ifdef RUBY_SITE_ARCHLIB addpath(RUBY_SITE_LIB2);
addpath(RUBY_SITE_ARCHLIB); addpath(RUBY_SITE_ARCHLIB);
#endif
#ifdef RUBY_SITE_THIN_ARCHLIB #ifdef RUBY_SITE_THIN_ARCHLIB
addpath(RUBY_SITE_THIN_ARCHLIB); addpath(RUBY_SITE_THIN_ARCHLIB);
#endif #endif

3
ruby.h
View file

@ -115,10 +115,13 @@ typedef unsigned long ID;
#define FIXNUM_FLAG 0x01 #define FIXNUM_FLAG 0x01
#define INT2FIX(i) (VALUE)(((long)(i))<<1 | FIXNUM_FLAG) #define INT2FIX(i) (VALUE)(((long)(i))<<1 | FIXNUM_FLAG)
#define rb_fix_new(v) INT2FIX(v)
VALUE rb_int2inum _((long)); VALUE rb_int2inum _((long));
#define INT2NUM(v) rb_int2inum(v) #define INT2NUM(v) rb_int2inum(v)
#define rb_int_new(v) rb_int2inum(v)
VALUE rb_uint2inum _((unsigned long)); VALUE rb_uint2inum _((unsigned long));
#define UINT2NUM(v) rb_uint2inum(v) #define UINT2NUM(v) rb_uint2inum(v)
#define rb_uint_new(v) rb_uint2inum(v)
#define FIX2LONG(x) RSHIFT((long)x,1) #define FIX2LONG(x) RSHIFT((long)x,1)
#define FIX2ULONG(x) (((unsigned long)(x))>>1) #define FIX2ULONG(x) (((unsigned long)(x))>>1)

View file

@ -340,6 +340,13 @@ rb_str_modify(str)
RSTRING(str)->orig = 0; RSTRING(str)->orig = 0;
} }
VALUE
rb_str_freeze(str)
VALUE str;
{
return rb_obj_freeze(str);
}
VALUE VALUE
rb_str_dup_frozen(str) rb_str_dup_frozen(str)
VALUE str; VALUE str;
@ -561,6 +568,10 @@ rb_str_index_m(argc, argv, str)
else { else {
pos = 0; pos = 0;
} }
if (pos < 0) {
pos += RSTRING(str)->len;
if (pos < 0) return Qnil;
}
switch (TYPE(sub)) { switch (TYPE(sub)) {
case T_REGEXP: case T_REGEXP:

8
time.c
View file

@ -394,7 +394,7 @@ time_cmp(time1, time2)
i = FIX2LONG(time2); i = FIX2LONG(time2);
if (tobj1->tv.tv_sec == i) return INT2FIX(0); if (tobj1->tv.tv_sec == i) return INT2FIX(0);
if (tobj1->tv.tv_sec > i) return INT2FIX(1); if (tobj1->tv.tv_sec > i) return INT2FIX(1);
return FIX2INT(-1); return INT2FIX(-1);
case T_FLOAT: case T_FLOAT:
{ {
@ -414,15 +414,15 @@ time_cmp(time1, time2)
if (tobj1->tv.tv_sec == tobj2->tv.tv_sec) { if (tobj1->tv.tv_sec == tobj2->tv.tv_sec) {
if (tobj1->tv.tv_usec == tobj2->tv.tv_usec) return INT2FIX(0); if (tobj1->tv.tv_usec == tobj2->tv.tv_usec) return INT2FIX(0);
if (tobj1->tv.tv_usec > tobj2->tv.tv_usec) return INT2FIX(1); if (tobj1->tv.tv_usec > tobj2->tv.tv_usec) return INT2FIX(1);
return FIX2INT(-1); return INT2FIX(-1);
} }
if (tobj1->tv.tv_sec > tobj2->tv.tv_sec) return INT2FIX(1); if (tobj1->tv.tv_sec > tobj2->tv.tv_sec) return INT2FIX(1);
return FIX2INT(-1); return INT2FIX(-1);
} }
i = NUM2LONG(time2); i = NUM2LONG(time2);
if (tobj1->tv.tv_sec == i) return INT2FIX(0); if (tobj1->tv.tv_sec == i) return INT2FIX(0);
if (tobj1->tv.tv_sec > i) return INT2FIX(1); if (tobj1->tv.tv_sec > i) return INT2FIX(1);
return FIX2INT(-1); return INT2FIX(-1);
} }
static VALUE static VALUE

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.2" #define RUBY_VERSION "1.5.2"
#define RUBY_RELEASE_DATE "2000-02-08" #define RUBY_RELEASE_DATE "2000-02-17"
#define RUBY_VERSION_CODE 152 #define RUBY_VERSION_CODE 152
#define RUBY_RELEASE_CODE 20000208 #define RUBY_RELEASE_CODE 20000217