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/branches/ruby_1_4@620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-02-17 08:29:09 +00:00
parent e9bdbbdb75
commit bc5ff99474
17 changed files with 160 additions and 112 deletions

View file

@ -1,3 +1,41 @@
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 (rb_f_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>
* 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_*.
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].
Fri Feb 4 10:20:25 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* io.c (rb_io_close): should not check closed IO.
@ -6,6 +44,10 @@ Fri Feb 4 05:44:01 2000 Kentaro Inagaki <inagaki@tg.rim.or.jp>
* ext/socket/socket.c (s_recv): TRAP_BEG after retry entry.
Thu Jan 27 01:27:10 2000 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
* dir.c (glob): glob pattern "/*" did not match.
Wed Jan 26 22:30:47 2000 Shigeo Kobayashi <shigeo@tinyforest.gr.jp>
* numeric.c (flo_modulo): wrong result for negative modulo.

4
dir.c
View file

@ -576,11 +576,11 @@ glob(path, func, arg)
break;
}
magic = extract_elem(p);
#define BASE (*base && !(*base == '/' && !base[1]))
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if (fnmatch(magic, dp->d_name, FNM_PERIOD|FNM_PATHNAME) == 0) {
char *fix = ALLOC_N(char, strlen(base)+NAMLEN(dp)+2);
#define BASE (*base && !(*base == '/' && !base[1]))
sprintf(fix, "%s%s%s", base, (BASE)?"/":"", dp->d_name);
if (!m) {
(*func)(fix, arg);

130
eval.c
View file

@ -3622,7 +3622,7 @@ rb_f_missing(argc, argv, obj)
if (argc == 0) rb_raise(rb_eArgError, "no id given");
id = FIX2INT(argv[0]);
id = NUM2INT(argv[0]);
argc--; argv++;
switch (TYPE(obj)) {
@ -5736,7 +5736,7 @@ proc_arity(proc)
int n;
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)) {
default:
return INT2FIX(-2);
@ -5933,7 +5933,7 @@ method_arity(method)
body = body->nd_head;
if (!body) return INT2FIX(0);
n = body->nd_cnt;
if (body->nd_rest) n = -n-1;
if (body->nd_rest >= 0) n = -n-1;
return INT2FIX(n);
}
}
@ -6223,6 +6223,21 @@ rb_thread_check(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
rb_thread_save_context(th)
thread_t th;
@ -6260,6 +6275,41 @@ rb_thread_save_context(th)
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
@ -6273,21 +6323,6 @@ stack_extend(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
rb_thread_restore_context(th, exit)
thread_t th;
@ -6333,35 +6368,7 @@ rb_thread_restore_context(th, exit)
rb_lastline_set(tmp->last_line);
rb_backref_set(tmp->last_match);
switch (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);
}
longjmp(tmp->context, ex);
}
static void
@ -6595,8 +6602,7 @@ rb_thread_schedule()
/* context switch */
if (curr == curr_thread) {
rb_thread_save_context(curr);
if (setjmp(curr->context)) {
if (THREAD_SAVE_CONTEXT(curr)) {
return;
}
}
@ -7098,15 +7104,13 @@ rb_thread_create_0(fn, arg, klass)
#endif
FL_SET(ruby_scope, SCOPE_SHARED);
rb_thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) {
return thread;
}
PUSH_TAG(PROT_THREAD);
if ((state = EXEC_TAG()) == 0) {
rb_thread_save_context(th);
if (setjmp(th->context) == 0) {
if (THREAD_SAVE_CONTEXT(th) == 0) {
curr_thread = th;
th->result = (*fn)(arg, th);
}
@ -7260,8 +7264,7 @@ rb_thread_interrupt()
if (curr_thread == main_thread) {
rb_interrupt();
}
rb_thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) {
return;
}
curr_thread = main_thread;
@ -7279,8 +7282,7 @@ rb_thread_signal_raise(sig)
rb_raise(rb_eSignal, "SIG%s", sig);
}
rb_thread_ready(main_thread);
rb_thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) {
return;
}
th_signm = sig;
@ -7300,8 +7302,7 @@ rb_thread_trap_eval(cmd, sig)
return;
}
rb_thread_ready(main_thread);
rb_thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) {
return;
}
th_cmd = cmd;
@ -7323,9 +7324,9 @@ rb_thread_raise(argc, argv, thread)
rb_f_raise(argc, argv);
}
if (curr_thread->status != THREAD_KILLED)
if (!curr_thread->status != THREAD_KILLED)
rb_thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
if (thread_switch(setjmp(curr_thread->context))) {
return thread;
}
@ -7452,8 +7453,7 @@ rb_callcc(self)
for (tag=prot_tag; tag; tag=tag->prev) {
scope_dup(tag->scope);
}
rb_thread_save_context(th);
if (setjmp(th->context)) {
if (THREAD_SAVE_CONTEXT(th)) {
return th->result;
}
else {
@ -7561,7 +7561,7 @@ static VALUE
catch_i(tag)
ID tag;
{
return rb_funcall(Qnil, rb_intern("catch"), 0, FIX2INT(tag));
return rb_funcall(Qnil, rb_intern("catch"), 0, INT2FIX(tag));
}
VALUE
@ -7614,7 +7614,7 @@ rb_throw(tag, val)
VALUE argv[2];
ID t = rb_intern(tag);
argv[0] = FIX2INT(t);
argv[0] = INT2FIX(t);
argv[1] = val;
rb_f_throw(2, argv);
}

View file

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

View file

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

View file

@ -86,7 +86,7 @@ int Rconnect();
* RFC 2553: protocol-independent placeholder for socket addresses
*/
#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_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
_SS_PAD1SIZE - _SS_ALIGNSIZE)
@ -99,7 +99,7 @@ struct sockaddr_storage {
unsigned short ss_family;
#endif
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];
};
#endif

