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

2000-05-30

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-05-30 04:24:17 +00:00
parent 869b1efeb4
commit 9a1716fdb2
21 changed files with 245 additions and 185 deletions

View file

@ -1,3 +1,7 @@
Mon May 29 10:41:10 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* file.c (rb_file_s_basename): should propagate taintness.
Sun May 28 21:37:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* eval.c: bug fix: DLEXT2.
@ -18,6 +22,20 @@ Wed May 25 22:25:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* lib/mkmf.rb: ditto.
Thu May 25 22:01:32 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* defines.h: mswin32: remove obsolete USHORT definition.
* re.h: mswin32: use EXTERN instead of extern.
* regex.h: mswin32: export re_mbctab properly.
* win32/win32.def: add ruby_ignorecase and regex.c's exports.
Thu May 25 21:28:44 JST 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* re.c (rb_reg_expr_str): escape un-printable character.
Wed May 24 23:17:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* win32/Makefile: remove unnecessary mv and rm command call.
@ -34,6 +52,10 @@ Wed May 24 23:49:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* object.c (rb_mod_initialize): should provide initialize.
Wed May 24 23:17:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* win32/Makefile: remove unnecessary mv and rm command call.
Wed May 24 21:01:04 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* ext/pty/pty.c: use "" instead of <> to include ruby.h and rubyio.h

10
ToDo
View file

@ -24,6 +24,7 @@ Language Spec.
* discourage use of symbol variable (e.g. $/, etc.) in manual
* discourage use of Perlish features by giving warnings.
* `exception' method to be alternative for `$!'. ??
* non confusing in-block local variable (is it possible?)
Hacking Interpreter
@ -63,9 +64,11 @@ Standard Libraries
- Struct::new([name,]member,...)
- IO#reopen accepts path as well
- Kernel#scan
- call initialize for builtin classes too (not yet: Class, Module)
- call initialize for builtin classes too
- performance tune for String's non-bang methods.
- 'w' template for pack/unpack
- alternative for interator? => block_given?
- regex - /p (make obsolete), /m (new)
* String#scanf(?)
* Object#fmt(?)
* Integer#{bin,oct,hex,heX}
@ -106,8 +109,5 @@ Things To Do Before 1.6
* fix spec. for the following:
* alternative for $! (exception? in? into? =>?)
* alternative for interator?
- regex - /p, /m
* odd? even?
* alternative for $! (exception? in? =>? :?)
* mkmf.rb - create_makefile("net/socket")

View file

@ -1082,6 +1082,13 @@ rb_ary_delete_at(ary, pos)
return del;
}
VALUE
rb_ary_delete_at_m(ary, pos)
VALUE ary, pos;
{
return rb_ary_delete_at(ary, NUM2LONG(pos));
}
static VALUE
rb_ary_slice_bang(argc, argv, ary)
int argc;
@ -1629,7 +1636,7 @@ Init_Array()
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at, -1);
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at_m, 1);
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
rb_define_method(rb_cArray, "reject!", rb_ary_delete_if, 0);
rb_define_method(rb_cArray, "replace", rb_ary_replace_m, 1);

View file

@ -31,9 +31,7 @@
#endif /* NeXT */
#ifdef NT
#define USHORT _USHORT
#include "win32/win32.h"
#undef USHORT
#endif
#if defined __CYGWIN__

4
eval.c
View file

