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
9a21aa2d
Commit
9a21aa2d
authored
Dec 01, 2015
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preserve original string for error message
parent
ca417dac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
src/string.c
src/string.c
+23
-23
No files found.
src/string.c
View file @
9a21aa2d
...
...
@@ -2052,23 +2052,23 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
ISUPPER(c) ? ((c) - 'A' + 10) : \
-1)
if
(
!
str
)
{
if
(
!
p
)
{
if
(
badcheck
)
goto
bad
;
return
mrb_fixnum_value
(
0
);
}
while
(
str
<
pend
&&
ISSPACE
(
*
str
))
str
++
;
while
(
p
<
pend
&&
ISSPACE
(
*
p
))
p
++
;
if
(
str
[
0
]
==
'+'
)
{
str
++
;
if
(
p
[
0
]
==
'+'
)
{
p
++
;
}
else
if
(
str
[
0
]
==
'-'
)
{
str
++
;
else
if
(
p
[
0
]
==
'-'
)
{
p
++
;
sign
=
0
;
}
if
(
base
<=
0
)
{
if
(
str
[
0
]
==
'0'
)
{
switch
(
str
[
1
])
{
if
(
p
[
0
]
==
'0'
)
{
switch
(
p
[
1
])
{
case
'x'
:
case
'X'
:
base
=
16
;
break
;
...
...
@@ -2095,27 +2095,27 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
}
switch
(
base
)
{
case
2
:
if
(
str
[
0
]
==
'0'
&&
(
str
[
1
]
==
'b'
||
str
[
1
]
==
'B'
))
{
str
+=
2
;
if
(
p
[
0
]
==
'0'
&&
(
p
[
1
]
==
'b'
||
p
[
1
]
==
'B'
))
{
p
+=
2
;
}
break
;
case
3
:
break
;
case
8
:
if
(
str
[
0
]
==
'0'
&&
(
str
[
1
]
==
'o'
||
str
[
1
]
==
'O'
))
{
str
+=
2
;
if
(
p
[
0
]
==
'0'
&&
(
p
[
1
]
==
'o'
||
p
[
1
]
==
'O'
))
{
p
+=
2
;
}
case
4
:
case
5
:
case
6
:
case
7
:
break
;
case
10
:
if
(
str
[
0
]
==
'0'
&&
(
str
[
1
]
==
'd'
||
str
[
1
]
==
'D'
))
{
str
+=
2
;
if
(
p
[
0
]
==
'0'
&&
(
p
[
1
]
==
'd'
||
p
[
1
]
==
'D'
))
{
p
+=
2
;
}
case
9
:
case
11
:
case
12
:
case
13
:
case
14
:
case
15
:
break
;
case
16
:
if
(
str
[
0
]
==
'0'
&&
(
str
[
1
]
==
'x'
||
str
[
1
]
==
'X'
))
{
str
+=
2
;
if
(
p
[
0
]
==
'0'
&&
(
p
[
1
]
==
'x'
||
p
[
1
]
==
'X'
))
{
p
+=
2
;
}
break
;
default:
...
...
@@ -2124,18 +2124,18 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
}
break
;
}
/* end of switch (base) { */
if
(
*
str
==
'0'
)
{
/* squeeze preceding 0s */
while
(
str
<
pend
&&
((
c
=
*++
str
)
==
'0'
||
c
==
'_'
))
{
if
(
*
p
==
'0'
)
{
/* squeeze preceding 0s */
while
(
p
<
pend
&&
((
c
=
*++
p
)
==
'0'
||
c
==
'_'
))
{
if
(
c
==
'_'
)
{
if
(
*
str
==
'_'
)
{
if
(
*
p
==
'_'
)
{
if
(
badcheck
)
goto
bad
;
break
;
}
}
}
if
(
!
(
c
=
*
str
)
||
ISSPACE
(
c
))
--
str
;
if
(
!
(
c
=
*
p
)
||
ISSPACE
(
c
))
--
p
;
}
c
=
*
str
;
c
=
*
p
;
if
(
badcheck
&&
c
==
'\0'
)
{
goto
nullbyte
;
}
...
...
@@ -2145,7 +2145,7 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
return
mrb_fixnum_value
(
0
);
}
for
(
p
=
str
;
p
<
pend
;
p
++
)
{
for
(
;
p
<
pend
;
p
++
)
{
if
(
*
p
==
'_'
)
{
if
(
p
[
1
]
==
'_'
)
{
if
(
badcheck
)
goto
bad
;
...
...
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