aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/b2m.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib-src/b2m.c')
-rw-r--r--lib-src/b2m.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/lib-src/b2m.c b/lib-src/b2m.c
index 7de48e6a522..803d75e233c 100644
--- a/lib-src/b2m.c
+++ b/lib-src/b2m.c
@@ -64,12 +64,13 @@ struct linebuffer
64 char *buffer; 64 char *buffer;
65}; 65};
66 66
67extern char *strtok(); 67extern char *strtok(char *, const char *);
68 68
69long *xmalloc (), *xrealloc (); 69long *xmalloc (unsigned int size);
70char *concat (); 70long *xrealloc (char *ptr, unsigned int size);
71long readline (); 71char *concat (const char *s1, const char *s2, const char *s3);
72void fatal (); 72long readline (struct linebuffer *linebuffer, register FILE *stream);
73void fatal (const char *message) NO_RETURN;
73 74
74/* 75/*
75 * xnew -- allocate storage. SYNOPSIS: Type *xnew (int n, Type); 76 * xnew -- allocate storage. SYNOPSIS: Type *xnew (int n, Type);
@@ -90,9 +91,7 @@ struct option longopts[] =
90extern int optind; 91extern int optind;
91 92
92int 93int
93main (argc, argv) 94main (int argc, char **argv)
94 int argc;
95 char **argv;
96{ 95{
97 logical labels_saved, printing, header, first, last_was_blank_line; 96 logical labels_saved, printing, header, first, last_was_blank_line;
98 time_t ltoday; 97 time_t ltoday;
@@ -171,6 +170,7 @@ main (argc, argv)
171 continue; 170 continue;
172 else if (data.buffer[1] == '\f') 171 else if (data.buffer[1] == '\f')
173 { 172 {
173 static char babyl[] = "X-Babyl-Labels: ";
174 if (first) 174 if (first)
175 first = FALSE; 175 first = FALSE;
176 else if (! last_was_blank_line) 176 else if (! last_was_blank_line)
@@ -178,7 +178,7 @@ main (argc, argv)
178 /* Save labels. */ 178 /* Save labels. */
179 readline (&data, stdin); 179 readline (&data, stdin);
180 p = strtok (data.buffer, " ,\r\n\t"); 180 p = strtok (data.buffer, " ,\r\n\t");
181 labels = "X-Babyl-Labels: "; 181 labels = babyl;
182 182
183 while ((p = strtok (NULL, " ,\r\n\t"))) 183 while ((p = strtok (NULL, " ,\r\n\t")))
184 labels = concat (labels, p, ", "); 184 labels = concat (labels, p, ", ");
@@ -219,8 +219,7 @@ main (argc, argv)
219 * concatenate those of s1, s2, s3. 219 * concatenate those of s1, s2, s3.
220 */ 220 */
221char * 221char *
222concat (s1, s2, s3) 222concat (const char *s1, const char *s2, const char *s3)
223 char *s1, *s2, *s3;
224{ 223{
225 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); 224 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
226 char *result = xnew (len1 + len2 + len3 + 1, char); 225 char *result = xnew (len1 + len2 + len3 + 1, char);
@@ -239,9 +238,7 @@ concat (s1, s2, s3)
239 * which is the length of the line including the newline, if any. 238 * which is the length of the line including the newline, if any.
240 */ 239 */
241long 240long
242readline (linebuffer, stream) 241readline (struct linebuffer *linebuffer, register FILE *stream)
243 struct linebuffer *linebuffer;
244 register FILE *stream;
245{ 242{
246 char *buffer = linebuffer->buffer; 243 char *buffer = linebuffer->buffer;
247 register char *p = linebuffer->buffer; 244 register char *p = linebuffer->buffer;
@@ -291,8 +288,7 @@ readline (linebuffer, stream)
291 * Like malloc but get fatal error if memory is exhausted. 288 * Like malloc but get fatal error if memory is exhausted.
292 */ 289 */
293long * 290long *
294xmalloc (size) 291xmalloc (unsigned int size)
295 unsigned int size;
296{ 292{
297 long *result = (long *) malloc (size); 293 long *result = (long *) malloc (size);
298 if (result == NULL) 294 if (result == NULL)
@@ -301,9 +297,7 @@ xmalloc (size)
301} 297}
302 298
303long * 299long *
304xrealloc (ptr, size) 300xrealloc (char *ptr, unsigned int size)
305 char *ptr;
306 unsigned int size;
307{ 301{
308 long *result = (long *) realloc (ptr, size); 302 long *result = (long *) realloc (ptr, size);
309 if (result == NULL) 303 if (result == NULL)
@@ -312,8 +306,7 @@ xrealloc (ptr, size)
312} 306}
313 307
314void 308void
315fatal (message) 309fatal (const char *message)
316 char *message;
317{ 310{
318 fprintf (stderr, "%s: %s\n", progname, message); 311 fprintf (stderr, "%s: %s\n", progname, message);
319 exit (EXIT_FAILURE); 312 exit (EXIT_FAILURE);