Skip to content

Commit

Permalink
matz
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Oct 10, 2000
1 parent ef45458 commit 1ce6f06
Show file tree
Hide file tree
Showing 16 changed files with 113 additions and 74 deletions.
28 changes: 28 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
Tue Oct 10 09:49:23 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* file.c (Init_File): FileTest.size should return 0 (not nil) for
empty files.

Sun Oct 8 13:20:26 2000 Guy Decoux <decoux@moulon.inra.fr>

* eval.c (POP_SCOPE): not just set SCOPE_DONT_RECYCLE, but do
scope_dup().

Sat Oct 7 15:10:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* string.c (rb_str_reverse_bang): unnecessary ALLOCA_N() was
removed.

Fri Oct 6 14:50:24 2000 WATANABE Hirofumi <eban@ruby-lang.org>

* ext/extmk.rb.in, lib/mkmf.rb: remove "DESTDIR =".

* Makefile.in, win32/Makefile.sub, ruby.1: renamed -X to -C.

Fri Oct 6 12:50:52 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* array.c (rb_ary_plus): use to_ary(), not Check_Type().

* array.c (rb_ary_concat): ditto.

* gc.c (rb_gc): use __builtin_frame_address() for gcc.

* eval.c (stack_length): ditto.

* parse.y (assign_in_cond): stop warning till some better warning
condition will be found.

Thu Oct 5 18:02:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* object.c (rb_obj_dup): should have propagated taint flag.
Expand Down
18 changes: 10 additions & 8 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ rb_ary_push_m(argc, argv, ary)
VALUE *argv;
VALUE ary;
{
if (argc == 0) {
rb_raise(rb_eArgError, "wrong # of arguments(at least 1)");
}
if (argc > 0) {
long len = RARRAY(ary)->len;

Expand Down Expand Up @@ -903,9 +906,8 @@ rb_ary_reverse(ary)

while (p1 < p2) {
tmp = *p1;
*p1 = *p2;
*p2 = tmp;
p1++; p2--;
*p1++ = *p2;
*p2-- = tmp;
}

return ary;
Expand Down Expand Up @@ -1236,8 +1238,7 @@ rb_ary_plus(x, y)
{
VALUE z;

Check_Type(y, T_ARRAY);

y = to_ary(y);
z = rb_ary_new2(RARRAY(x)->len + RARRAY(y)->len);
MEMCPY(RARRAY(z)->ptr, RARRAY(x)->ptr, VALUE, RARRAY(x)->len);
MEMCPY(RARRAY(z)->ptr+RARRAY(x)->len, RARRAY(y)->ptr, VALUE, RARRAY(y)->len);
Expand All @@ -1249,9 +1250,10 @@ VALUE
rb_ary_concat(x, y)
VALUE x, y;
{
Check_Type(y, T_ARRAY);

rb_ary_push_m(RARRAY(y)->len, RARRAY(y)->ptr, x);
y = to_ary(y);
if (RARRAY(y)->len > 0) {
rb_ary_push_m(RARRAY(y)->len, RARRAY(y)->ptr, x);
}
return x;
}

Expand Down
21 changes: 13 additions & 8 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,10 +796,12 @@ static VALUE ruby_wrapper; /* security wrapper */

typedef struct thread * rb_thread_t;
static rb_thread_t curr_thread = 0;
static void scope_dup _((struct SCOPE *));

#define POP_SCOPE() \
if (ruby_scope->flag & SCOPE_DONT_RECYCLE) {\
if (_old) _old->flag |= SCOPE_DONT_RECYCLE;\
if (_old)\
scope_dup(_old);\
} \
if (!(ruby_scope->flag & SCOPE_MALLOC)) {\
ruby_scope->local_vars = 0; \
Expand Down Expand Up @@ -1259,7 +1261,7 @@ rb_eval_cmd(cmd, arg)
}

if (ruby_scope->flag & SCOPE_DONT_RECYCLE)
saved_scope->flag |= SCOPE_DONT_RECYCLE;
scope_dup(saved_scope);
ruby_scope = saved_scope;
ruby_safe_level = safe;
POP_TAG();
Expand Down Expand Up @@ -3499,7 +3501,7 @@ rb_yield_0(val, self, klass, acheck)
ruby_block = block;
ruby_frame = ruby_frame->prev;
if (ruby_scope->flag & SCOPE_DONT_RECYCLE)
old_scope->flag |= SCOPE_DONT_RECYCLE;
scope_dup(old_scope);
ruby_scope = old_scope;
if (state) JUMP_TAG(state);
return result;
Expand Down Expand Up @@ -3994,7 +3996,11 @@ stack_length(p)
alloca(0);
# define STACK_END (&stack_end)
#else
# if defined(__GNUC__)
VALUE *stack_end = __builtin_frame_address(0);
# else
VALUE *stack_end = alloca(1);
# endif
# define STACK_END (stack_end)
#endif
if (p) *p = STACK_END;
Expand Down Expand Up @@ -4659,7 +4665,7 @@ eval(self, src, scope, file, line)
if (!NIL_P(scope)) {
ruby_frame = frame.tmp;
if (ruby_scope->flag & SCOPE_DONT_RECYCLE)
old_scope->flag |= SCOPE_DONT_RECYCLE;
scope_dup(old_scope);
ruby_scope = old_scope;
ruby_block = old_block;
ruby_dyna_vars = old_d_vars;
Expand Down Expand Up @@ -8164,9 +8170,8 @@ rb_thread_inspect(thread)
default:
status = "unknown"; break;
}
s = ALLOCA_N(char, strlen(cname)+6+16+9+1); /* 6:tags 16:addr 9:status 1:nul */
sprintf(s, "#<%s:0x%lx %s>", cname, thread, status);
str = rb_str_new2(s);
str = rb_str_new(0, strlen(cname)+6+16+9+1); /* 6:tags 16:addr 9:status 1:nul */
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx %s>", cname, thread, status);
OBJ_INFECT(str, thread);

return str;
Expand All @@ -8187,7 +8192,7 @@ rb_callcc(self)
cont = Data_Wrap_Struct(rb_cCont, thread_mark,
thread_free, th);

ruby_scope->flag |= SCOPE_DONT_RECYCLE;
scope_dup(ruby_scope);
for (tag=prot_tag; tag; tag=tag->prev) {
scope_dup(tag->scope);
}
Expand Down
3 changes: 1 addition & 2 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ Init_File()
define_filetest_function("file?", test_f, 1);
define_filetest_function("zero?", test_z, 1);
define_filetest_function("size?", test_s, 1);
define_filetest_function("size", test_s, 1);
define_filetest_function("size", rb_file_s_size, 1);
define_filetest_function("owned?", test_owned, 1);
define_filetest_function("grpowned?", test_grpowned, 1);

Expand All @@ -2194,7 +2194,6 @@ Init_File()
rb_define_singleton_method(rb_cFile, "atime", rb_file_s_atime, 1);
rb_define_singleton_method(rb_cFile, "mtime", rb_file_s_mtime, 1);
rb_define_singleton_method(rb_cFile, "ctime", rb_file_s_ctime, 1);
rb_define_singleton_method(rb_cFile, "size", rb_file_s_size, 1);

rb_define_singleton_method(rb_cFile, "utime", rb_file_s_utime, -1);
rb_define_singleton_method(rb_cFile, "chmod", rb_file_s_chmod, -1);
Expand Down
8 changes: 7 additions & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,11 @@ rb_gc()
alloca(0);
# define STACK_END (&stack_end)
#else
# if defined(__GNUC__)
VALUE *stack_end = __builtin_frame_address(0);
# else
VALUE *stack_end = alloca(1);
# endif
# define STACK_END (stack_end)
#endif

Expand Down Expand Up @@ -978,9 +982,11 @@ void
Init_stack(addr)
VALUE *addr;
{
#ifdef __human68k__
#if defined(__human68k__)
extern void *_SEND;
rb_gc_stack_start = _SEND;
#elsif defined(__GNUC__)
rb_gc_stack_start = __builtin_frame_address(2);
#else
VALUE start;

Expand Down
2 changes: 1 addition & 1 deletion lib/cgi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def CGI::unescape(string)


=begin
=== ESCAPE HTML &"<>
=== ESCAPE HTML &\"<>
CGI::escapeHTML("string")
=end
def CGI::escapeHTML(string)
Expand Down
2 changes: 1 addition & 1 deletion lib/mailread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(f)
@header = {}
@body = []
begin
while line = f.gets()
f.each do |line|
line.chop!
next if /^From /=~line # skip From-line
break if /^$/=~line # end of header
Expand Down
11 changes: 5 additions & 6 deletions misc/ruby-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ The variable ruby-indent-level controls the amount of indentation.
(cond
((nth 0 state) ; within string
(setq indent nil)) ; do nothing

((car (nth 1 state)) ; in paren
(goto-char (cdr (nth 1 state)))
(if (eq (car (nth 1 state)) ?\( )
Expand All @@ -463,8 +462,7 @@ The variable ruby-indent-level controls the amount of indentation.
(goto-char parse-start)
(back-to-indentation)
(setq indent (ruby-indent-size (current-column) (nth 2 state)))))
))

))
((and (nth 2 state)(> (nth 2 state) 0)) ; in nest
(if (null (cdr (nth 1 state)))
(error "invalid nest"))
Expand All @@ -485,7 +483,7 @@ The variable ruby-indent-level controls the amount of indentation.

((and (nth 2 state) (< (nth 2 state) 0)) ; in negative nest
(setq indent (ruby-indent-size (current-column) (nth 2 state)))))

(cond
(indent
(goto-char indent-point)
Expand Down Expand Up @@ -514,7 +512,7 @@ The variable ruby-indent-level controls the amount of indentation.
(setq end (point))
(beginning-of-line)
(if (re-search-forward "^\\s *#" end t)
(beginning-of-line)
(forward-line 1)
(setq done t))))
(setq bol (point))
(end-of-line)
Expand All @@ -538,9 +536,10 @@ The variable ruby-indent-level controls the amount of indentation.
(goto-char (match-end 0))
(not (looking-at "[a-z_]"))))
(and (looking-at ruby-operator-re)
(not (eq (char-after (1- (point))) ??))
(not (eq (char-after (1- (point))) ?$))
(or (not (eq ?/ (char-after (point))))
(null (nth 0 (ruby-parse-region parse-start (point)))))
(not (eq (char-after (1- (point))) ?$))
(or (not (eq ?| (char-after (point))))
(save-excursion
(or (eolp) (forward-char -1))
Expand Down
29 changes: 13 additions & 16 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,11 @@ VALUE
rb_any_to_s(obj)
VALUE obj;
{
char *s;
char *cname = rb_class2name(CLASS_OF(obj));
VALUE str;

s = ALLOCA_N(char, strlen(cname)+6+16+1); /* 6:tags 16:addr 1:eos */
sprintf(s, "#<%s:0x%lx>", cname, obj);
str = rb_str_new2(s);
str = rb_str_new(0, strlen(cname)+6+16+1); /* 6:tags 16:addr 1:eos */
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", cname, obj);
if (OBJ_TAINTED(obj)) OBJ_TAINT(str);

return str;
Expand Down Expand Up @@ -195,17 +193,16 @@ rb_obj_inspect(obj)
&& ROBJECT(obj)->iv_tbl
&& ROBJECT(obj)->iv_tbl->num_entries > 0) {
VALUE str;
char *c, *b;
char *c;

c = rb_class2name(CLASS_OF(obj));
if (rb_inspecting_p(obj)) {
b = ALLOCA_N(char, strlen(c)+8+16+1); /* 8:tags 16:addr 1:eos */
sprintf(b, "#<%s:0x%lx ...>", c, obj);
return rb_str_new2(b);
str = rb_str_new(0, strlen(c)+8+16+1); /* 8:tags 16:addr 1:eos */
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx ...>", c, obj);
return str;
}
b = ALLOCA_N(char, strlen(c)+4+16+1); /* 4:tags 16:addr 1:eos */
sprintf(b, "-<%s:0x%lx ", c, obj);
str = rb_str_new2(b);
str = rb_str_new(0, strlen(c)+4+16+1); /* 4:tags 16:addr 1:eos */
sprintf(RSTRING(str)->ptr, "-<%s:0x%lx ", c, obj);
return rb_protect_inspect(inspect_obj, obj, str);
}
return rb_funcall(obj, rb_intern("to_s"), 0, 0);
Expand Down Expand Up @@ -495,13 +492,13 @@ static VALUE
sym_inspect(sym)
VALUE sym;
{
char *name, *buf;
VALUE str;
char *name;

str = rb_str_new(0, strlen(name)+2);
name = rb_id2name(SYM2ID(sym));
buf = ALLOCA_N(char, strlen(name)+2);
sprintf(buf, ":%s", name);

return rb_str_new2(buf);
sprintf(RSTRING(str)->ptr, ":%s", name);
return str;
}

static VALUE
Expand Down
12 changes: 7 additions & 5 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -4342,24 +4342,26 @@ assign_in_cond(node)
switch (nd_type(node->nd_value)) {
case NODE_LIT:
case NODE_STR:
case NODE_DSTR:
case NODE_XSTR:
case NODE_DXSTR:
case NODE_EVSTR:
case NODE_DREGX:
case NODE_NIL:
case NODE_TRUE:
case NODE_FALSE:
/* reports always */
rb_warn("found = in conditional, should be ==");
return 1;

case NODE_DSTR:
case NODE_XSTR:
case NODE_DXSTR:
case NODE_EVSTR:
case NODE_DREGX:
default:
break;
}
#if 0
if (assign_in_cond(node->nd_value) == 0) {
rb_warning("assignment in condition");
}
#endif
return 1;
}

Expand Down
10 changes: 5 additions & 5 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ proc_exec_v(argv, prog)

for (n = 0; argv[n]; n++)
/* no-op */;
new_argv = ALLOCA_N(char *, n + 2);
new_argv = ALLOCA_N(char*, n + 2);
for (; n > 0; n--)
new_argv[n + 1] = argv[n];
new_argv[1] = strcpy(ALLOCA_N(char, strlen(argv[0]) + 1), argv[0]);
Expand Down Expand Up @@ -409,7 +409,7 @@ proc_spawn_v(argv, prog)

for (n = 0; argv[n]; n++)
/* no-op */;
new_argv = ALLOCA_N(char *, n + 2);
new_argv = ALLOCA_N(char*, n + 2);
for (; n > 0; n--)
new_argv[n + 1] = argv[n];
new_argv[1] = strcpy(ALLOCA_N(char, strlen(argv[0]) + 1), argv[0]);
Expand Down Expand Up @@ -439,13 +439,13 @@ proc_spawn_n(argc, argv, prog)
char **args;
int i;

args = ALLOCA_N(char *, argc + 1);
args = ALLOCA_N(char*, argc + 1);
for (i = 0; i < argc; i++) {
Check_SafeStr(argv[i]);
args[i] = RSTRING(argv[i])->ptr;
}
Check_SafeStr(prog);
args[i] = (char *) 0;
args[i] = (char*) 0;
if (args[0])
return proc_spawn_v(args, RSTRING(prog)->ptr);
return -1;
Expand All @@ -471,7 +471,7 @@ proc_spawn(sv)
return state;
}
}
a = argv = ALLOCA_N(char *, (s - str) / 2 + 2);
a = argv = ALLOCA_N(char*, (s - str) / 2 + 2);
s = ALLOCA_N(char, s - str + 1);
strcpy(s, str);
if (*a++ = strtok(s, " \t")) {
Expand Down
Loading

0 comments on commit 1ce6f06

Please sign in to comment.