From 5ff88ce21031f304dc5b457d3b3daad2ef968f11 Mon Sep 17 00:00:00 2001 From: "Gregory J. Ward" Date: Fri, 13 Nov 2020 01:06:14 +0000 Subject: [PATCH] fix: avoid quoting words that are already in quotes --- src/common/fputword.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/fputword.c b/src/common/fputword.c index 7cbc9e210..f50d013be 100644 --- a/src/common/fputword.c +++ b/src/common/fputword.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: fputword.c,v 3.9 2011/06/22 16:55:35 greg Exp $"; +static const char RCSid[] = "$Id: fputword.c,v 3.10 2020/11/13 01:06:14 greg Exp $"; #endif /* * Write word to stream, quoting as necessary @@ -25,9 +25,9 @@ FILE *fp; for (cp = s; *cp; cp++) if (isspace(*cp)) hasspace++; - else if (*cp == '"') + else if ((cp > s) & (*cp == '"') && cp[1]) quote = '\''; - else if (*cp == '\'') + else if ((cp > s) & (*cp == '\'') && cp[1]) quote = '"'; if (hasspace || quote) { /* output with quotes */