modify the previous fix so that no pointless realloc()s are done in

the case of multiple empty continuation lines, and comment the code
to make the logics obvious
fix an unrelated comment
This commit is contained in:
drochner 2007-03-08 19:57:53 +00:00
parent af336998bf
commit 5a8030ba23
1 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fparseln.c,v 1.6 2007/03/07 15:12:01 drochner Exp $ */
/* $NetBSD: fparseln.c,v 1.7 2007/03/08 19:57:53 drochner Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fparseln.c,v 1.6 2007/03/07 15:12:01 drochner Exp $");
__RCSID("$NetBSD: fparseln.c,v 1.7 2007/03/08 19:57:53 drochner Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -155,13 +155,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 && cnt)
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) {
FUNLOCKFILE(fp);