24 |
|
|
25 |
|
#define MAXLINE 512 |
26 |
|
|
27 |
+ |
#ifndef BSD |
28 |
+ |
#define index strchr |
29 |
+ |
#endif |
30 |
+ |
|
31 |
+ |
extern char *index(); |
32 |
+ |
|
33 |
|
char FMTSTR[] = "FORMAT="; |
34 |
|
int FMTSTRL = 7; |
35 |
|
|
37 |
|
printargs(ac, av, fp) /* print arguments to a file */ |
38 |
|
int ac; |
39 |
|
char **av; |
40 |
< |
FILE *fp; |
40 |
> |
register FILE *fp; |
41 |
|
{ |
42 |
+ |
int quote; |
43 |
+ |
|
44 |
|
while (ac-- > 0) { |
45 |
< |
fputs(*av++, fp); |
45 |
> |
if (index(*av, ' ') != NULL) { /* quote it */ |
46 |
> |
if (index(*av, '\'') != NULL) |
47 |
> |
quote = '"'; |
48 |
> |
else |
49 |
> |
quote = '\''; |
50 |
> |
putc(quote, fp); |
51 |
> |
fputs(*av++, fp); |
52 |
> |
putc(quote, fp); |
53 |
> |
} else |
54 |
> |
fputs(*av++, fp); |
55 |
|
putc(' ', fp); |
56 |
|
} |
57 |
|
putc('\n', fp); |