Skip to content

Commit abfaac7

Browse files
author
matz
committed
* ruby.c (proc_options): unexpected SecurityError happens when -T4.
* regex.c (re_compile_pattern): * \1 .. \9 should be backreferences always. * regex.c (re_match): backreferences corresponding to unclosed/unmatched parentheses should fail always. * string.c (rb_str_cat): use rb_str_buf_cat() if possible. [new] * string.c (rb_str_append): ditto. * string.c (rb_str_buf_cat): remove unnecessary check (type, taint, modify) to gain performance. * string.c (rb_str_buf_append): ditto. * string.c (rb_str_buf_new): buffering string function. [new] * string.c (rb_str_buf_append): ditto. * string.c (rb_str_buf_cat): ditto. * time.c (make_time_t): local time adjustment revised. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 4cd1cd7 commit abfaac7

24 files changed

+922
-420
lines changed

ChangeLog

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
Tue May 29 17:24:23 2001 K.Kosako <kosako@sofnec.co.jp>
2+
3+
* ruby.c (proc_options): unexpected SecurityError happens when -T4.
4+
5+
Tue May 29 18:46:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
6+
7+
* regex.c (re_compile_pattern): * \1 .. \9 should be
8+
backreferences always.
9+
10+
* regex.c (re_match): backreferences corresponding to
11+
unclosed/unmatched parentheses should fail always.
12+
13+
Tue May 29 16:35:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
14+
15+
* string.c (rb_str_cat): use rb_str_buf_cat() if possible. [new]
16+
17+
* string.c (rb_str_append): ditto.
18+
19+
* string.c (rb_str_buf_cat): remove unnecessary check (type,
20+
taint, modify) to gain performance.
21+
22+
* string.c (rb_str_buf_append): ditto.
23+
24+
* string.c (rb_str_buf_finish): removed.
25+
26+
Tue May 29 02:05:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
27+
28+
* string.c (rb_str_buf_new): buffering string function. [new]
29+
30+
* string.c (rb_str_buf_append): ditto.
31+
32+
* string.c (rb_str_buf_cat): ditto.
33+
34+
* string.c (rb_str_buf_finish): ditto.
35+
136
Mon May 28 23:20:43 2001 WATANABE Hirofumi <eban@ruby-lang.org>
237

338
* configure.in: remove unnecessary AC_CANONICAL_BUILD
@@ -21,6 +56,10 @@ Mon May 28 22:12:01 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
2156
* ext/extconf.rb.in: make the priority of the make rule of .c
2257
higher than .C .
2358

59+
Mon May 28 13:22:19 2001 Tanaka Akira <akr@m17n.org>
60+
61+
* time.c (make_time_t): local time adjustment revised.
62+
2463
Mon May 28 02:20:38 2001 Akinori MUSHA <knu@iDaemons.org>
2564

2665
* dir.c (glob_helper): teach has_magic() to handle flags and get
@@ -29,10 +68,38 @@ Mon May 28 02:20:38 2001 Akinori MUSHA <knu@iDaemons.org>
2968
* dir.c (fnmatch): fix a bug when FNM_PATHNAME and FNM_PERIOD are
3069
specified at the same time.
3170

71+
Sat May 26 09:55:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
72+
73+
* parse.y: accomplish extended syntax described in [ruby-talk:14525]
74+
using tSPC token. [new, experimental]
75+
3276
Sat May 26 07:05:45 2001 Usaku Nakamura <usa@osb.att.ne.jp>
3377

3478
* MANIFEST: add win32/dir.h .
3579

80+
Fri May 25 20:03:51 2001 Pascal Rigaux <pixel@mandrakesoft.com>
81+
82+
* dln.c (dln_find_1): should exclude directories in executable
83+
file lookup.
84+
85+
Fri May 25 18:00:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
86+
87+
* class.c (rb_obj_singleton_methods): list methods in extended
88+
modules if optional argument is true. [new]
89+
90+
Fri May 25 14:19:25 2001 K.Kosako <kosako@sofnec.co.jp>
91+
92+
* string.c (rb_str_replace): add taint status infection
93+
(OBJ_INFECT()).
94+
95+
* string.c (rb_str_crypt): ditto.
96+
97+
* string.c (rb_str_ljust): ditto.
98+
99+
* string.c (rb_str_rjust): ditto.
100+
101+
* string.c (rb_str_center): ditto.
102+
36103
Fri May 25 05:39:03 2001 Akinori MUSHA <knu@iDaemons.org>
37104

