summaryrefslogtreecommitdiffstats
path: root/lib/libutil/fparseln.c
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
committersjg <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
commitd7cd1d425cc1ea9451fa235e3af9b6625c3e0de2 (patch)
treeb04f4bd7cd887f50e7d98af35f46b9834ff86c80 /lib/libutil/fparseln.c
parent3c8e37b1d04827f33c0c9a7594bd1b1ef7cdb3d3 (diff)
parent4fbde208c6460d576f64d6dc3cdc6cab085a4283 (diff)
downloadFreeBSD-src-d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2.zip
FreeBSD-src-d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2.tar.gz
Merge head from 7/28
Diffstat (limited to 'lib/libutil/fparseln.c')
-rw-r--r--lib/libutil/fparseln.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/libutil/fparseln.c b/lib/libutil/fparseln.c
index 0624f0e..d03357e 100644
--- a/lib/libutil/fparseln.c
+++ b/lib/libutil/fparseln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fparseln.c,v 1.9 1999/09/20 04:48:06 lukem Exp $ */
+/* $NetBSD: fparseln.c,v 1.7 2007/03/08 19:57:53 drochner Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -59,7 +59,7 @@ isescaped(const char *sp, const char *p, int esc)
/* No escape character */
if (esc == '\0')
- return 1;
+ return 0;
/* Count the number of escape characters that precede ours */
for (ne = 0, cp = p; --cp >= sp && *cp == esc; ne++)
@@ -135,13 +135,19 @@ fparseln(FILE *fp, size_t *size, size_t *lineno, const char str[3], int flags)
cp = &ptr[s - 1];
if (*cp == con && !isescaped(ptr, cp, esc)) {
- s--; /* forget escape */
+ s--; /* forget continuation char */
cnt = 1;
}
}
- if (s == 0 && buf != NULL)
- continue;
+ if (s == 0) {
+ /*
+ * nothing to add, skip realloc except in case
+ * we need a minimal buf to return an empty line
+ */
+ if (cnt || buf != NULL)
+ continue;
+ }
if ((cp = realloc(buf, len + s + 1)) == NULL) {
free(buf);
OpenPOWER on IntegriCloud