--- ray/src/common/fputword.c 2003/06/27 06:53:21 3.4 +++ ray/src/common/fputword.c 2020/11/13 01:06:14 3.10 @@ -1,18 +1,17 @@ #ifndef lint -static const char RCSid[] = "$Id: fputword.c,v 3.4 2003/06/27 06:53:21 greg Exp $"; +static const char RCSid[] = "$Id: fputword.c,v 3.10 2020/11/13 01:06:14 greg Exp $"; #endif /* - * Read white space separated words from stream + * Write word to stream, quoting as necessary * * External symbols declared in rtio.h */ #include "copyright.h" -#include "rtio.h" - #include +#include "rtio.h" void fputword(s, fp) /* put (quoted) word to file stream */ @@ -26,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 */