summaryrefslogtreecommitdiffstats
path: root/lib/libedit
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2007-03-11 21:47:40 +0000
committerstefanf <stefanf@FreeBSD.org>2007-03-11 21:47:40 +0000
commit176735320e11768e9f5b034525cd406666c745a6 (patch)
tree7c5a511c1579d52e93b7e0c88360011ccae165db /lib/libedit
parent50b3f4c302935f38be277cc4f2b41c73be99018b (diff)
downloadFreeBSD-src-176735320e11768e9f5b034525cd406666c745a6.zip
FreeBSD-src-176735320e11768e9f5b034525cd406666c745a6.tar.gz
Merge the following changes from NetBSD:
history.c 1.32: # Fix memory leak found by valgrind (Julien Torres) map.c 1.24: # fix debugging printf format. read.c 1.40: # Fix bug with multiple pending el_pushes. Reported by Julien Torres. tty.c 1.24: # Coverity CID 1216: Prevent negative index use. MFC after: 3 weeks
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/history.c3
-rw-r--r--lib/libedit/map.c4
-rw-r--r--lib/libedit/read.c32
-rw-r--r--lib/libedit/tty.c14
4 files changed, 37 insertions, 16 deletions
diff --git a/lib/libedit/history.c b/lib/libedit/history.c
index af4892a..76b3b07 100644
--- a/lib/libedit/history.c
+++ b/lib/libedit/history.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: history.c,v 1.31 2005/08/01 14:34:06 christos Exp $
+ * $NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -543,6 +543,7 @@ history_end(History *h)
if (h->h_next == history_def_next)
history_def_clear(h->h_ref, &ev);
+ h_free(h->h_ref);
h_free(h);
}
diff --git a/lib/libedit/map.c b/lib/libedit/map.c
index c4121a6..591118f 100644
--- a/lib/libedit/map.c
+++ b/lib/libedit/map.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: map.c,v 1.23 2006/03/06 21:11:56 christos Exp $
+ * $NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -1381,7 +1381,7 @@ map_bind(EditLine *el, int argc, const char **argv)
break;
default:
- EL_ABORT((el->el_errfile, "Bad XK_ type\n", ntype));
+ EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
break;
}
return (0);
diff --git a/lib/libedit/read.c b/lib/libedit/read.c
index 4d0b394..f774217 100644
--- a/lib/libedit/read.c
+++ b/lib/libedit/read.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: read.c,v 1.39 2005/08/02 12:11:14 christos Exp $
+ * $NetBSD: read.c,v 1.40 2007/03/01 21:41:45 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -55,6 +55,7 @@ private int read__fixio(int, int);
private int read_preread(EditLine *);
private int read_char(EditLine *, char *);
private int read_getcmd(EditLine *, el_action_t *, char *);
+private void read_pop(c_macro_t *);
/* read_init():
* Initialize the read stuff
@@ -299,6 +300,19 @@ read_char(EditLine *el, char *cp)
return (num_read);
}
+/* read_pop():
+ * Pop a macro from the stack
+ */
+private void
+read_pop(c_macro_t *ma)
+{
+ int i;
+
+ el_free(ma->macro[0]);
+ for (i = ma->level--; i > 0; i--)
+ ma->macro[i - 1] = ma->macro[i];
+ ma->offset = 0;
+}
/* el_getc():
* Read a character
@@ -315,20 +329,22 @@ el_getc(EditLine *el, char *cp)
if (!read_preread(el))
break;
}
+
if (ma->level < 0)
break;
- if (ma->macro[ma->level][ma->offset] == '\0') {
- el_free(ma->macro[ma->level--]);
- ma->offset = 0;
+ if (ma->macro[0][ma->offset] == '\0') {
+ read_pop(ma);
continue;
}
- *cp = ma->macro[ma->level][ma->offset++] & 0377;
- if (ma->macro[ma->level][ma->offset] == '\0') {
+
+ *cp = ma->macro[0][ma->offset++] & 0377;
+
+ if (ma->macro[0][ma->offset] == '\0') {
/* Needed for QuoteMode On */
- el_free(ma->macro[ma->level--]);
- ma->offset = 0;
+ read_pop(ma);
}
+
return (1);
}
diff --git a/lib/libedit/tty.c b/lib/libedit/tty.c
index e2b9932..fca3c2b 100644
--- a/lib/libedit/tty.c
+++ b/lib/libedit/tty.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: tty.c,v 1.23 2005/06/01 11:37:52 lukem Exp $
+ * $NetBSD: tty.c,v 1.24 2006/03/18 09:07:05 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -1149,10 +1149,14 @@ tty_stty(EditLine *el, int argc __unused, const char **argv)
st = len =
strlen(el->el_tty.t_t[z][m->m_type].t_name);
}
- x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
- ? '+' : '\0';
- x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
- ? '-' : x;
+ if (i != -1) {
+ x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
+ ? '+' : '\0';
+ x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
+ ? '-' : x;
+ } else {
+ x = '\0';
+ }
if (x != '\0' || aflag) {
OpenPOWER on IntegriCloud