aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorDavid J. MacKenzie1994-12-21 15:58:28 +0000
committerDavid J. MacKenzie1994-12-21 15:58:28 +0000
commitb3dcbddbfc673d8b2361ffc7af09e22875e1e0a4 (patch)
treee9a4e4b387b431b0583086ba8ccbd9dcca455da4 /lib-src
parentdca5ea48d9293c3c097bda171f75074bd930bd32 (diff)
downloademacs-b3dcbddbfc673d8b2361ffc7af09e22875e1e0a4.tar.gz
emacs-b3dcbddbfc673d8b2361ffc7af09e22875e1e0a4.zip
Include program name in error messages.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/yow.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib-src/yow.c b/lib-src/yow.c
index 05ec9d43415..606074834cd 100644
--- a/lib-src/yow.c
+++ b/lib-src/yow.c
@@ -30,6 +30,11 @@
30 &res;}) 30 &res;})
31#endif 31#endif
32 32
33char *malloc(), *realloc();
34
35void yow();
36void setup_yow();
37
33int 38int
34main (argc, argv) 39main (argc, argv)
35 int argc; 40 int argc;
@@ -37,7 +42,6 @@ main (argc, argv)
37{ 42{
38 FILE *fp; 43 FILE *fp;
39 char file[BUFSIZ]; 44 char file[BUFSIZ];
40 void yow(), setup_yow();
41 45
42 if (argc > 2 && !strcmp (argv[1], "-f")) 46 if (argc > 2 && !strcmp (argv[1], "-f"))
43 strcpy (file, argv[2]); 47 strcpy (file, argv[2]);
@@ -49,6 +53,7 @@ main (argc, argv)
49#endif 53#endif
50 54
51 if ((fp = fopen(file, "r")) == NULL) { 55 if ((fp = fopen(file, "r")) == NULL) {
56 fprintf(stderr, "yow: ");
52 perror(file); 57 perror(file);
53 exit(1); 58 exit(1);
54 } 59 }
@@ -80,7 +85,7 @@ setup_yow(fp)
80 * we explicitly skip that. */ 85 * we explicitly skip that. */
81 while ((c = getc(fp)) != SEP) { 86 while ((c = getc(fp)) != SEP) {
82 if (c == EOF) { 87 if (c == EOF) {
83 fprintf(stderr, "File contains no separators.\n"); 88 fprintf(stderr, "yow: file contains no separators\n");
84 exit(2); 89 exit(2);
85 } 90 }
86 } 91 }
@@ -89,7 +94,7 @@ setup_yow(fp)
89 header_len -= AVG_LEN; /* allow the first quotation to appear */ 94 header_len -= AVG_LEN; /* allow the first quotation to appear */
90 95
91 if (fseek(fp, 0L, 2) == -1) { 96 if (fseek(fp, 0L, 2) == -1) {
92 perror("fseek 1"); 97 perror("yow");
93 exit(1); 98 exit(1);
94 } 99 }
95 len = ftell(fp) - header_len; 100 len = ftell(fp) - header_len;
@@ -105,11 +110,10 @@ yow (fp)
105 int c, i = 0; 110 int c, i = 0;
106 char *buf; 111 char *buf;
107 unsigned int bufsize; 112 unsigned int bufsize;
108 char *malloc(), *realloc();
109 113
110 offset = rand() % len + header_len; 114 offset = rand() % len + header_len;
111 if (fseek(fp, offset, 0) == -1) { 115 if (fseek(fp, offset, 0) == -1) {
112 perror("fseek 2"); 116 perror("yow");
113 exit(1); 117 exit(1);
114 } 118 }
115 119
@@ -134,7 +138,7 @@ yow (fp)
134 bufsize = BUFSIZE; 138 bufsize = BUFSIZE;
135 buf = malloc(bufsize); 139 buf = malloc(bufsize);
136 if (buf == (char *)0) { 140 if (buf == (char *)0) {
137 fprintf(stderr, "can't allocate any memory\n"); 141 fprintf(stderr, "yow: virtual memory exhausted\n");
138 exit (3); 142 exit (3);
139 } 143 }
140 144
@@ -147,7 +151,7 @@ yow (fp)
147 bufsize *= 2; 151 bufsize *= 2;
148 buf = realloc(buf, bufsize); 152 buf = realloc(buf, bufsize);
149 if (buf == (char *)0) { 153 if (buf == (char *)0) {
150 fprintf(stderr, "can't allocate more memory\n"); 154 fprintf(stderr, "yow: virtual memory exhausted\n");
151 exit (3); 155 exit (3);
152 } 156 }
153 } 157 }