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

* parse.y: yyparse #defines moved from intern.h

* ruby.c (proc_options): access prefixed "ruby_yydebug".

* applied modifies to pacify some of gcc -Wall warnings.

* parse.y (arg): no more ugly hack for "**", so that "-2**2" to be
  parsed as "(-2)**2", whereas "- 2**2" or "-(2)**2" to be parsed
  as "-(2**2)".

* parse.y (yylex): '-2' to be literal fixnum. [new]

* time.c (time_succ): new method for Range support.

* time.c (time_arg): nil test against v[6] (usec).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-05-29 05:20:39 +00:00
parent 99551555c8
commit 4ab1577db3
19 changed files with 166 additions and 59 deletions

View file

@ -2,6 +2,22 @@ Wed May 29 13:45:15 2002 Wakou Aoyama <wakou@ruby-lang.org>
* lib/cgi.rb: not use const if GET, HEAD. check multipart form head.
Tue May 28 17:56:02 2002 Sean Chittenden <sean@ruby-lang.org>
* parse.y: yyparse #defines moved from intern.h
* ruby.c (proc_options): access prefixed "ruby_yydebug".
* applied modifies to pacify some of gcc -Wall warnings.
Tue May 28 14:07:00 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (arg): no more ugly hack for "**", so that "-2**2" to be
parsed as "(-2)**2", whereas "- 2**2" or "-(2)**2" to be parsed
as "-(2**2)".
* parse.y (yylex): '-2' to be literal fixnum. [new]
Tue May 28 12:13:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (scope_node): trick to keep the node has a scope.
@ -16,6 +32,14 @@ Tue May 28 12:13:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* node.h (NEW_DASGN, NEW_DASGN_CURR): remove surplus semicolons.
Mon May 27 04:31:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* time.c (time_succ): new method for Range support.
Fri May 24 09:06:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* time.c (time_arg): nil test against v[6] (usec).
Thu May 23 16:39:21 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* ruby.c (proc_options): option parsing problem.

View file

@ -1,3 +1,7 @@
: parser
Digits preceded minus sign is a literal integer.
: IO::sysopen
a new method to get a raw file descriptor.

26
eval.c
View file

@ -3075,6 +3075,7 @@ rb_eval(self, n)
ruby_errinfo = Qnil;
ruby_sourceline = nd_line(node);
ruby_in_eval++;
rb_dvar_push(0, 0);
list->nd_head = compile(list->nd_head->nd_lit,
ruby_sourcefile,
ruby_sourceline);
@ -6627,7 +6628,7 @@ proc_to_s(self, other)
Data_Get_Struct(self, struct BLOCK, data);
str = rb_str_new(0, strlen(cname)+6+16+1); /* 6:tags 16:addr 1:nul */
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", cname, data->tag);
sprintf(RSTRING(str)->ptr, "#<%s:0x%p>", cname, data->tag);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
if (OBJ_TAINTED(self)) OBJ_TAINT(str);
@ -6641,6 +6642,28 @@ proc_to_proc(proc)
return proc;
}
static VALUE
proc_binding(proc)
VALUE proc;
{
struct BLOCK *orig, *data;
VALUE bind;
Data_Get_Struct(proc, struct BLOCK, orig);
bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
MEMCPY(data, orig, struct BLOCK, 1);
frame_dup(&data->frame);
if (data->iter) {
blk_copy_prev(data);
}
else {
data->prev = 0;
}
return bind;
}
static VALUE
block_pass(self, node)
VALUE self;
@ -7149,6 +7172,7 @@ Init_Proc()
rb_define_method(rb_cProc, "==", proc_eq, 1);
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0);
rb_define_method(rb_cProc, "binding", proc_binding, 0);
rb_define_global_function("proc", rb_f_lambda, 0);
rb_define_global_function("lambda", rb_f_lambda, 0);
rb_define_global_function("binding", rb_f_binding, 0);

View file

