Skip to content

Commit

Permalink
* parse.y: yyparse #defines moved from intern.h
Browse files Browse the repository at this point in the history
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@2500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed May 29, 2002
1 parent baa320b commit 01d834c
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 59 deletions.
24 changes: 24 additions & 0 deletions ChangeLog
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions doc/NEWS
@@ -1,3 +1,7 @@
: parser

Digits preceded minus sign is a literal integer.

: IO::sysopen

a new method to get a raw file descriptor.
Expand Down
26 changes: 25 additions & 1 deletion eval.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
86 changes: 68 additions & 18 deletions ext/etc/etc.c
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -126,20 +128,43 @@ 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;
{
#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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -203,20 +230,43 @@ 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;
{
#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);
Expand Down Expand Up @@ -258,7 +308,7 @@ Init_etc()
"age",
#endif
#ifdef PW_CLASS
"class",
"uclass",
#endif
#ifdef PW_COMMENT
"comment",
Expand Down
6 changes: 3 additions & 3 deletions file.c
Expand Up @@ -294,7 +294,7 @@ rb_stat_inspect(self)
{
VALUE str;
int i;
struct {
static struct {
char *name;
VALUE (*func)();
} member[] = {
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 0 additions & 13 deletions hash.c
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions intern.h
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions io.c
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/thread.rb
Expand Up @@ -215,6 +215,7 @@ def num_waiting

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
Expand Down
2 changes: 1 addition & 1 deletion node.h
Expand Up @@ -138,7 +138,7 @@ typedef struct RNode {
union {
struct RNode *node;
ID id;
long argc;
int argc;
VALUE value;
} u2;
union {
Expand Down
4 changes: 2 additions & 2 deletions pack.c
Expand Up @@ -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];

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 01d834c

Please sign in to comment.