38105
* ext/sha1/sha1-ruby.c (sha1_hexdigest): fix buffer overflow. The
@@ -54,6 +121,17 @@ Fri May 25 00:53:41 2001 Akinori MUSHA <knu@iDaemons.org>
54121
* ext/dbm/extconf.rb: fix support for *BSD and set $CFLAGS
55122
properly.
56123

124+
Thu May 24 16:10:33 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
125+
126+
* range.c (range_member): check based on "<=>" comparison. [new]
127+
128+
* range.c (range_check): add "succ" check if first end is not a
129+
numeric.
130+
131+
* range.c (range_eqq): comparison should based on "<=>".
132+
133+
* range.c (range_each): ditto.
134+
57135
Thu May 24 16:08:21 2001 WATANABE Hirofumi <eban@ruby-lang.org>
58136

59137
* mkconfig.rb: autoconf 2.50 support.

array.c

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -739,26 +739,11 @@ inspect_join(ary, arg)
739739
return rb_ary_join(arg[0], arg[1]);
740740
}
741741

742-
static long
743-
str_cpy(str, idx, str2)
744-
VALUE str;
745-
long idx;
746-
VALUE str2;
747-
{
748-
long len = idx + RSTRING(str2)->len;
749-
750-
if (RSTRING(str)->len < len) {
751-
rb_str_resize(str, len);
752-
}
753-
memcpy(RSTRING(str)->ptr+idx, RSTRING(str2)->ptr, RSTRING(str2)->len);
754-
return len;
755-
}
756-
757742
VALUE
758743
rb_ary_join(ary, sep)
759744
VALUE ary, sep;
760745
{
761-
long len, i, j;
746+
long len, i;
762747
int taint = 0;
763748
VALUE result, tmp;
764749

@@ -778,9 +763,8 @@ rb_ary_join(ary, sep)
778763
if (!NIL_P(sep) && TYPE(sep) == T_STRING) {
779764
len += RSTRING(sep)->len * RARRAY(ary)->len - 1;
780765
}
781-
result = rb_str_new(0, len);
782-
783-
for (i=0, j=0; i<RARRAY(ary)->len; i++) {
766+
result = rb_str_buf_new(len);
767+
for (i=0; i<RARRAY(ary)->len; i++) {
784768
tmp = RARRAY(ary)->ptr[i];
785769
switch (TYPE(tmp)) {
786770
case T_STRING:
@@ -800,11 +784,11 @@ rb_ary_join(ary, sep)
800784
default:
801785
tmp = rb_obj_as_string(tmp);
802786
}
803-
if (i > 0 && !NIL_P(sep)) j = str_cpy(result, j, sep);
804-
j = str_cpy(result, j, tmp);
787+
if (i > 0 && !NIL_P(sep))
788+
rb_str_buf_append(result, sep);
789+
rb_str_buf_append(result, tmp);
805790
if (OBJ_TAINTED(tmp)) taint = 1;
806791
}
807-
rb_str_resize(result, j);
808792

809793
if (taint) OBJ_TAINT(result);
810794
return result;
@@ -909,16 +893,14 @@ inspect_ary(ary)
909893
long i = 0;
910894
VALUE s, str;
911895

912-
str = rb_str_new2("[");
913-
896+
str = rb_str_buf_new2("[");
914897
for (i=0; i<RARRAY(ary)->len; i++) {
915898
s = rb_inspect(RARRAY(ary)->ptr[i]);
916-
tainted = OBJ_TAINTED(s);
917-
if (i > 0) rb_str_cat2(str, ", ");
918-
rb_str_append(str, s);
899+
if (OBJ_TAINTED(s)) tainted = 1;
900+
if (i > 0) rb_str_buf_cat2(str, ", ");
901+
rb_str_buf_append(str, s);
919902
}
920-
rb_str_cat(str, "]", 1);
921-
903+
rb_str_buf_cat2(str, "]");
922904
if (tainted) OBJ_TAINT(str);
923905
return str;
924906
}

class.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,19 +484,29 @@ rb_class_private_instance_methods(argc, argv, mod)
484484
}
485485

