Bug fix: -backslash_codes "with_program_arguments" was interpreted too late
This commit is contained in:
parent
e5fe7c117d
commit
4cae30b6fe
@ -2086,6 +2086,26 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
/* @return 1=replaced , 2=not replaced , <=0 = error
|
||||
*/
|
||||
int Xorriso_replace_arg_by_bsl(struct XorrisO *xorriso, char **arg,
|
||||
char **argpt, int flag)
|
||||
{
|
||||
int ret, eaten, l;
|
||||
|
||||
if(!(xorriso->bsl_interpretation & 16))
|
||||
return(2);
|
||||
l= strlen(*argpt);
|
||||
Xorriso_free_meM(*arg);
|
||||
Xorriso_alloc_meM(*arg, char, l + 1);
|
||||
strcpy(*arg, *argpt);
|
||||
*argpt= *arg;
|
||||
ret= Sfile_bsl_interpreter(*arg, l, &eaten, 0);
|
||||
ex:;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int flag)
|
||||
/*
|
||||
@ -2100,14 +2120,16 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
*/
|
||||
{
|
||||
int i, ret, was_dashed, num2, arg_count;
|
||||
int advice, mem_add_plainly, error_seen= 0;
|
||||
int advice, mem_add_plainly, error_seen= 0, mem_bsl;
|
||||
int was_report_about= 0, was_abort_on= 0, was_return_with= 0;
|
||||
int was_signal_handling= 0, was_scsi_log= 0, cmd_data_size= 5 * SfileadrL;
|
||||
char *cmd, *original_cmd, *cmd_data= NULL, *arg1, *arg2;
|
||||
char *arg1_data= NULL, *arg2_data= NULL;
|
||||
char mem_list_delimiter[81];
|
||||
|
||||
strcpy(mem_list_delimiter, xorriso->list_delimiter);
|
||||
mem_add_plainly= xorriso->add_plainly;
|
||||
mem_bsl= xorriso->bsl_interpretation;
|
||||
|
||||
Xorriso_alloc_meM(cmd_data, char, cmd_data_size);
|
||||
|
||||
@ -2121,11 +2143,19 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
arg1= "";
|
||||
if(i+1<argc)
|
||||
arg1= argv[i+1];
|
||||
if(i + 1 < argc) {
|
||||
arg1= argv[i + 1];
|
||||
ret= Xorriso_replace_arg_by_bsl(xorriso, &arg1_data, &arg1, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
}
|
||||
arg2= "";
|
||||
if(i+2<argc)
|
||||
arg2= argv[i+2];
|
||||
if(i + 2 < argc) {
|
||||
arg2= argv[i + 2];
|
||||
ret= Xorriso_replace_arg_by_bsl(xorriso, &arg2_data, &arg2, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
}
|
||||
if(i>1)
|
||||
xorriso->did_something_useful= 1;
|
||||
if(i==1 && argc==2) {
|
||||
@ -2255,6 +2285,12 @@ protect_stdout:;
|
||||
} else if(strcmp(original_cmd, "-x") == 0) {
|
||||
xorriso->arrange_args= 1;
|
||||
|
||||
} else if(strcmp(cmd, "backslash_codes") == 0) {
|
||||
i++;
|
||||
ret= Xorriso_option_backslash_codes(xorriso, arg1, 0);
|
||||
if(ret <= 0)
|
||||
error_seen= 1;
|
||||
|
||||
} else {
|
||||
ret= Xorriso_count_args(xorriso, argc - i, argv + i, &arg_count, 1);
|
||||
if(ret == 1) {
|
||||
@ -2272,6 +2308,9 @@ protect_stdout:;
|
||||
ex:;
|
||||
strcpy(xorriso->list_delimiter, mem_list_delimiter);
|
||||
xorriso->add_plainly= mem_add_plainly;
|
||||
xorriso->bsl_interpretation= mem_bsl;
|
||||
Xorriso_free_meM(arg1_data);
|
||||
Xorriso_free_meM(arg2_data);
|
||||
Xorriso_free_meM(cmd_data);
|
||||
if(error_seen && ret > 0) {
|
||||
advice= Xorriso_eval_problem_status(xorriso, 0, 0);
|
||||
@ -2472,11 +2511,74 @@ int Xorriso_make_return_value(struct XorrisO *xorriso, int flag)
|
||||
int Xorriso_program_arg_bsl(struct XorrisO *xorriso, int argc, char ***argv,
|
||||
int flag)
|
||||
{
|
||||
int ret;
|
||||
int i, ret, eaten, bsl_mem, params_to_come= 0, cmd_data_size= 5 * SfileadrL;
|
||||
int next_is_backslash_codes= 0, next_is_list_delimiter= 0;
|
||||
char **new_argv= NULL, *cmd, *cmd_data= NULL;
|
||||
char mem_list_delimiter[81];
|
||||
|
||||
if(!(xorriso->bsl_interpretation & 16))
|
||||
return(1);
|
||||
ret= Sfile_argv_bsl(argc, argv, 0);
|
||||
strcpy(mem_list_delimiter, xorriso->list_delimiter);
|
||||
bsl_mem= xorriso->bsl_interpretation;
|
||||
if(argc <= 0)
|
||||
return(0);
|
||||
Xorriso_alloc_meM(cmd_data, char, cmd_data_size);
|
||||
new_argv= (char **) Smem_malloC(argc * sizeof(char *));
|
||||
if(new_argv == NULL)
|
||||
return(-1);
|
||||
for(i= 0; i < argc; i++) {
|
||||
new_argv[i]= strdup((*argv)[i]);
|
||||
if(new_argv[i] == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
if(i == 0)
|
||||
continue;
|
||||
if(xorriso->bsl_interpretation & 16) {
|
||||
ret= Sfile_bsl_interpreter(new_argv[i], strlen(new_argv[i]), &eaten, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
}
|
||||
if(params_to_come == 0) {
|
||||
ret= Xorriso_normalize_command(xorriso, new_argv[i], i,
|
||||
cmd_data, cmd_data_size, &cmd, 0);
|
||||
if(ret < 0)
|
||||
goto ex;
|
||||
if(strcmp(cmd, "backslash_codes") == 0) {
|
||||
params_to_come= 1;
|
||||
next_is_backslash_codes= 1;
|
||||
} else if(strcmp(cmd, "list_delimiter") == 0) {
|
||||
params_to_come= 1;
|
||||
next_is_list_delimiter= 1;
|
||||
} else {
|
||||
ret= Xorriso_count_args(xorriso, argc - i, *argv + i,
|
||||
¶ms_to_come, 1);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
if(ret != 1)
|
||||
params_to_come= 0;
|
||||
}
|
||||
} else {
|
||||
params_to_come--;
|
||||
if(next_is_backslash_codes) {
|
||||
next_is_backslash_codes= 0;
|
||||
ret= Xorriso_option_backslash_codes(xorriso, new_argv[i], 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
} else if(next_is_list_delimiter) {
|
||||
next_is_list_delimiter= 0;
|
||||
ret= Xorriso_option_list_delimiter(xorriso, new_argv[i], 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret= 1;
|
||||
ex:;
|
||||
Xorriso_free_meM(cmd_data);
|
||||
strcpy(xorriso->list_delimiter, mem_list_delimiter);
|
||||
xorriso->bsl_interpretation= bsl_mem;
|
||||
if(ret <= 0) {
|
||||
if(new_argv != NULL)
|
||||
free((char *) new_argv);
|
||||
} else
|
||||
*argv= new_argv;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
@ -519,35 +519,6 @@ not_a_code:;
|
||||
}
|
||||
|
||||
|
||||
int Sfile_argv_bsl(int argc, char ***argv, int flag)
|
||||
{
|
||||
int i, ret, eaten;
|
||||
char **new_argv= NULL;
|
||||
|
||||
if(argc <= 0)
|
||||
return(0);
|
||||
new_argv= (char **) Smem_malloC(argc * sizeof(char *));
|
||||
if(new_argv == NULL)
|
||||
return(-1);
|
||||
for(i= 0; i < argc; i++) {
|
||||
new_argv[i]= strdup((*argv)[i]);
|
||||
if(new_argv[i] == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
ret= Sfile_bsl_interpreter(new_argv[i], strlen(new_argv[i]), &eaten, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
}
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(ret <= 0) {
|
||||
if(new_argv != NULL)
|
||||
free((char *) new_argv);
|
||||
} else
|
||||
*argv= new_argv;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= only encode inside quotes
|
||||
bit1= encode < 32 outside quotes except 7, 8, 9, 10, 12, 13
|
||||
bit2= encode in any case above 126
|
||||
|
@ -9,7 +9,7 @@
|
||||
.\" First parameter, NAME, should be all caps
|
||||
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||
.\" other parameters are allowed: see man(7), man(1)
|
||||
.TH XORRISO 1 "Version 1.3.1, Mai 17, 2013"
|
||||
.TH XORRISO 1 "Version 1.3.1, Mai 29, 2013"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
@ -4433,7 +4433,7 @@ Translations can occur with quoted input in 3 modes:
|
||||
.br
|
||||
With the start program arguments there is mode:
|
||||
.br
|
||||
"with_program_arguments" translates all program arguments.
|
||||
"with_program_arguments" translates program arguments.
|
||||
.br
|
||||
.br
|
||||
Mode "encode_output" encodes output characters. It combines "encode_results"
|
||||
|
@ -241,7 +241,7 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag);
|
||||
/* This special interpreter may be called between Xorriso_new() and
|
||||
Xorriso_startup_libraries(). It interprets certain commands which shall
|
||||
get into effect before the libraries get initialized:
|
||||
-abort_on , -report_about , -return_with , -list_delimiter ,
|
||||
-abort_on , -report_about , -return_with ,
|
||||
-scsi_log , -signal_handling
|
||||
This is the only occasion where command -x has an effect:
|
||||
-x
|
||||
@ -251,9 +251,10 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag);
|
||||
-no_rc
|
||||
Some get examined for the need to redirect stdout messages:
|
||||
-dev , -outdev , -indev , -as
|
||||
Commands -list_delimiter and -add_plainly get into effect during this
|
||||
call. But their setting at begin of the call gets restored before the
|
||||
call returns.
|
||||
Commands
|
||||
-backslash_codes , -list_delimiter , -add_plainly
|
||||
get into effect during this call. But their setting at begin of the call
|
||||
gets restored before the call returns.
|
||||
@param xorriso The context object in which to perform the commands.
|
||||
@param argc Number of arguments.
|
||||
@param argv The arguments. argv[0] contains the program name.
|
||||
@ -288,6 +289,17 @@ int Xorriso_read_rc(struct XorrisO *xorriso, int flag);
|
||||
replace *argv by a new argument vector. The old one will not be freed
|
||||
by this call. If it is dynamic memory then you need to keep a copy of
|
||||
the pointer and free it yourself after this call.
|
||||
|
||||
@since 1.3.2:
|
||||
This call internally interprets the commands -backslash_codes and
|
||||
-list_delimiter if it encounters them among the arguments. The
|
||||
decoding of backslashes can thus be enabled and disabled by the
|
||||
arguments themselves. The state of the xorriso object in respect
|
||||
to these commands gets preserved at the start of the call and restored
|
||||
when the call ends.
|
||||
(*argv)[0] never gets decoded.
|
||||
The old *argv will always be replaced by a new one.
|
||||
|
||||
@param xorriso The context object
|
||||
@param argc Number of arguments.
|
||||
@param argv The arguments. (*argv)[0] contains the program name.
|
||||
|
@ -3882,7 +3882,7 @@ File: xorriso.info, Node: Scripting, Next: Frontend, Prev: Emulation, Up: Co
|
||||
"in_quotes" translates inside " and ' quotation.
|
||||
"with_quoted_input" translates inside and outside quotes.
|
||||
With the start program arguments there is mode:
|
||||
"with_program_arguments" translates all program arguments.
|
||||
"with_program_arguments" translates program arguments.
|
||||
Mode "encode_output" encodes output characters. It combines
|
||||
"encode_results" with "encode_infos". Inside single or double
|
||||
quotation marks encoding applies to 8-bit characters octal 001 to
|
||||
@ -5269,29 +5269,29 @@ Node: Verify169213
|
||||
Node: Restore178245
|
||||
Node: Emulation185332
|
||||
Node: Scripting195456
|
||||
Node: Frontend202617
|
||||
Node: Examples210692
|
||||
Node: ExDevices211870
|
||||
Node: ExCreate212529
|
||||
Node: ExDialog213814
|
||||
Node: ExGrowing215079
|
||||
Node: ExModifying215884
|
||||
Node: ExBootable216388
|
||||
Node: ExCharset216940
|
||||
Node: ExPseudo217761
|
||||
Node: ExCdrecord218659
|
||||
Node: ExMkisofs218976
|
||||
Node: ExGrowisofs220316
|
||||
Node: ExException221451
|
||||
Node: ExTime221905
|
||||
Node: ExIncBackup222364
|
||||
Node: ExRestore226344
|
||||
Node: ExRecovery227277
|
||||
Node: Files227847
|
||||
Node: Seealso229146
|
||||
Node: Bugreport229869
|
||||
Node: Legal230450
|
||||
Node: CommandIdx231461
|
||||
Node: ConceptIdx247763
|
||||
Node: Frontend202613
|
||||
Node: Examples210688
|
||||
Node: ExDevices211866
|
||||
Node: ExCreate212525
|
||||
Node: ExDialog213810
|
||||
Node: ExGrowing215075
|
||||
Node: ExModifying215880
|
||||
Node: ExBootable216384
|
||||
Node: ExCharset216936
|
||||
Node: ExPseudo217757
|
||||
Node: ExCdrecord218655
|
||||
Node: ExMkisofs218972
|
||||
Node: ExGrowisofs220312
|
||||
Node: ExException221447
|
||||
Node: ExTime221901
|
||||
Node: ExIncBackup222360
|
||||
Node: ExRestore226340
|
||||
Node: ExRecovery227273
|
||||
Node: Files227843
|
||||
Node: Seealso229142
|
||||
Node: Bugreport229865
|
||||
Node: Legal230446
|
||||
Node: CommandIdx231457
|
||||
Node: ConceptIdx247759
|
||||
|
||||
End Tag Table
|
||||
|
@ -50,7 +50,7 @@
|
||||
@c man .\" First parameter, NAME, should be all caps
|
||||
@c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||
@c man .\" other parameters are allowed: see man(7), man(1)
|
||||
@c man .TH XORRISO 1 "Version 1.3.1, Mai 17, 2013"
|
||||
@c man .TH XORRISO 1 "Version 1.3.1, Mai 29, 2013"
|
||||
@c man .\" Please adjust this date whenever revising the manpage.
|
||||
@c man .\"
|
||||
@c man .\" Some roff macros, for reference:
|
||||
@ -5183,7 +5183,7 @@ Translations can occur with quoted input in 3 modes:
|
||||
@*
|
||||
With the start program arguments there is mode:
|
||||
@*
|
||||
"with_program_arguments" translates all program arguments.
|
||||
"with_program_arguments" translates program arguments.
|
||||
@*
|
||||
@*
|
||||
Mode "encode_output" encodes output characters. It combines "encode_results"
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2013.05.28.175212"
|
||||
#define Xorriso_timestamP "2013.05.30.192537"
|
||||
|
Loading…
Reference in New Issue
Block a user