Eat up leading dashes with command options, convert inner dashes to underscores
This commit is contained in:
parent
be78c03e66
commit
28e8709660
@ -399,6 +399,9 @@ All command words are shown with a leading dash although this dash is not
|
||||
mandatory for the option to be recognized. There may be future emulation
|
||||
modes, where dashes may become mandatory in order to distinguish options
|
||||
from file addresses.
|
||||
.br
|
||||
Normally any number of leading dashes is ignored with command words and
|
||||
inner dashes are interpreted as underscores.
|
||||
.TP
|
||||
.B Aquiring source and target drive:
|
||||
.TP
|
||||
|
@ -9040,7 +9040,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
"",
|
||||
" -list_formats Show media specific list of format descriptors.",
|
||||
"",
|
||||
" -print-size Print the foreseeable consumption by next -commit.",
|
||||
" -print_size Print the foreseeable consumption by next -commit.",
|
||||
"",
|
||||
" -tell_media_space",
|
||||
" Print foreseeable available space on output media",
|
||||
@ -10198,7 +10198,7 @@ int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag)
|
||||
}
|
||||
|
||||
|
||||
/* Option -print-size
|
||||
/* Option -print_size
|
||||
@param flag bit0= report in mkisofs compatible form on real stdout
|
||||
*/
|
||||
int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
|
||||
@ -10206,7 +10206,7 @@ int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
|
||||
int ret, fd;
|
||||
|
||||
if(!xorriso->volset_change_pending) {
|
||||
sprintf(xorriso->info_text,"-print-size: No image modifications pending");
|
||||
sprintf(xorriso->info_text,"-print_size: No image modifications pending");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||
sprintf(xorriso->result_line,"Image size : 0s\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
@ -10214,7 +10214,7 @@ int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
ret= Xorriso_write_session(xorriso, 1);
|
||||
if(ret<=0) {
|
||||
sprintf(xorriso->info_text,"-print-size: Failed to set up virtual -commit");
|
||||
sprintf(xorriso->info_text,"-print_size: Failed to set up virtual -commit");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
@ -10897,6 +10897,41 @@ int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag)
|
||||
/* ---------------------------- End Options API ------------------------ */
|
||||
|
||||
|
||||
/* @return <0 error , >=0 number of skipped dashes
|
||||
*/
|
||||
int Xorriso_normalize_command(struct XorrisO *xorriso, char *original_cmd,
|
||||
int argno, char *cmd_data, int sizeof_cmd_data,
|
||||
char **cmd, int flag)
|
||||
{
|
||||
int was_dashed= 0;
|
||||
char *dash_pt;
|
||||
|
||||
if(strlen(original_cmd)>= sizeof_cmd_data) {
|
||||
if(argno>=0)
|
||||
sprintf(xorriso->info_text, "Oversized argument #%d (length %d)\n",
|
||||
argno, (int) strlen(original_cmd));
|
||||
else
|
||||
sprintf(xorriso->info_text, "Oversized option (length %d)\n",
|
||||
(int) strlen(original_cmd));
|
||||
return(-1);
|
||||
}
|
||||
strcpy(cmd_data, original_cmd);
|
||||
*cmd= cmd_data;
|
||||
if(strcmp(*cmd, "--")==0)
|
||||
return(1);
|
||||
while((*cmd)[0]=='-') {
|
||||
if((*cmd)[1]==0)
|
||||
break;
|
||||
was_dashed++;
|
||||
(*cmd)++;
|
||||
}
|
||||
for(dash_pt= *cmd; *dash_pt!=0; dash_pt++)
|
||||
if(*dash_pt=='-')
|
||||
*dash_pt= '_';
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_interpreter(struct XorrisO *xorriso,
|
||||
int argc, char **argv, int *idx, int flag)
|
||||
/*
|
||||
@ -10909,7 +10944,7 @@ return:
|
||||
{
|
||||
int ret, was_dashed, end_ret;
|
||||
int num1, num2;
|
||||
char *cmd, *arg1, *arg2;
|
||||
char *cmd, *original_cmd, cmd_data[2*SfileadrL], *arg1, *arg2;
|
||||
|
||||
if(xorriso==NULL)
|
||||
return(0);
|
||||
@ -10924,18 +10959,32 @@ next_command:;
|
||||
xorriso->request_to_abort= xorriso->request_not_to_ask= 0;
|
||||
Xorriso_set_problem_status(xorriso, "", 0);
|
||||
if((*idx)<argc)
|
||||
cmd= argv[*idx];
|
||||
original_cmd= cmd= argv[*idx];
|
||||
else
|
||||
cmd= "";
|
||||
original_cmd= cmd= "";
|
||||
if(xorriso->add_plainly==3 && cmd[0] && !xorriso->is_dialog) {
|
||||
(*idx)++;
|
||||
goto add_plain_argument;
|
||||
}
|
||||
was_dashed= 0;
|
||||
|
||||
#ifdef NIX
|
||||
|
||||
if(cmd[0]=='-' && cmd[1]!='-' && cmd[1]!=0) {
|
||||
was_dashed= 1;
|
||||
cmd++;
|
||||
}
|
||||
|
||||
#else /* NIX */
|
||||
|
||||
ret= Xorriso_normalize_command(xorriso, original_cmd, -1,
|
||||
cmd_data, sizeof(cmd_data), &cmd, 0);
|
||||
if(ret<0)
|
||||
goto eval_any_problems;
|
||||
was_dashed= ret;
|
||||
|
||||
#endif /* ! NIX */
|
||||
|
||||
(*idx)++;
|
||||
|
||||
if((*idx)<argc)
|
||||
@ -11234,7 +11283,7 @@ next_command:;
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_print(xorriso, arg1, 0);
|
||||
|
||||
} else if(strcmp(cmd,"print-size")==0 || strcmp(cmd,"print_size")==0) {
|
||||
} else if(strcmp(cmd,"print_size")==0) {
|
||||
Xorriso_option_print_size(xorriso, 0);
|
||||
|
||||
} else if(strcmp(cmd,"prompt")==0) {
|
||||
@ -11357,10 +11406,8 @@ next_command:;
|
||||
if(xorriso->add_plainly>1)
|
||||
goto add_plain_argument;
|
||||
unknown_option:;
|
||||
sprintf(xorriso->info_text,
|
||||
"=== Not a known option:\n");
|
||||
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
||||
"=== '%s%s'\n",(was_dashed ? "-" : ""), cmd);
|
||||
sprintf(xorriso->info_text, "=== Not a known option:\n === '%s'\n",
|
||||
original_cmd);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
{ret= 0; goto eval_any_problems;}
|
||||
|
||||
@ -11514,15 +11561,28 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
{
|
||||
int i, ret, was_dashed, num2;
|
||||
int was_report_about= 0, was_abort_on= 0, was_return_with= 0;
|
||||
char *cmd, *arg1, *arg2;
|
||||
char *cmd, *original_cmd, cmd_data[5*SfileadrL], *arg1, *arg2;
|
||||
|
||||
for(i=1+(flag&1);i<argc;i++) {
|
||||
cmd= argv[i];
|
||||
original_cmd= cmd= argv[i];
|
||||
was_dashed= 0;
|
||||
|
||||
#ifdef NIX
|
||||
|
||||
if(cmd[0]=='-' && cmd[1]!='-' && cmd[1]!=0) {
|
||||
was_dashed= 1;
|
||||
cmd++;
|
||||
}
|
||||
|
||||
#else /* NIX */
|
||||
|
||||
was_dashed= Xorriso_normalize_command(xorriso, original_cmd, i,
|
||||
cmd_data, sizeof(cmd_data), &cmd, 0);
|
||||
if(was_dashed<0)
|
||||
return(-1);
|
||||
|
||||
#endif /* ! NIX */
|
||||
|
||||
arg1= "";
|
||||
if(i+1<argc)
|
||||
arg1= argv[i+1];
|
||||
|
@ -386,7 +386,7 @@ int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag);
|
||||
/* Option -print */
|
||||
int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag);
|
||||
|
||||
/* Option -print-size
|
||||
/* Option -print_size
|
||||
@param flag bit0= report in mkisofs compatible form on real stdout
|
||||
*/
|
||||
int Xorriso_option_print_size(struct XorrisO *xorriso, int flag);
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2008.05.13.180624"
|
||||
#define Xorriso_timestamP "2008.05.13.180912"
|
||||
|
Loading…
Reference in New Issue
Block a user