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
380805ec
Commit
380805ec
authored
Jul 14, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep `MRB_STR_ASCII` flag in some methods of `String`
parent
a7be9f1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
include/mruby/string.h
include/mruby/string.h
+8
-1
src/string.c
src/string.c
+7
-8
No files found.
include/mruby/string.h
View file @
380805ec
...
...
@@ -107,7 +107,6 @@ MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
#define MRB_STR_EMBED_LEN_SHIFT 6
void
mrb_gc_free_str
(
mrb_state
*
,
struct
RString
*
);
MRB_API
void
mrb_str_modify
(
mrb_state
*
,
struct
RString
*
);
/*
* Finds the index of a substring in a string
...
...
@@ -454,6 +453,14 @@ mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str);
mrb_bool
mrb_str_beg_len
(
mrb_int
str_len
,
mrb_int
*
begp
,
mrb_int
*
lenp
);
mrb_value
mrb_str_byte_subseq
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
beg
,
mrb_int
len
);
void
mrb_str_modify_keep_ascii
(
mrb_state
*
mrb
,
struct
RString
*
s
);
MRB_INLINE
void
mrb_str_modify
(
mrb_state
*
mrb
,
struct
RString
*
s
)
{
mrb_str_modify_keep_ascii
(
mrb
,
s
);
RSTR_UNSET_ASCII_FLAG
(
s
);
}
#ifdef MRB_UTF8_STRING
mrb_int
mrb_utf8_len
(
const
char
*
str
,
mrb_int
byte_len
);
...
...
src/string.c
View file @
380805ec
...
...
@@ -706,11 +706,10 @@ mrb_locale_from_utf8(const char *utf8, int len)
}
#endif
MRB_API
void
mrb_str_modify
(
mrb_state
*
mrb
,
struct
RString
*
s
)
void
mrb_str_modify
_keep_ascii
(
mrb_state
*
mrb
,
struct
RString
*
s
)
{
mrb_check_frozen
(
mrb
,
s
);
RSTR_UNSET_ASCII_FLAG
(
s
);
if
(
RSTR_SHARED_P
(
s
))
{
mrb_shared_string
*
shared
=
s
->
as
.
heap
.
aux
.
shared
;
...
...
@@ -1339,7 +1338,7 @@ mrb_str_capitalize_bang(mrb_state *mrb, mrb_value str)
mrb_bool
modify
=
FALSE
;
struct
RString
*
s
=
mrb_str_ptr
(
str
);
mrb_str_modify
(
mrb
,
s
);
mrb_str_modify
_keep_ascii
(
mrb
,
s
);
if
(
RSTR_LEN
(
s
)
==
0
||
!
RSTR_PTR
(
s
))
return
mrb_nil_value
();
p
=
RSTR_PTR
(
s
);
pend
=
RSTR_PTR
(
s
)
+
RSTR_LEN
(
s
);
if
(
ISLOWER
(
*
p
))
{
...
...
@@ -1398,7 +1397,7 @@ mrb_str_chomp_bang(mrb_state *mrb, mrb_value str)
struct
RString
*
s
=
mrb_str_ptr
(
str
);
argc
=
mrb_get_args
(
mrb
,
"|S"
,
&
rs
);
mrb_str_modify
(
mrb
,
s
);
mrb_str_modify
_keep_ascii
(
mrb
,
s
);
len
=
RSTR_LEN
(
s
);
if
(
argc
==
0
)
{
if
(
len
==
0
)
return
mrb_nil_value
();
...
...
@@ -1497,7 +1496,7 @@ mrb_str_chop_bang(mrb_state *mrb, mrb_value str)
{
struct
RString
*
s
=
mrb_str_ptr
(
str
);
mrb_str_modify
(
mrb
,
s
);
mrb_str_modify
_keep_ascii
(
mrb
,
s
);
if
(
RSTR_LEN
(
s
)
>
0
)
{
mrb_int
len
;
#ifdef MRB_UTF8_STRING
...
...
@@ -1566,7 +1565,7 @@ mrb_str_downcase_bang(mrb_state *mrb, mrb_value str)
mrb_bool
modify
=
FALSE
;
struct
RString
*
s
=
mrb_str_ptr
(
str
);
mrb_str_modify
(
mrb
,
s
);
mrb_str_modify
_keep_ascii
(
mrb
,
s
);
p
=
RSTR_PTR
(
s
);
pend
=
RSTR_PTR
(
s
)
+
RSTR_LEN
(
s
);
while
(
p
<
pend
)
{
...
...
@@ -2536,7 +2535,7 @@ mrb_str_upcase_bang(mrb_state *mrb, mrb_value str)
char
*
p
,
*
pend
;
mrb_bool
modify
=
FALSE
;
mrb_str_modify
(
mrb
,
s
);
mrb_str_modify
_keep_ascii
(
mrb
,
s
);
p
=
RSTRING_PTR
(
str
);
pend
=
RSTRING_END
(
str
);
while
(
p
<
pend
)
{
...
...
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