summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/class.c2
-rw-r--r--src/hash.c11
-rw-r--r--src/parse.y12
3 files changed, 10 insertions, 15 deletions
diff --git a/src/class.c b/src/class.c
index f94f9a933..6eb70dce6 100644
--- a/src/class.c
+++ b/src/class.c
@@ -487,7 +487,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
if (i < argc) {
ss = to_str(mrb, *sp++);
s = mrb_str_ptr(ss);
- if (strlen(s->ptr) != s->len) {
+ if (strlen(s->ptr) < s->len) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "String contains NUL");
}
*ps = s->ptr;
diff --git a/src/hash.c b/src/hash.c
index e08de0cfe..3684b3b40 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -776,16 +776,9 @@ mrb_value
mrb_hash_empty_p(mrb_state *mrb, mrb_value self)
{
khash_t(ht) *h = RHASH_TBL(self);
- mrb_bool empty_p;
- if (h) {
- empty_p = (kh_size(h) == 0);
- }
- else {
- empty_p = 1;
- }
-
- return mrb_bool_value(empty_p);
+ if (h) return mrb_bool_value(kh_size(h) == 0);
+ return mrb_true_value();
}
static mrb_value
diff --git a/src/parse.y b/src/parse.y
index 1d5366d17..fda66e92c 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -3620,12 +3620,14 @@ parse_string(parser_state *p)
tokadd(p, '\n');
}
else {
- pushback(p, c);
-
- if(type & STR_FUNC_REGEXP)
+ if (type & STR_FUNC_REGEXP) {
tokadd(p, '\\');
-
- tokadd(p, read_escape(p));
+ if (c != -1)
+ tokadd(p, c);
+ } else {
+ pushback(p, c);
+ tokadd(p, read_escape(p));
+ }
if (hinf)
hinf->line_head = FALSE;
}