--- ray/src/util/getinfo.c 2014/07/28 17:25:03 2.10 +++ ray/src/util/getinfo.c 2018/03/20 17:48:16 2.15 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: getinfo.c,v 2.10 2014/07/28 17:25:03 greg Exp $"; +static const char RCSid[] = "$Id: getinfo.c,v 2.15 2018/03/20 17:48:16 greg Exp $"; #endif /* * getinfo.c - program to read info. header from file. @@ -11,6 +11,7 @@ static const char RCSid[] = "$Id: getinfo.c,v 2.10 201 #include #include "platform.h" +#include "rtprocess.h" #include "resolu.h" #ifdef getc_unlocked /* avoid nasty file-locking overhead */ @@ -20,10 +21,6 @@ static const char RCSid[] = "$Id: getinfo.c,v 2.10 201 #define putchar putchar_unlocked #endif -#ifdef _WIN32 -#define execvp _execvp -#endif - static gethfunc tabstr; static void getdim(FILE *fp); static void copycat(void); @@ -62,6 +59,7 @@ main( } else if (argc > 2 && !strcmp(argv[1], "-c")) { SET_FILE_BINARY(stdin); SET_FILE_BINARY(stdout); + setvbuf(stdin, NULL, _IONBF, 2); getheader(stdin, (gethfunc *)fputs, stdout); printargs(argc-2, argv+2, stdout); fputc('\n', stdout); @@ -69,6 +67,20 @@ main( execvp(argv[2], argv+2); perror(argv[2]); return 1; + } else if (argc > 2 && !strcmp(argv[1], "-a")) { + SET_FILE_BINARY(stdin); + SET_FILE_BINARY(stdout); + getheader(stdin, (gethfunc *)fputs, stdout); + for (i = 2; i < argc; i++) { + int len = strlen(argv[i]); + if (!len) continue; + fputs(argv[i], stdout); + if (argv[i][len-1] != '\n') + fputc('\n', stdout); + } + fputc('\n', stdout); + copycat(); + return 0; } else if (argc == 2 && !strcmp(argv[1], "-")) { SET_FILE_BINARY(stdin); SET_FILE_BINARY(stdout); @@ -145,10 +157,10 @@ static void copycat(void) /* copy input to output */ { char buf[8192]; - ssize_t n; + int n; fflush(stdout); while ((n = fread(buf, 1, sizeof(buf), stdin)) > 0) - if (write(fileno(stdout), buf, n) != n) + if (writebuf(fileno(stdout), buf, n) != n) break; }