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
4ece1e3e
Commit
4ece1e3e
authored
Aug 11, 2014
by
mattn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"-a-a-".succ should be "-a-b-"
parent
3103d063
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
mrbgems/mruby-string-ext/src/string.c
mrbgems/mruby-string-ext/src/string.c
+15
-13
mrbgems/mruby-string-ext/test/string.rb
mrbgems/mruby-string-ext/test/string.rb
+3
-0
No files found.
mrbgems/mruby-string-ext/src/string.c
View file @
4ece1e3e
...
...
@@ -266,25 +266,27 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self)
t
=
e
=
p
+
l
;
*
(
e
--
)
=
0
;
while
(
b
<
e
)
{
if
(
ISALNUM
(
*
b
))
break
;
b
++
;
}
if
(
b
>
e
)
{
b
=
p
;
result
=
mrb_str_new_lit
(
mrb
,
""
);
}
else
result
=
mrb_str_new
(
mrb
,
(
char
*
)
p
,
b
-
p
);
// find trailing ascii/number
while
(
e
>=
b
)
{
if
(
ISALNUM
(
*
e
))
break
;
e
--
;
}
if
(
e
<
b
)
if
(
e
<
b
)
{
e
=
p
+
l
-
1
;
result
=
mrb_str_new_lit
(
mrb
,
""
);
}
else
{
// find leading letter of the ascii/number
b
=
e
;
while
(
b
>
p
)
{
if
(
!
ISALNUM
(
*
b
)
||
(
ISALNUM
(
*
b
)
&&
*
b
!=
'9'
&&
*
b
!=
'z'
&&
*
b
!=
'Z'
))
break
;
b
--
;
}
if
(
!
ISALNUM
(
*
b
))
b
++
;
result
=
mrb_str_new
(
mrb
,
(
char
*
)
p
,
b
-
p
);
}
while
(
e
>=
b
)
{
if
(
!
ISALNUM
(
*
e
))
{
...
...
mrbgems/mruby-string-ext/test/string.rb
View file @
4ece1e3e
...
...
@@ -285,6 +285,7 @@ assert('String#succ') do
assert_equal
"
\x01\x00
"
,
"
\xff
"
.
succ
assert_equal
"-b"
,
"-a"
.
succ
assert_equal
"-aa"
,
"-z"
.
succ
assert_equal
"-a-b-"
,
"-a-a-"
.
succ
assert_equal
"-b-"
,
"-a-"
.
succ
assert_equal
"-aa-"
,
"-z-"
.
succ
assert_equal
"あb"
,
"あa"
.
succ
...
...
@@ -351,6 +352,8 @@ assert('String#succ') do
assert_equal
"-b"
,
a
a
=
"-z"
;
a
.
succ!
assert_equal
"-aa"
,
a
a
=
"-a-a-"
;
a
.
succ!
assert_equal
"-a-b-"
,
a
a
=
"-a-"
;
a
.
succ!
assert_equal
"-b-"
,
a
a
=
"-z-"
;
a
.
succ!
...
...
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