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
9ea7b718
Unverified
Commit
9ea7b718
authored
Sep 25, 2020
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Sep 25, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5087 from dearblue/get-args-string
Prohibit string changes by "s"/"z" specifier of `mrb_get_args()`
parents
a97f085c
57611240
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
18 deletions
+23
-18
include/mruby.h
include/mruby.h
+2
-2
mrbgems/mruby-eval/src/eval.c
mrbgems/mruby-eval/src/eval.c
+5
-5
mrbgems/mruby-io/src/file.c
mrbgems/mruby-io/src/file.c
+2
-1
mrbgems/mruby-socket/src/socket.c
mrbgems/mruby-socket/src/socket.c
+4
-2
mrbgems/mruby-string-ext/src/string.c
mrbgems/mruby-string-ext/src/string.c
+6
-4
src/class.c
src/class.c
+4
-4
No files found.
include/mruby.h
View file @
9ea7b718
...
@@ -876,8 +876,8 @@ MRB_API struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *o
...
@@ -876,8 +876,8 @@ MRB_API struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *o
* | `S` | {String} | {mrb_value} | when `!` follows, the value may be `nil` |
* | `S` | {String} | {mrb_value} | when `!` follows, the value may be `nil` |
* | `A` | {Array} | {mrb_value} | when `!` follows, the value may be `nil` |
* | `A` | {Array} | {mrb_value} | when `!` follows, the value may be `nil` |
* | `H` | {Hash} | {mrb_value} | when `!` follows, the value may be `nil` |
* | `H` | {Hash} | {mrb_value} | when `!` follows, the value may be `nil` |
* | `s` | {String} | c
har *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil`
|
* | `s` | {String} | c
onst char *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil`
|
* | `z` | {String} | c
har * | `NULL` terminated string; `z!` gives `NULL` for `nil`
|
* | `z` | {String} | c
onst char * | `NULL` terminated string; `z!` gives `NULL` for `nil`
|
* | `a` | {Array} | {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
* | `a` | {Array} | {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
* | `f` | {Fixnum}/{Float} | {mrb_float} | |
* | `f` | {Fixnum}/{Float} | {mrb_float} | |
* | `i` | {Fixnum}/{Float} | {mrb_int} | |
* | `i` | {Fixnum}/{Float} | {mrb_int} | |
...
...
mrbgems/mruby-eval/src/eval.c
View file @
9ea7b718
...
@@ -12,7 +12,7 @@ mrb_value mrb_obj_instance_eval(mrb_state *mrb, mrb_value self);
...
@@ -12,7 +12,7 @@ mrb_value mrb_obj_instance_eval(mrb_state *mrb, mrb_value self);
void
mrb_codedump_all
(
mrb_state
*
,
struct
RProc
*
);
void
mrb_codedump_all
(
mrb_state
*
,
struct
RProc
*
);
static
struct
RProc
*
static
struct
RProc
*
create_proc_from_string
(
mrb_state
*
mrb
,
char
*
s
,
mrb_int
len
,
mrb_value
binding
,
const
char
*
file
,
mrb_int
line
)
create_proc_from_string
(
mrb_state
*
mrb
,
c
onst
c
har
*
s
,
mrb_int
len
,
mrb_value
binding
,
const
char
*
file
,
mrb_int
line
)
{
{
mrbc_context
*
cxt
;
mrbc_context
*
cxt
;
struct
mrb_parser_state
*
p
;
struct
mrb_parser_state
*
p
;
...
@@ -131,10 +131,10 @@ exec_irep(mrb_state *mrb, mrb_value self, struct RProc *proc)
...
@@ -131,10 +131,10 @@ exec_irep(mrb_state *mrb, mrb_value self, struct RProc *proc)
static
mrb_value
static
mrb_value
f_eval
(
mrb_state
*
mrb
,
mrb_value
self
)
f_eval
(
mrb_state
*
mrb
,
mrb_value
self
)
{
{
char
*
s
;
c
onst
c
har
*
s
;
mrb_int
len
;
mrb_int
len
;
mrb_value
binding
=
mrb_nil_value
();
mrb_value
binding
=
mrb_nil_value
();
char
*
file
=
NULL
;
c
onst
c
har
*
file
=
NULL
;
mrb_int
line
=
1
;
mrb_int
line
=
1
;
struct
RProc
*
proc
;
struct
RProc
*
proc
;
...
@@ -154,9 +154,9 @@ f_instance_eval(mrb_state *mrb, mrb_value self)
...
@@ -154,9 +154,9 @@ f_instance_eval(mrb_state *mrb, mrb_value self)
mrb_get_args
(
mrb
,
"*!&"
,
&
argv
,
&
argc
,
&
b
);
mrb_get_args
(
mrb
,
"*!&"
,
&
argv
,
&
argc
,
&
b
);
if
(
mrb_nil_p
(
b
))
{
if
(
mrb_nil_p
(
b
))
{
char
*
s
;
c
onst
c
har
*
s
;
mrb_int
len
;
mrb_int
len
;
char
*
file
=
NULL
;
c
onst
c
har
*
file
=
NULL
;
mrb_int
line
=
1
;
mrb_int
line
=
1
;
mrb_value
cv
;
mrb_value
cv
;
struct
RProc
*
proc
;
struct
RProc
*
proc
;
...
...
mrbgems/mruby-io/src/file.c
View file @
9ea7b718
...
@@ -557,7 +557,8 @@ mrb_file_s_readlink(mrb_state *mrb, mrb_value klass) {
...
@@ -557,7 +557,8 @@ mrb_file_s_readlink(mrb_state *mrb, mrb_value klass) {
mrb_raise
(
mrb
,
E_NOTIMP_ERROR
,
"readlink is not supported on this platform"
);
mrb_raise
(
mrb
,
E_NOTIMP_ERROR
,
"readlink is not supported on this platform"
);
return
mrb_nil_value
();
// unreachable
return
mrb_nil_value
();
// unreachable
#else
#else
char
*
path
,
*
buf
,
*
tmp
;
const
char
*
path
;
char
*
buf
,
*
tmp
;
size_t
bufsize
=
100
;
size_t
bufsize
=
100
;
ssize_t
rc
;
ssize_t
rc
;
mrb_value
ret
;
mrb_value
ret
;
...
...
mrbgems/mruby-socket/src/socket.c
View file @
9ea7b718
...
@@ -515,7 +515,8 @@ static mrb_value
...
@@ -515,7 +515,8 @@ static mrb_value
mrb_ipsocket_ntop
(
mrb_state
*
mrb
,
mrb_value
klass
)
mrb_ipsocket_ntop
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
{
mrb_int
af
,
n
;
mrb_int
af
,
n
;
char
*
addr
,
buf
[
50
];
const
char
*
addr
;
char
buf
[
50
];
mrb_get_args
(
mrb
,
"is"
,
&
af
,
&
addr
,
&
n
);
mrb_get_args
(
mrb
,
"is"
,
&
af
,
&
addr
,
&
n
);
if
((
af
==
AF_INET
&&
n
!=
4
)
||
(
af
==
AF_INET6
&&
n
!=
16
))
if
((
af
==
AF_INET
&&
n
!=
4
)
||
(
af
==
AF_INET6
&&
n
!=
16
))
...
@@ -529,7 +530,8 @@ static mrb_value
...
@@ -529,7 +530,8 @@ static mrb_value
mrb_ipsocket_pton
(
mrb_state
*
mrb
,
mrb_value
klass
)
mrb_ipsocket_pton
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
{
mrb_int
af
,
n
;
mrb_int
af
,
n
;
char
*
bp
,
buf
[
50
];
const
char
*
bp
;
char
buf
[
50
];
mrb_get_args
(
mrb
,
"is"
,
&
af
,
&
bp
,
&
n
);
mrb_get_args
(
mrb
,
"is"
,
&
af
,
&
bp
,
&
n
);
if
((
size_t
)
n
>
sizeof
(
buf
)
-
1
)
if
((
size_t
)
n
>
sizeof
(
buf
)
-
1
)
...
...
mrbgems/mruby-string-ext/src/string.c
View file @
9ea7b718
...
@@ -1072,7 +1072,8 @@ static mrb_value
...
@@ -1072,7 +1072,8 @@ static mrb_value
mrb_str_del_prefix_bang
(
mrb_state
*
mrb
,
mrb_value
self
)
mrb_str_del_prefix_bang
(
mrb_state
*
mrb
,
mrb_value
self
)
{
{
mrb_int
plen
,
slen
;
mrb_int
plen
,
slen
;
char
*
ptr
,
*
s
;
const
char
*
ptr
;
char
*
s
;
struct
RString
*
str
=
RSTRING
(
self
);
struct
RString
*
str
=
RSTRING
(
self
);
mrb_get_args
(
mrb
,
"s"
,
&
ptr
,
&
plen
);
mrb_get_args
(
mrb
,
"s"
,
&
ptr
,
&
plen
);
...
@@ -1105,7 +1106,7 @@ static mrb_value
...
@@ -1105,7 +1106,7 @@ static mrb_value
mrb_str_del_prefix
(
mrb_state
*
mrb
,
mrb_value
self
)
mrb_str_del_prefix
(
mrb_state
*
mrb
,
mrb_value
self
)
{
{
mrb_int
plen
,
slen
;
mrb_int
plen
,
slen
;
char
*
ptr
;
c
onst
c
har
*
ptr
;
mrb_get_args
(
mrb
,
"s"
,
&
ptr
,
&
plen
);
mrb_get_args
(
mrb
,
"s"
,
&
ptr
,
&
plen
);
slen
=
RSTRING_LEN
(
self
);
slen
=
RSTRING_LEN
(
self
);
...
@@ -1129,7 +1130,8 @@ static mrb_value
...
@@ -1129,7 +1130,8 @@ static mrb_value
mrb_str_del_suffix_bang
(
mrb_state
*
mrb
,
mrb_value
self
)
mrb_str_del_suffix_bang
(
mrb_state
*
mrb
,
mrb_value
self
)
{
{
mrb_int
plen
,
slen
;
mrb_int
plen
,
slen
;
char
*
ptr
,
*
s
;
const
char
*
ptr
;
char
*
s
;
struct
RString
*
str
=
RSTRING
(
self
);
struct
RString
*
str
=
RSTRING
(
self
);
mrb_get_args
(
mrb
,
"s"
,
&
ptr
,
&
plen
);
mrb_get_args
(
mrb
,
"s"
,
&
ptr
,
&
plen
);
...
@@ -1160,7 +1162,7 @@ static mrb_value
...
@@ -1160,7 +1162,7 @@ static mrb_value
mrb_str_del_suffix
(
mrb_state
*
mrb
,
mrb_value
self
)
mrb_str_del_suffix
(
mrb_state
*
mrb
,
mrb_value
self
)
{
{
mrb_int
plen
,
slen
;
mrb_int
plen
,
slen
;
char
*
ptr
;
c
onst
c
har
*
ptr
;
mrb_get_args
(
mrb
,
"s"
,
&
ptr
,
&
plen
);
mrb_get_args
(
mrb
,
"s"
,
&
ptr
,
&
plen
);
slen
=
RSTRING_LEN
(
self
);
slen
=
RSTRING_LEN
(
self
);
...
...
src/class.c
View file @
9ea7b718
...
@@ -584,8 +584,8 @@ void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self);
...
@@ -584,8 +584,8 @@ void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self);
S: String [mrb_value] when ! follows, the value may be nil
S: String [mrb_value] when ! follows, the value may be nil
A: Array [mrb_value] when ! follows, the value may be nil
A: Array [mrb_value] when ! follows, the value may be nil
H: Hash [mrb_value] when ! follows, the value may be nil
H: Hash [mrb_value] when ! follows, the value may be nil
s: String [c
har*,mrb_int]
Receive two arguments; s! gives (NULL,0) for nil
s: String [c
onst char*,mrb_int]
Receive two arguments; s! gives (NULL,0) for nil
z: String [c
har*]
NUL terminated string; z! gives NULL for nil
z: String [c
onst char*]
NUL terminated string; z! gives NULL for nil
a: Array [mrb_value*,mrb_int] Receive two arguments; a! gives (NULL,0) for nil
a: Array [mrb_value*,mrb_int] Receive two arguments; a! gives (NULL,0) for nil
c: Class/Module [strcut RClass*]
c: Class/Module [strcut RClass*]
f: Fixnum/Float [mrb_float]
f: Fixnum/Float [mrb_float]
...
@@ -772,10 +772,10 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -772,10 +772,10 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
case
's'
:
case
's'
:
{
{
mrb_value
ss
;
mrb_value
ss
;
char
**
ps
=
0
;
c
onst
c
har
**
ps
=
0
;
mrb_int
*
pl
=
0
;
mrb_int
*
pl
=
0
;
ps
=
va_arg
(
ap
,
char
**
);
ps
=
va_arg
(
ap
,
c
onst
c
har
**
);
pl
=
va_arg
(
ap
,
mrb_int
*
);
pl
=
va_arg
(
ap
,
mrb_int
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
ss
=
argv
[
i
++
];
ss
=
argv
[
i
++
];
...
...
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