summaryrefslogtreecommitdiffhomepage
path: root/src/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse.y')
-rw-r--r--src/parse.y22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/parse.y b/src/parse.y
index 5c49db07e..90e38e0be 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -882,7 +882,7 @@ heredoc_start_sym(parser_state *p, node *beg, mrb_sym sym, enum heredoc_type typ
{
char *bs = (char*)beg->cdr->car;
int allow_indent = (bs[2] == '-');
- int len;
+ size_t len;
const char *s = mrb_sym2name_len(p->mrb, sym, &len);
return heredoc_start_sb(p, s, len, type, allow_indent);
}
@@ -3393,34 +3393,38 @@ toklen(parser_state *p)
#define IS_LABEL_POSSIBLE() ((p->lstate == EXPR_BEG && !cmd_state) || IS_ARG())
#define IS_LABEL_SUFFIX(n) (peek_n(p, ':',(n)) && !peek_n(p, ':', (n)+1))
-static unsigned long
+static int
scan_oct(const int *start, int len, int *retlen)
{
const int *s = start;
- unsigned long retval = 0;
+ int retval = 0;
+ /* assert(len <= 3) */
while (len-- && *s >= '0' && *s <= '7') {
retval <<= 3;
retval |= *s++ - '0';
}
*retlen = s - start;
+
return retval;
}
-static unsigned long
+static int
scan_hex(const int *start, int len, int *retlen)
{
static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
register const int *s = start;
- register unsigned long retval = 0;
+ register int retval = 0;
char *tmp;
- while (len-- && *s && (tmp = (char *)strchr(hexdigit, *s))) {
+ /* assert(len <= 2) */
+ while (len-- && *s && (tmp = strchr(hexdigit, *s))) {
retval <<= 4;
retval |= (tmp - hexdigit) & 15;
s++;
}
*retlen = s - start;
+
return retval;
}
@@ -5153,13 +5157,13 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
n = snprintf(buf, sizeof(buf), "line %d: %s\n",
p->error_buffer[0].lineno, p->error_buffer[0].message);
- mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, n));
+ mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, n));
mrb_parser_free(p);
return mrb_undef_value();
}
else {
static const char msg[] = "syntax error";
- mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SYNTAX_ERROR, msg, sizeof(msg) - 1));
+ mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SYNTAX_ERROR, msg, sizeof(msg) - 1));
mrb_parser_free(p);
return mrb_undef_value();
}
@@ -5168,7 +5172,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
mrb_parser_free(p);
if (n < 0) {
static const char msg[] = "codegen error";
- mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
+ mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
return mrb_nil_value();
}
if (c) {