Skip to content

Commit b9228a0

Browse files
author
matz
committed
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 40412b7 commit b9228a0

File tree

7 files changed

+50
-32
lines changed

7 files changed

+50
-32
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Mon Sep 25 18:13:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
2+
3+
* eval.c (rb_add_method): cache mismatch by method
4+
definition. need to clear_cache_by_id every time.
5+
16
Mon Sep 25 13:31:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
27

38
* win32/win32.c (NtCmdGlob): substitute '\\' with '/'.
@@ -10,6 +15,11 @@ Sun Sep 24 03:01:53 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
1015

1116
* lib/net/protocol.rb, http.rb: typo.
1217

18+
Sat Sep 23 07:33:20 2000 Aleksi Niemela <aleksi.niemela@cinnober.com>
19+
20+
* regex.c (re_compile_pattern): nicer regexp error messages for
21+
invalid patterns.
22+
1323
Sat Sep 23 03:06:25 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
1424

1525
* variable.c (rb_autoload_load): should not require already

eval.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ rb_add_method(klass, mid, node, noex)
238238
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
239239
body = NEW_METHOD(node, noex);
240240
st_insert(RCLASS(klass)->m_tbl, mid, body);
241+
rb_clear_cache_by_id(mid);
241242
}
242243

243244
static NODE*
@@ -358,7 +359,6 @@ rb_disable_super(klass, name)
358359
body->nd_noex |= NOEX_UNDEF;
359360
}
360361
else {
361-
rb_clear_cache_by_id(mid);
362362
rb_add_method(klass, mid, 0, NOEX_UNDEF);
363363
}
364364
}
@@ -408,7 +408,6 @@ rb_export_method(klass, name, noex)
408408
body->nd_noex = noex;
409409
}
410410
else {
411-
rb_clear_cache_by_id(name);
412411
rb_add_method(klass, name, NEW_ZSUPER(), noex);
413412
}
414413
}
@@ -1495,7 +1494,6 @@ rb_undef(klass, id)
14951494
rb_id2name(id),s0,rb_class2name(c));
14961495
}
14971496
rb_add_method(klass, id, 0, NOEX_PUBLIC);
1498-
rb_clear_cache_by_id(id);
14991497
}
15001498

