Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
4406a08d
Commit
4406a08d
authored
Jul 06, 2012
by
Yukihiro Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove debug printf; close #345
parent
5b3cc4a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
21 deletions
+15
-21
src/string.c
src/string.c
+15
-21
No files found.
src/string.c
View file @
4406a08d
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment