ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fputword.c
Revision: 3.8
Committed: Fri Apr 2 21:41:23 2004 UTC (20 years ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9
Changes since 3.7: +1 -2 lines
Log Message:
Took out redundant inclusion of stdio.h

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: fputword.c,v 3.7 2003/07/17 09:21:29 schorsch Exp $";
3 #endif
4 /*
5 * Read white space separated words from stream
6 *
7 * External symbols declared in rtio.h
8 */
9
10 #include "copyright.h"
11
12 #include <ctype.h>
13
14 #include "rtio.h"
15
16 void
17 fputword(s, fp) /* put (quoted) word to file stream */
18 char *s;
19 FILE *fp;
20 {
21 int hasspace = 0;
22 int quote = 0;
23 register char *cp;
24 /* check if quoting needed */
25 for (cp = s; *cp; cp++)
26 if (isspace(*cp))
27 hasspace++;
28 else if (*cp == '"')
29 quote = '\'';
30 else if (*cp == '\'')
31 quote = '"';
32
33 if (hasspace || quote) { /* output with quotes */
34 if (!quote) quote = '"';
35 fputc(quote, fp);
36 fputs(s, fp);
37 fputc(quote, fp);
38 } else /* output sans quotes */
39 fputs(s, fp);
40 }