Corrected interpretation of flag in Xorriso_parse_line()

This commit is contained in:
Thomas Schmitt 2012-09-29 17:36:53 +00:00
parent d083214971
commit d7b1bd988f
2 changed files with 38 additions and 33 deletions

View File

@ -1725,6 +1725,7 @@ next_command:;
/* install temporary test code here */; /* install temporary test code here */;
/* Test setup for for Xorriso_push_outlists() et.al. */ /* Test setup for for Xorriso_push_outlists() et.al. */
/* Test setup for Xorriso_parse_line */
{ {
int stack_handle = -1, line_count= 0; int stack_handle = -1, line_count= 0;
struct Xorriso_lsT *result_list, *info_list; struct Xorriso_lsT *result_list, *info_list;
@ -1732,6 +1733,8 @@ next_command:;
struct Xorriso_lsT *result_list, struct Xorriso_lsT *result_list,
struct Xorriso_lsT *info_list, struct Xorriso_lsT *info_list,
int *line_count, int flag); int *line_count, int flag);
int pargc, pflag, max_words;
char **pargv= NULL, *pline, *prefix, *separators;
(*idx)++; (*idx)++;
if(strcmp(arg1, "push") == 0) { if(strcmp(arg1, "push") == 0) {
@ -1774,41 +1777,39 @@ next_command:;
} else if(strcmp(arg1, "stop") == 0) { } else if(strcmp(arg1, "stop") == 0) {
ret= Xorriso_stop_msg_watcher(xorriso, 0); ret= Xorriso_stop_msg_watcher(xorriso, 0);
fprintf(stderr, "xorriso -test: Xorriso_stop_msg_watcher() = %d\n", ret); fprintf(stderr, "xorriso -test: Xorriso_stop_msg_watcher() = %d\n", ret);
} else if(strcmp(arg1, "parse") == 0) {
(*idx)+= 5;
pline= "";
if(*idx - 5 < argc)
pline= argv[*idx - 5];
prefix= "";
if(*idx - 4 < argc)
prefix= argv[*idx - 4];
separators= "";
if(*idx - 3 < argc)
separators= argv[*idx - 3];
max_words= 0;
if(*idx - 2 < argc)
sscanf(argv[*idx - 2], "%d", &max_words);
pflag= 0;
if(*idx - 1 < argc)
sscanf(argv[*idx - 1], "%d", &pflag);
ret= Xorriso_parse_line(xorriso, pline, prefix, separators, max_words,
&pargc, &pargv, pflag);
fprintf(stderr,
"xorriso_test: Xorriso_parse_line: ret= %d , argc= %d , argv= 0x%lX\n",
ret, pargc, (unsigned long) pargv);
if(ret == 1)
for(i= 0; i < pargc; i++)
fprintf(stderr, "xorriso_test: argv[%d]= '%s'\n", i, pargv[i]);
Xorriso__dispose_words(&pargc, &pargv);
} else { } else {
fprintf(stderr, "xorriso -test: unknwon mode: %s\n", arg1); fprintf(stderr, "xorriso -test: unknwon mode: %s\n", arg1);
} }
ret= 0; ret= 0;
} }
/* Test setup for Xorriso_parse_line */
if(0){
int pargc, pflag, max_words;
char **pargv= NULL, *pline, *prefix, *separators;
(*idx)+= 5;
pline= arg1;
prefix= arg2;
separators= "";
if(*idx - 3 < argc)
separators= argv[*idx - 3];
max_words= 0;
if(*idx - 2 < argc)
sscanf(argv[*idx - 2], "%d", &max_words);
pflag= 0;
if(*idx - 1 < argc)
sscanf(argv[*idx - 1], "%d", &pflag);
ret= Xorriso_parse_line(xorriso, pline, prefix, separators, max_words,
&pargc, &pargv, pflag);
fprintf(stderr,
"xorriso_test: Xorriso_parse_line: ret= %d , argc= %d , argv= 0x%lX\n",
ret, pargc, (unsigned long) pargv);
if(ret == 1)
for(i= 0; i < pargc; i++)
fprintf(stderr, "xorriso_test: argv[%d]= '%s'\n", i, pargv[i]);
Xorriso__dispose_words(&pargc, &pargv);
}
} else if(strcmp(cmd,"toc")==0) { } else if(strcmp(cmd,"toc")==0) {
Xorriso_option_toc(xorriso, 0); Xorriso_option_toc(xorriso, 0);
@ -1907,13 +1908,17 @@ int Xorriso_parse_line(struct XorrisO *xorriso, char *line,
char *prefix, char *separators, int max_words, char *prefix, char *separators, int max_words,
int *argc, char ***argv, int flag) int *argc, char ***argv, int flag)
{ {
int ret; int ret, bsl_mode;
char *to_parse; char *to_parse;
*argc= 0; *argc= 0;
*argv= NULL; *argv= NULL;
to_parse= line; to_parse= line;
if(flag & 1)
bsl_mode= (flag >> 1) & 3;
else
bsl_mode= xorriso->bsl_interpretation & 3;
if(prefix[0]) { if(prefix[0]) {
if(strncmp(line, prefix, strlen(prefix)) == 0) { if(strncmp(line, prefix, strlen(prefix)) == 0) {
to_parse= line + strlen(prefix); to_parse= line + strlen(prefix);
@ -1923,8 +1928,8 @@ int Xorriso_parse_line(struct XorrisO *xorriso, char *line,
} }
ret= Sfile_sep_make_argv(xorriso->progname, to_parse, separators, ret= Sfile_sep_make_argv(xorriso->progname, to_parse, separators,
max_words, argc, argv, max_words, argc, argv,
(!(flag & 32)) | 4 | ((xorriso->bsl_interpretation & 3) << 5)); (!(flag & 32)) | 4 | (bsl_mode << 5));
if(ret < 0) { if(ret < 0) {
Xorriso_msgs_submit(xorriso, 0, Xorriso_msgs_submit(xorriso, 0,
"Severe lack of resources during command line parsing", 0, "FATAL", 0); "Severe lack of resources during command line parsing", 0, "FATAL", 0);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2012.09.21.120245" #define Xorriso_timestamP "2012.09.29.173546"