summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-10 07:03:36 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-10 07:03:36 +0000
commit1ce6f065b519284a5ad7135a6db77fcbe1aa778a (patch)
tree79c663a365cc039f46e51658f288538eade86658
parentef45458e9405c57ab4f59f648c4001ea4df30489 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog28
-rw-r--r--array.c18
-rw-r--r--eval.c21
-rw-r--r--file.c3
-rw-r--r--gc.c8
-rw-r--r--lib/cgi.rb2
-rw-r--r--lib/mailread.rb2
-rw-r--r--misc/ruby-mode.el11
-rw-r--r--object.c29
-rw-r--r--parse.y12
-rw-r--r--process.c10
-rw-r--r--re.c9
-rw-r--r--sample/from.rb2
-rw-r--r--string.c12
-rw-r--r--struct.c12
-rw-r--r--version.h8
16 files changed, 113 insertions, 74 deletions
diff --git a/ChangeLog b/ChangeLog
index 7039df50b2..9cc9c5e176 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/array.c b/array.c
index 09c3a0489d..4cd5689838 100644
--- a/array.c
+++ b/array.c
@@ -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;
@@ -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;
@@ -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);
@@ -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;
}
diff --git a/eval.c b/eval.c
index 88b2cf346e..03f822ab34 100644
--- a/eval.c
+++ b/eval.c
@@ -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; \
@@ -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();
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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);
}
diff --git a/file.c b/file.c
index 14c24c5ace..abbae82e44 100644
--- a/file.c
+++ b/file.c
@@ -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);
@@ -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);
diff --git a/gc.c b/gc.c
index a7e272f257..2b50ffa0dc 100644
--- a/gc.c
+++ b/gc.c
@@ -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
@@ -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;
diff --git a/lib/cgi.rb b/lib/cgi.rb
index b146efddd7..a4138c3782 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -258,7 +258,7 @@ class CGI
=begin
-=== ESCAPE HTML &"<>
+=== ESCAPE HTML &\"<>
CGI::escapeHTML("string")
=end
def CGI::escapeHTML(string)
diff --git a/lib/mailread.rb b/lib/mailread.rb
index ee86d353eb..6d59a08fc9 100644
--- a/lib/mailread.rb
+++ b/lib/mailread.rb
@@ -9,7 +9,7 @@ class Mail
@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
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 787a048b37..33b88a2942 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -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)) ?\( )
@@ -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"))
@@ -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)
@@ -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)
@@ -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))
diff --git a/object.c b/object.c
index cfc1f125c6..7f18675d7d 100644
--- a/object.c
+++ b/object.c
@@ -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;
@@ -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);
@@ -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
diff --git a/parse.y b/parse.y
index 85cc49bceb..3959679628 100644
--- a/parse.y
+++ b/parse.y
@@ -4342,11 +4342,6 @@ 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:
@@ -4354,12 +4349,19 @@ assign_in_cond(node)
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;
}
diff --git a/process.c b/process.c
index c052bb1de8..a99e902b59 100644
--- a/process.c
+++ b/process.c
@@ -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]);
@@ -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]);
@@ -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;
@@ -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")) {
diff --git a/re.c b/re.c
index eeb89cf129..a69cf1c7ec 100644
--- a/re.c
+++ b/re.c
@@ -1038,7 +1038,7 @@ rb_reg_s_quote(argc, argv)
VALUE str, kcode;
int kcode_saved = reg_kcode;
char *s, *send, *t;
- char *tmp;
+ VALUE tmp;
int len;
rb_scan_args(argc, argv, "11", &str, &kcode);
@@ -1049,8 +1049,8 @@ rb_reg_s_quote(argc, argv)
}
s = rb_str2cstr(str, &len);
send = s + len;
- tmp = ALLOCA_N(char, len*2);
- t = tmp;
+ tmp = rb_str_new(0, len*2);
+ t = RSTRING(tmp)->ptr;
for (; s < send; s++) {
if (ismbchar(*s)) {
@@ -1073,8 +1073,9 @@ rb_reg_s_quote(argc, argv)
*t++ = *s;
}
kcode_reset_option();
+ rb_str_resize(tmp, t - RSTRING(tmp)->ptr);
- return rb_str_new(tmp, t - tmp);
+ return tmp;
}
int
diff --git a/sample/from.rb b/sample/from.rb
index bed3433f1e..59cc387792 100644
--- a/sample/from.rb
+++ b/sample/from.rb
@@ -50,8 +50,8 @@ end
$outcount = 0;
def fromout(date, from, subj)
return if !date
- y = m = d = 0
y, m, d = parsedate(date) if date
+ y ||= 0; m ||= 0; d ||= 0
if from
from.gsub! /\n/, ""
else
diff --git a/string.c b/string.c
index ff9e6bd0c2..46f9725ce3 100644
--- a/string.c
+++ b/string.c
@@ -1381,16 +1381,16 @@ static VALUE
rb_str_reverse_bang(str)
VALUE str;
{
- char *s, *e, *p, *q;
+ char *s, *e;
+ char c;
s = RSTRING(str)->ptr;
e = s + RSTRING(str)->len - 1;
- p = q = ALLOCA_N(char, RSTRING(str)->len);
-
- while (e >= s) {
- *p++ = *e--;
+ while (s < e) {
+ c = *s;
+ *s++ = *e;
+ *e-- = c;
}
- MEMCPY(RSTRING(str)->ptr, q, char, RSTRING(str)->len);
return str;
}
diff --git a/struct.c b/struct.c
index 31103a452b..4d9b81a7ca 100644
--- a/struct.c
+++ b/struct.c
@@ -338,10 +338,10 @@ rb_struct_to_s(s)
VALUE s;
{
char *cname = rb_class2name(CLASS_OF(s));
- char *buf = ALLOCA_N(char, strlen(cname) + 4);
+ VALUE str = rb_str_new(0, strlen(cname) + 4);
- sprintf(buf, "#<%s>", cname);
- return rb_str_new2(buf);
+ sprintf(RSTRING(str)->ptr, "#<%s>", cname);
+ return str;
}
static VALUE
@@ -386,10 +386,10 @@ rb_struct_inspect(s)
{
if (rb_inspecting_p(s)) {
char *cname = rb_class2name(CLASS_OF(s));
- char *buf = ALLOCA_N(char, strlen(cname) + 8);
+ VALUE str = rb_str_new(0, strlen(cname) + 8);
- sprintf(buf, "#<%s:...>", cname);
- return rb_str_new2(buf);
+ sprintf(RSTRING(str)->ptr, "#<%s:...>", cname);
+ return str;
}
return rb_protect_inspect(inspect_struct, s, 0);
}
diff --git a/version.h b/version.h
index 0064b66cad..59c6536f35 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
-#define RUBY_VERSION "1.6.1"
-#define RUBY_RELEASE_DATE "2000-10-05"
-#define RUBY_VERSION_CODE 161
-#define RUBY_RELEASE_CODE 20001005
+#define RUBY_VERSION "1.6.2"
+#define RUBY_RELEASE_DATE "2000-10-08"
+#define RUBY_VERSION_CODE 162
+#define RUBY_RELEASE_CODE 20001008