summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c29
-rw-r--r--src/string.c15
2 files changed, 14 insertions, 30 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 03c752826..531cfcb11 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -1095,6 +1095,7 @@ readint_mrb_int(codegen_scope *s, const char *p, int base, mrb_bool neg, mrb_boo
mrb_int result = 0;
int n;
+ mrb_assert(base >= 2 && base <= 36);
if (*p == '+') p++;
while (p < e) {
char c = *p;
@@ -1108,23 +1109,21 @@ readint_mrb_int(codegen_scope *s, const char *p, int base, mrb_bool neg, mrb_boo
codegen_error(s, "malformed readint input");
}
- if(base > 0) {
- if (neg) {
- if ((MRB_INT_MIN + n)/base > result) {
- *overflow = TRUE;
- return 0;
- }
- result *= base;
- result -= n;
+ if (neg) {
+ if ((MRB_INT_MIN + n)/base > result) {
+ *overflow = TRUE;
+ return 0;
}
- else {
- if ((MRB_INT_MAX - n)/base < result) {
- *overflow = TRUE;
- return 0;
- }
- result *= base;
- result += n;
+ result *= base;
+ result -= n;
+ }
+ else {
+ if ((MRB_INT_MAX - n)/base < result) {
+ *overflow = TRUE;
+ return 0;
}
+ result *= base;
+ result += n;
}
p++;
}
diff --git a/src/string.c b/src/string.c
index 6570c89fb..a22060e37 100644
--- a/src/string.c
+++ b/src/string.c
@@ -361,21 +361,6 @@ str_make_shared(mrb_state *mrb, struct RString *s)
}
/*
- * call-seq:
- * char* str = String("abcd"), len=strlen("abcd")
- *
- * Returns a new string object containing a copy of <i>str</i>.
- */
-const char*
-mrb_str_body(mrb_value str, int *len_p)
-{
- struct RString *s = mrb_str_ptr(str);
-
- *len_p = RSTR_LEN(s);
- return RSTR_PTR(s);
-}
-
-/*
* call-seq: (Caution! String("abcd") change)
* String("abcdefg") = String("abcd") + String("efg")
*