ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fputword.c
(Generate patch)

Comparing ray/src/common/fputword.c (file contents):
Revision 3.2 by greg, Tue Feb 25 02:47:21 2003 UTC vs.
Revision 3.3 by greg, Thu Mar 27 04:16:33 2003 UTC

# Line 19 | Line 19 | fputword(s, fp)                        /* put (quoted) word to file stream
19   char  *s;
20   FILE  *fp;
21   {
22 +        int             hasspace = 0;
23 +        int             quote = 0;
24          register char   *cp;
25                                          /* check if quoting needed */
26          for (cp = s; *cp; cp++)
27 <                if (isspace(*cp)) {
28 <                        int     quote;
29 <                        if (index(s, '"'))
30 <                                quote = '\'';
31 <                        else
32 <                                quote = '"';
33 <                        fputc(quote, fp);
34 <                        fputs(s, fp);
35 <                        fputc(quote, fp);
36 <                        return;
37 <                }
38 <                                        /* output sans quotes */
39 <        fputs(s, fp);
27 >                if (isspace(*cp))
28 >                        hasspace++;
29 >                else if (*cp == '"')
30 >                        quote = '\'';
31 >                else if (*cp == '\'')
32 >                        quote = '"';
33 >
34 >        if (hasspace || quote) {        /* output with quotes */
35 >                if (!quote) quote = '"';
36 >                fputc(quote, fp);
37 >                fputs(s, fp);
38 >                fputc(quote, fp);
39 >        } else                          /* output sans quotes */
40 >                fputs(s, fp);
41   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines