Oops just noticed I left "mode_insert = 1" in. That's not part of the fix, I just prefer insert mode.
James > -----Original Message----- > From: James Harper > Sent: Friday, 30 October 2009 23:20 > To: James Harper; [email protected] > Subject: RE: [Bacula-devel] bugs in conio > > The patch below (excuse the possible formatting problems, but you get the > idea) almost completely fixes the problem for me - I can't break it except for > one thing. If you hit backspace, then delete, then the next character you type > erases the '*' prompt. Bacula still must be looking at characters in the > buffer that aren't actually valid... I'll keep looking. > > James > > diff --git a/bacula/src/console/conio.c b/bacula/src/console/conio.c > index 157df55..e55ef85 100755 > --- a/bacula/src/console/conio.c > +++ b/bacula/src/console/conio.c > @@ -188,7 +188,7 @@ static struct lstr *slptr; /* store line > pointer */ > static int cl, cp; > static char *getnext(), *getprev(); > static int first = 1; > -static int mode_insert = 0; > +static int mode_insert = 1; > static int mode_wspace = 1; /* words separated by spaces */ > > > @@ -646,7 +646,7 @@ insert_space(char *curline, int curline_len) > /* Note! source and destination overlap */ > memmove(&curline[cp+1],&curline[cp],i=cl-cp); > cl++; > - curline[cp] = ' '; > + curline[cl] = ' '; > i = 0; > while (cl > cp) { > forward(curline, curline_len); > @@ -739,7 +739,7 @@ delchr(int del, char *curline, int line_len) > if (cp > cl || del == 0) { > return; > } > - while (del-- && cp > 0) { > + while (del-- && cl > 0) { > cnt = char_count(cp, curline); > if ((i=cl-cp-cnt) > 0) { > memcpy(&curline[cp], &curline[cp+cnt], i); > > > > -----Original Message----- > > From: James Harper [mailto:[email protected]] > > Sent: Friday, 30 October 2009 22:50 > > To: [email protected] > > Subject: [Bacula-devel] bugs in conio > > > > I changed mode_insert in conio.c to 1 so that the default mode would be > > insert, and since then the console just doesn't seem to work right, at > > least for the first command you enter. Eg if I type: > > > > restore pool=aurora-disk > > > > Bacula would tell me something like "restorepool: is an invalid > > command.". You can get the same effect by building with conio (the > > default), pressing the insert key, then typing a command. > > > > I added some debugging to conio.c and it seems that cl is being > > decremented somewhere, I think in forward() which is called by > > insert_space(). If I initialise curline in Putting a '\0' character at > > position 0 of curline is sufficient to fix the problem for me, but I'm > > not sure that it's completely the correct solution. > > > > The other problem I have seen is where I type a command and then > > backspace over it. To reproduce this problem: > > > > 1. start up bconsole > > 2. type 'status' > > 3. hit backspace 6 times > > 4. press enter > > > > Bacula will respond with "Status available for: etc", indicating that it > > received an 's'. Debugging shows this to be true - when you backspace, > > cp gets reduced to 0 but cl doesn't. Under some circumstances, repeating > > steps 1-3 above result in a buffer overflow or something but I can't > > reproduce that reliably. I guess it depends somewhat on what is in the > > uninitialised buffers when bconsole starts. > > > > According to the source code, conio is preferred over readline. Is this > > still the case? > > > > It's probably going to be a few off-by-one errors in conio.c... has > > anyone looked into this before? > > > > Thanks > > > > James > > > > > > > > ------------------------------------------------------------------------ ---- > -- > > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > > is the only developer event you need to attend this year. Jumpstart your > > developing skills, take BlackBerry mobile applications to market and stay > > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > > http://p.sf.net/sfu/devconference > > _______________________________________________ > > Bacula-devel mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/bacula-devel ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Bacula-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/bacula-devel