486486
VALUE
487-
rb_obj_singleton_methods(obj)
487+
rb_obj_singleton_methods(argc, argv, obj)
488+
int argc;
489+
VALUE *argv;
488490
VALUE obj;
489491
{
492+
VALUE all;
490493
VALUE ary;
491494
VALUE klass;
492495
VALUE *p, *q, *pend;
493496

497+
rb_scan_args(argc, argv, "01", &all);
494498
ary = rb_ary_new();
495499
klass = CLASS_OF(obj);
496500
while (klass && FL_TEST(klass, FL_SINGLETON)) {
497501
st_foreach(RCLASS(klass)->m_tbl, ins_methods_i, ary);
498502
klass = RCLASS(klass)->super;
499503
}
504+
if (RTEST(all)) {
505+
while (klass && TYPE(klass) == T_ICLASS) {
506+
st_foreach(RCLASS(klass)->m_tbl, ins_methods_i, ary);
507+
klass = RCLASS(klass)->super;
508+
}
509+
}
500510
p = q = RARRAY(ary)->ptr; pend = p + RARRAY(ary)->len;
501511
while (p < pend) {
502512
if (*p == Qnil) {

dln.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ void *xrealloc();
5050
#include <sys/types.h>
5151
#include <sys/stat.h>
5252

53+
#ifndef S_ISDIR
54+
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
55+
#endif
56+
5357
#ifdef HAVE_SYS_PARAM_H
5458
# include <sys/param.h>
5559
#else
@@ -1582,9 +1586,8 @@ dln_find_1(fname, path, exe_flag)
15821586
register char *dp;
15831587
register char *ep;
15841588
register char *bp;
1585-
#ifndef __MACOS__
15861589
struct stat st;
1587-
#else
1590+
#ifdef __MACOS__
15881591
const char* mac_fullpath;
15891592
#endif
15901593

@@ -1669,13 +1672,17 @@ dln_find_1(fname, path, exe_flag)
16691672
if (stat(fbuf, &st) == 0) {
16701673
if (exe_flag == 0) return fbuf;
16711674
/* looking for executable */
1672-
if (eaccess(fbuf, X_OK) == 0) return fbuf;
1675+
if (!S_ISDIR(st.st_mode) && eaccess(fbuf, X_OK) == 0)
1676+
return fbuf;
16731677
}
16741678
#else
16751679
if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf)) {
16761680
if (exe_flag == 0) return mac_fullpath;
16771681
/* looking for executable */
1678-
if (eaccess(mac_fullpath, X_OK) == 0) return mac_fullpath;
1682+
if (stat(mac_fullpath, &st) == 0) {
1683+
if (!S_ISDIR(st.st_mode) && eaccess(mac_fullpath, X_OK) == 0)
1684+
return mac_fullpath;
1685+
}
16791686
}
16801687
#endif
16811688
#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)

error.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ exc_inspect(exc)
359359
return rb_str_dup(rb_class_path(klass));
360360
}
361361

362-
str = rb_str_new2("#<");
362+
str = rb_str_buf_new2("#<");
363363
klass = rb_class_path(klass);
364-
rb_str_append(str, klass);
365-
rb_str_cat(str, ": ", 2);
366-
rb_str_append(str, exc);
367-
rb_str_cat(str, ">", 1);
364+
rb_str_buf_append(str, klass);
365+
rb_str_buf_cat(str, ": ", 2);
366+
rb_str_buf_append(str, exc);
367+
rb_str_buf_cat(str, ">", 1);
368368

369369
return str;
370370
}

eval.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "ruby.h"
1616
#include "node.h"
1717
#include "env.h"
18+
#include "util.h"
1819
#include "rubysig.h"
1920

2021
#include <stdio.h>
@@ -1213,14 +1214,14 @@ compile_error(at)
12131214
VALUE str;
12141215

