142 |
|
return(ST_NONE); |
143 |
|
} |
144 |
|
|
145 |
+ |
/* Check if any of the characters in str2 are found in str1 */ |
146 |
+ |
static int |
147 |
+ |
matchany(const char *str1, const char *str2) |
148 |
+ |
{ |
149 |
+ |
while (*str1) { |
150 |
+ |
const char *cp = str2; |
151 |
+ |
while (*cp) |
152 |
+ |
if (*cp++ == *str1) |
153 |
+ |
return(*str1); |
154 |
+ |
++str1; |
155 |
+ |
} |
156 |
+ |
return(0); |
157 |
+ |
} |
158 |
+ |
|
159 |
|
/* Add arguments to oconv command */ |
160 |
|
static char * |
161 |
|
oconv_command(int ac, char *av[]) |
170 |
|
strcpy(cp, *av++); |
171 |
|
while (*cp) cp++; |
172 |
|
*cp++ = ' '; |
173 |
< |
if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) { |
174 |
< |
fputs(progname, stderr); |
161 |
< |
fputs(": too many file arguments!\n", stderr); |
162 |
< |
exit(1); |
163 |
< |
} |
173 |
> |
if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) |
174 |
> |
goto overrun; |
175 |
|
} |
176 |
< |
strcpy(cp, recv); /* receiver goes last */ |
176 |
> |
/* receiver goes last */ |
177 |
> |
if (matchany(recv, SPECIALS)) { |
178 |
> |
*cp++ = QUOTCHAR; |
179 |
> |
while (*recv) { |
180 |
> |
if (cp >= oconvbuf+(sizeof(oconvbuf)-3)) |
181 |
> |
goto overrun; |
182 |
> |
*cp++ = *recv++; |
183 |
> |
} |
184 |
> |
*cp++ = QUOTCHAR; |
185 |
> |
*cp = '\0'; |
186 |
> |
} else |
187 |
> |
strcpy(cp, recv); |
188 |
|
return(oconvbuf); |
189 |
+ |
overrun: |
190 |
+ |
fputs(progname, stderr); |
191 |
+ |
fputs(": too many file arguments!\n", stderr); |
192 |
+ |
exit(1); |
193 |
|
} |
194 |
|
|
169 |
– |
/* Check if any of the characters in str2 are found in str1 */ |
170 |
– |
static int |
171 |
– |
matchany(const char *str1, const char *str2) |
172 |
– |
{ |
173 |
– |
while (*str1) { |
174 |
– |
const char *cp = str2; |
175 |
– |
while (*cp) |
176 |
– |
if (*cp++ == *str1) |
177 |
– |
return(*str1); |
178 |
– |
++str1; |
179 |
– |
} |
180 |
– |
return(0); |
181 |
– |
} |
182 |
– |
|
183 |
– |
|
195 |
|
/* Convert a set of arguments into a command line for pipe() or system() */ |
196 |
|
static char * |
197 |
|
convert_commandline(char *cmd, const int len, char *av[]) |
205 |
|
fputs(progname, stderr); |
206 |
|
return(NULL); |
207 |
|
} |
208 |
< |
if ((match = matchany(*av, SPECIALS))) { |
208 |
> |
if (matchany(*av, SPECIALS)) { |
209 |
|
const int quote = |
210 |
|
#ifdef ALTQUOT |
211 |
< |
(match == QUOTCHAR) ? ALTQUOT : |
211 |
> |
strchr(*av, QUOTCHAR) ? ALTQUOT : |
212 |
|
#endif |
213 |
|
QUOTCHAR; |
214 |
|
*cp++ = quote; |