Skip to content

Commit

Permalink
fix: avoid quoting words that are already in quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Nov 13, 2020
1 parent b075a84 commit 5ff88ce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/common/fputword.c
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 */
Expand Down

0 comments on commit 5ff88ce

Please sign in to comment.