20 |
|
#define putchar putchar_unlocked |
21 |
|
#endif |
22 |
|
|
23 |
< |
#ifdef _WIN32 |
23 |
> |
#if defined(_WIN32) || defined(_WIN64) |
24 |
> |
#include <process.h> |
25 |
|
#define execvp _execvp |
26 |
|
#endif |
27 |
|
|
63 |
|
} else if (argc > 2 && !strcmp(argv[1], "-c")) { |
64 |
|
SET_FILE_BINARY(stdin); |
65 |
|
SET_FILE_BINARY(stdout); |
66 |
+ |
setvbuf(stdin, NULL, _IONBF, 2); |
67 |
|
getheader(stdin, (gethfunc *)fputs, stdout); |
68 |
|
printargs(argc-2, argv+2, stdout); |
69 |
|
fputc('\n', stdout); |
71 |
|
execvp(argv[2], argv+2); |
72 |
|
perror(argv[2]); |
73 |
|
return 1; |
74 |
+ |
} else if (argc > 2 && !strcmp(argv[1], "-a")) { |
75 |
+ |
SET_FILE_BINARY(stdin); |
76 |
+ |
SET_FILE_BINARY(stdout); |
77 |
+ |
getheader(stdin, (gethfunc *)fputs, stdout); |
78 |
+ |
for (i = 2; i < argc; i++) { |
79 |
+ |
int len = strlen(argv[i]); |
80 |
+ |
if (!len) continue; |
81 |
+ |
fputs(argv[i], stdout); |
82 |
+ |
if (argv[i][len-1] != '\n') |
83 |
+ |
fputc('\n', stdout); |
84 |
+ |
} |
85 |
+ |
fputc('\n', stdout); |
86 |
+ |
copycat(); |
87 |
+ |
return 0; |
88 |
|
} else if (argc == 2 && !strcmp(argv[1], "-")) { |
89 |
|
SET_FILE_BINARY(stdin); |
90 |
|
SET_FILE_BINARY(stdout); |
161 |
|
copycat(void) /* copy input to output */ |
162 |
|
{ |
163 |
|
char buf[8192]; |
164 |
< |
ssize_t n; |
164 |
> |
int n; |
165 |
|
|
166 |
|
fflush(stdout); |
167 |
|
while ((n = fread(buf, 1, sizeof(buf), stdin)) > 0) |