Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit use fparseln() to avoid needing to deal with mis...



details:   https://anonhg.NetBSD.org/src/rev/2875d88594fe
branches:  trunk
changeset: 813717:2875d88594fe
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Feb 15 15:18:01 2016 +0000

description:
use fparseln() to avoid needing to deal with missing \n in the last line
and also to handle comments automatically.

diffstat:

 lib/libedit/el.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r 6f3102c5acb6 -r 2875d88594fe lib/libedit/el.c
--- a/lib/libedit/el.c  Mon Feb 15 14:59:38 2016 +0000
+++ b/lib/libedit/el.c  Mon Feb 15 15:18:01 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.c,v 1.75 2016/02/11 19:21:04 christos Exp $ */
+/*     $NetBSD: el.c,v 1.76 2016/02/15 15:18:01 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c       8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.75 2016/02/11 19:21:04 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.76 2016/02/15 15:18:01 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -549,7 +549,7 @@
                return -1;
        }
 
-       while ((ptr = fgetln(fp, &len)) != NULL) {
+       for (; (ptr = fparseln(fp, &len, NULL, NULL, 0)) != NULL; free(ptr)) {
                if (*ptr == '\n')
                        continue;       /* Empty line. */
                dptr = ct_decode_string(ptr, &el->el_scratch);
@@ -566,6 +566,7 @@
                if ((error = parse_line(el, dptr)) == -1)
                        break;
        }
+       free(ptr);
 
        el_free(path);
        (void) fclose(fp);



Home | Main Index | Thread Index | Old Index