summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-09-25 09:15:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-09-25 09:15:08 +0000
commitb9228a014ba4818cdf584e3dda63ed1aed3ad1c7 (patch)
tree02b5b0ea6c42aa4186fe5095141f8782076fea8e
parent40412b77305befcaffd0f3fcf85d6cd8f2d75f3d (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--eval.c11
-rw-r--r--file.c8
-rw-r--r--gc.c1
-rw-r--r--lib/thwait.rb14
-rw-r--r--regex.c36
-rw-r--r--ruby.h2
7 files changed, 50 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index d73bbef671..3879e8bc00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Sep 25 18:13:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_add_method): cache mismatch by method
+ definition. need to clear_cache_by_id every time.
+
Mon Sep 25 13:31:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* 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>
* lib/net/protocol.rb, http.rb: typo.
+Sat Sep 23 07:33:20 2000 Aleksi Niemela <aleksi.niemela@cinnober.com>
+
+ * regex.c (re_compile_pattern): nicer regexp error messages for
+ invalid patterns.
+
Sat Sep 23 03:06:25 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_autoload_load): should not require already
diff --git a/eval.c b/eval.c
index 770dd920ff..b2e9deb4c0 100644
--- a/eval.c
+++ b/eval.c
@@ -238,6 +238,7 @@ rb_add_method(klass, mid, node, noex)
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
body = NEW_METHOD(node, noex);
st_insert(RCLASS(klass)->m_tbl, mid, body);
+ rb_clear_cache_by_id(mid);
}
static NODE*
@@ -358,7 +359,6 @@ rb_disable_super(klass, name)
body->nd_noex |= NOEX_UNDEF;
}
else {
- rb_clear_cache_by_id(mid);
rb_add_method(klass, mid, 0, NOEX_UNDEF);
}
}
@@ -408,7 +408,6 @@ rb_export_method(klass, name, noex)
body->nd_noex = noex;
}
else {
- rb_clear_cache_by_id(name);
rb_add_method(klass, name, NEW_ZSUPER(), noex);
}
}
@@ -1495,7 +1494,6 @@ rb_undef(klass, id)
rb_id2name(id),s0,rb_class2name(c));
}
rb_add_method(klass, id, 0, NOEX_PUBLIC);
- rb_clear_cache_by_id(id);
}
static VALUE
@@ -2825,7 +2823,6 @@ rb_eval(self, n)
if (RTEST(ruby_verbose) && ruby_class == origin && body->nd_cnt == 0) {
rb_warning("discarding old %s", rb_id2name(node->nd_mid));
}
- rb_clear_cache_by_id(node->nd_mid);
if (node->nd_noex) { /* toplevel */
/* should upgrade to rb_warn() if no super was called inside? */
rb_warning("overriding global function `%s'",
@@ -2891,7 +2888,6 @@ rb_eval(self, n)
rb_warning("redefine %s", rb_id2name(node->nd_mid));
}
}
- rb_clear_cache_by_id(node->nd_mid);
rb_add_method(klass, node->nd_mid, node->nd_defn,
NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
rb_funcall(recv, singleton_added, 1, ID2SYM(node->nd_mid));
@@ -5040,8 +5036,8 @@ rb_feature_p(feature, wait)
if (strcmp(f, feature) == 0) {
goto load_wait;
}
- len = strlen(feature);
- if (strncmp(f, feature, len) == 0) {
+ len = strlen(f);
+ if (strncmp(f, feature, strlen(feature)) == 0) {
if (strcmp(f+len, ".so") == 0) {
return Qtrue;
}
@@ -5348,7 +5344,6 @@ rb_mod_modfunc(argc, argv, module)
if (body == 0 || body->nd_body == 0) {
rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
}
- rb_clear_cache_by_id(id);
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
rb_funcall(module, singleton_added, 1, ID2SYM(id));
}
diff --git a/file.c b/file.c
index 85d7d5056e..14c24c5ace 100644
--- a/file.c
+++ b/file.c
@@ -1980,15 +1980,14 @@ rb_stat_sticky(obj)
return Qfalse;
}
-static VALUE rb_mConst;
+static VALUE rb_mFConst;
void
rb_file_const(name, value)
const char *name;
VALUE value;
{
- rb_define_const(rb_cFile, name, value);
- rb_define_const(rb_mConst, name, value);
+ rb_define_const(rb_mFConst, name, value);
}
static int
@@ -2240,7 +2239,8 @@ Init_File()
rb_define_method(rb_cFile, "flock", rb_file_flock, 1);
- rb_mConst = rb_define_module_under(rb_cFile, "Constants");
+ rb_mFConst = rb_define_module_under(rb_cFile, "Constants");
+ rb_include_module(rb_cFile, rb_mFConst);
rb_file_const("LOCK_SH", INT2FIX(LOCK_SH));
rb_file_const("LOCK_EX", INT2FIX(LOCK_EX));
rb_file_const("LOCK_UN", INT2FIX(LOCK_UN));
diff --git a/gc.c b/gc.c
index 52fd735e9e..b6b0aa8a71 100644
--- a/gc.c
+++ b/gc.c
@@ -1298,4 +1298,3 @@ xfree(ptr)
{
ruby_xfree(ptr);
}
-
diff --git a/lib/thwait.rb b/lib/thwait.rb
index 3c17009310..00c8a8dd36 100644
--- a/lib/thwait.rb
+++ b/lib/thwait.rb
@@ -44,13 +44,12 @@ class ThreadsWait
Exception2MessageMapper.extend_to(binding)
def_exception("ErrNoWaitingThread", "No threads for waiting.")
- def_exception("ErrNoFinshedThread", "No finished threads.")
+ def_exception("ErrNoFinishedThread", "No finished threads.")
def ThreadsWait.all_waits(*threads)
tw = ThreadsWait.new(*threads)
if block_given?
- tw.all_waits do
- |th|
+ tw.all_waits do |th|
yield th
end
else
@@ -96,11 +95,12 @@ class ThreadsWait
# adds thread(s) to join, no wait.
def join_nowait(*threads)
- @threads.concat threads.flatten
+ threads.flatten!
+ @threads.concat threads
for th in threads
- Thread.start do
- th = th.join
- @wait_queue.push th
+ Thread.start(th) do |t|
+ t.join
+ @wait_queue.push t
end
end
end
diff --git a/regex.c b/regex.c
index 47da2ffdf3..61bc7253a9 100644
--- a/regex.c
+++ b/regex.c
@@ -1190,6 +1190,8 @@ re_compile_pattern(pattern, size, bufp)
register unsigned int c, c1;
const char *p0;
int numlen;
+#define ERROR_MSG_MAX_SIZE 200
+ static char error_msg[ERROR_MSG_MAX_SIZE+1];
/* Address of the count-byte of the most recently inserted `exactn'
command. This makes it possible to tell whether a new exact-match
@@ -1318,7 +1320,10 @@ re_compile_pattern(pattern, size, bufp)
case '*':
/* If there is no previous pattern, char not special. */
if (!laststart) {
- goto invalid_pattern;
+ snprintf(error_msg, ERROR_MSG_MAX_SIZE,
+ "invalid regular expression; there's no previous pattern, to which '%c' would define cardinality at %d",
+ c, p-pattern);
+ FREE_AND_RETURN(stackb, error_msg);
}
/* If there is a sequence of repetition chars,
collapse it down to just one. */
@@ -1400,7 +1405,7 @@ re_compile_pattern(pattern, size, bufp)
case '[':
if (p == pend)
- goto invalid_pattern;
+ FREE_AND_RETURN(stackb, "invalid regular expression; '[' can't be the last character ie. can't start range at the end of pattern");
while ((b - bufp->buffer + 9 + (1 << BYTEWIDTH) / BYTEWIDTH)
> bufp->allocated)
EXTEND_BUFFER;
@@ -1441,7 +1446,7 @@ re_compile_pattern(pattern, size, bufp)
if (c == ']') {
if (p == p0 + 1) {
if (p == pend)
- goto invalid_pattern;
+ FREE_AND_RETURN(stackb, "invalid regular expression; empty character class");
}
else
/* Stop if this isn't merely a ] inside a bracket
@@ -1452,7 +1457,7 @@ re_compile_pattern(pattern, size, bufp)
/* Look ahead to see if it's a range when the last thing
was a character class. */
if (had_char_class && c == '-' && *p != ']')
- goto invalid_pattern;
+ FREE_AND_RETURN(stackb, "invalid regular expression; can't use character class as a start value of range");
if (ismbchar(c)) {
PATFETCH_MBC(c);
had_mbchar++;
@@ -1582,7 +1587,7 @@ re_compile_pattern(pattern, size, bufp)
/* If pattern is `[[:'. */
if (p == pend)
- goto invalid_pattern;
+ FREE_AND_RETURN(stackb, "invalid regular expression; re can't end '[[:'");
for (;;) {
PATFETCH (c);
@@ -1611,14 +1616,17 @@ re_compile_pattern(pattern, size, bufp)
char is_upper = STREQ(str, "upper");
char is_xdigit = STREQ(str, "xdigit");
- if (!IS_CHAR_CLASS(str))
- goto invalid_pattern;
+ if (!IS_CHAR_CLASS(str)){
+ snprintf(error_msg, ERROR_MSG_MAX_SIZE,
+ "invalid regular expression; [:%s:] is not a character class", str);
+ FREE_AND_RETURN(stackb, error_msg);
+ }
/* Throw away the ] at the end of the character class. */
PATFETCH(c);
if (p == pend)
- goto invalid_pattern;
+ FREE_AND_RETURN(stackb, "invalid regular expression; range doesn't have ending ']' after a character class");
for (ch = 0; ch < 1 << BYTEWIDTH; ch++) {
if ( (is_alnum && ISALNUM(ch))
@@ -1938,9 +1946,14 @@ re_compile_pattern(pattern, size, bufp)
case '{':
/* If there is no previous pattern, this is an invalid pattern. */
- if (!laststart || p == pend) {
- goto invalid_pattern;
+ if (!laststart) {
+ snprintf(error_msg, ERROR_MSG_MAX_SIZE,
+ "invalid regular expression; there's no previous pattern, to which '{' would define cardinality at %d",
+ p-pattern);
+ FREE_AND_RETURN(stackb, error_msg);
}
+ if( p == pend)
+ FREE_AND_RETURN(stackb, "invalid regular expression; '{' can't be last character" );
beg_interval = p - 1;
@@ -2119,7 +2132,8 @@ re_compile_pattern(pattern, size, bufp)
goto normal_char;
case '\\':
- if (p == pend) goto invalid_pattern;
+ if (p == pend)
+ FREE_AND_RETURN(stackb, "invalid regular expression; '\\' can't be last character");
/* Do not translate the character after the \, so that we can
distinguish, e.g., \B from \b, even if we normally would
translate, e.g., B to b. */
diff --git a/ruby.h b/ruby.h
index 09fb395ace..8f1fbf970d 100644
--- a/ruby.h
+++ b/ruby.h
@@ -136,7 +136,7 @@ VALUE rb_uint2inum _((unsigned long));
#define Qnil 4
#define Qundef 6 /* undefined value for placeholder */
-#define RTEST(v) ((VALUE)(v) & ~Qnil)
+#define RTEST(v) (((VALUE)(v) & ~Qnil) != 0)
#define NIL_P(v) ((VALUE)(v) == Qnil)
#define CLASS_OF(v) rb_class_of((VALUE)(v))