-fix a condition so that fparseln() doesn'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
This commit is contained in:
parent
de8ce52c3b
commit
7af4323f9b
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: fparseln.c,v 1.5 2004/06/20 22:20:15 jmc Exp $ */
|
/* $NetBSD: fparseln.c,v 1.6 2007/03/07 15:12:01 drochner Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
|
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
|
||||||
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
__RCSID("$NetBSD: fparseln.c,v 1.5 2004/06/20 22:20:15 jmc Exp $");
|
__RCSID("$NetBSD: fparseln.c,v 1.6 2007/03/07 15:12:01 drochner Exp $");
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include "namespace.h"
|
#include "namespace.h"
|
||||||
@ -79,7 +79,7 @@ isescaped(const char *sp, const char *p, int esc)
|
|||||||
|
|
||||||
/* No escape character */
|
/* No escape character */
|
||||||
if (esc == '\0')
|
if (esc == '\0')
|
||||||
return 1;
|
return 0;
|
||||||
|
|
||||||
/* Count the number of escape characters that precede ours */
|
/* Count the number of escape characters that precede ours */
|
||||||
for (ne = 0, cp = p; --cp >= sp && *cp == esc; ne++)
|
for (ne = 0, cp = p; --cp >= sp && *cp == esc; ne++)
|
||||||
@ -160,7 +160,7 @@ fparseln(FILE *fp, size_t *size, size_t *lineno, const char str[3], int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s == 0 && buf != NULL)
|
if (s == 0 && buf == NULL && cnt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((cp = realloc(buf, len + s + 1)) == NULL) {
|
if ((cp = realloc(buf, len + s + 1)) == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user