summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--hash.c25
-rw-r--r--parse.y8
-rw-r--r--regex.c6
4 files changed, 36 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 979f764..ed72b57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed May 27 17:33:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_fetch): new method.
+
+ * regex.c (re_search): check whether translate table is set.
+
Tue May 26 11:39:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_23.
diff --git a/hash.c b/hash.c
index dd01aa1..59f157b 100644
--- a/hash.c
+++ b/hash.c
@@ -341,6 +341,29 @@ hash_aref(hash, key)
}
static VALUE
+hash_fetch(argc, argv, hash)
+ int argc;
+ VALUE *argv;
+ VALUE hash;
+{
+ VALUE key, if_none;
+ VALUE val;
+
+ rb_scan_args(argc, argv, "11", &key, &if_none);
+
+ if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
+ if (iterator_p()) {
+ if (argc > 1) {
+ ArgError("wrong # of arguments", argc);
+ }
+ return rb_yield(argv[0]);
+ }
+ return if_none;
+ }
+ return val;
+}
+
+static VALUE
hash_indexes(argc, argv, hash)
int argc;
VALUE *argv;
@@ -1159,7 +1182,9 @@ Init_Hash()
rb_define_method(cHash,"==", hash_equal, 1);
rb_define_method(cHash,"[]", hash_aref, 1);
+ rb_define_method(cHash,"fetch", hash_fetch, -1);
rb_define_method(cHash,"[]=", hash_aset, 2);
+ rb_define_method(cHash,"store", hash_aset, 2);
rb_define_method(cHash,"indexes", hash_indexes, -1);
rb_define_method(cHash,"indices", hash_indexes, -1);
rb_define_method(cHash,"length", hash_length, 0);
diff --git a/parse.y b/parse.y
index 0fcd991..1b4bbf2 100644
--- a/parse.y
+++ b/parse.y
@@ -1535,15 +1535,15 @@ static NODE *str_extend();
static VALUE lex_input; /* non-nil if File */
static VALUE lex_lastline; /* gc protect */
-static UCHAR *lex_pbeg;
-static UCHAR *lex_p;
-static UCHAR *lex_pend;
+static char *lex_pbeg;
+static char *lex_p;
+static char *lex_pend;
static int
yyerror(msg)
char *msg;
{
- UCHAR *p, *pe, *buf;
+ char *p, *pe, *buf;
int len, i;
void Error_Append();
diff --git a/regex.c b/regex.c
index a7a158e..071703c 100644
--- a/regex.c
+++ b/regex.c
@@ -1633,7 +1633,7 @@ re_compile_pattern(pattern, size, bufp)
|| *laststart == start_paren
|| (*laststart == exactn
&& (laststart[1] == 1
- || laststart[1] == 2 && ismbchar(laststart[2])))
+ || (laststart[1] == 2 && ismbchar(laststart[2]))))
|| *laststart == duplicate))
{
/* Posix extended syntax is handled in previous
@@ -1958,9 +1958,6 @@ re_compile_pattern(pattern, size, bufp)
bufp->must = calculate_must_string(bufp->buffer, b);
FREE_AND_RETURN(stackb, 0);
- invalid_char:
- FREE_AND_RETURN(stackb, "invalid character in regular expression");
-
invalid_pattern:
FREE_AND_RETURN(stackb, "invalid regular expression");
@@ -2502,7 +2499,6 @@ re_search(bufp, string, size, startpos, range, regs)
{
register char *fastmap = bufp->fastmap;
int val, anchor = 0;
- int options = bufp->options;
/* Check for out-of-range starting position. */
if (startpos < 0 || startpos > size)