--- ray/src/util/getinfo.c 2014/07/28 17:25:03 2.10 +++ ray/src/util/getinfo.c 2016/08/30 06:10:12 2.14 @@ -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.14 2016/08/30 06:10:12 greg Exp $"; #endif /* * getinfo.c - program to read info. header from file. @@ -20,7 +20,8 @@ static const char RCSid[] = "$Id: getinfo.c,v 2.10 201 #define putchar putchar_unlocked #endif -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) +#include #define execvp _execvp #endif @@ -62,6 +63,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 +71,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,7 +161,7 @@ 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)