Mercurial > emacs
comparison lib-src/yow.c @ 62694:00adf45090ee
(setup_yow): Use EXIT_FAILURE in case no separators found.
(yow): Use EXIT_FAILURE in case of memory error.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Wed, 25 May 2005 14:16:31 +0000 |
parents | a47704955f8d |
children | 1a11061f92fa 5b029ff3b08d |
comparison
equal
deleted
inserted
replaced
62693:368b11560704 | 62694:00adf45090ee |
---|---|
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); |