Remove the advertising clause and appease the eye a bit (still not good, but better). Almost no functional change.diff -r1.8 -r1.9 src/usr.bin/menuc/defs.h
(mbalmer)
--- src/usr.bin/menuc/defs.h 2003/10/27 00:12:43 1.8
+++ src/usr.bin/menuc/defs.h 2012/03/06 16:55:18 1.9
@@ -1,34 +1,30 @@ | @@ -1,34 +1,30 @@ | |||
1 | /* $NetBSD: defs.h,v 1.8 2003/10/27 00:12:43 lukem Exp $ */ | 1 | /* $NetBSD: defs.h,v 1.9 2012/03/06 16:55:18 mbalmer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | 17 | * 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
18 | * must display the following acknowledgement: | |||
19 | * This product includes software develooped for the NetBSD Project by | |||
20 | * Piermont Information Systems Inc. | |||
21 | * 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
22 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior | |
23 | * written permission. | 19 | * written permission. | |
24 | * | 20 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 21 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
--- src/usr.bin/menuc/mdb.h 2006/02/20 21:06:40 1.8
+++ src/usr.bin/menuc/mdb.h 2012/03/06 16:55:18 1.9
@@ -1,34 +1,30 @@ | @@ -1,34 +1,30 @@ | |||
1 | /* $NetBSD: mdb.h,v 1.8 2006/02/20 21:06:40 dsl Exp $ */ | 1 | /* $NetBSD: mdb.h,v 1.9 2012/03/06 16:55:18 mbalmer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | 17 | * 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
18 | * must display the following acknowledgement: | |||
19 | * This product includes software develooped for the NetBSD Project by | |||
20 | * Piermont Information Systems Inc. | |||
21 | * 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
22 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior | |
23 | * written permission. | 19 | * written permission. | |
24 | * | 20 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 21 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
--- src/usr.bin/menuc/main.c 2004/06/20 22:20:16 1.10
+++ src/usr.bin/menuc/main.c 2012/03/06 16:55:18 1.11
@@ -1,124 +1,115 @@ | @@ -1,124 +1,115 @@ | |||
1 | /* $NetBSD: main.c,v 1.10 2004/06/20 22:20:16 jmc Exp $ */ | 1 | /* $NetBSD: main.c,v 1.11 2012/03/06 16:55:18 mbalmer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | 17 | * 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
18 | * must display the following acknowledgement: | |||
19 | * This product includes software develooped for the NetBSD Project by | |||
20 | * Piermont Information Systems Inc. | |||
21 | * 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
22 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior | |
23 | * written permission. | 19 | * written permission. | |
24 | * | 20 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 21 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
35 | * THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THE POSSIBILITY OF SUCH DAMAGE. | |
36 | * | 32 | * | |
37 | */ | 33 | */ | |
38 | 34 | |||
39 | /* main.c - main program for menu compiler. */ | 35 | /* main.c - main program for menu compiler. */ | |
40 | 36 | |||
41 | #if HAVE_NBTOOL_CONFIG_H | 37 | #if HAVE_NBTOOL_CONFIG_H | |
42 | #include "nbtool_config.h" | 38 | #include "nbtool_config.h" | |
43 | #endif | 39 | #endif | |
44 | 40 | |||
45 | #include <sys/cdefs.h> | 41 | #include <sys/cdefs.h> | |
46 | 42 | |||
47 | #if defined(__RCSID) && !defined(lint) | 43 | #if defined(__RCSID) && !defined(lint) | |
48 | __RCSID("$NetBSD: main.c,v 1.10 2004/06/20 22:20:16 jmc Exp $"); | 44 | __RCSID("$NetBSD: main.c,v 1.11 2012/03/06 16:55:18 mbalmer Exp $"); | |
49 | #endif | 45 | #endif | |
50 | 46 | |||
51 | 47 | |||
52 | #include <stdio.h> | 48 | #include <stdio.h> | |
53 | #include <stdlib.h> | 49 | #include <stdlib.h> | |
54 | #include <unistd.h> | 50 | #include <unistd.h> | |
55 | 51 | |||
56 | #define MAIN | 52 | #define MAIN | |
57 | #include "defs.h" | 53 | #include "defs.h" | |
58 | 54 | |||
59 | /* Local prototypes */ | 55 | /* Local prototypes */ | |
60 | void usage (char *); | 56 | __dead void usage(void); | |
61 | 57 | |||
62 | int | 58 | int | |
63 | main (int argc, char **argv) | 59 | main(int argc, char **argv) | |
64 | { | 60 | { | |
65 | int ch; | 61 | int ch; | |
66 | 62 | |||
67 | prog_name = argv[0]; | |||
68 | ||||
69 | /* Process the arguments. */ | 63 | /* Process the arguments. */ | |
70 | while ( (ch = getopt (argc, argv, "o:")) != -1 ) { | 64 | while ((ch = getopt(argc, argv, "o:")) != -1 ) { | |
71 | switch (ch) { | 65 | switch (ch) { | |
72 | case 'o': /* output file name */ | 66 | case 'o': /* output file name */ | |
73 | out_name = optarg; | 67 | out_name = optarg; | |
74 | break; | 68 | break; | |
75 | default: | 69 | default: | |
76 | usage (prog_name); | 70 | usage(); | |
77 | } | 71 | } | |
78 | } | 72 | } | |
79 | 73 | |||
80 | if (optind != argc-1) | 74 | if (optind != argc - 1) | |
81 | usage (prog_name); | 75 | usage(); | |
82 | 76 | |||
83 | src_name = argv[optind]; | 77 | src_name = argv[optind]; | |
84 | 78 | |||
85 | yyin = fopen (src_name, "r"); | 79 | yyin = fopen(src_name, "r"); | |
86 | if (yyin == NULL) { | 80 | if (yyin == NULL) { | |
87 | (void) fprintf (stderr, "%s: could not open %s.\n", | 81 | (void)fprintf(stderr, "%s: could not open %s.\n", prog_name, | |
88 | prog_name, src_name); | 82 | src_name); | |
89 | exit (1); | 83 | exit(1); | |
90 | } | 84 | } | |
91 | 85 | |||
92 | /* The default menu */ | 86 | /* The default menu */ | |
93 | default_menu.info = &default_info; | 87 | default_menu.info = &default_info; | |
94 | default_info.title = "\"\""; | 88 | default_info.title = "\"\""; | |
95 | default_info.helpstr = NULL; | 89 | default_info.helpstr = NULL; | |
96 | default_info.exitstr = NULL; | 90 | default_info.exitstr = NULL; | |
97 | default_info.mopt = 0; | 91 | default_info.mopt = 0; | |
98 | default_info.x = -1; | 92 | default_info.x = -1; | |
99 | default_info.y = 0; | 93 | default_info.y = 0; | |
100 | default_info.h = 0; | 94 | default_info.h = 0; | |
101 | default_info.w = 0; | 95 | default_info.w = 0; | |
102 | default_info.numopt = 0; | 96 | default_info.numopt = 0; | |
103 | default_info.optns = NULL; | 97 | default_info.optns = NULL; | |
104 | default_info.postact.code = NULL; | 98 | default_info.postact.code = NULL; | |
105 | default_info.postact.endwin = FALSE; | 99 | default_info.postact.endwin = FALSE; | |
106 | default_info.exitact.code = NULL; | 100 | default_info.exitact.code = NULL; | |
107 | default_info.exitact.endwin = FALSE; | 101 | default_info.exitact.endwin = FALSE; | |
108 | 102 | |||
109 | /* Do the parse */ | 103 | /* Do the parse */ | |
110 | (void) yyparse (); | 104 | (void)yyparse(); | |
111 | 105 | |||
112 | if (had_errors) | 106 | return had_errors ? 1 : 0; | |
113 | return 1; | |||
114 | ||||
115 | return 0; | |||
116 | } | 107 | } | |
117 | 108 | |||
118 | 109 | |||
119 | void | 110 | __dead void | |
120 | usage (char *prog) | 111 | usage(void) | |
121 | { | 112 | { | |
122 | (void) fprintf (stderr, "%s [-o name] file\n", prog); | 113 | (void)fprintf (stderr, "%s [-o name] file\n", getprogname()); | |
123 | exit (1); | 114 | exit(1); | |
124 | } | 115 | } |
--- src/usr.bin/menuc/mdb.c 2011/09/06 18:16:38 1.45
+++ src/usr.bin/menuc/mdb.c 2012/03/06 16:55:18 1.46
@@ -1,176 +1,162 @@ | @@ -1,176 +1,162 @@ | |||
1 | /* $NetBSD: mdb.c,v 1.45 2011/09/06 18:16:38 joerg Exp $ */ | 1 | /* $NetBSD: mdb.c,v 1.46 2012/03/06 16:55:18 mbalmer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | 17 | * 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
18 | * must display the following acknowledgement: | |||
19 | * This product includes software develooped for the NetBSD Project by | |||
20 | * Piermont Information Systems Inc. | |||
21 | * 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
22 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior | |
23 | * written permission. | 19 | * written permission. | |
24 | * | 20 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 21 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
35 | * THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THE POSSIBILITY OF SUCH DAMAGE. | |
36 | * | 32 | * | |
37 | */ | 33 | */ | |
38 | 34 | |||
39 | /* mdb.c - menu database manipulation */ | 35 | /* mdb.c - menu database manipulation */ | |
40 | 36 | |||
41 | #if HAVE_NBTOOL_CONFIG_H | 37 | #if HAVE_NBTOOL_CONFIG_H | |
42 | #include "nbtool_config.h" | 38 | #include "nbtool_config.h" | |
43 | #endif | 39 | #endif | |
44 | 40 | |||
45 | #include <sys/cdefs.h> | 41 | #include <sys/cdefs.h> | |
46 | 42 | |||
47 | #if defined(__RCSID) && !defined(lint) | 43 | #if defined(__RCSID) && !defined(lint) | |
48 | __RCSID("$NetBSD: mdb.c,v 1.45 2011/09/06 18:16:38 joerg Exp $"); | 44 | __RCSID("$NetBSD: mdb.c,v 1.46 2012/03/06 16:55:18 mbalmer Exp $"); | |
49 | #endif | 45 | #endif | |
50 | 46 | |||
51 | 47 | |||
52 | #include <stdio.h> | 48 | #include <stdio.h> | |
53 | #include <stdlib.h> | 49 | #include <stdlib.h> | |
54 | #include <string.h> | 50 | #include <string.h> | |
55 | #include "mdb.h" | 51 | #include "mdb.h" | |
56 | #include "defs.h" | 52 | #include "defs.h" | |
57 | #include "pathnames.h" | 53 | #include "pathnames.h" | |
58 | 54 | |||
59 | /* Data */ | 55 | /* Data */ | |
60 | #undef MAX | 56 | #undef MAX | |
61 | #define MAX 1000 | 57 | #define MAX 1000 | |
62 | static int menu_no = 0; | 58 | static int menu_no = 0; | |
63 | static id_rec *menus[MAX]; | 59 | static id_rec *menus[MAX]; | |
64 | 60 | |||
65 | /* Other defines */ | 61 | /* Other defines */ | |
66 | #define OPT_SUB 1 | 62 | #define OPT_SUB 1 | |
67 | #define OPT_ENDWIN 2 | 63 | #define OPT_ENDWIN 2 | |
68 | #define OPT_EXIT 4 | 64 | #define OPT_EXIT 4 | |
69 | 65 | |||
70 | 66 | |||
71 | /* get_menu returns a pointer to a newly created id_rec or an old one. */ | 67 | /* get_menu returns a pointer to a newly created id_rec or an old one. */ | |
72 | 68 | |||
73 | id_rec * | 69 | id_rec * | |
74 | get_menu (char *name) | 70 | get_menu(char *name) | |
75 | { | 71 | { | |
76 | id_rec *temp; | 72 | id_rec *temp; | |
77 | 73 | |||
78 | temp = find_id (root, name); | 74 | temp = find_id (root, name); | |
79 | 75 | |||
80 | if (temp == NULL) { | 76 | if (temp == NULL) { | |
81 | if (menu_no < MAX) { | 77 | if (menu_no < MAX) { | |
82 | temp = (id_rec *) malloc (sizeof(id_rec)); | 78 | temp = (id_rec *)malloc(sizeof(id_rec)); | |
83 | temp->id = strdup(name); | 79 | temp->id = strdup(name); | |
84 | temp->info = NULL; | 80 | temp->info = NULL; | |
85 | temp->menu_no = menu_no; | 81 | temp->menu_no = menu_no; | |
86 | menus[menu_no++] = temp; | 82 | menus[menu_no++] = temp; | |
87 | insert_id (&root, temp); | 83 | insert_id(&root, temp); | |
88 | } else { | 84 | } else { | |
89 | (void) fprintf (stderr, "Too many menus. " | 85 | (void)fprintf(stderr, "Too many menus. " | |
90 | "Increase MAX.\n"); | 86 | "Increase MAX.\n"); | |
91 | exit(1); | 87 | exit(1); | |
92 | } | 88 | } | |
93 | } | 89 | } | |
94 | 90 | |||
95 | return temp; | 91 | return temp; | |
96 | } | 92 | } | |
97 | 93 | |||
98 | 94 | |||
99 | /* Verify that all menus are defined. */ | 95 | /* Verify that all menus are defined. */ | |
100 | ||||
101 | void | 96 | void | |
102 | check_defined (void) | 97 | check_defined(void) | |
103 | { | 98 | { | |
104 | int i; | 99 | int i; | |
105 | 100 | |||
106 | for (i=0; i<menu_no; i++) | 101 | for (i = 0; i < menu_no; i++) | |
107 | if (!menus[i]->info) | 102 | if (!menus[i]->info) | |
108 | yyerror ("Menu '%s' undefined.", menus[i]->id); | 103 | yyerror ("Menu '%s' undefined.", menus[i]->id); | |
109 | } | 104 | } | |
110 | 105 | |||
111 | 106 | |||
112 | /* Write out the menu file. */ | 107 | /* Write out the menu file. */ | |
113 | void | 108 | void | |
114 | write_menu_file (char *initcode) | 109 | write_menu_file(char *initcode) | |
115 | { | 110 | { | |
116 | FILE *out_file; | 111 | FILE *out_file, *sys_file; | |
117 | FILE *sys_file; | |||
118 | int i, j; | 112 | int i, j; | |
119 | char hname[1024]; | 113 | char hname[1024], cname[1024], sname[1024]; | |
120 | char cname[1024]; | 114 | char *sys_prefix, *tmpstr; | |
121 | char sname[1024]; | 115 | int name_is_code, nlen, ch; | |
122 | char *sys_prefix; | |||
123 | char *tmpstr; | |||
124 | int name_is_code; | |||
125 | ||||
126 | int nlen; | |||
127 | ||||
128 | int ch; | |||
129 | ||||
130 | optn_info *toptn; | 116 | optn_info *toptn; | |
131 | 117 | |||
132 | /* Generate file names */ | 118 | /* Generate file names */ | |
133 | snprintf (hname, 1024, "%s.h", out_name); | 119 | snprintf(hname, 1024, "%s.h", out_name); | |
134 | nlen = strlen(hname); | 120 | nlen = strlen(hname); | |
135 | if (hname[nlen-2] != '.' || hname[nlen-1] != 'h') { | 121 | if (hname[nlen-2] != '.' || hname[nlen-1] != 'h') { | |
136 | (void) fprintf (stderr, "%s: name `%s` too long.\n", | 122 | (void)fprintf(stderr, "%s: name `%s` too long.\n", | |
137 | prog_name, out_name); | 123 | prog_name, out_name); | |
138 | exit(1); | 124 | exit(1); | |
139 | } | 125 | } | |
140 | snprintf (cname, 1024, "%s.c", out_name); | 126 | snprintf(cname, 1024, "%s.c", out_name); | |
141 | 127 | |||
142 | /* Open the menu_sys file first. */ | 128 | /* Open the menu_sys file first. */ | |
143 | sys_prefix = getenv ("MENUDEF"); | 129 | sys_prefix = getenv("MENUDEF"); | |
144 | if (sys_prefix == NULL) | 130 | if (sys_prefix == NULL) | |
145 | sys_prefix = _PATH_DEFSYSPREFIX; | 131 | sys_prefix = _PATH_DEFSYSPREFIX; | |
146 | snprintf (sname, 1024, "%s/%s", sys_prefix, sys_name); | 132 | snprintf(sname, 1024, "%s/%s", sys_prefix, sys_name); | |
147 | sys_file = fopen (sname, "r"); | 133 | sys_file = fopen (sname, "r"); | |
148 | if (sys_file == NULL) { | 134 | if (sys_file == NULL) { | |
149 | (void) fprintf (stderr, "%s: could not open %s.\n", | 135 | (void)fprintf(stderr, "%s: could not open %s.\n", | |
150 | prog_name, sname); | 136 | prog_name, sname); | |
151 | exit (1); | 137 | exit(1); | |
152 | } | 138 | } | |
153 | 139 | |||
154 | /* Output the .h file first. */ | 140 | /* Output the .h file first. */ | |
155 | out_file = fopen (hname, "w"); | 141 | out_file = fopen(hname, "w"); | |
156 | if (out_file == NULL) { | 142 | if (out_file == NULL) { | |
157 | (void) fprintf (stderr, "%s: could not open %s.\n", | 143 | (void)fprintf(stderr, "%s: could not open %s.\n", | |
158 | prog_name, hname); | 144 | prog_name, hname); | |
159 | exit (1); | 145 | exit(1); | |
160 | } | 146 | } | |
161 | 147 | |||
162 | /* Write it */ | 148 | /* Write it */ | |
163 | (void) fprintf (out_file, "%s", | 149 | (void)fprintf(out_file, "%s", | |
164 | "/* menu system definitions. */\n" | 150 | "/* menu system definitions. */\n" | |
165 | "\n" | 151 | "\n" | |
166 | "#ifndef MENU_DEFS_H\n" | 152 | "#ifndef MENU_DEFS_H\n" | |
167 | "#define MENU_DEFS_H\n" | 153 | "#define MENU_DEFS_H\n" | |
168 | "#include <stdlib.h>\n" | 154 | "#include <stdlib.h>\n" | |
169 | "#include <string.h>\n" | 155 | "#include <string.h>\n" | |
170 | "#include <ctype.h>\n" | 156 | "#include <ctype.h>\n" | |
171 | "#include <curses.h>\n\n" | 157 | "#include <curses.h>\n\n" | |
172 | ); | 158 | ); | |
173 | 159 | |||
174 | if (do_msgxlat) | 160 | if (do_msgxlat) | |
175 | (void)fprintf(out_file, "#define MSG_XLAT(x) msg_string(x)\n"); | 161 | (void)fprintf(out_file, "#define MSG_XLAT(x) msg_string(x)\n"); | |
176 | else | 162 | else | |
@@ -218,237 +204,228 @@ write_menu_file (char *initcode) | @@ -218,237 +204,228 @@ write_menu_file (char *initcode) | |||
218 | MC_OPT(MC_NOEXITOPT) | 204 | MC_OPT(MC_NOEXITOPT) | |
219 | MC_OPT(MC_NOBOX) | 205 | MC_OPT(MC_NOBOX) | |
220 | MC_OPT(MC_SCROLL) | 206 | MC_OPT(MC_SCROLL) | |
221 | MC_OPT(MC_NOSHORTCUT) | 207 | MC_OPT(MC_NOSHORTCUT) | |
222 | MC_OPT(MC_NOCLEAR) | 208 | MC_OPT(MC_NOCLEAR) | |
223 | MC_OPT(MC_DFLTEXIT) | 209 | MC_OPT(MC_DFLTEXIT) | |
224 | MC_OPT(MC_ALWAYS_SCROLL) | 210 | MC_OPT(MC_ALWAYS_SCROLL) | |
225 | MC_OPT(MC_SUBMENU) | 211 | MC_OPT(MC_SUBMENU) | |
226 | MC_OPT(MC_VALID) | 212 | MC_OPT(MC_VALID) | |
227 | #undef MC_OPT | 213 | #undef MC_OPT | |
228 | #undef STR | 214 | #undef STR | |
229 | ); | 215 | ); | |
230 | 216 | |||
231 | (void) fprintf (out_file, "%s", | 217 | (void)fprintf(out_file, "%s", | |
232 | "\n" | 218 | "\n" | |
233 | "/* Prototypes */\n" | 219 | "/* Prototypes */\n" | |
234 | "int menu_init(void);\n" | 220 | "int menu_init(void);\n" | |
235 | "void process_menu(int, void *);\n" | 221 | "void process_menu(int, void *);\n" | |
236 | "__dead void __menu_initerror(void);\n" | 222 | "__dead void __menu_initerror(void);\n" | |
237 | ); | 223 | ); | |
238 | 224 | |||
239 | if (do_dynamic) | 225 | if (do_dynamic) | |
240 | (void) fprintf (out_file, "%s", | 226 | (void)fprintf(out_file, "%s", | |
241 | "int new_menu(const char *, menu_ent *, int, \n" | 227 | "int new_menu(const char *, menu_ent *, int, \n" | |
242 | "\tint, int, int, int, int,\n" | 228 | "\tint, int, int, int, int,\n" | |
243 | "\tvoid (*)(menudesc *, void *), " | 229 | "\tvoid (*)(menudesc *, void *), " | |
244 | "void (*)(menudesc *, int, void *),\n" | 230 | "void (*)(menudesc *, int, void *),\n" | |
245 | "\tvoid (*)(menudesc *, void *), " | 231 | "\tvoid (*)(menudesc *, void *), " | |
246 | "const char *, const char *);\n" | 232 | "const char *, const char *);\n" | |
247 | "void free_menu(int);\n" | 233 | "void free_menu(int);\n" | |
248 | "void set_menu_numopts(int, int);\n" | 234 | "void set_menu_numopts(int, int);\n" | |
249 | ); | 235 | ); | |
250 | 236 | |||
251 | (void) fprintf (out_file, "\n/* Menu names */\n"); | 237 | (void)fprintf(out_file, "\n/* Menu names */\n"); | |
252 | for (i=0; i<menu_no; i++) { | 238 | for (i = 0; i < menu_no; i++) | |
253 | (void) fprintf (out_file, "#define MENU_%s\t%d\n", | 239 | (void)fprintf(out_file, "#define MENU_%s\t%d\n", | |
254 | menus[i]->id, i); | 240 | menus[i]->id, i); | |
255 | } | |||
256 | 241 | |||
257 | if (do_dynamic) | 242 | if (do_dynamic) | |
258 | (void) fprintf (out_file, "\n#define DYN_MENU_START\t%d", | 243 | (void)fprintf(out_file, "\n#define DYN_MENU_START\t%d", | |
259 | menu_no); | 244 | menu_no); | |
260 | 245 | |||
261 | (void) fprintf (out_file, "\n#define MAX_STRLEN %d\n" | 246 | (void)fprintf (out_file, "\n#define MAX_STRLEN %d\n" | |
262 | "#endif\n", max_strlen); | 247 | "#endif\n", max_strlen); | |
263 | fclose (out_file); | 248 | fclose(out_file); | |
264 | 249 | |||
265 | /* Now the C file */ | 250 | /* Now the C file */ | |
266 | out_file = fopen (cname, "w"); | 251 | out_file = fopen(cname, "w"); | |
267 | if (out_file == NULL) { | 252 | if (out_file == NULL) { | |
268 | (void) fprintf (stderr, "%s: could not open %s.\n", | 253 | (void)fprintf(stderr, "%s: could not open %s.\n", | |
269 | prog_name, cname); | 254 | prog_name, cname); | |
270 | exit (1); | 255 | exit(1); | |
271 | } | 256 | } | |
272 | 257 | |||
273 | /* initial code */ | 258 | /* initial code */ | |
274 | fprintf (out_file, "#include \"%s\"\n\n", hname); | 259 | fprintf(out_file, "#include \"%s\"\n\n", hname); | |
275 | fprintf (out_file, "%s\n\n", initcode); | 260 | fprintf(out_file, "%s\n\n", initcode); | |
276 | 261 | |||
277 | /* data definitions */ | 262 | /* data definitions */ | |
278 | 263 | |||
279 | /* func defs */ | 264 | /* func defs */ | |
280 | for (i=0; i<menu_no; i++) { | 265 | for (i = 0; i < menu_no; i++) { | |
281 | if (strlen(menus[i]->info->postact.code)) { | 266 | if (strlen(menus[i]->info->postact.code)) { | |
282 | (void) fprintf (out_file, | 267 | (void)fprintf(out_file, "/*ARGSUSED*/\n" | |
283 | "/*ARGSUSED*/\n" | 268 | "static void menu_%d_postact(menudesc *menu, void *arg)\n{\n", i); | |
284 | "static void menu_%d_postact(menudesc *menu, void *arg)\n{\n", i); | |||
285 | if (menus[i]->info->postact.endwin) | 269 | if (menus[i]->info->postact.endwin) | |
286 | (void) fprintf (out_file, "\tendwin();\n"); | 270 | (void)fprintf(out_file, "\tendwin();\n"); | |
287 | (void) fprintf (out_file, | 271 | (void)fprintf(out_file, "\t%s\n}\n\n", | |
288 | "\t%s\n}\n\n", | 272 | menus[i]->info->postact.code); | |
289 | menus[i]->info->postact.code); | |||
290 | } | 273 | } | |
291 | if (strlen(menus[i]->info->exitact.code)) { | 274 | if (strlen(menus[i]->info->exitact.code)) { | |
292 | (void) fprintf (out_file, | 275 | (void)fprintf(out_file, "/*ARGSUSED*/\n" | |
293 | "/*ARGSUSED*/\n" | 276 | "static void menu_%d_exitact(menudesc *menu, void *arg)\n{\n", i); | |
294 | "static void menu_%d_exitact(menudesc *menu, void *arg)\n{\n", i); | |||
295 | if (menus[i]->info->exitact.endwin) | 277 | if (menus[i]->info->exitact.endwin) | |
296 | (void) fprintf (out_file, "\tendwin();\n"); | 278 | (void)fprintf(out_file, "\tendwin();\n"); | |
297 | (void) fprintf (out_file, "\t%s\n}\n\n", | 279 | (void)fprintf(out_file, "\t%s\n}\n\n", | |
298 | menus[i]->info->exitact.code); | 280 | menus[i]->info->exitact.code); | |
299 | } | 281 | } | |
300 | j = 0; | 282 | j = 0; | |
301 | toptn = menus[i]->info->optns; | 283 | toptn = menus[i]->info->optns; | |
302 | for (;toptn != NULL; j++, toptn = toptn->next) { | 284 | for (; toptn != NULL; j++, toptn = toptn->next) { | |
303 | if (strlen(toptn->optact.code) == 0) | 285 | if (strlen(toptn->optact.code) == 0) | |
304 | continue; | 286 | continue; | |
305 | 287 | |||
306 | (void) fprintf (out_file, | 288 | (void)fprintf(out_file, "/*ARGSUSED*/\n" | |
307 | "/*ARGSUSED*/\n" | 289 | "static int opt_act_%d_%d(menudesc *m, void *arg)\n" | |
308 | "static int opt_act_%d_%d(menudesc *m, void *arg)\n" | 290 | "{\n\t%s\n\treturn %s;\n}\n\n", | |
309 | "{\n\t%s\n\treturn %s;\n}\n\n", | 291 | i, j, toptn->optact.code, | |
310 | i, j, toptn->optact.code, | 292 | (toptn->doexit ? "1" : "0")); | |
311 | (toptn->doexit ? "1" : "0")); | |||
312 | } | 293 | } | |
313 | 294 | |||
314 | } | 295 | } | |
315 | 296 | |||
316 | /* optentX */ | 297 | /* optentX */ | |
317 | for (i=0; i<menu_no; i++) { | 298 | for (i = 0; i < menu_no; i++) { | |
318 | if (menus[i]->info->numopt > 53) { | 299 | if (menus[i]->info->numopt > 53) { | |
319 | (void) fprintf (stderr, "Menu %s has " | 300 | (void)fprintf(stderr, "Menu %s has " | |
320 | "too many options.\n", | 301 | "too many options.\n", | |
321 | menus[i]->info->title); | 302 | menus[i]->info->title); | |
322 | exit (1); | 303 | exit(1); | |
323 | } | 304 | } | |
324 | (void) fprintf (out_file, | 305 | (void)fprintf(out_file, "static menu_ent optent%d[] = {\n", i); | |
325 | "static menu_ent optent%d[] = {\n", i); | |||
326 | name_is_code = 0; | 306 | name_is_code = 0; | |
327 | for (j = 0, toptn = menus[i]->info->optns; toptn; | 307 | for (j = 0, toptn = menus[i]->info->optns; toptn; | |
328 | toptn = toptn->next, j++) { | 308 | toptn = toptn->next, j++) { | |
329 | name_is_code += toptn->name_is_code; | 309 | name_is_code += toptn->name_is_code; | |
330 | (void) fprintf (out_file, "\t{%s,%d,%d,", | 310 | (void)fprintf(out_file, "\t{%s,%d,%d,", | |
331 | toptn->name_is_code ? "0" : toptn->name, | 311 | toptn->name_is_code ? "0" : toptn->name, | |
332 | toptn->menu, | 312 | toptn->menu, | |
333 | (toptn->issub ? OPT_SUB : 0) | 313 | (toptn->issub ? OPT_SUB : 0) | |
334 | +(toptn->doexit ? OPT_EXIT : 0) | 314 | +(toptn->doexit ? OPT_EXIT : 0) | |
335 | +(toptn->optact.endwin ? OPT_ENDWIN : 0)); | 315 | +(toptn->optact.endwin ? OPT_ENDWIN : 0)); | |
336 | if (strlen(toptn->optact.code)) | 316 | if (strlen(toptn->optact.code)) | |
337 | (void) fprintf (out_file, "opt_act_%d_%d}", | 317 | (void)fprintf(out_file, "opt_act_%d_%d}", i, j); | |
338 | i, j); | |||
339 | else | 318 | else | |
340 | (void) fprintf (out_file, "NULL}"); | 319 | (void)fprintf(out_file, "NULL}"); | |
341 | (void) fprintf (out_file, "%s\n", | 320 | (void)fprintf(out_file, "%s\n", | |
342 | (toptn->next ? "," : "")); | 321 | (toptn->next ? "," : "")); | |
343 | } | 322 | } | |
344 | (void) fprintf (out_file, "\t};\n\n"); | 323 | (void)fprintf(out_file, "\t};\n\n"); | |
345 | 324 | |||
346 | if (name_is_code) { | 325 | if (name_is_code) { | |
347 | menus[i]->info->name_is_code = 1; | 326 | menus[i]->info->name_is_code = 1; | |
348 | fprintf(out_file, "static void menu_%d_legend(" | 327 | fprintf(out_file, "static void menu_%d_legend(" | |
349 | "menudesc *menu, int opt, void *arg)\n{\n" | 328 | "menudesc *menu, int opt, void *arg)\n{\n" | |
350 | "\tswitch (opt) {\n", i); | 329 | "\tswitch (opt) {\n", i); | |
351 | for (j = 0, toptn = menus[i]->info->optns; toptn; | 330 | for (j = 0, toptn = menus[i]->info->optns; toptn; | |
352 | toptn = toptn->next, j++) { | 331 | toptn = toptn->next, j++) { | |
353 | if (!toptn->name_is_code) | 332 | if (!toptn->name_is_code) | |
354 | continue; | 333 | continue; | |
355 | fprintf(out_file, "\tcase %d:\n\t\t{%s};\n" | 334 | fprintf(out_file, "\tcase %d:\n\t\t{%s};\n" | |
356 | "\t\tbreak;\n", j, toptn->name); | 335 | "\t\tbreak;\n", j, toptn->name); | |
357 | } | 336 | } | |
358 | fprintf(out_file, "\t}\n}\n\n"); | 337 | fprintf(out_file, "\t}\n}\n\n"); | |
359 | } | 338 | } | |
360 | } | 339 | } | |
361 | 340 | |||
362 | 341 | |||
363 | /* menus */ | 342 | /* menus */ | |
364 | if (!do_dynamic) { | 343 | if (!do_dynamic) | |
365 | (void) fprintf (out_file, "static int num_menus = %d;\n", menu_no); | 344 | (void)fprintf(out_file, "static int num_menus = %d;\n", | |
366 | } | 345 | menu_no); | |
367 | 346 | |||
368 | (void) fprintf (out_file, "static struct menudesc menu_def[] = {\n"); | 347 | (void)fprintf(out_file, "static struct menudesc menu_def[] = {\n"); | |
369 | for (i=0; i<menu_no; i++) { | 348 | for (i = 0; i < menu_no; i++) { | |
370 | (void) fprintf (out_file, | 349 | (void)fprintf(out_file, | |
371 | "\t{%s,%d,%d,%d,%d,%d,%d,0,0,optent%d,NULL,NULL,", | 350 | "\t{%s,%d,%d,%d,%d,%d,%d,0,0,optent%d,NULL,NULL,", | |
372 | menus[i]->info->title, menus[i]->info->y, | 351 | menus[i]->info->title, menus[i]->info->y, | |
373 | menus[i]->info->x, menus[i]->info->h, | 352 | menus[i]->info->x, menus[i]->info->h, | |
374 | menus[i]->info->w, menus[i]->info->mopt, | 353 | menus[i]->info->w, menus[i]->info->mopt, | |
375 | menus[i]->info->numopt, i); | 354 | menus[i]->info->numopt, i); | |
376 | if (menus[i]->info->helpstr == NULL) | 355 | if (menus[i]->info->helpstr == NULL) | |
377 | (void) fprintf (out_file, "NULL"); | 356 | (void)fprintf(out_file, "NULL"); | |
378 | else { | 357 | else { | |
379 | tmpstr = menus[i]->info->helpstr; | 358 | tmpstr = menus[i]->info->helpstr; | |
380 | if (*tmpstr != '"') | 359 | if (*tmpstr != '"') | |
381 | (void)fprintf(out_file, "%s", tmpstr); | 360 | (void)fprintf(out_file, "%s", tmpstr); | |
382 | else { | 361 | else { | |
383 | /* Skip an initial newline. */ | 362 | /* Skip an initial newline. */ | |
384 | if (tmpstr[1] == '\n') | 363 | if (tmpstr[1] == '\n') | |
385 | *++tmpstr = '"'; | 364 | *++tmpstr = '"'; | |
386 | (void) fprintf (out_file, "\n"); | 365 | (void)fprintf(out_file, "\n"); | |
387 | while (*tmpstr) { | 366 | while (*tmpstr) { | |
388 | if (*tmpstr != '\n') { | 367 | if (*tmpstr != '\n') { | |
389 | fputc (*tmpstr++, out_file); | 368 | fputc(*tmpstr++, out_file); | |
390 | continue; | 369 | continue; | |
391 | } | 370 | } | |
392 | (void) fprintf (out_file, "\\n\"\n\""); | 371 | (void)fprintf(out_file, "\\n\"\n\""); | |
393 | tmpstr++; | 372 | tmpstr++; | |
394 | } | 373 | } | |
395 | } | 374 | } | |
396 | } | 375 | } | |
397 | (void) fprintf (out_file, ","); | 376 | (void)fprintf(out_file, ","); | |
398 | if (menus[i]->info->mopt & MC_NOEXITOPT) | 377 | if (menus[i]->info->mopt & MC_NOEXITOPT) | |
399 | (void) fprintf (out_file, "NULL"); | 378 | (void) fprintf (out_file, "NULL"); | |
400 | else if (menus[i]->info->exitstr != NULL) | 379 | else if (menus[i]->info->exitstr != NULL) | |
401 | (void) fprintf (out_file, "%s", | 380 | (void)fprintf(out_file, "%s", menus[i]->info->exitstr); | |
402 | menus[i]->info->exitstr); | |||
403 | else | 381 | else | |
404 | (void) fprintf (out_file, "\"Exit\""); | 382 | (void)fprintf(out_file, "\"Exit\""); | |
405 | if (strlen(menus[i]->info->postact.code)) | 383 | if (strlen(menus[i]->info->postact.code)) | |
406 | (void) fprintf (out_file, ",menu_%d_postact", i); | 384 | (void)fprintf(out_file, ",menu_%d_postact", i); | |
407 | else | 385 | else | |
408 | (void) fprintf (out_file, ",NULL"); | 386 | (void)fprintf(out_file, ",NULL"); | |
409 | if (strlen(menus[i]->info->exitact.code)) | 387 | if (strlen(menus[i]->info->exitact.code)) | |
410 | (void) fprintf (out_file, ",menu_%d_exitact", i); | 388 | (void)fprintf(out_file, ",menu_%d_exitact", i); | |
411 | else | 389 | else | |
412 | (void) fprintf (out_file, ",NULL"); | 390 | (void)fprintf(out_file, ",NULL"); | |
413 | if (menus[i]->info->name_is_code) | 391 | if (menus[i]->info->name_is_code) | |
414 | (void) fprintf (out_file, ",menu_%d_legend", i); | 392 | (void)fprintf(out_file, ",menu_%d_legend", i); | |
415 | else | 393 | else | |
416 | (void) fprintf (out_file, ",NULL"); | 394 | (void)fprintf(out_file, ",NULL"); | |
417 | 395 | |||
418 | (void) fprintf (out_file, "},\n"); | 396 | (void)fprintf(out_file, "},\n"); | |
419 | 397 | |||
420 | } | 398 | } | |
421 | (void) fprintf (out_file, "{NULL, 0, 0, 0, 0, 0, 0, 0, 0, " | 399 | (void)fprintf(out_file, "{NULL, 0, 0, 0, 0, 0, 0, 0, 0, " | |
422 | "NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}};\n\n"); | 400 | "NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}};\n\n"); | |
423 | 401 | |||
424 | /* __menu_initerror: initscr failed. */ | 402 | /* __menu_initerror: initscr failed. */ | |
425 | (void) fprintf (out_file, | 403 | (void)fprintf(out_file, | |
426 | "/* __menu_initerror: initscr failed. */\n" | 404 | "/* __menu_initerror: initscr failed. */\n" | |
427 | "void __menu_initerror (void) {\n"); | 405 | "void __menu_initerror (void) {\n"); | |
428 | if (error_act.code == NULL) { | 406 | if (error_act.code == NULL) { | |
429 | (void) fprintf (out_file, | 407 | (void)fprintf(out_file, | |
430 | "\t(void) fprintf (stderr, " | 408 | "\t(void) fprintf (stderr, " | |
431 | "\"%%s: Could not initialize curses\\n\", " | 409 | "\"%%s: Could not initialize curses\\n\", " | |
432 | "getprogname());\n" | 410 | "getprogname());\n" | |
433 | "\texit(1);\n" | 411 | "\texit(1);\n" | |
434 | "}\n"); | 412 | "}\n"); | |
435 | } else { | 413 | } else { | |
436 | if (error_act.endwin) | 414 | if (error_act.endwin) | |
437 | (void) fprintf (out_file, "\tendwin();\n"); | 415 | (void)fprintf(out_file, "\tendwin();\n"); | |
438 | (void) fprintf (out_file, "%s\n}\n", error_act.code); | 416 | (void)fprintf(out_file, "%s\n}\n", error_act.code); | |
439 | } | 417 | } | |
440 | 418 | |||
441 | /* Copy menu_sys.def file. */ | 419 | /* Copy menu_sys.def file. */ | |
442 | while ((ch = fgetc(sys_file)) != '\014') /* Control-L */ | 420 | while ((ch = fgetc(sys_file)) != '\014') /* Control-L */ | |
443 | fputc(ch, out_file); | 421 | fputc(ch, out_file); | |
444 | 422 | |||
445 | if (do_dynamic) { | 423 | if (do_dynamic) { | |
446 | while ((ch = fgetc(sys_file)) != '\n') | 424 | while ((ch = fgetc(sys_file)) != '\n') | |
447 | /* skip it */; | 425 | /* skip it */; | |
448 | while ((ch = fgetc(sys_file)) != EOF) | 426 | while ((ch = fgetc(sys_file)) != EOF) | |
449 | fputc(ch, out_file); | 427 | fputc(ch, out_file); | |
450 | } | 428 | } | |
451 | 429 | fclose(out_file); | ||
452 | fclose (out_file); | 430 | fclose(sys_file); | |
453 | fclose (sys_file); | |||
454 | } | 431 | } |
--- src/usr.bin/menuc/menu_sys.def 2006/02/20 21:06:40 1.58
+++ src/usr.bin/menuc/menu_sys.def 2012/03/06 16:55:18 1.59
@@ -1,34 +1,30 @@ | @@ -1,34 +1,30 @@ | |||
1 | /* $NetBSD: menu_sys.def,v 1.58 2006/02/20 21:06:40 dsl Exp $ */ | 1 | /* $NetBSD: menu_sys.def,v 1.59 2012/03/06 16:55:18 mbalmer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | 17 | * 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
18 | * must display the following acknowledgement: | |||
19 | * This product includes software develooped for the NetBSD Project by | |||
20 | * Piermont Information Systems Inc. | |||
21 | * 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
22 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior | |
23 | * written permission. | 19 | * written permission. | |
24 | * | 20 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 21 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
--- src/usr.bin/menuc/menuc.1 2009/07/11 18:38:30 1.29
+++ src/usr.bin/menuc/menuc.1 2012/03/06 16:55:18 1.30
@@ -1,33 +1,29 @@ | @@ -1,33 +1,29 @@ | |||
1 | .\" $NetBSD: menuc.1,v 1.29 2009/07/11 18:38:30 joerg Exp $ | 1 | .\" $NetBSD: menuc.1,v 1.30 2012/03/06 16:55:18 mbalmer Exp $ | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright 1997 Piermont Information Systems Inc. | 3 | .\" Copyright 1997 Piermont Information Systems Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" Written by Philip A. Nelson for Piermont Information Systems Inc. | 6 | .\" Written by Philip A. Nelson for Piermont Information Systems Inc. | |
7 | .\" | 7 | .\" | |
8 | .\" Redistribution and use in source and binary forms, with or without | 8 | .\" Redistribution and use in source and binary forms, with or without | |
9 | .\" modification, are permitted provided that the following conditions | 9 | .\" modification, are permitted provided that the following conditions | |
10 | .\" are met: | 10 | .\" are met: | |
11 | .\" 1. Redistributions of source code must retain the above copyright | 11 | .\" 1. Redistributions of source code must retain the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer. | 12 | .\" notice, this list of conditions and the following disclaimer. | |
13 | .\" 2. Redistributions in binary form must reproduce the above copyright | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
14 | .\" notice, this list of conditions and the following disclaimer in the | 14 | .\" notice, this list of conditions and the following disclaimer in the | |
15 | .\" documentation and/or other materials provided with the distribution. | 15 | .\" documentation and/or other materials provided with the distribution. | |
16 | .\" 3. All advertising materials mentioning features or use of this software | 16 | .\" 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
17 | .\" must display the following acknowledgement: | |||
18 | .\" This product includes software developed for the NetBSD Project by | |||
19 | .\" Piermont Information Systems Inc. | |||
20 | .\" 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
21 | .\" or promote products derived from this software without specific prior | 17 | .\" or promote products derived from this software without specific prior | |
22 | .\" written permission. | 18 | .\" written permission. | |
23 | .\" | 19 | .\" | |
24 | .\" THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 20 | .\" THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
25 | .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 21 | .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
26 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
27 | .\" ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
28 | .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
29 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
30 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
31 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
32 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
33 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 29 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
--- src/usr.bin/menuc/parse.y 2006/02/20 21:06:40 1.15
+++ src/usr.bin/menuc/parse.y 2012/03/06 16:55:18 1.16
@@ -1,34 +1,30 @@ | @@ -1,34 +1,30 @@ | |||
1 | /* $NetBSD: parse.y,v 1.15 2006/02/20 21:06:40 dsl Exp $ */ | 1 | /* $NetBSD: parse.y,v 1.16 2012/03/06 16:55:18 mbalmer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | 17 | * 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
18 | * must display the following acknowledgement: | |||
19 | * This product includes software develooped for the NetBSD Project by | |||
20 | * Piermont Information Systems Inc. | |||
21 | * 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
22 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior | |
23 | * written permission. | 19 | * written permission. | |
24 | * | 20 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 21 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
--- src/usr.bin/menuc/scan.l 2009/10/29 14:36:14 1.15
+++ src/usr.bin/menuc/scan.l 2012/03/06 16:55:18 1.16
@@ -1,34 +1,30 @@ | @@ -1,34 +1,30 @@ | |||
1 | /* $NetBSD: scan.l,v 1.15 2009/10/29 14:36:14 christos Exp $ */ | 1 | /* $NetBSD: scan.l,v 1.16 2012/03/06 16:55:18 mbalmer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | 17 | * 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
18 | * must display the following acknowledgement: | |||
19 | * This product includes software develooped for the NetBSD Project by | |||
20 | * Piermont Information Systems Inc. | |||
21 | * 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
22 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior | |
23 | * written permission. | 19 | * written permission. | |
24 | * | 20 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 21 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
--- src/usr.bin/menuc/util.c 2004/06/20 22:20:16 1.4
+++ src/usr.bin/menuc/util.c 2012/03/06 16:55:18 1.5
@@ -1,112 +1,107 @@ | @@ -1,112 +1,107 @@ | |||
1 | /* $NetBSD: util.c,v 1.4 2004/06/20 22:20:16 jmc Exp $ */ | 1 | /* $NetBSD: util.c,v 1.5 2012/03/06 16:55:18 mbalmer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | 17 | * 3. The name of Piermont Information Systems Inc. may not be used to endorse | |
18 | * must display the following acknowledgement: | |||
19 | * This product includes software develooped for the NetBSD Project by | |||
20 | * Piermont Information Systems Inc. | |||
21 | * 4. The name of Piermont Information Systems Inc. may not be used to endorse | |||
22 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior | |
23 | * written permission. | 19 | * written permission. | |
24 | * | 20 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | 21 | * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
35 | * THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THE POSSIBILITY OF SUCH DAMAGE. | |
36 | * | 32 | * | |
37 | */ | 33 | */ | |
38 | 34 | |||
39 | /* util.c - utility routines. */ | 35 | /* util.c - utility routines. */ | |
40 | 36 | |||
41 | #if HAVE_NBTOOL_CONFIG_H | 37 | #if HAVE_NBTOOL_CONFIG_H | |
42 | #include "nbtool_config.h" | 38 | #include "nbtool_config.h" | |
43 | #endif | 39 | #endif | |
44 | 40 | |||
45 | #include <sys/cdefs.h> | 41 | #include <sys/cdefs.h> | |
46 | 42 | |||
47 | #if defined(__RCSID) && !defined(lint) | 43 | #if defined(__RCSID) && !defined(lint) | |
48 | __RCSID("$NetBSD: util.c,v 1.4 2004/06/20 22:20:16 jmc Exp $"); | 44 | __RCSID("$NetBSD: util.c,v 1.5 2012/03/06 16:55:18 mbalmer Exp $"); | |
49 | #endif | 45 | #endif | |
50 | 46 | |||
51 | ||||
52 | #include <stdio.h> | 47 | #include <stdio.h> | |
53 | #include <stdlib.h> | 48 | #include <stdlib.h> | |
54 | #include <string.h> | 49 | #include <string.h> | |
55 | #include <stdarg.h> | 50 | #include <stdarg.h> | |
56 | #include "defs.h" | 51 | #include "defs.h" | |
57 | 52 | |||
58 | /* Error routine */ | 53 | /* Error routine */ | |
59 | void | 54 | void | |
60 | yyerror(const char *fmt, ...) | 55 | yyerror(const char *fmt, ...) | |
61 | { | 56 | { | |
62 | va_list args; | 57 | va_list args; | |
63 | 58 | |||
64 | va_start (args, fmt); | 59 | va_start(args, fmt); | |
65 | printf ("%s:%d: ", src_name, line_no); | 60 | printf("%s:%d: ", src_name, line_no); | |
66 | vfprintf (stdout, fmt, args); | 61 | vfprintf(stdout, fmt, args); | |
67 | printf ("\n"); | 62 | printf("\n"); | |
68 | va_end (args); | 63 | va_end(args); | |
69 | had_errors = TRUE; | 64 | had_errors = TRUE; | |
70 | } | 65 | } | |
71 | 66 | |||
72 | ||||
73 | /* Buffer routines */ | 67 | /* Buffer routines */ | |
74 | static char *mc_buff = NULL; | 68 | static char *mc_buff = NULL; | |
75 | static int mc_size = 0; | 69 | static int mc_size = 0; | |
76 | static int mc_loc = 0; | 70 | static int mc_loc = 0; | |
77 | 71 | |||
78 | void buff_add_ch (char ch) | 72 | void | |
73 | buff_add_ch(char ch) | |||
79 | { | 74 | { | |
80 | char *t; | 75 | char *t; | |
81 | 76 | |||
82 | if (mc_loc >= mc_size-1) { | 77 | if (mc_loc >= mc_size-1) { | |
83 | if (mc_size == 0) | 78 | if (mc_size == 0) | |
84 | mc_size = 80; | 79 | mc_size = 80; | |
85 | else | 80 | else | |
86 | mc_size *= 2; | 81 | mc_size *= 2; | |
87 | t = (char *) malloc (mc_size); | 82 | t = (char *)malloc(mc_size); | |
88 | if (t == NULL) { | 83 | if (t == NULL) { | |
89 | (void) fprintf (stderr, "%s:%d: Malloc error\n", | 84 | (void)fprintf(stderr, "%s:%d: Malloc error\n", | |
90 | src_name, line_no); | 85 | src_name, line_no); | |
91 | exit (1); | 86 | exit(1); | |
92 | } | 87 | } | |
93 | if (mc_buff != NULL) { | 88 | if (mc_buff != NULL) { | |
94 | strcpy (t, mc_buff); | 89 | strcpy(t, mc_buff); | |
95 | free (mc_buff); | 90 | free(mc_buff); | |
96 | } | 91 | } | |
97 | mc_buff = t; | 92 | mc_buff = t; | |
98 | } | 93 | } | |
99 | mc_buff[mc_loc++] = ch; | 94 | mc_buff[mc_loc++] = ch; | |
100 | mc_buff[mc_loc] = '\0'; | 95 | mc_buff[mc_loc] = '\0'; | |
101 | } | 96 | } | |
102 | 97 | |||
103 | /* get a copy of the string ! */ | 98 | /* get a copy of the string ! */ | |
104 | ||||
105 | char * | 99 | char * | |
106 | buff_copy (void) | 100 | buff_copy(void) | |
107 | { | 101 | { | |
108 | char *res = strdup (mc_buff); | 102 | char *res = strdup(mc_buff); | |
103 | ||||
109 | mc_loc = 0; | 104 | mc_loc = 0; | |
110 | mc_buff[0] = '\0'; | 105 | mc_buff[0] = '\0'; | |
111 | return res; | 106 | return res; | |
112 | } | 107 | } |