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
17ec8852
Unverified
Commit
17ec8852
authored
Nov 27, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Nov 27, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4843 from shuujii/support-end-of-options-to-mruby-command
Support `--` (end of options) to `mruby` command
parents
190649e5
f4b528e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
mrbgems/mruby-bin-mruby/bintest/mruby.rb
mrbgems/mruby-bin-mruby/bintest/mruby.rb
+4
-0
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
+13
-0
No files found.
mrbgems/mruby-bin-mruby/bintest/mruby.rb
View file @
17ec8852
...
...
@@ -128,6 +128,10 @@ assert('mruby -r option (file not found)') do
assert_mruby
(
""
,
/\A.*: Cannot open library file: .*\n\z/
,
false
,
%w[-r _no_exists_]
)
end
assert
(
'mruby --'
)
do
assert_mruby
(
%{["-x", "1"]\n}
,
""
,
true
,
%w[-e p(ARGV) -- -x 1]
)
end
assert
(
'mruby invalid short option'
)
do
assert_mruby
(
""
,
/\A.*: invalid option -1 .*\n\z/
,
false
,
%w[-1]
)
end
...
...
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
View file @
17ec8852
...
...
@@ -64,21 +64,33 @@ options_init(struct options *opts, int argc, char **argv)
static
const
char
*
options_opt
(
struct
options
*
opts
)
{
/* concatenated short options (e.g. `-cv`) */
if
(
*
opts
->
short_opt
&&
*++
opts
->
opt
)
{
short_opt:
opts
->
short_opt
[
0
]
=
*
opts
->
opt
;
opts
->
short_opt
[
1
]
=
0
;
return
opts
->
short_opt
;
}
while
(
++
opts
->
argv
,
--
opts
->
argc
)
{
opts
->
opt
=
*
opts
->
argv
;
/* empty || not start with `-` || `-` */
if
(
!
opts
->
opt
[
0
]
||
opts
->
opt
[
0
]
!=
'-'
||
!
opts
->
opt
[
1
])
return
NULL
;
if
(
opts
->
opt
[
1
]
==
'-'
)
{
/* `--` */
if
(
!
opts
->
opt
[
2
])
{
++
opts
->
argv
,
--
opts
->
argc
;
return
NULL
;
}
/* long option */
opts
->
opt
+=
2
;
*
opts
->
short_opt
=
0
;
return
opts
->
opt
;
}
else
{
/* short option */
++
opts
->
opt
;
goto
short_opt
;
}
...
...
@@ -90,6 +102,7 @@ static const char *
options_arg
(
struct
options
*
opts
)
{
if
(
*
opts
->
short_opt
&&
opts
->
opt
[
1
])
{
/* concatenated short option and option argument (e.g. `-rLIBRARY`) */
*
opts
->
short_opt
=
0
;
return
opts
->
opt
+
1
;
}
...
...
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