Module Name:    othersrc
Committed By:   lukem
Date:           Wed Jan 23 05:34:09 UTC 2019

Modified Files:
        othersrc/libexec/tnftpd/libnetbsd: fparseln.c

Log Message:
sync to fparseln.c 1.10

Update from NetBSD src/lib/libc/stdio/fparseln.c 1.5 to 1.10:
- Don't report spurious empty lines eg after 2 comment lines, or on
  EOF after a single comment line.
- No escape character means no escaped characters.
- Remove 3rd and 4th clauses in christos' license.  OK christos.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/libexec/tnftpd/libnetbsd/fparseln.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/libexec/tnftpd/libnetbsd/fparseln.c
diff -u othersrc/libexec/tnftpd/libnetbsd/fparseln.c:1.2 othersrc/libexec/tnftpd/libnetbsd/fparseln.c:1.3
--- othersrc/libexec/tnftpd/libnetbsd/fparseln.c:1.2	Sun Sep 21 16:35:25 2008
+++ othersrc/libexec/tnftpd/libnetbsd/fparseln.c	Wed Jan 23 05:34:09 2019
@@ -1,5 +1,6 @@
-/* $NetBSD: fparseln.c,v 1.2 2008/09/21 16:35:25 lukem Exp $ */
+/* $NetBSD: fparseln.c,v 1.3 2019/01/23 05:34:09 lukem Exp $ */
 /* from NetBSD: fparseln.c,v 1.5 1997/12/01 02:58:41 lukem Exp */
+/* from NetBSD: fparseln.c,v 1.10 2009/10/21 01:07:45 snj Exp */
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -12,11 +13,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -46,7 +42,7 @@ isescaped(const char *sp, const char *p,
 
 	/* 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++)
@@ -118,13 +114,19 @@ fparseln(FILE *fp, size_t *size, size_t 
 			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);
@@ -175,10 +177,10 @@ fparseln(FILE *fp, size_t *size, size_t 
 
 #ifdef TEST
 
-int main(int, char *[]);
+int main(int, char **);
 
 int
-main(int argc, char *argv[])
+main(int argc, char **argv)
 {
 	char   *ptr;
 	size_t	size, line;

Reply via email to