@ -6793,7 +6793,7 @@ rb_thread_schedule()
END_FOREACH_FROM(curr, th);
/* Do the select if needed */
if (need_select || !found) {
if (need_select) {
/* Convert delay to a timeval */
/* If a thread is runnable, just poll */
if (found) {
@ -7321,7 +7321,7 @@ rb_thread_abort_exc_set(thread, val)
#define THREAD_ALLOC(th) do {\
th = ALLOC(struct thread);\
\
th->status = 0;\
th->status = THREAD_RUNNABLE;\
th->result = 0;\
th->errinfo = Qnil;\
\

View file

@ -277,17 +277,17 @@ EOS
exit
end
case with_config("ipv6-lookup-order", "INET")
case with_config("lookup-order-hack", "UNSPEC")
when "INET"
$CFLAGS="-DDEFAULT_LOOKUP_ORDER_INET "+$CFLAGS
$CFLAGS="-DLOOKUP_ORDER_HACK_INET "+$CFLAGS
when "INET6"
$CFLAGS="-DDEFAULT_LOOKUP_ORDER_INET6 "+$CFLAGS
$CFLAGS="-DLOOKUP_ORDER_HACK_INET6 "+$CFLAGS
when "UNSPEC"
$CFLAGS="-DDEFAULT_LOOKUP_ORDER_UNSPEC "+$CFLAGS
# nothing special
else
print <<EOS
Fatal: invalid --ipv6-lookup-order (expected INET, INET6 or UNSPEC)
Fatal: invalid value for --with-lookup-order-hack (expected INET, INET6 or UNSPEC)
EOS
exit
end

View file

@ -104,48 +104,18 @@ struct sockaddr_storage {
};
#endif
#define LOOKUP_ORDER_UNSPEC 0
#define LOOKUP_ORDER_INET 1
#define LOOKUP_ORDER_INET6 2
#if defined(DEFAULT_LOOKUP_ORDER_UNSPEC)
# define LOOKUP_ORDER_DEFAULT LOOKUP_ORDER_UNSPEC
#elif defined(DEFAULT_LOOKUP_ORDER_INET)
# define LOOKUP_ORDER_DEFAULT LOOKUP_ORDER_INET
#elif defined(DEFAULT_LOOKUP_ORDER_INET6)
# define LOOKUP_ORDER_DEFAULT LOOKUP_ORDER_INET6
#endif
#ifdef INET6
#if defined(INET6) && (defined(LOOKUP_ORDER_HACK_INET) || defined(LOOKUP_ORDER_HACK_INET))
#define LOOKUP_ORDERS 3
int lookup_order_table[LOOKUP_ORDERS][LOOKUP_ORDERS] = {
{PF_UNSPEC, PF_UNSPEC, PF_UNSPEC}, /* 0:unspec */
{PF_INET, PF_INET6, PF_UNSPEC}, /* 1:inet inet6 */
{PF_INET6, PF_INET, PF_UNSPEC} /* 2:inet6 inet */
static int lookup_order_table[LOOKUP_ORDERS] = {
#if defined(LOOKUP_ORDER_HACK_INET)
PF_INET, PF_INET6, PF_UNSPEC,
#elif defined(LOOKUP_ORDER_HACK_INET6)
PF_INET6, PF_INET, PF_UNSPEC,
#else
/* should not happen */
#endif
};
static int lookup_order = LOOKUP_ORDER_DEFAULT;
static VALUE
lookup_order_get(self)
VALUE self;
{
return INT2FIX(lookup_order);
}
static VALUE
lookup_order_set(self, order)
VALUE self, order;
{
int n = NUM2INT(order);
if (n < 0 || LOOKUP_ORDERS <= n) {
rb_raise(rb_eArgError, "invalid value for lookup_order");
}
lookup_order = n;
return order;
}
static int
rb_getaddrinfo(nodename, servname, hints, res)
char *nodename;
@ -156,8 +126,12 @@ rb_getaddrinfo(nodename, servname, hints, res)
struct addrinfo tmp_hints;
int i, af, error;
if (hints->ai_family != PF_UNSPEC) {
return getaddrinfo(nodename, servname, hints, res);
}
for (i = 0; i < LOOKUP_ORDERS; i++) {
af = lookup_order_table[lookup_order][i];
af = lookup_order_table[i];
MEMCPY(&tmp_hints, hints, struct addrinfo, 1);
tmp_hints.ai_family = af;
error = getaddrinfo(nodename, servname, &tmp_hints, res);
@ -173,20 +147,7 @@ rb_getaddrinfo(nodename, servname, hints, res)
return error;
}
#else
static VALUE
lookup_order_get(self)
VALUE self;
{
return INT2FIX(LOOKUP_ORDER_DEFAULT);
}
static VALUE
lookup_order_set(self, order)
VALUE self, order;
{
return order;
}
#define getaddrinfo(node,serv,hints,res) rb_getaddrinfo((node),(serv),(hints),(res))
#endif
#ifdef NT
@ -641,11 +602,7 @@ ip_addrsetup(host, port)
MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
#ifndef INET6
error = getaddrinfo(hostp, portp, &hints, &res);
#else
error = rb_getaddrinfo(hostp, portp, &hints, &res);
#endif
if (error) {
if (hostp && hostp[strlen(hostp)-1] == '\n') {
rb_raise(rb_eSocket, "newline at the end of hostname");
@ -839,11 +796,7 @@ open_inet(class, h, serv, type)
if (type == INET_SERVER) {
hints.ai_flags = AI_PASSIVE;
}
#ifndef INET6
error = getaddrinfo(host, portp, &hints, &res0);
#else
error = rb_getaddrinfo(host, portp, &hints, &res0);
#endif
if (error) {
rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
@ -1878,11 +1831,9 @@ sock_s_getaddrinfo(argc, argv)
if (!NIL_P(family)) {
hints.ai_family = NUM2INT(family);
}
#ifndef INET6
else {
hints.ai_family = PF_UNSPEC;
}
#endif
if (!NIL_P(socktype)) {
hints.ai_socktype = NUM2INT(socktype);
}
@ -1892,16 +1843,7 @@ sock_s_getaddrinfo(argc, argv)
if (!NIL_P(flags)) {
hints.ai_flags = NUM2INT(flags);
}
#ifndef INET6
error = getaddrinfo(hptr, pptr, &hints, &res);
#else
if (!NIL_P(family)) {
error = getaddrinfo(hptr, pptr, &hints, &res);
}
else {
error = rb_getaddrinfo(hptr, pptr, &hints, &res);
}
#endif
if (error) {
rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
@ -1917,13 +1859,14 @@ sock_s_getnameinfo(argc, argv)
VALUE *argv;
{
VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags;
static char hbuf[1024], pbuf[1024];
char *hptr, *pptr;
char hbuf[1024], pbuf[1024];
int fl;
struct addrinfo hints, *res = NULL;
struct addrinfo hints, *res = NULL, *r;
int error;
struct sockaddr_storage ss;
struct sockaddr *sap;
char *ep;
sa = flags = Qnil;
rb_scan_args(argc, argv, "11", &sa, &flags);
@ -1932,7 +1875,6 @@ sock_s_getnameinfo(argc, argv)
if (!NIL_P(flags)) {
fl = NUM2INT(flags);
}
if (TYPE(sa) == T_STRING) {
if (sizeof(ss) < RSTRING(sa)->len) {
rb_raise(rb_eTypeError, "sockaddr length too big");
@ -1944,6 +1886,7 @@ sock_s_getnameinfo(argc, argv)
sap = (struct sockaddr *)&ss;
}
else if (TYPE(sa) == T_ARRAY) {
MEMZERO(&hints, struct addrinfo, 1);
if (RARRAY(sa)->len == 3) {
af = RARRAY(sa)->ptr[0];
port = RARRAY(sa)->ptr[1];
@ -1956,11 +1899,19 @@ sock_s_getnameinfo(argc, argv)
if (NIL_P(host)) {
host = RARRAY(sa)->ptr[2];
}
else {
/*
* 4th element holds numeric form, don't resolve.
* see ipaddr().
*/
hints.ai_flags |= AI_NUMERICHOST;
}
}
else {
rb_raise(rb_eArgError, "array size should be 3 or 4, %d given",
RARRAY(sa)->len);
}
/* host */
if (NIL_P(host)) {
hptr = NULL;
}
@ -1969,6 +1920,7 @@ sock_s_getnameinfo(argc, argv)
hbuf[sizeof(hbuf) - 1] = '\0';
hptr = hbuf;
}
/* port */
if (NIL_P(port)) {
strcpy(pbuf, "0");
pptr = NULL;
@ -1976,15 +1928,21 @@ sock_s_getnameinfo(argc, argv)
else if (FIXNUM_P(port)) {
snprintf(pbuf, sizeof(pbuf), "%ld", NUM2INT(port));
pptr = pbuf;
fl |= NI_NUMERICSERV;
}
else {
strncpy(pbuf, STR2CSTR(port), sizeof(pbuf));
pbuf[sizeof(pbuf) - 1] = '\0';
pptr = pbuf;
}
MEMZERO(&hints, struct addrinfo, 1);
if (strcmp(STR2CSTR(af), "AF_INET") == 0) {
hints.ai_socktype = (fl & NI_DGRAM) ? SOCK_DGRAM : SOCK_STREAM;
/* af */
if (NIL_P(af)) {
hints.ai_family = PF_UNSPEC;
}
else if (FIXNUM_P(af)) {
hints.ai_family = FIX2INT(af);
}
else if (strcmp(STR2CSTR(af), "AF_INET") == 0) {
hints.ai_family = PF_INET;
}
#ifdef INET6
@ -1992,13 +1950,8 @@ sock_s_getnameinfo(argc, argv)
hints.ai_family = PF_INET6;
}
#endif
else {
hints.ai_family = PF_UNSPEC;
}
error = getaddrinfo(hptr, pptr, &hints, &res);
if (error) {
rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
if (error) goto error_exit;
sap = res->ai_addr;
}
else {
@ -2007,13 +1960,25 @@ sock_s_getnameinfo(argc, argv)
error = getnameinfo(sap, SA_LEN(sap), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), fl);
if (error) {
rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
if (res)
freeaddrinfo(res);
if (error) goto error_exit;
for (r = res->ai_next; r; r = r->ai_next) {
char hbuf2[1024], pbuf2[1024];
sap = r->ai_addr;
error = getnameinfo(sap, SA_LEN(sap), hbuf2, sizeof(hbuf2),
pbuf2, sizeof(pbuf2), fl);
if (error) goto error_exit;
if (strcmp(hbuf, hbuf2) != 0|| strcmp(pbuf, pbuf2) != 0) {
freeaddrinfo(res);
rb_raise(rb_eSocket, "sockaddr resolved to multiple nodename");
}
}
freeaddrinfo(res);
return rb_assoc_new(rb_tainted_str_new2(hbuf), rb_tainted_str_new2(pbuf));
error_exit:
if (res) freeaddrinfo(res);
rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
static VALUE mConst;
@ -2175,12 +2140,6 @@ Init_socket()
sock_define_const("PF_INET6", PF_INET6);
#endif
sock_define_const("LOOKUP_INET", LOOKUP_ORDER_INET);
sock_define_const("LOOKUP_INET6", LOOKUP_ORDER_INET6);
sock_define_const("LOOKUP_UNSPEC", LOOKUP_ORDER_UNSPEC);
rb_define_singleton_method(rb_cBasicSocket, "lookup_order", lookup_order_get, 0);
rb_define_singleton_method(rb_cBasicSocket, "lookup_order=", lookup_order_set, 1);
sock_define_const("MSG_OOB", MSG_OOB);
#ifdef MSG_PEEK
sock_define_const("MSG_PEEK", MSG_PEEK);

23
file.c
View file

@ -1330,19 +1330,20 @@ rb_file_s_basename(argc, argv)
name = STR2CSTR(fname);
p = strrchr(name, '/');
if (!p) {
if (!NIL_P(fext)) {
f = rmext(name, ext);
if (f) return rb_str_new(name, f);
if (NIL_P(fext) || !(f = rmext(p, ext)))
return fname;
basename = rb_str_new(p, f);
}
else {
p++; /* skip last `/' */
if (NIL_P(fext) || !(f = rmext(p, ext))) {
basename = rb_str_new2(p);
}
else {
basename = rb_str_new(p, f);
}
return fname;
}
p++; /* skip last `/' */
if (!NIL_P(fext)) {
f = rmext(p, ext);
if (f) return rb_str_new(p, f);
}
basename = rb_str_new2(p);
if (OBJ_TAINTED(fname)) OBJ_TAINT(basename);
OBJ_INFECT(basename, fname);
return basename;
}

View file

@ -11,7 +11,7 @@ break, kBREAK, kBREAK, EXPR_END
case, kCASE, kCASE, EXPR_BEG
class, kCLASS, kCLASS, EXPR_CLASS
def, kDEF, kDEF, EXPR_FNAME
defined?, kDEFINED, kDEFINED, EXPR_END
defined?, kDEFINED, kDEFINED, EXPR_ARG
do, kDO, kDO, EXPR_BEG
else, kELSE, kELSE, EXPR_BEG
elsif, kELSIF, kELSIF, EXPR_BEG
@ -27,11 +27,11 @@ nil, kNIL, kNIL, EXPR_END
not, kNOT, kNOT, EXPR_BEG
or, kOR, kOR, EXPR_BEG
redo, kREDO, kREDO, EXPR_END
rescue, kRESCUE, kRESCUE_MOD, EXPR_MID
rescue, kRESCUE, kRESCUE_MOD, EXPR_END
retry, kRETRY, kRETRY, EXPR_END
return, kRETURN, kRETURN, EXPR_MID
self, kSELF, kSELF, EXPR_END
super, kSUPER, kSUPER, EXPR_END
super, kSUPER, kSUPER, EXPR_ARG
then, kTHEN, kTHEN, EXPR_BEG
true, kTRUE, kTRUE, EXPR_END
undef, kUNDEF, kUNDEF, EXPR_FNAME
@ -39,4 +39,4 @@ unless, kUNLESS, kUNLESS_MOD, EXPR_BEG
until, kUNTIL, kUNTIL_MOD, EXPR_BEG
when, kWHEN, kWHEN, EXPR_BEG
while, kWHILE, kWHILE_MOD, EXPR_BEG
yield, kYIELD, kYIELD, EXPR_END
yield, kYIELD, kYIELD, EXPR_ARG

10
lex.c
View file

@ -1,4 +1,4 @@
/* C code produced by gperf version 2.7 */
/* C code produced by gperf version 2.7.1 (19981006 egcs) */
/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ ./keywords */
struct kwtable {char *name; int id[2]; enum lex_state state;};
@ -79,10 +79,10 @@ rb_reserved_word (str, len)
{"module", kMODULE, kMODULE, EXPR_BEG},
{"elsif", kELSIF, kELSIF, EXPR_BEG},
{"def", kDEF, kDEF, EXPR_FNAME},
{"rescue", kRESCUE, kRESCUE_MOD, EXPR_MID},
{"rescue", kRESCUE, kRESCUE_MOD, EXPR_END},
{"not", kNOT, kNOT, EXPR_BEG},
{"then", kTHEN, kTHEN, EXPR_BEG},
{"yield", kYIELD, kYIELD, EXPR_END},
{"yield", kYIELD, kYIELD, EXPR_ARG},
{"for", kFOR, kFOR, EXPR_BEG},
{"self", kSELF, kSELF, EXPR_END},
{"false", kFALSE, kFALSE, EXPR_END},
@ -90,8 +90,8 @@ rb_reserved_word (str, len)
{"return", kRETURN, kRETURN, EXPR_MID},
{"true", kTRUE, kTRUE, EXPR_END},
{"if", kIF, kIF_MOD, EXPR_BEG},
{"defined?", kDEFINED, kDEFINED, EXPR_END},
{"super", kSUPER, kSUPER, EXPR_END},
{"defined?", kDEFINED, kDEFINED, EXPR_ARG},
{"super", kSUPER, kSUPER, EXPR_ARG},
{"undef", kUNDEF, kUNDEF, EXPR_FNAME},
{"break", kBREAK, kBREAK, EXPR_END},
{"in", kIN, kIN, EXPR_BEG},

View file

@ -162,9 +162,11 @@ class Queue
end
t.run if t
end
alias enq push
def enq(obj)
push(obj)
end
def pop non_block=false
def pop(non_block=false)
Thread.critical = true
begin
loop do
@ -182,8 +184,10 @@ class Queue
Thread.critical = false
end
end
alias shift pop
alias deq pop
def shift(non_block=false)
pop(non_block=false)
end
alias deq shift
def empty?
@que.length == 0
@ -196,8 +200,9 @@ class Queue
def length
@que.length
end
alias size length
def size
length
end
def num_waiting
@waiting.size

View file

@ -29,6 +29,7 @@ class TimeoutError<StandardError
end
def timeout(sec)
return yield if sec == nil
begin
x = Thread.current
y = Thread.start {

64
parse.y
View file

@ -48,10 +48,10 @@ static int yyerror();
static enum lex_state {
EXPR_BEG, /* ignore newline, +/- is a sign. */
EXPR_MID, /* newline significant, +/- is a sign. */
EXPR_END, /* newline significant, +/- is a operator. */
EXPR_PAREN, /* almost like EXPR_END, `do' works as `{'. */
EXPR_ARG, /* newline significant, +/- is a operator. */
EXPR_MID, /* newline significant, +/- is a operator. */
EXPR_FNAME, /* ignore newline, no reserved words. */
EXPR_DOT, /* right after `.' or `::', no reserved words. */
EXPR_CLASS, /* immediate after `class', no here document. */
@ -1431,16 +1431,16 @@ when_args : args
cases : opt_else
| case_body
exc_list : args
| none
exc_list : none
| args
exc_var : ':' lhs
exc_var : tASSOC lhs
{
$$ = $2;
}
| none
rescue : kRESCUE exc_list exc_var do
rescue : kRESCUE exc_list exc_var then
compstmt
rescue
{
@ -1908,7 +1908,7 @@ rb_compile_string(f, s, line)
lex_input = s;
lex_pbeg = lex_p = lex_pend = 0;
ruby_sourceline = line - 1;
compile_for_eval = 1;
compile_for_eval = ruby_in_eval;
return yycompile(f, line);
}
@ -2743,15 +2743,17 @@ yylex()
}
pushback(c);
if (lex_state == EXPR_ARG && space_seen && !ISSPACE(c)){
lex_state = EXPR_BEG;
return tSTAR;
rb_warning("`*' interpreted as argument prefix");
c = tSTAR;
}
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
lex_state = EXPR_BEG;
return tSTAR;
else if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
c = tSTAR;
}
else {
c = '*';
}
lex_state = EXPR_BEG;
return '*';
return c;
case '!':
lex_state = EXPR_BEG;
@ -2900,15 +2902,17 @@ yylex()
}
pushback(c);
if (lex_state == EXPR_ARG && space_seen && !ISSPACE(c)){
lex_state = EXPR_BEG;
return tAMPER;
rb_warning("`&' interpreted as argument prefix");
c = tAMPER;
}
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
lex_state = EXPR_BEG;
return tAMPER;
else if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
c = tAMPER;
}
else {
c = '&';
}
lex_state = EXPR_BEG;
return '&';
return c;
case '|':
lex_state = EXPR_BEG;
@ -2943,13 +2947,13 @@ yylex()
}
if (lex_state == EXPR_BEG || lex_state == EXPR_MID ||
(lex_state == EXPR_ARG && space_seen && !ISSPACE(c))) {
pushback(c);
if (lex_state == EXPR_ARG) arg_ambiguous();
lex_state = EXPR_BEG;
pushback(c);
if (ISDIGIT(c)) {
c = '+';
goto start_num;
}
lex_state = EXPR_BEG;
return tUPLUS;
}
lex_state = EXPR_BEG;
@ -3147,7 +3151,7 @@ yylex()
case ':':
c = nextc();
if (c == ':') {
if (lex_state == EXPR_BEG || lex_state == EXPR_MID ||
if (lex_state == EXPR_BEG || lex_state == EXPR_MID ||
(lex_state == EXPR_ARG && space_seen)) {
lex_state = EXPR_BEG;
return tCOLON3;
@ -3172,15 +3176,14 @@ yylex()
yylval.id = '/';
return tOP_ASGN;
}
if (lex_state == EXPR_ARG) {
if (space_seen && !ISSPACE(c)) {
pushback(c);
arg_ambiguous();
pushback(c);
if (lex_state == EXPR_ARG && space_seen) {
arg_ambiguous();
if (!ISSPACE(c)) {
return parse_regx('/', '/');
}
}
lex_state = EXPR_BEG;
pushback(c);
return '/';
case '^':
@ -3209,14 +3212,11 @@ yylex()
case '(':
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
c = tLPAREN;
lex_state = EXPR_BEG;
}
else {
if (lex_state == EXPR_ARG && space_seen) {
rb_warning("%s (...) interpreted as function", tok());
}
lex_state = EXPR_BEG;
else if (lex_state == EXPR_ARG && space_seen) {
rb_warning("%s (...) interpreted as method call", tok());
}
lex_state = EXPR_BEG;
return c;
case '[':

45
re.c
View file

@ -211,17 +211,17 @@ rb_reg_expr_str(str, s, len)
int len;
{
const char *p, *pend;
int slash = 0;
int need_escape = 0;
p = s; pend = p + len;
while (p<pend) {
if (*p == '/') {
slash = 1;
if (*p == '/' || (!ISPRINT(*p) && !ismbchar(*p))) {
need_escape = 1;
break;
}
p++;
}
if (!slash) {
if (!need_escape) {
rb_str_cat(str, s, len);
}
else {
@ -232,9 +232,44 @@ rb_reg_expr_str(str, s, len)
rb_str_cat(str, &c, 1);
rb_str_cat(str, p, 1);
}
else {
else if (ismbchar(*p)) {
rb_str_cat(str, p, mbclen(*p));
p += mbclen(*p);
continue;
}
else if (ISPRINT(*p)) {
rb_str_cat(str, p, 1);
}
else {
char b[8];
switch (*p) {
case '\r':
rb_str_cat(str, "\\r", 2);
break;
case '\n':
rb_str_cat(str, "\\n", 2);
break;
case '\t':
rb_str_cat(str, "\\t", 2);
break;
case '\f':
rb_str_cat(str, "\\f", 2);
break;
case 007:
rb_str_cat(str, "\\a", 2);
break;
case 013:
rb_str_cat(str, "\\v", 2);
break;
case 033:
rb_str_cat(str, "\\e", 2);
break;
default:
sprintf(b, "\\%03o", *p & 0377);
rb_str_cat(str, b, 4);
break;
}
}
p++;
}
}

2
re.h
View file

@ -37,7 +37,7 @@ int rb_reg_adjust_startpos _((VALUE, VALUE, int, int));
int rb_kcode _((void));
void rb_match_busy _((VALUE));
extern int ruby_ignorecase;
EXTERN int ruby_ignorecase;
int rb_reg_mbclen2 _((unsigned int, VALUE));
#define mbclen2(c,re) rb_reg_mbclen2((c),(re))

View file

@ -90,7 +90,14 @@
#define MBCTYPE_SJIS 2
#define MBCTYPE_UTF8 3
extern const unsigned char *re_mbctab;
#if defined IMPORT
extern __declspec(dllimport)
#elif defined EXPORT
extern __declspec(dllexport)
#else
extern
#endif
const unsigned char *re_mbctab;
#if defined(__STDC__)
void re_mbcinit (int);
#else

17
ruby.c
View file

@ -229,13 +229,16 @@ void
require_libraries()
{
extern NODE *ruby_eval_tree;
extern NODE *ruby_eval_tree_begin;
char *orig_sourcefile = ruby_sourcefile;
NODE *save;
NODE *save[2];
struct req_list *list = req_list_head.next;
struct req_list *tmp;
ruby_sourcefile = 0;
save = ruby_eval_tree;
save[0] = ruby_eval_tree;
save[1] = ruby_eval_tree_begin;
ruby_eval_tree = ruby_eval_tree_begin = 0;
req_list_last = 0;
while (list) {
rb_require(list->name);
@ -244,7 +247,8 @@ require_libraries()
free(list);
list = tmp;
}
ruby_eval_tree = save;
ruby_eval_tree = save[0];
ruby_eval_tree_begin = save[1];
ruby_sourcefile = orig_sourcefile;
}
@ -622,8 +626,10 @@ proc_options(argc, argv)
ruby_set_argv(argc, argv);
process_sflag();
#if 0
Init_ext(); /* should be called here for some reason :-( */
require_libraries();
#endif
ruby_sourcefile = argv0;
if (e_script) {
@ -643,6 +649,11 @@ proc_options(argc, argv)
process_sflag();
xflag = 0;
#if 1
Init_ext(); /* should be called here for some reason :-( */
require_libraries();
#endif
}
extern int ruby__end__seen;

View file

@ -1026,10 +1026,10 @@ ok($x == Marshal.load($y))
check "pack"
$format = "c2x5CCxsdila6";
$format = "c2x5CCxsdils_l_a6";
# Need the expression in here to force ary[5] to be numeric. This avoids
# test2 failing because ary2 goes str->numeric->str and ary does not.
ary = [1,-100,127,128,32767,987.654321098 / 100.0,12345,123456,"abcdef"]
ary = [1,-100,127,128,32767,987.654321098 / 100.0,12345,123456,-32767,-123456,"abcdef"]
$x = ary.pack($format)
ary2 = $x.unpack($format)

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.4"
#define RUBY_RELEASE_DATE "2000-05-28"
#define RUBY_RELEASE_DATE "2000-05-30"
#define RUBY_VERSION_CODE 154
#define RUBY_RELEASE_CODE 20000528
#define RUBY_RELEASE_CODE 20000530

View file

@ -6,7 +6,7 @@ s%@CXXFLAGS@%%g
s%@FFLAGS@%%g
s%@DEFS@%
-DUSE_THREAD -DSIZEOF_INT=4 -DSIZEOF_SHORT=2 -DSIZEOF_LONG=4 -DSIZEOF_VOIDP=4 -DSIZEOF_FLOAT=4 -DSIZEOF_DOUBLE=8 -DHAVE_PROTOTYPES=1 -DHAVE_STDARG_PROTOTYPES=1 -DHAVE_STDLIB_H=1 -DHAVE_LIMITS_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ST_RDEV=1 -DGETGROUPS_T=int -DRETSIGTYPE=void -DHAVE_ALLOCA=1 -DHAVE_FMOD=1 -DHAVE_WAITPID=1 -DHAVE_GETCWD=1 -DHAVE_CHSIZE=1 -DHAVE_GETGROUPS=1 -DHAVE_GETLOGIN=1 -DRSHIFT=\(x,y\)\ \(\(x\)\>\>y\) -DFILE_COUNT=_cnt -DDLEXT=\".so\" -DDLEXT2=\".dll\" -DRUBY_PLATFORM=\"i386-mswin32\" %g
s%@LDFLAGS@%%g
s%@LDFLAGS@%$(CFLAGS) -Fm%g
s%@LIBS@%user32.lib advapi32.lib wsock32.lib%g
s%@exec_prefix@%${prefix}%g
s%@prefix@%/usr/local%g
@ -57,7 +57,7 @@ s%@LIBRUBY_A@%lib$(RUBY_INSTALL_NAME).lib%g
s%@LIBRUBY_SO@%%g
s%@LIBRUBY_ALIASES@%%g
s%@LIBRUBY@%libruby.lib%g
s%@LIBRUBYARG@%libruby.lib%g
s%@LIBRUBYARG@%$(topdir)/rubymw.lib%g
s%@SOLIBS@%%g
s%@DLDLIBS@%%g
s%@arch@%i386-mswin32%g

View file

@ -88,6 +88,7 @@ EXPORTS
;range.c
rb_cRange
;re.c
ruby_ignorecase
rb_cRegexp
;regex.c
re_mbctab
@ -236,6 +237,8 @@ EXPORTS
rb_define_alias
rb_define_attr
rb_scan_args
;dir.c
rb_glob
;dln.c
dln_load
dln_find_exe
@ -479,6 +482,17 @@ EXPORTS
rb_reg_regsub
rb_get_kcode
rb_set_kcode
;regex.c
ruby_re_set_casetable
ruby_re_compile_pattern
ruby_re_free_pattern
ruby_re_compile_fastmap
ruby_re_adjust_startpos
ruby_re_search
ruby_re_match
ruby_re_copy_registers
ruby_re_free_registers
ruby_re_mbcinit
;ruby.c
rb_load_file
ruby_script