| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | /* $OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $ */ | | 1 | /* $OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $ */ |
2 | /* $NetBSD: main.c,v 1.45 2016/01/16 21:12:27 christos Exp $ */ | | 2 | /* $NetBSD: main.c,v 1.46 2016/01/23 14:24:43 christos Exp $ */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 1989, 1993 | | 5 | * Copyright (c) 1989, 1993 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * Ozan Yigit at York University. | | 9 | * Ozan Yigit at York University. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
15 | * notice, this list of conditions and the following disclaimer. | | 15 | * notice, this list of conditions and the following disclaimer. |
| @@ -32,27 +32,27 @@ | | | @@ -32,27 +32,27 @@ |
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
33 | * SUCH DAMAGE. | | 33 | * SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | /* | | 36 | /* |
37 | * main.c | | 37 | * main.c |
38 | * Facility: m4 macro processor | | 38 | * Facility: m4 macro processor |
39 | * by: oz | | 39 | * by: oz |
40 | */ | | 40 | */ |
41 | #if HAVE_NBTOOL_CONFIG_H | | 41 | #if HAVE_NBTOOL_CONFIG_H |
42 | #include "nbtool_config.h" | | 42 | #include "nbtool_config.h" |
43 | #endif | | 43 | #endif |
44 | #include <sys/cdefs.h> | | 44 | #include <sys/cdefs.h> |
45 | __RCSID("$NetBSD: main.c,v 1.45 2016/01/16 21:12:27 christos Exp $"); | | 45 | __RCSID("$NetBSD: main.c,v 1.46 2016/01/23 14:24:43 christos Exp $"); |
46 | #include <assert.h> | | 46 | #include <assert.h> |
47 | #include <signal.h> | | 47 | #include <signal.h> |
48 | #include <getopt.h> | | 48 | #include <getopt.h> |
49 | #include <err.h> | | 49 | #include <err.h> |
50 | #include <errno.h> | | 50 | #include <errno.h> |
51 | #include <unistd.h> | | 51 | #include <unistd.h> |
52 | #include <stdio.h> | | 52 | #include <stdio.h> |
53 | #include <ctype.h> | | 53 | #include <ctype.h> |
54 | #include <string.h> | | 54 | #include <string.h> |
55 | #include <stddef.h> | | 55 | #include <stddef.h> |
56 | #include <stdint.h> | | 56 | #include <stdint.h> |
57 | #include <stdlib.h> | | 57 | #include <stdlib.h> |
58 | #include <ohash.h> | | 58 | #include <ohash.h> |
| @@ -315,26 +315,31 @@ main(int argc, char *argv[]) | | | @@ -315,26 +315,31 @@ main(int argc, char *argv[]) |
315 | fprintf(stderr, "%s version %d\n", getprogname(), | | 315 | fprintf(stderr, "%s version %d\n", getprogname(), |
316 | VERSION); | | 316 | VERSION); |
317 | return EXIT_SUCCESS; | | 317 | return EXIT_SUCCESS; |
318 | case OPT_HELP: | | 318 | case OPT_HELP: |
319 | help(); | | 319 | help(); |
320 | return EXIT_SUCCESS; | | 320 | return EXIT_SUCCESS; |
321 | case '?': | | 321 | case '?': |
322 | default: | | 322 | default: |
323 | usage(stderr); | | 323 | usage(stderr); |
324 | return EXIT_FAILURE; | | 324 | return EXIT_FAILURE; |
325 | } | | 325 | } |
326 | | | 326 | |
327 | #ifdef REDIRECT | | 327 | #ifdef REDIRECT |
| | | 328 | /* |
| | | 329 | * This is meant only for debugging; it makes all output |
| | | 330 | * go to a known file, even if the command line options |
| | | 331 | * send it elsewhere. It should not be turned of in production code. |
| | | 332 | */ |
328 | if (freopen("/tmp/m4", "w+", stderr) == NULL) | | 333 | if (freopen("/tmp/m4", "w+", stderr) == NULL) |
329 | err(EXIT_FAILURE, "Can't redirect errors to `%s'", | | 334 | err(EXIT_FAILURE, "Can't redirect errors to `%s'", |
330 | "/tmp/m4"); | | 335 | "/tmp/m4"); |
331 | #endif | | 336 | #endif |
332 | argc -= optind; | | 337 | argc -= optind; |
333 | argv += optind; | | 338 | argv += optind; |
334 | | | 339 | |
335 | | | 340 | |
336 | initkwds(); | | 341 | initkwds(); |
337 | if (mimic_gnu) | | 342 | if (mimic_gnu) |
338 | setup_builtin("format", FORMATTYPE); | | 343 | setup_builtin("format", FORMATTYPE); |
339 | | | 344 | |
340 | active = stdout; /* default active output */ | | 345 | active = stdout; /* default active output */ |