12151216
ruby_nerrs = 0;
1216-
str = rb_str_new2("compile error");
1217+
str = rb_str_buf_new2("compile error");
12171218
if (at) {
1218-
rb_str_cat2(str, " in ");
1219-
rb_str_cat2(str, at);
1219+
rb_str_buf_cat2(str, " in ");
1220+
rb_str_buf_cat2(str, at);
12201221
}
1221-
rb_str_cat(str, "\n", 1);
1222+
rb_str_buf_cat(str, "\n", 1);
12221223
if (!NIL_P(ruby_errinfo)) {
1223-
rb_str_concat(str, ruby_errinfo);
1224+
rb_str_append(str, ruby_errinfo);
12241225
}
12251226
rb_exc_raise(rb_exc_new3(rb_eSyntaxError, str));
12261227
}
@@ -2351,9 +2352,7 @@ rb_eval(self, n)
23512352
case NODE_YIELD:
23522353
if (node->nd_stts) {
23532354
result = rb_eval(self, node->nd_stts);
2354-
if (nd_type(node->nd_stts) == NODE_RESTARGS &&
2355-
RARRAY(result)->len == 1)
2356-
{
2355+
if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) {
23572356
result = RARRAY(result)->ptr[0];
23582357
}
23592358
}
@@ -6752,19 +6751,19 @@ method_inspect(method)
67526751
const char *s;
67536752

67546753
Data_Get_Struct(method, struct METHOD, data);
6755-
str = rb_str_new2("#<");
6754+
str = rb_str_buf_new2("#<");
67566755
s = rb_class2name(CLASS_OF(method));
6757-
rb_str_cat2(str, s);
6758-
rb_str_cat2(str, ": ");
6756+
rb_str_buf_cat2(str, s);
6757+
rb_str_buf_cat2(str, ": ");
67596758
s = rb_class2name(data->oklass);
6760-
rb_str_cat2(str, s);
6761-
rb_str_cat2(str, "(");
6759+
rb_str_buf_cat2(str, s);
6760+
rb_str_buf_cat2(str, "(");
67626761
s = rb_class2name(data->klass);
6763-
rb_str_cat2(str, s);
6764-
rb_str_cat2(str, ")#");
6762+
rb_str_buf_cat2(str, s);
6763+
rb_str_buf_cat2(str, ")#");
67656764
s = rb_id2name(data->oid);
6766-
rb_str_cat2(str, s);
6767-
rb_str_cat2(str, ">");
6765+
rb_str_buf_cat2(str, s);
6766+
rb_str_buf_cat2(str, ">");
67686767

67696768
return str;
67706769
}

file.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,22 +281,22 @@ rb_stat_inspect(self)
281281
{"ctime", rb_stat_ctime},
282282
};
283283

284-
str = rb_str_new2("#<");
285-
rb_str_cat2(str, rb_class2name(CLASS_OF(self)));
286-
rb_str_cat2(str, " ");
284+
str = rb_str_buf_new2("#<");
285+
rb_str_buf_cat2(str, rb_class2name(CLASS_OF(self)));
286+
rb_str_buf_cat2(str, " ");
287287

288288
for (i = 0; i < sizeof(member)/sizeof(member[0]); i++) {
289289
VALUE str2;
290290

291291
if (i > 0) {
292-
rb_str_cat2(str, ", ");
292+
rb_str_buf_cat2(str, ", ");
293293
}
294-
rb_str_cat2(str, member[i].name);
295-
rb_str_cat2(str, "=");
294+
rb_str_buf_cat2(str, member[i].name);
295+
rb_str_buf_cat2(str, "=");
296296
str2 = rb_inspect((*member[i].func)(self));
297297
rb_str_append(str, str2);
298298
}
299-
rb_str_cat2(str, ">");
299+
rb_str_buf_cat2(str, ">");
300300
OBJ_INFECT(str, self);
301301

302302
return str;
@@ -449,7 +449,7 @@ eaccess(path, mode)
449449
if (st.st_mode & mode) return 0;
450450

451451
return -1;
452-
#else /* !NT */
452+
#else
453453
return access(path, mode);
454454
#endif
455455
}

0 commit comments

Comments
 (0)