15011499
static VALUE
@@ -2825,7 +2823,6 @@ rb_eval(self, n)
28252823
if (RTEST(ruby_verbose) && ruby_class == origin && body->nd_cnt == 0) {
28262824
rb_warning("discarding old %s", rb_id2name(node->nd_mid));
28272825
}
2828-
rb_clear_cache_by_id(node->nd_mid);
28292826
if (node->nd_noex) { /* toplevel */
28302827
/* should upgrade to rb_warn() if no super was called inside? */
28312828
rb_warning("overriding global function `%s'",
@@ -2891,7 +2888,6 @@ rb_eval(self, n)
28912888
rb_warning("redefine %s", rb_id2name(node->nd_mid));
28922889
}
28932890
}
2894-
rb_clear_cache_by_id(node->nd_mid);
28952891
rb_add_method(klass, node->nd_mid, node->nd_defn,
28962892
NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
28972893
rb_funcall(recv, singleton_added, 1, ID2SYM(node->nd_mid));
@@ -5040,8 +5036,8 @@ rb_feature_p(feature, wait)
50405036
if (strcmp(f, feature) == 0) {
50415037
goto load_wait;
50425038
}
5043-
len = strlen(feature);
5044-
if (strncmp(f, feature, len) == 0) {
5039+
len = strlen(f);
5040+
if (strncmp(f, feature, strlen(feature)) == 0) {
50455041
if (strcmp(f+len, ".so") == 0) {
50465042
return Qtrue;
50475043
}
@@ -5348,7 +5344,6 @@ rb_mod_modfunc(argc, argv, module)
53485344
if (body == 0 || body->nd_body == 0) {
53495345
rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
53505346
}
5351-
rb_clear_cache_by_id(id);
53525347
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
53535348
rb_funcall(module, singleton_added, 1, ID2SYM(id));
53545349
}

file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,15 +1980,14 @@ rb_stat_sticky(obj)
19801980
return Qfalse;
19811981
}
19821982

1983-
static VALUE rb_mConst;
1983+
static VALUE rb_mFConst;
19841984

19851985
void
19861986
rb_file_const(name, value)
19871987
const char *name;
19881988
VALUE value;
19891989
{
1990-
rb_define_const(rb_cFile, name, value);
1991-
rb_define_const(rb_mConst, name, value);
1990+
rb_define_const(rb_mFConst, name, value);
19921991
}
19931992

19941993
static int
@@ -2240,7 +2239,8 @@ Init_File()
22402239

22412240
rb_define_method(rb_cFile, "flock", rb_file_flock, 1);
22422241

2243-
rb_mConst = rb_define_module_under(rb_cFile, "Constants");
2242+
rb_mFConst = rb_define_module_under(rb_cFile, "Constants");
2243+
rb_include_module(rb_cFile, rb_mFConst);
22442244
rb_file_const("LOCK_SH", INT2FIX(LOCK_SH));
22452245
rb_file_const("LOCK_EX", INT2FIX(LOCK_EX));
22462246
rb_file_const("LOCK_UN", INT2FIX(LOCK_UN));

gc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,4 +1298,3 @@ xfree(ptr)
12981298
{
12991299
ruby_xfree(ptr);
13001300
}
1301-

lib/thwait.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ class ThreadsWait
4444

4545
Exception2MessageMapper.extend_to(binding)
4646
def_exception("ErrNoWaitingThread", "No threads for waiting.")
47-
def_exception("ErrNoFinshedThread", "No finished threads.")
47+
def_exception("ErrNoFinishedThread", "No finished threads.")
4848

4949
def ThreadsWait.all_waits(*threads)
5050
tw = ThreadsWait.new(*threads)
5151
if block_given?
52-
tw.all_waits do
53-
|th|
52+
tw.all_waits do |th|
5453
yield th
5554
end
5655
else
@@ -96,11 +95,12 @@ def join(*threads)
9695

9796
# adds thread(s) to join, no wait.
9897
def join_nowait(*threads)
99-
@threads.concat threads.flatten
98+
threads.flatten!
99+
@threads.concat threads
100100
for th in threads
101-
Thread.start do
102-
th = th.join
103-
@wait_queue.push th
101+
Thread.start(th) do |t|
102+
t.join
103+
@wait_queue.push t
104104
end
105105
end
106106
end

regex.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,8 @@ re_compile_pattern(pattern, size, bufp)
11901190
register unsigned int c, c1;
11911191
const char *p0;
11921192
int numlen;
1193+
#define ERROR_MSG_MAX_SIZE 200
1194+
static char error_msg[ERROR_MSG_MAX_SIZE+1];
11931195

11941196
/* Address of the count-byte of the most recently inserted `exactn'
11951197
command. This makes it possible to tell whether a new exact-match
@@ -1318,7 +1320,10 @@ re_compile_pattern(pattern, size, bufp)
13181320
case '*':
13191321
/* If there is no previous pattern, char not special. */
13201322
if (!laststart) {
1321-
goto invalid_pattern;
1323+
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
1324+
"invalid regular expression; there's no previous pattern, to which '%c' would define cardinality at %d",
1325+
c, p-pattern);
1326+
FREE_AND_RETURN(stackb, error_msg);
13221327
}
13231328
/* If there is a sequence of repetition chars,
13241329
collapse it down to just one. */
@@ -1400,7 +1405,7 @@ re_compile_pattern(pattern, size, bufp)
14001405

