comparison lib-src/yow.c @ 90185:5b029ff3b08d

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-55 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 320-323) - Update from CVS
author Miles Bader <miles@gnu.org>
date Thu, 26 May 2005 05:42:19 +0000
parents 4c90ffeb71c5 00adf45090ee
children 2ecafc6d5db7
comparison
equal deleted inserted replaced
90184:9e5e2f01c7ab 90185:5b029ff3b08d
102 * thus biasing our search in favor of the first quotation in the file, 102 * thus biasing our search in favor of the first quotation in the file,
103 * we explicitly skip that. */ 103 * we explicitly skip that. */
104 while ((c = getc(fp)) != SEP) { 104 while ((c = getc(fp)) != SEP) {
105 if (c == EOF) { 105 if (c == EOF) {
106 fprintf(stderr, "yow: file contains no separators\n"); 106 fprintf(stderr, "yow: file contains no separators\n");
107 exit(2); 107 exit(EXIT_FAILURE);
108 } 108 }
109 } 109 }
110 header_len = ftell(fp); 110 header_len = ftell(fp);
111 if (header_len > AVG_LEN) 111 if (header_len > AVG_LEN)
112 header_len -= AVG_LEN; /* allow the first quotation to appear */ 112 header_len -= AVG_LEN; /* allow the first quotation to appear */
155 155
156 bufsize = BUFSIZE; 156 bufsize = BUFSIZE;
157 buf = (char *) malloc(bufsize); 157 buf = (char *) malloc(bufsize);
158 if (buf == (char *)0) { 158 if (buf == (char *)0) {
159 fprintf(stderr, "yow: virtual memory exhausted\n"); 159 fprintf(stderr, "yow: virtual memory exhausted\n");
160 exit (3); 160 exit (EXIT_FAILURE);
161 } 161 }
162 162
163 buf[i++] = c; 163 buf[i++] = c;
164 while ((c = getc(fp)) != SEP && c != EOF) { 164 while ((c = getc(fp)) != SEP && c != EOF) {
165 buf[i++] = c; 165 buf[i++] = c;
168 /* Yow! Is this quotation too long yet? */ 168 /* Yow! Is this quotation too long yet? */
169 bufsize *= 2; 169 bufsize *= 2;
170 buf = (char *) realloc(buf, bufsize); 170 buf = (char *) realloc(buf, bufsize);
171 if (buf == (char *)0) { 171 if (buf == (char *)0) {
172 fprintf(stderr, "yow: virtual memory exhausted\n"); 172 fprintf(stderr, "yow: virtual memory exhausted\n");
173 exit (3); 173 exit (EXIT_FAILURE);
174 } 174 }
175 } 175 }
176 } 176 }
177 buf[i++] = 0; 177 buf[i++] = 0;
178 printf("%s\n", buf); 178 printf("%s\n", buf);