/[emacs]/emacs/lib-src/yow.c
ViewVC logotype

Diff of /emacs/lib-src/yow.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by pj, Sat Dec 29 22:24:28 2001 UTC revision 1.15.4.1 by miles, Fri Apr 4 06:19:55 2003 UTC
# Line 1  Line 1 
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    
# Line 16  Line 16 
16    
17  #include <stdio.h>  #include <stdio.h>
18  #include <ctype.h>  #include <ctype.h>
 #ifdef HAVE_STRING_H  
 #include <string.h>  
 #endif  
19  #ifdef TIME_WITH_SYS_TIME  #ifdef TIME_WITH_SYS_TIME
20  #include <sys/time.h>  #include <sys/time.h>
21  #include <time.h>  #include <time.h>
# Line 53  Line 50 
50      &res;})      &res;})
51  #endif  #endif
52    
 #ifndef HAVE_STDLIB_H  
 char *malloc __P ((size_t size))), *realloc __P ((POINTER_TYPE *ptr, size_t size));  
 #endif  
   
53  void yow();  void yow();
54  void setup_yow();  void setup_yow();
55    
# Line 117  setup_yow(fp) Line 110  setup_yow(fp)
110    header_len = ftell(fp);    header_len = ftell(fp);
111    if (header_len > AVG_LEN)    if (header_len > AVG_LEN)
112      header_len -= AVG_LEN;      /* allow the first quotation to appear */      header_len -= AVG_LEN;      /* allow the first quotation to appear */
113            
114    if (fseek(fp, 0L, 2) == -1) {    if (fseek(fp, 0L, 2) == -1) {
115      perror("yow");      perror("yow");
116      exit(1);      exit(1);
# Line 161  yow (fp) Line 154  yow (fp)
154    }    }
155    
156    bufsize = BUFSIZE;    bufsize = BUFSIZE;
157    buf = malloc(bufsize);    buf = (char *) malloc(bufsize);
158    if (buf == (char *)0) {    if (buf == (char *)0) {
159      fprintf(stderr, "yow: virtual memory exhausted\n");      fprintf(stderr, "yow: virtual memory exhausted\n");
160      exit (3);      exit (3);
# Line 170  yow (fp) Line 163  yow (fp)
163    buf[i++] = c;    buf[i++] = c;
164    while ((c = getc(fp)) != SEP && c != EOF) {    while ((c = getc(fp)) != SEP && c != EOF) {
165      buf[i++] = c;      buf[i++] = c;
166            
167      if (i == bufsize-1) {      if (i == bufsize-1) {
168        /* Yow! Is this quotation too long yet? */        /* Yow! Is this quotation too long yet? */
169        bufsize *= 2;        bufsize *= 2;
170        buf = realloc(buf, bufsize);        buf = (char *) realloc(buf, bufsize);
171        if (buf == (char *)0) {        if (buf == (char *)0) {
172          fprintf(stderr, "yow: virtual memory exhausted\n");          fprintf(stderr, "yow: virtual memory exhausted\n");
173          exit (3);          exit (3);

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.15.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26