@ -25,16 +25,17 @@
static VALUE sPasswd, sGroup;
char *getenv();
char *getlogin();
static VALUE
etc_getlogin(obj)
VALUE obj;
{
char *getenv();
char *login;
rb_secure(4);
#ifdef HAVE_GETLOGIN
char *getlogin();
login = getlogin();
if (!login) login = getenv("USER");
#else
@ -91,11 +92,12 @@ etc_getpwuid(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
#ifdef HAVE_GETPWENT
VALUE id;
#if defined(HAVE_GETPWENT)
VALUE id, ary;
int uid;
struct passwd *pwd;
rb_secure(4);
if (rb_scan_args(argc, argv, "01", &id) == 1) {
uid = NUM2INT(id);
}
@ -117,7 +119,7 @@ etc_getpwnam(obj, nam)
#ifdef HAVE_GETPWENT
struct passwd *pwd;
StringValue(nam);
SafeStringValue(nam);
pwd = getpwnam(RSTRING(nam)->ptr);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", RSTRING(nam)->ptr);
return setup_passwd(pwd);
@ -126,6 +128,29 @@ etc_getpwnam(obj, nam)
#endif
}
#ifdef HAVE_GETPWENT
static int passwd_blocking = 0;
static VALUE
passwd_ensure()
{
passwd_blocking = Qfalse;
return Qnil;
}
static VALUE
passwd_iterate()
{
struct passwd *pw;
setpwent();
while (pw = getpwent()) {
rb_yield(setup_passwd(pw));
}
endpwent();
return Qnil;
}
#endif
static VALUE
etc_passwd(obj)
VALUE obj;
@ -133,13 +158,13 @@ etc_passwd(obj)
#ifdef HAVE_GETPWENT
struct passwd *pw;
rb_secure(4);
if (rb_block_given_p()) {
setpwent();
while (pw = getpwent()) {
rb_yield(setup_passwd(pw));
if (passwd_blocking) {
rb_raise(rb_eRuntimeError, "parallel passwd iteration");
}
endpwent();
return obj;
passwd_blocking = Qtrue;
rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
}
if (pw = getpwent()) {
return setup_passwd(pw);
@ -178,6 +203,7 @@ etc_getgrgid(obj, id)
int gid;
struct group *grp;
rb_secure(4);
gid = NUM2INT(id);
grp = getgrgid(gid);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", gid);
@ -194,7 +220,8 @@ etc_getgrnam(obj, nam)
#ifdef HAVE_GETGRENT
struct group *grp;
StringValue(nam);
rb_secure(4);
SafeStringValue(nam);
grp = getgrnam(RSTRING(nam)->ptr);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %s", RSTRING(nam)->ptr);
return setup_group(grp);
@ -203,6 +230,29 @@ etc_getgrnam(obj, nam)
#endif
}
#ifdef HAVE_GETGRENT
static int group_blocking = 0;
static VALUE
group_ensure()
{
group_blocking = Qfalse;
return Qnil;
}
static VALUE
group_iterate()
{
struct group *pw;
setpwent();
while (pw = getgrent()) {
rb_yield(setup_group(pw));
}
endpwent();
return Qnil;
}
#endif
static VALUE
etc_group(obj)
VALUE obj;
@ -210,13 +260,13 @@ etc_group(obj)
#ifdef HAVE_GETGRENT
struct group *grp;
rb_secure(4);
if (rb_block_given_p()) {
setgrent();
while (grp = getgrent()) {
rb_yield(setup_group(grp));
if (group_blocking) {
rb_raise(rb_eRuntimeError, "parallel group iteration");
}
endgrent();
return obj;
group_blocking = Qtrue;
rb_ensure(group_iterate, 0, group_ensure, 0);
}
if (grp = getgrent()) {
return setup_group(grp);
@ -258,7 +308,7 @@ Init_etc()
"age",
#endif
#ifdef PW_CLASS
"class",
"uclass",
#endif
#ifdef PW_COMMENT
"comment",

6
file.c
View file

@ -294,7 +294,7 @@ rb_stat_inspect(self)
{
VALUE str;
int i;
struct {
static struct {
char *name;
VALUE (*func)();
} member[] = {
@ -329,13 +329,13 @@ rb_stat_inspect(self)
if (i == 2) { /* mode */
char buf[32];
sprintf(buf, "0%o", NUM2INT(v));
sprintf(buf, "0%lo", NUM2INT(v));
rb_str_buf_cat2(str, buf);
}
else if (i == 0 || i == 6) { /* dev/rdev */
char buf[32];
sprintf(buf, "0x%x", NUM2ULONG(v));
sprintf(buf, "0x%lx", NUM2ULONG(v));
rb_str_buf_cat2(str, buf);
}
else {

13
hash.c
View file

@ -55,19 +55,6 @@ eql(args)
return (VALUE)rb_eql(args[0], args[1]);
}
static VALUE
eql_failed()
{
return Qfalse;
}
static VALUE
any_eql(args)
VALUE *args;
{
return rb_rescue(eql, (VALUE)args, eql_failed, 0);
}
static int
rb_any_cmp(a, b)
VALUE a, b;

View file

@ -284,12 +284,6 @@ double rb_str_to_dbl _((VALUE, int));
/* parse.y */
EXTERN int ruby_sourceline;
EXTERN char *ruby_sourcefile;
#define yyparse ruby_yyparse
#define yylex ruby_yylex
#define yyerror ruby_yyerror
#define yylval ruby_yylval
#define yychar ruby_yychar
#define yydebug ruby_yydebug
int yyparse _((void));
ID rb_id_attrset _((ID));
void rb_parser_append_print _((void));

4
io.c
View file

@ -2081,7 +2081,7 @@ io_reopen(io, nfile)
OpenFile *fptr, *orig;
char *mode;
int fd;
off_t pos;
off_t pos = 0;
nfile = rb_io_get_io(nfile);
if (rb_safe_level() >= 4 && (!OBJ_TAINTED(io) || !OBJ_TAINTED(nfile))) {
@ -3508,7 +3508,7 @@ argf_read(argc, argv)
VALUE *argv;
{
VALUE tmp, str;
int len;
int len = 0;
if (argc == 1) len = NUM2INT(argv[0]);
str = Qnil;

View file

@ -215,6 +215,7 @@ end
class SizedQueue<Queue
def initialize(max)
raise ArgumentError, "queue size must be positive" unless max > 0
@max = max
@queue_wait = []
@queue_wait.taint # enable tainted comunication

2
node.h
View file

@ -138,7 +138,7 @@ typedef struct RNode {
union {
struct RNode *node;
ID id;
long argc;
int argc;
VALUE value;
} u2;
union {

4
pack.c
View file

@ -1549,7 +1549,7 @@ pack_unpack(str, fmt)
{
VALUE str = infected_str_new(0, (send - s)*3/4, str);
char *ptr = RSTRING(str)->ptr;
int a,b,c,d;
int a,b,c = 0,d;
static int first = 1;
static int b64_xtable[256];
@ -1834,7 +1834,7 @@ utf8_to_uv(p, lenp)
if (n != 0) {
uv &= (1<<(BYTEWIDTH-2-n)) - 1;
while (n--) {
uv = uv << 6 | *p++ & ((1<<6)-1);
uv = uv << 6 | (*p++ & ((1<<6)-1));
}
}
return uv;

View file

@ -13,14 +13,23 @@
%{
#define YYDEBUG 1
#include "ruby.h"
#include "env.h"
#include "intern.h"
#include "node.h"
#include "st.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#define yyparse ruby_yyparse
#define yylex ruby_yylex
#define yyerror ruby_yyerror
#define yylval ruby_yylval
#define yychar ruby_yychar
#define yydebug ruby_yydebug
#define ID_SCOPE_SHIFT 3
#define ID_SCOPE_MASK 0x07
#define ID_LOCAL 0x01

View file

@ -22,9 +22,9 @@ static VALUE
range_check(args)
VALUE *args;
{
rb_funcall(args[0], id_cmp, 1, args[1]);
if (!FIXNUM_P(args[0]) && !rb_obj_is_kind_of(args[0], rb_cNumeric)) {
rb_funcall(args[0], id_succ, 0, 0);
rb_funcall(args[0], id_cmp, 1, args[1]);
/* rb_funcall(args[0], id_succ, 0, 0); */
}
return Qnil;
}

6
ruby.c
View file

@ -46,7 +46,7 @@ VALUE ruby_debug = Qfalse;
VALUE ruby_verbose = Qfalse;
static int sflag = 0;
static int xflag = 0;
extern int yydebug;
extern int ruby_yydebug;
char *ruby_inplace_mode = Qfalse;
@ -436,7 +436,7 @@ proc_options(argc, argv)
goto reswitch;
case 'y':
yydebug = 1;
ruby_yydebug = 1;
s++;
goto reswitch;
@ -612,7 +612,7 @@ proc_options(argc, argv)
ruby_verbose = Qtrue;
}
else if (strcmp("yydebug", s) == 0)
yydebug = 1;
ruby_yydebug = 1;
else if (strcmp("help", s) == 0) {
usage(origargv[0]);
exit(0);

2
st.c
View file

@ -1,6 +1,6 @@
/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible";
/* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */
#include "config.h"
#include <stdio.h>

View file

@ -2444,7 +2444,7 @@ rb_str_split_m(argc, argv, str)
VALUE spat;
VALUE limit;
int char_sep = -1;
long beg, end, i;
long beg, end, i = 0;
int lim = 0;
VALUE result, tmp;

14
time.c
View file

@ -254,7 +254,7 @@ time_arg(argc, argv, tm, usec)
}
else {
rb_scan_args(argc, argv, "16", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6]);
*usec = (argc == 7) ? NUM2INT(v[6]) : 0;
*usec = NIL_P(v[6]) ? 0 : obj2long(v[6]);
tm->tm_isdst = -1;
}
@ -688,6 +688,16 @@ time_usec(time)
return INT2NUM(tobj->tv.tv_usec);
}
static VALUE
time_succ(time)
VALUE time;
{
struct time_object *tobj;
GetTimeval(time, tobj);
return rb_time_new(tobj->tv.tv_sec + 1, tobj->tv.tv_usec);
}
static VALUE
time_cmp(time1, time2)
VALUE time1, time2;
@ -1437,6 +1447,8 @@ Init_Time()
rb_define_method(rb_cTime, "hash", time_hash, 0);
rb_define_method(rb_cTime, "clone", time_clone, 0);
rb_define_method(rb_cTime, "dup", time_dup, 0);
rb_define_method(rb_cTime, "succ", time_succ, 0);
rb_define_method(rb_cTime, "next", time_succ, 0);
rb_define_method(rb_cTime, "localtime", time_localtime, 0);
rb_define_method(rb_cTime, "gmtime", time_gmtime, 0);

8
util.c
View file

@ -12,6 +12,7 @@
#include "ruby.h"
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
@ -747,8 +748,9 @@ ruby_strtod(string, endPtr)
* Strip off leading blanks and check for a sign.
*/
errno = 0;
p = string;
while (isspace(*p)) {
while (ISSPACE(*p)) {
p += 1;
}
if (*p == '-') {
@ -770,7 +772,7 @@ ruby_strtod(string, endPtr)
decPt = -1;
for (mantSize = 0; ; mantSize += 1) {
c = *p;
if (!isdigit(c)) {
if (!ISDIGIT(c)) {
if ((c != '.') || (decPt >= 0)) {
break;
}
@ -848,7 +850,7 @@ ruby_strtod(string, endPtr)
}
expSign = FALSE;
}
while (isdigit(*p)) {
while (ISDIGIT(*p)) {
exp = exp * 10 + (*p - '0');
p += 1;
}

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.2"
#define RUBY_RELEASE_DATE "2002-05-28"
#define RUBY_RELEASE_DATE "2002-05-29"
#define RUBY_VERSION_CODE 172
#define RUBY_RELEASE_CODE 20020528
#define RUBY_RELEASE_CODE 20020529