1 |
/* |
/* |
2 |
* yow.c |
* yow.c |
3 |
* |
* |
4 |
* Print a quotation from Zippy the Pinhead. |
* Print a quotation from Zippy the Pinhead. |
5 |
* Qux <Kaufman-David@Yale> March 6, 1986 |
* Qux <Kaufman-David@Yale> March 6, 1986 |
6 |
* |
* |
7 |
* This file is in the public domain because the author published it |
* This file is in the public domain because the author published it |
8 |
* with no copyright notice before the US signed the Bern Convention. |
* with no copyright notice before the US signed the Bern Convention. |
9 |
* |
* |
10 |
* With dynamic memory allocation. |
* With dynamic memory allocation. |
11 |
*/ |
*/ |
12 |
|
|
114 |
header_len = ftell(fp); |
header_len = ftell(fp); |
115 |
if (header_len > AVG_LEN) |
if (header_len > AVG_LEN) |
116 |
header_len -= AVG_LEN; /* allow the first quotation to appear */ |
header_len -= AVG_LEN; /* allow the first quotation to appear */ |
117 |
|
|
118 |
if (fseek(fp, 0L, 2) == -1) { |
if (fseek(fp, 0L, 2) == -1) { |
119 |
perror("yow"); |
perror("yow"); |
120 |
exit(1); |
exit(1); |
167 |
buf[i++] = c; |
buf[i++] = c; |
168 |
while ((c = getc(fp)) != SEP && c != EOF) { |
while ((c = getc(fp)) != SEP && c != EOF) { |
169 |
buf[i++] = c; |
buf[i++] = c; |
170 |
|
|
171 |
if (i == bufsize-1) { |
if (i == bufsize-1) { |
172 |
/* Yow! Is this quotation too long yet? */ |
/* Yow! Is this quotation too long yet? */ |
173 |
bufsize *= 2; |
bufsize *= 2; |