14011406
case '[':
14021407
if (p == pend)
1403-
goto invalid_pattern;
1408+
FREE_AND_RETURN(stackb, "invalid regular expression; '[' can't be the last character ie. can't start range at the end of pattern");
14041409
while ((b - bufp->buffer + 9 + (1 << BYTEWIDTH) / BYTEWIDTH)
14051410
> bufp->allocated)
14061411
EXTEND_BUFFER;
@@ -1441,7 +1446,7 @@ re_compile_pattern(pattern, size, bufp)
14411446
if (c == ']') {
14421447
if (p == p0 + 1) {
14431448
if (p == pend)
1444-
goto invalid_pattern;
1449+
FREE_AND_RETURN(stackb, "invalid regular expression; empty character class");
14451450
}
14461451
else
14471452
/* Stop if this isn't merely a ] inside a bracket
@@ -1452,7 +1457,7 @@ re_compile_pattern(pattern, size, bufp)
14521457
/* Look ahead to see if it's a range when the last thing
14531458
was a character class. */
14541459
if (had_char_class && c == '-' && *p != ']')
1455-
goto invalid_pattern;
1460+
FREE_AND_RETURN(stackb, "invalid regular expression; can't use character class as a start value of range");
14561461
if (ismbchar(c)) {
14571462
PATFETCH_MBC(c);
14581463
had_mbchar++;
@@ -1582,7 +1587,7 @@ re_compile_pattern(pattern, size, bufp)
15821587

15831588
/* If pattern is `[[:'. */
15841589
if (p == pend)
1585-
goto invalid_pattern;
1590+
FREE_AND_RETURN(stackb, "invalid regular expression; re can't end '[[:'");
15861591

15871592
for (;;) {
15881593
PATFETCH (c);
@@ -1611,14 +1616,17 @@ re_compile_pattern(pattern, size, bufp)
16111616
char is_upper = STREQ(str, "upper");
16121617
char is_xdigit = STREQ(str, "xdigit");
16131618

1614-
if (!IS_CHAR_CLASS(str))
1615-
goto invalid_pattern;
1619+
if (!IS_CHAR_CLASS(str)){
1620+
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
1621+
"invalid regular expression; [:%s:] is not a character class", str);
1622+
FREE_AND_RETURN(stackb, error_msg);
1623+
}
16161624

16171625
/* Throw away the ] at the end of the character class. */
16181626
PATFETCH(c);
16191627

16201628
if (p == pend)
1621-
goto invalid_pattern;
1629+
FREE_AND_RETURN(stackb, "invalid regular expression; range doesn't have ending ']' after a character class");
16221630

16231631
for (ch = 0; ch < 1 << BYTEWIDTH; ch++) {
16241632
if ( (is_alnum && ISALNUM(ch))
@@ -1938,9 +1946,14 @@ re_compile_pattern(pattern, size, bufp)
19381946

19391947
case '{':
19401948
/* If there is no previous pattern, this is an invalid pattern. */
1941-
if (!laststart || p == pend) {
1942-
goto invalid_pattern;
1949+
if (!laststart) {
1950+
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
1951+
"invalid regular expression; there's no previous pattern, to which '{' would define cardinality at %d",
1952+
p-pattern);
1953+
FREE_AND_RETURN(stackb, error_msg);
19431954
}
1955+
if( p == pend)
1956+
FREE_AND_RETURN(stackb, "invalid regular expression; '{' can't be last character" );
19441957

19451958
beg_interval = p - 1;
19461959

@@ -2119,7 +2132,8 @@ re_compile_pattern(pattern, size, bufp)
21192132
goto normal_char;
21202133

21212134
case '\\':
2122-
if (p == pend) goto invalid_pattern;
2135+
if (p == pend)
2136+
FREE_AND_RETURN(stackb, "invalid regular expression; '\\' can't be last character");
21232137
/* Do not translate the character after the \, so that we can
21242138
distinguish, e.g., \B from \b, even if we normally would
21252139
translate, e.g., B to b. */

ruby.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ VALUE rb_uint2inum _((unsigned long));
136136
#define Qnil 4
137137
#define Qundef 6 /* undefined value for placeholder */
138138

139-
#define RTEST(v) ((VALUE)(v) & ~Qnil)
139+
#define RTEST(v) (((VALUE)(v) & ~Qnil) != 0)
140140
#define NIL_P(v) ((VALUE)(v) == Qnil)
141141

142142
#define CLASS_OF(v) rb_class_of((VALUE)(v))

0 commit comments

Comments
 (0)