Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Dec 2017 08:57:37 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326844 - head/usr.sbin/mailwrapper
Message-ID:  <201712140857.vBE8vbEY069664@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Thu Dec 14 08:57:37 2017
New Revision: 326844
URL: https://svnweb.freebsd.org/changeset/base/326844

Log:
  Replace usage of fparselen(3) by a getline(3)
  
  This allow to remove the dependency on libutil

Modified:
  head/usr.sbin/mailwrapper/Makefile
  head/usr.sbin/mailwrapper/Makefile.depend
  head/usr.sbin/mailwrapper/mailwrapper.c

Modified: head/usr.sbin/mailwrapper/Makefile
==============================================================================
--- head/usr.sbin/mailwrapper/Makefile	Thu Dec 14 07:55:11 2017	(r326843)
+++ head/usr.sbin/mailwrapper/Makefile	Thu Dec 14 08:57:37 2017	(r326844)
@@ -5,8 +5,6 @@
 .if ${MK_MAILWRAPPER} != "no"
 PROG=	mailwrapper
 MAN=	mailwrapper.8
-
-LIBADD=	util
 .endif
 
 .if ${MK_MAILWRAPPER} != "no" || ${MK_SENDMAIL} != "no"

Modified: head/usr.sbin/mailwrapper/Makefile.depend
==============================================================================
--- head/usr.sbin/mailwrapper/Makefile.depend	Thu Dec 14 07:55:11 2017	(r326843)
+++ head/usr.sbin/mailwrapper/Makefile.depend	Thu Dec 14 08:57:37 2017	(r326844)
@@ -7,8 +7,7 @@ DIRDEPS = \
 	include/xlocale \
 	lib/${CSU_DIR} \
 	lib/libc \
-	lib/libcompiler_rt \
-	lib/libutil \
+	lib/libcompiler_rt
 
 
 .include <dirdeps.mk>

Modified: head/usr.sbin/mailwrapper/mailwrapper.c
==============================================================================
--- head/usr.sbin/mailwrapper/mailwrapper.c	Thu Dec 14 07:55:11 2017	(r326843)
+++ head/usr.sbin/mailwrapper/mailwrapper.c	Thu Dec 14 08:57:37 2017	(r326844)
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <libutil.h>
 #include <sysexits.h>
 #include <syslog.h>
 
@@ -89,14 +88,17 @@ int
 main(int argc, char *argv[], char *envp[])
 {
 	FILE *config;
-	char *line, *cp, *from, *to, *ap;
+	char *line, *cp, *from, *to, *ap, *walk;
 	const char *progname;
 	char localmailerconf[MAXPATHLEN];
 	const char *mailerconf;
-	size_t len, lineno = 0;
+	size_t linecap = 0, lineno = 0;
+	ssize_t linelen;
 	int i;
 	struct arglist al;
 
+	line = NULL;
+
 	/* change __progname to mailwrapper so we get sensible error messages */
 	progname = getprogname();
 	setprogname("mailwrapper");
@@ -123,12 +125,16 @@ main(int argc, char *argv[], char *envp[])
 	}
 
 	for (;;) {
-		if ((line = fparseln(config, &len, &lineno, NULL, 0)) == NULL) {
-			if (feof(config))
+		if ((linelen = getline(&line, &linecap, config)) <= 0) {
+			if (feof(config)) {
 				errx(EX_CONFIG, "no mapping in %s", mailerconf);
+			}
 			err(EX_CONFIG, "cannot parse line %lu", (u_long)lineno);
 		}
-
+		lineno++;
+		walk = line;
+		/* strip comments */
+		strsep(&walk, "#");
 #define	WS	" \t\n"
 		cp = line;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712140857.vBE8vbEY069664>