From owner-svn-src-stable-10@FreeBSD.ORG Sat Aug 16 00:54:56 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D2A343A4; Sat, 16 Aug 2014 00:54:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A320522D4; Sat, 16 Aug 2014 00:54:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7G0suDA009902; Sat, 16 Aug 2014 00:54:56 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7G0su2P009901; Sat, 16 Aug 2014 00:54:56 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201408160054.s7G0su2P009901@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 16 Aug 2014 00:54:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r270031 - stable/10/lib/libutil X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Aug 2014 00:54:56 -0000 Author: pfg Date: Sat Aug 16 00:54:56 2014 New Revision: 270031 URL: http://svnweb.freebsd.org/changeset/base/270031 Log: MFC r269015: fparseln(3): Update from NetBSD sources. -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 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. fparseln is now part of libc in NetBSD so this changes the previous revision numbering. Obtained from: NetBSD (CVS Rev. 1.6-1.7) Modified: stable/10/lib/libutil/fparseln.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libutil/fparseln.c ============================================================================== --- stable/10/lib/libutil/fparseln.c Sat Aug 16 00:52:13 2014 (r270030) +++ stable/10/lib/libutil/fparseln.c Sat Aug 16 00:54:56 2014 (r270031) @@ -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, /* 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 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);