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