diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-07-06 19:46:27 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-07-06 19:46:27 +0900 |
| commit | 4406a08d58f55f1d3d32c98a78bd7dc61a242c8d (patch) | |
| tree | 974a0c92db3a351ce1aaef4821ecfe43c3151062 /src/string.c | |
| parent | 5b3cc4a068ffab7973c819aafd054907f7e52349 (diff) | |
| download | mruby-4406a08d58f55f1d3d32c98a78bd7dc61a242c8d.tar.gz mruby-4406a08d58f55f1d3d32c98a78bd7dc61a242c8d.zip | |
remove debug printf; close #345
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/string.c b/src/string.c index 02f71ef96..b2cdc1212 100644 --- a/src/string.c +++ b/src/string.c @@ -2381,17 +2381,10 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck) #define BDIGIT unsigned int #define BDIGIT_DBL unsigned long -// const char *s = str; char *end; char sign = 1; -// char nondigit = 0; int c; -// BDIGIT_DBL num; long len; -// long blen = 1; -// long i; -// mrb_value z; -// BDIGIT *zds; unsigned long val; #undef ISDIGIT @@ -2508,21 +2501,22 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck) } len *= strlen(str)*sizeof(char); - val = strtoul((char*)str, &end, base); + val = strtoul((char*)str, &end, base); - if (badcheck) { - if (end == str) goto bad; /* no number */ - while (*end && ISSPACE(*end)) end++; - if (*end) goto bad; /* trailing garbage */ - } + if (badcheck) { + if (end == str) goto bad; /* no number */ + while (*end && ISSPACE(*end)) end++; + if (*end) goto bad; /* trailing garbage */ + } - if (sign) return mrb_fixnum_value(val); - else { - long result = -(long)val; - return mrb_fixnum_value(result); - } + if (sign) return mrb_fixnum_value(val); + else { + long result = -(long)val; + return mrb_fixnum_value(result); + } bad: - printf("Integer"); + mrb_raise(mrb, E_ARGUMENT_ERROR, "invalide string for number(%s)", str); + /* not reached */ return mrb_fixnum_value(0); } @@ -2631,8 +2625,8 @@ mrb_cstr_to_dbl(mrb_state *mrb, const char * p, int badcheck) if (p == end) { if (badcheck) { bad: - //mrb_invalid_str(q, "Float()"); - printf("Float()\n"); + mrb_raise(mrb, E_ARGUMENT_ERROR, "invalide string for float(%s)", p); + /* not reached */ } return d; } |
