Bug fix: readline history was spammed by -msg_op parsing and pipe loops

This commit is contained in:
Thomas Schmitt 2013-07-06 11:01:42 +00:00
parent cf24917670
commit fefda9c182
3 changed files with 16 additions and 8 deletions

View File

@ -2263,7 +2263,7 @@ ex:;
/* Option -history */ /* Option -history */
int Xorriso_option_history(struct XorrisO *xorriso, char *line, int flag) int Xorriso_option_history(struct XorrisO *xorriso, char *line, int flag)
{ {
Xorriso_dialog_input(xorriso,line,strlen(line)+1,2); Xorriso_dialog_input(xorriso, line, strlen(line) + 1, 2 | 32);
return(1); return(1);
} }

View File

@ -68,10 +68,11 @@ int Xorriso_dialog_input(struct XorrisO *xorriso, char line[], int linesize,
bit2= do not write to history line which begin with "-history:" or "-history " bit2= do not write to history line which begin with "-history:" or "-history "
bit3= enforce single line dialog mode bit3= enforce single line dialog mode
bit4= do not read from xorriso->buffered_dialog bit4= do not read from xorriso->buffered_dialog
bit5= write to history in any case (if it is enabled at compile time)
*/ */
{ {
char *cpt= NULL, **argv= NULL, *linept, *why_append= ""; char *cpt= NULL, **argv= NULL, *linept, *why_append= "";
int ret, argc= 0, base_length= 0, l, append_line; int ret, argc= 0, base_length= 0, l, append_line, no_history= 0;
#ifdef Xorriso_with_readlinE #ifdef Xorriso_with_readlinE
static char last_input[SfileadrL]= {""}; static char last_input[SfileadrL]= {""};
#endif /* ! Xorriso_with_readlinE */ #endif /* ! Xorriso_with_readlinE */
@ -85,6 +86,7 @@ int Xorriso_dialog_input(struct XorrisO *xorriso, char line[], int linesize,
fflush(stdout); fflush(stdout);
linept= line; linept= line;
no_history= (flag & 1) || xorriso->use_stdin;
get_single:; get_single:;
@ -101,8 +103,11 @@ get_single:;
if(xorriso->use_stdin || xorriso->dev_fd_1>=0 || if(xorriso->use_stdin || xorriso->dev_fd_1>=0 ||
xorriso->tolerate_stdin_eof) { xorriso->tolerate_stdin_eof) {
if(flag&2) if(flag&2) {
if(flag & 32)
goto put_into_history;
{ret= 1; goto ex;} {ret= 1; goto ex;}
}
if(Sfile_fgets_n(linept,linesize - base_length - 1, stdin, if(Sfile_fgets_n(linept,linesize - base_length - 1, stdin,
(xorriso->dialog == 2)) == NULL) { (xorriso->dialog == 2)) == NULL) {
if(xorriso->tolerate_stdin_eof) if(xorriso->tolerate_stdin_eof)
@ -202,13 +207,15 @@ new_empty:;
#ifdef Xorriso_with_readlinE #ifdef Xorriso_with_readlinE
if(line[0]!=0 && strcmp(last_input,line)!=0 && !(flag&1)) put_into_history:;
if((flag & 32) || (line[0]!=0 && strcmp(last_input,line)!=0 && !no_history)) {
if(!((flag&4) && if(!((flag&4) &&
(strncmp(line,"-history:",9)==0 || strncmp(line,"-history ",9)==0))) { (strncmp(line,"-history:",9)==0 || strncmp(line,"-history ",9)==0))) {
add_history(line); add_history(line);
strncpy(last_input,line,sizeof(last_input)-1); strncpy(last_input,line,sizeof(last_input)-1);
last_input[sizeof(last_input)-1]= 0; last_input[sizeof(last_input)-1]= 0;
} }
}
#endif /* ! Xorriso_with_readlinE */ #endif /* ! Xorriso_with_readlinE */
@ -3656,7 +3663,7 @@ int Xorriso_msg_op_parse(struct XorrisO *xorriso, char *line,
pline[0]= 0; pline[0]= 0;
for(i= 0; i < input_lines; i++) { for(i= 0; i < input_lines; i++) {
l= strlen(pline); l= strlen(pline);
ret= Xorriso_dialog_input(xorriso, pline + l, SfileadrL - l - 1, 8); ret= Xorriso_dialog_input(xorriso, pline + l, SfileadrL - l - 1, 8 | 1);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
if(i < input_lines - 1) if(i < input_lines - 1)
@ -3735,7 +3742,7 @@ int Xorriso_msg_op_parse_bulk(struct XorrisO *xorriso,
Xorriso_alloc_meM(pline, char, SfileadrL); Xorriso_alloc_meM(pline, char, SfileadrL);
for(i= 0; i < bulk_lines; i++) { for(i= 0; i < bulk_lines; i++) {
ret= Xorriso_dialog_input(xorriso, line, sizeof(line), 8); ret= Xorriso_dialog_input(xorriso, line, sizeof(line), 8 | 1);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
input_lines= -1; input_lines= -1;
@ -3743,7 +3750,7 @@ int Xorriso_msg_op_parse_bulk(struct XorrisO *xorriso,
pline[0]= 0; pline[0]= 0;
for(j= 0; j < input_lines; j++) { for(j= 0; j < input_lines; j++) {
l= strlen(pline); l= strlen(pline);
ret= Xorriso_dialog_input(xorriso, pline + l, SfileadrL - l - 1, 8); ret= Xorriso_dialog_input(xorriso, pline + l, SfileadrL - l - 1, 8 | 1);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
if(j < input_lines - 1) if(j < input_lines - 1)
@ -3884,6 +3891,7 @@ no_pipe_open:
if (cpid != 0) { if (cpid != 0) {
/* Parent becomes the xorriso slave */ /* Parent becomes the xorriso slave */
xorriso->use_stdin= 1;
if(cmd_pipe_adr[0] && reply_pipe_adr[0]) { if(cmd_pipe_adr[0] && reply_pipe_adr[0]) {
command_pipe[0]= open(cmd_pipe_adr, O_RDONLY); command_pipe[0]= open(cmd_pipe_adr, O_RDONLY);
if(command_pipe[0] == -1) { if(command_pipe[0] == -1) {

View File

@ -1 +1 @@
#define Xorriso_timestamP "2013.07.05.164001" #define Xorriso_timestamP "2013.07.06.110101"