6
io.c
View file

@ -1588,8 +1588,8 @@ rb_file_s_open(argc, argv, klass)
path = RSTRING(fname)->ptr;
if (FIXNUM_P(vmode)) {
int flags = FIX2INT(vmode);
int fmode = NIL_P(perm) ? 0666 : FIX2INT(perm);
int flags = NUM2INT(vmode);
int fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
file = rb_file_sysopen_internal(klass, path, flags, fmode);
}
@ -1629,7 +1629,7 @@ rb_f_open(argc, argv)
mode = "r";
}
else if (FIXNUM_P(pmode)) {
mode = rb_io_flags_mode(FIX2INT(pmode));
mode = rb_io_flags_mode(NUM2INT(pmode));
}
else {
int len;

View file

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

View file

@ -1,31 +1,23 @@
/* 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_
#define _FILE_H_
#include <fcntl.h>
#define L_SET 0
#define L_CURR 1
#define L_INCR 1
#define L_XTND 2
#ifndef L_SET
# define L_SET 0 /* seek from beginning. */
# define L_CURR 1 /* seek from current position. */
# define L_INCR 1 /* ditto. */
# define L_XTND 2 /* seek from end. */
#endif
#define F_OK 0 /* does file exist */
#define X_OK 1 /* is it executable by caller */
#define W_OK 2 /* is it writable by caller */
#define R_OK 4 /* is it readable by caller */
# ifndef R_OK
# define R_OK 4 /* test whether readable. */
# define W_OK 2 /* test whether writable. */
# define X_OK 1 /* test whether execubale. */
# define F_OK 0 /* test whether exist. */
# endif
#endif
#endif

View file

@ -6,8 +6,13 @@
* Copyright (c) 1988-1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* Permission to use, copy, modify, and distribute this
* 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$
*/

View file

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

View file

@ -3264,8 +3264,8 @@ yylex()
}
else {
result = tIDENTIFIER;
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
if ((c = nextc()) == '=' && !peek('=')) {
if (lex_state == EXPR_FNAME) {
if ((c = nextc()) == '=' && !peek('=') && !peek('~')) {
tokadd(c);
}
else {

View file

@ -195,10 +195,11 @@ rb_f_waitpid(obj, vpid, vflags)
int pid, flags, status;
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);
if (pid == 0) return Qnil;
return INT2FIX(pid);
}

6
ruby.c
View file

@ -683,7 +683,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);
}
}

View file

@ -580,6 +580,10 @@ rb_str_index_method(argc, argv, str)
else {
pos = 0;
}
if (pos < 0) {
pos += RSTRING(str)->len;
if (pos < 0) return Qnil;
}
switch (TYPE(sub)) {
case T_REGEXP:

10
time.c
View file

@ -386,7 +386,7 @@ time_cmp(time1, time2)
i = FIX2LONG(time2);
if (tobj1->tv.tv_sec == i) return INT2FIX(0);
if (tobj1->tv.tv_sec > i) return INT2FIX(1);
return FIX2INT(-1);
return INT2FIX(-1);
case T_FLOAT:
{
@ -399,7 +399,7 @@ time_cmp(time1, time2)
return INT2FIX(0);
if (tobj1->tv.tv_sec > (time_t)RFLOAT(time2)->value)
return INT2FIX(1);
return FIX2INT(-1);
return INT2FIX(-1);
}
}
@ -408,15 +408,15 @@ time_cmp(time1, time2)
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(1);
return FIX2INT(-1);
return INT2FIX(-1);
}
if (tobj1->tv.tv_sec > tobj2->tv.tv_sec) return INT2FIX(1);
return FIX2INT(-1);
return INT2FIX(-1);
}
i = NUM2LONG(time2);
if (tobj1->tv.tv_sec == i) return INT2FIX(0);
if (tobj1->tv.tv_sec > i) return INT2FIX(1);
return FIX2INT(-1);
return INT2FIX(-1);
}
static VALUE

View file

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