lemon: Add -- support to end options, use in our lemon
Patch lemon to stop parsing options upon encountering "--".
This prevents an issue in the unlikely situation where the
source directory or a source filename has a '=' in it, or
starts with a "-".
Redo 3716933046
but only
use the -- option in our lemon, not when using system lemon.
This commit is contained in:
parent
4fc1eadde2
commit
2b4f939761
|
@ -21,7 +21,7 @@ if(LEMON_EXECUTABLE)
|
|||
endmacro()
|
||||
add_custom_target(lemon)
|
||||
else()
|
||||
# Compile bundled lemon
|
||||
# Compile bundled lemon with support for -- to end options
|
||||
macro(generate_lemon_file _out _in)
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
|
@ -32,6 +32,7 @@ else()
|
|||
COMMAND $<TARGET_FILE:lemon>
|
||||
-T${CMAKE_SOURCE_DIR}/tools/lemon/lempar.c
|
||||
-d.
|
||||
--
|
||||
${_in}
|
||||
DEPENDS
|
||||
${_in}
|
||||
|
|
|
@ -2106,6 +2106,7 @@ int OptInit(char **a, struct s_options *o, FILE *err)
|
|||
if( g_argv && *g_argv && op ){
|
||||
int i;
|
||||
for(i=1; g_argv[i]; i++){
|
||||
if( strcmp(g_argv[i],"--")==0 ) break;
|
||||
if( g_argv[i][0]=='+' || g_argv[i][0]=='-' ){
|
||||
errcnt += handleflags(i,err);
|
||||
}else if( strchr(g_argv[i],'=') ){
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
Don't try to parse flags and options that are after "--". This makes it
|
||||
possible to prevent a filename path with an '=' in it from being processed
|
||||
as an option.
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
--- a/lemon.c
|
||||
+++ b/lemon.c
|
||||
@@ -2106,6 +2106,7 @@ int OptInit(char **a, struct s_options *o, FILE *err)
|
||||
if( g_argv && *g_argv && op ){
|
||||
int i;
|
||||
for(i=1; g_argv[i]; i++){
|
||||
+ if( strcmp(g_argv[i],"--")==0 ) break;
|
||||
if( g_argv[i][0]=='+' || g_argv[i][0]=='-' ){
|
||||
errcnt += handleflags(i,err);
|
||||
}else if( strchr(g_argv[i],'=') ){
|
Loading…
Reference in New Issue