From: James Harper Date: Wed, 4 Nov 2009 14:39:36 +0000 (+0100) Subject: Apply James' conio patches X-Git-Tag: Release-7.0.0~2597^2~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d3e7fb46347f28d75d9198a117ef6caedfbbce87;p=bacula%2Fbacula Apply James' conio patches --- diff --git a/bacula/src/console/conio.c b/bacula/src/console/conio.c index 157df55e7c..f35dda8976 100755 --- a/bacula/src/console/conio.c +++ b/bacula/src/console/conio.c @@ -1,17 +1,7 @@ -/* - Generalized console input/output handler - A maintanable replacement for readline() - - Updated for Bacula, Kern Sibbald, December MMIII - - This code is in part derived from code that I wrote in - 1981, so some of it is a bit old and could use a cleanup. - -*/ /* Bacula® - The Network Backup Solution - Copyright (C) 1981-2006 Free Software Foundation Europe e.V. + Copyright (C) 1981-2009 Free Software Foundation Europe e.V. Yes, that is 1981 no error. The main author of Bacula is Kern Sibbald, with contributions from @@ -36,6 +26,16 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + Generalized console input/output handler + A maintanable replacement for readline() + + Updated for Bacula, Kern Sibbald, December MMIII + + This code is in part derived from code that I wrote in + 1981, so some of it is a bit old and could use a cleanup. + +*/ /* * UTF-8 @@ -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 */ @@ -629,8 +629,10 @@ input_line(char *string, int length) done: curline[cl++] = EOS; /* terminate */ bstrncpy(string,curline,length); /* return line to caller */ - /* Note, put line zaps curline */ - putline(curline,cl); /* save line for posterity */ + /* Save non-blank lines. Note, put line zaps curline */ + if (curline[0] != EOS) { + putline(curline,cl); /* save line for posterity */ + } return 0; /* give it to him/her */ } @@ -640,7 +642,7 @@ insert_space(char *curline, int curline_len) { int i; - if (cp > cl || cl+1 > curline_len) { + if (cp >= cl || cl+1 > curline_len) { return; } /* Note! source and destination overlap */ @@ -739,7 +741,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);