--- ray/src/util/getinfo.c 2016/03/06 01:13:18 2.13 +++ ray/src/util/getinfo.c 2018/03/20 18:18:39 2.16 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: getinfo.c,v 2.13 2016/03/06 01:13:18 schorsch Exp $"; +static const char RCSid[] = "$Id: getinfo.c,v 2.16 2018/03/20 18:18:39 greg Exp $"; #endif /* * getinfo.c - program to read info. header from file. @@ -11,20 +11,18 @@ static const char RCSid[] = "$Id: getinfo.c,v 2.13 201 #include #include "platform.h" +#include "rtprocess.h" #include "resolu.h" #ifdef getc_unlocked /* avoid nasty file-locking overhead */ +#undef getc #undef getchar #undef putchar +#define getc getc_unlocked #define getchar getchar_unlocked #define putchar putchar_unlocked #endif -#if defined(_WIN32) || defined(_WIN64) -#include -#define execvp _execvp -#endif - static gethfunc tabstr; static void getdim(FILE *fp); static void copycat(void); @@ -71,6 +69,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); @@ -151,6 +163,6 @@ copycat(void) /* copy input to output */ 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; }