Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Mar 2014 08:54:29 +0000 (UTC)
From:      Poul-Henning Kamp <phk@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263077 - head/usr.bin/ministat
Message-ID:  <201403120854.s2C8sTCx079976@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: phk
Date: Wed Mar 12 08:54:29 2014
New Revision: 263077
URL: http://svnweb.freebsd.org/changeset/base/263077

Log:
  Make ministat CRNL tolerant by stripping all isspace() from the tail
  end of input lines.

Modified:
  head/usr.bin/ministat/ministat.c

Modified: head/usr.bin/ministat/ministat.c
==============================================================================
--- head/usr.bin/ministat/ministat.c	Wed Mar 12 08:32:01 2014	(r263076)
+++ head/usr.bin/ministat/ministat.c	Wed Mar 12 08:54:29 2014	(r263077)
@@ -13,6 +13,7 @@ __FBSDID("$FreeBSD$");
 
 #include <stdio.h>
 #include <math.h>
+#include <ctype.h>
 #include <err.h>
 #include <string.h>
 #include <stdlib.h>
@@ -475,8 +476,8 @@ ReadSet(const char *n, int column, const
 		line++;
 
 		i = strlen(buf);
-		if (buf[i-1] == '\n')
-			buf[i-1] = '\0';
+		while (i > 0 && isspace(buf[i - 1]))
+			buf[--i] = '\0';
 		for (i = 1, t = strtok(buf, delim);
 		     t != NULL && *t != '#';
 		     i++, t = strtok(NULL, delim)) {



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