| @@ -1,173 +1,191 @@ | | | @@ -1,173 +1,191 @@ |
1 | $NetBSD: patch-aa,v 1.9 2007/03/09 15:38:32 rillig Exp $ | | 1 | $NetBSD: patch-aa,v 1.10 2009/09/27 22:27:23 apb Exp $ |
2 | | | 2 | |
3 | --- cdecl.c.orig 1996-01-16 04:54:46.000000000 +0100 | | 3 | --- cdecl.c.orig 1996-01-16 03:54:46.000000000 +0000 |
4 | +++ cdecl.c 2007-03-09 16:36:18.000000000 +0100 | | 4 | +++ cdecl.c |
5 | @@ -59,7 +59,9 @@ | | 5 | @@ -59,7 +59,9 @@ |
6 | */ | | 6 | */ |
7 | | | 7 | |
8 | char cdeclsccsid[] = "@(#)cdecl.c 2.5 1/15/96"; | | 8 | char cdeclsccsid[] = "@(#)cdecl.c 2.5 1/15/96"; |
9 | - | | 9 | - |
10 | + | | 10 | + |
11 | +#include <sys/param.h> | | 11 | +#include <sys/param.h> |
12 | + | | 12 | + |
13 | #include <stdio.h> | | 13 | #include <stdio.h> |
14 | #include <ctype.h> | | 14 | #include <ctype.h> |
15 | #if __STDC__ || defined(DOS) | | 15 | #if __STDC__ || defined(DOS) |
16 | @@ -71,11 +73,12 @@ char cdeclsccsid[] = "@(#)cdecl.c 2.5 1/ | | 16 | @@ -71,11 +73,12 @@ char cdeclsccsid[] = "@(#)cdecl.c 2.5 1/ |
17 | # ifndef NOVARARGS | | 17 | # ifndef NOVARARGS |
18 | # include <varargs.h> | | 18 | # include <varargs.h> |
19 | # endif /* ndef NOVARARGS */ | | 19 | # endif /* ndef NOVARARGS */ |
20 | +#if !(defined(__sun__) && defined(__svr4__)) && !(defined(BSD) && (BSD >= 199306)) && !defined(__INTERIX) | | 20 | +#if !(defined(__sun__) && defined(__svr4__)) && !(defined(BSD) && (BSD >= 199306)) && !defined(__INTERIX) |
21 | char *malloc(); | | 21 | char *malloc(); |
22 | void free(), exit(), perror(); | | 22 | void free(), exit(), perror(); |
23 | +#endif | | 23 | +#endif |
24 | # ifdef BSD | | 24 | # ifdef BSD |
25 | # include <strings.h> | | 25 | # include <strings.h> |
26 | - extern int errno; | | 26 | - extern int errno; |
27 | # define strrchr rindex | | 27 | # define strrchr rindex |
28 | # define NOTMPFILE | | 28 | # define NOTMPFILE |
29 | # else | | 29 | # else |
30 | @@ -87,13 +90,12 @@ void free(), exit(), perror(); | | 30 | @@ -87,13 +90,12 @@ void free(), exit(), perror(); |
31 | # endif /* NOVOID */ | | 31 | # endif /* NOVOID */ |
32 | #endif /* __STDC__ || DOS */ | | 32 | #endif /* __STDC__ || DOS */ |
33 | | | 33 | |
34 | +#include <errno.h> | | 34 | +#include <errno.h> |
35 | + | | 35 | + |
36 | #ifdef USE_READLINE | | 36 | #ifdef USE_READLINE |
37 | # include <readline/readline.h> | | 37 | # include <readline/readline.h> |
38 | /* prototypes for functions related to readline() */ | | 38 | /* prototypes for functions related to readline() */ |
39 | - char * getline(); | | 39 | - char * getline(); |
40 | - char ** attempt_completion(char *, int, int); | | 40 | - char ** attempt_completion(char *, int, int); |
41 | - char * keyword_completion(char *, int); | | 41 | - char * keyword_completion(char *, int); |
42 | - char * command_completion(char *, int); | | 42 | - char * command_completion(char *, int); |
43 | +char * command_completion(const char *, int); | | 43 | +char * command_completion(const char *, int); |
44 | #endif | | 44 | #endif |
45 | | | 45 | |
46 | /* maximum # of chars from progname to display in prompt */ | | 46 | /* maximum # of chars from progname to display in prompt */ |
47 | @@ -124,7 +126,11 @@ char real_prompt[MAX_NAME+3]; | | 47 | @@ -124,7 +126,11 @@ char real_prompt[MAX_NAME+3]; |
48 | | | 48 | |
49 | #if __STDC__ | | 49 | #if __STDC__ |
50 | char *ds(char *), *cat(char *, ...), *visible(int); | | 50 | char *ds(char *), *cat(char *, ...), *visible(int); |
51 | +#if !(defined(BSD) && BSD >= 199306) && \ | | 51 | +#if !(defined(BSD) && BSD >= 199306) && \ |
52 | + !(defined(__sun__) && defined(__svr4__)) && \ | | 52 | + !(defined(__sun__) && defined(__svr4__)) && \ |
53 | + !(defined(__linux__)) && !(defined(__INTERIX)) | | 53 | + !(defined(__linux__)) && !(defined(__INTERIX)) |
54 | int getopt(int,char **,char *); | | 54 | int getopt(int,char **,char *); |
55 | +#endif | | 55 | +#endif |
56 | int main(int, char **); | | 56 | int main(int, char **); |
57 | int yywrap(void); | | 57 | int yywrap(void); |
58 | int dostdin(void); | | 58 | int dostdin(void); |
59 | @@ -138,7 +144,7 @@ char real_prompt[MAX_NAME+3]; | | 59 | @@ -138,7 +144,7 @@ char real_prompt[MAX_NAME+3]; |
60 | void docast(char*, char*, char*, char*); | | 60 | void docast(char*, char*, char*, char*); |
61 | void dodexplain(char*, char*, char*, char*); | | 61 | void dodexplain(char*, char*, char*, char*); |
62 | void docexplain(char*, char*, char*, char*); | | 62 | void docexplain(char*, char*, char*, char*); |
63 | - void setprogname(char *); | | 63 | - void setprogname(char *); |
64 | + void mysetprogname(char *); | | 64 | + void mysetprogname(char *); |
65 | int dotmpfile(int, char**), dofileargs(int, char**); | | 65 | int dotmpfile(int, char**), dofileargs(int, char**); |
66 | #else | | 66 | #else |
67 | char *ds(), *cat(), *visible(); | | 67 | char *ds(), *cat(), *visible(); |
68 | @@ -148,7 +154,7 @@ char real_prompt[MAX_NAME+3]; | | 68 | @@ -148,7 +154,7 @@ char real_prompt[MAX_NAME+3]; |
69 | void unsupp(), notsupported(); | | 69 | void unsupp(), notsupported(); |
70 | void yyerror(); | | 70 | void yyerror(); |
71 | void doset(), dodeclare(), docast(), dodexplain(), docexplain(); | | 71 | void doset(), dodeclare(), docast(), dodexplain(), docexplain(); |
72 | - void setprogname(); | | 72 | - void setprogname(); |
73 | + void mysetprogname(); | | 73 | + void mysetprogname(); |
74 | int dotmpfile(), dofileargs(); | | 74 | int dotmpfile(), dofileargs(); |
75 | #endif /* __STDC__ */ | | 75 | #endif /* __STDC__ */ |
76 | FILE *tmpfile(); | | 76 | FILE *tmpfile(); |
77 | @@ -241,7 +247,7 @@ struct | | 77 | @@ -241,7 +247,7 @@ struct |
78 | /* for unsupported combinations of types. */ | | 78 | /* for unsupported combinations of types. */ |
79 | void mbcheck() | | 79 | void mbcheck() |
80 | { | | 80 | { |
81 | - register int i, j, restrict; | | 81 | - register int i, j, restrict; |
82 | + register int i, j, xrestrict; | | 82 | + register int i, j, xrestrict; |
83 | char *t1, *t2; | | 83 | char *t1, *t2; |
84 | | | 84 | |
85 | /* Loop through the types */ | | 85 | /* Loop through the types */ |
86 | @@ -258,26 +264,26 @@ void mbcheck() | | 86 | @@ -258,26 +264,26 @@ void mbcheck() |
87 | if (!(modbits & crosstypes[j].bit)) | | 87 | if (!(modbits & crosstypes[j].bit)) |
88 | continue; | | 88 | continue; |
89 | /* check the type of restriction */ | | 89 | /* check the type of restriction */ |
90 | - restrict = crosscheck[i][j]; | | 90 | - restrict = crosscheck[i][j]; |
91 | - if (restrict == ALWAYS) | | 91 | - if (restrict == ALWAYS) |
92 | + xrestrict = crosscheck[i][j]; | | 92 | + xrestrict = crosscheck[i][j]; |
93 | + if (xrestrict == ALWAYS) | | 93 | + if (xrestrict == ALWAYS) |
94 | continue; | | 94 | continue; |
95 | t1 = crosstypes[i].name; | | 95 | t1 = crosstypes[i].name; |
96 | t2 = crosstypes[j].name; | | 96 | t2 = crosstypes[j].name; |
97 | - if (restrict == NEVER) | | 97 | - if (restrict == NEVER) |
98 | + if (xrestrict == NEVER) | | 98 | + if (xrestrict == NEVER) |
99 | { | | 99 | { |
100 | notsupported("", t1, t2); | | 100 | notsupported("", t1, t2); |
101 | } | | 101 | } |
102 | - else if (restrict == RITCHIE) | | 102 | - else if (restrict == RITCHIE) |
103 | + else if (xrestrict == RITCHIE) | | 103 | + else if (xrestrict == RITCHIE) |
104 | { | | 104 | { |
105 | if (RitchieFlag) | | 105 | if (RitchieFlag) |
106 | notsupported(" (Ritchie Compiler)", t1, t2); | | 106 | notsupported(" (Ritchie Compiler)", t1, t2); |
107 | } | | 107 | } |
108 | - else if (restrict == PREANSI) | | 108 | - else if (restrict == PREANSI) |
109 | + else if (xrestrict == PREANSI) | | 109 | + else if (xrestrict == PREANSI) |
110 | { | | 110 | { |
111 | if (PreANSIFlag || RitchieFlag) | | 111 | if (PreANSIFlag || RitchieFlag) |
112 | notsupported(" (Pre-ANSI Compiler)", t1, t2); | | 112 | notsupported(" (Pre-ANSI Compiler)", t1, t2); |
113 | } | | 113 | } |
114 | - else if (restrict == ANSI) | | 114 | - else if (restrict == ANSI) |
115 | + else if (xrestrict == ANSI) | | 115 | + else if (xrestrict == ANSI) |
116 | { | | 116 | { |
117 | if (!RitchieFlag && !PreANSIFlag) | | 117 | if (!RitchieFlag && !PreANSIFlag) |
118 | notsupported(" (ANSI Compiler)", t1, t2); | | 118 | notsupported(" (ANSI Compiler)", t1, t2); |
119 | @@ -286,7 +292,7 @@ void mbcheck() | | 119 | @@ -286,7 +292,7 @@ void mbcheck() |
120 | { | | 120 | { |
121 | (void) fprintf (stderr, | | 121 | (void) fprintf (stderr, |
122 | "%s: Internal error in crosscheck[%d,%d]=%d!\n", | | 122 | "%s: Internal error in crosscheck[%d,%d]=%d!\n", |
123 | - progname, i, j, restrict); | | 123 | - progname, i, j, restrict); |
124 | + progname, i, j, xrestrict); | | 124 | + progname, i, j, xrestrict); |
125 | exit(1); /* NOTREACHED */ | | 125 | exit(1); /* NOTREACHED */ |
126 | } | | 126 | } |
127 | } | | 127 | } |
| | | 128 | @@ -375,7 +381,7 @@ char *options[] = { |
| | | 129 | static char *line_read = NULL; |
| | | 130 | |
| | | 131 | /* Read a string, and return a pointer to it. Returns NULL on EOF. */ |
| | | 132 | -char * getline () |
| | | 133 | +char * get_line () |
| | | 134 | { |
| | | 135 | /* If the buffer has already been allocated, return the memory |
| | | 136 | to the free pool. */ |
128 | @@ -399,12 +405,12 @@ char ** attempt_completion(char *text, i | | 137 | @@ -399,12 +405,12 @@ char ** attempt_completion(char *text, i |
129 | { | | 138 | { |
130 | char **matches = NULL; | | 139 | char **matches = NULL; |
131 | | | 140 | |
132 | - if (start == 0) matches = completion_matches(text, command_completion); | | 141 | - if (start == 0) matches = completion_matches(text, command_completion); |
133 | + if (start == 0) matches = rl_completion_matches(text, command_completion); | | 142 | + if (start == 0) matches = rl_completion_matches(text, command_completion); |
134 | | | 143 | |
135 | return matches; | | 144 | return matches; |
136 | } | | 145 | } |
137 | | | 146 | |
138 | -char * command_completion(char *text, int flag) | | 147 | -char * command_completion(char *text, int flag) |
139 | +char * command_completion(const char *text, int flag) | | 148 | +char * command_completion(const char *text, int flag) |
140 | { | | 149 | { |
141 | static int index, len; | | 150 | static int index, len; |
142 | char *command; | | 151 | char *command; |
143 | @@ -421,7 +427,7 @@ char * command_completion(char *text, in | | 152 | @@ -421,7 +427,7 @@ char * command_completion(char *text, in |
144 | return NULL; | | 153 | return NULL; |
145 | } | | 154 | } |
146 | | | 155 | |
147 | -char * keyword_completion(char *text, int flag) | | 156 | -char * keyword_completion(char *text, int flag) |
148 | +char * keyword_completion(const char *text, int flag) | | 157 | +char * keyword_completion(const char *text, int flag) |
149 | { | | 158 | { |
150 | static int index, len, set, into; | | 159 | static int index, len, set, into; |
151 | char *keyword, *option; | | 160 | char *keyword, *option; |
152 | @@ -803,7 +809,7 @@ void prompt() | | 161 | @@ -803,7 +809,7 @@ void prompt() |
153 | } | | 162 | } |
154 | | | 163 | |
155 | /* Save away the name of the program from argv[0] */ | | 164 | /* Save away the name of the program from argv[0] */ |
156 | -void setprogname(argv0) | | 165 | -void setprogname(argv0) |
157 | +void mysetprogname(argv0) | | 166 | +void mysetprogname(argv0) |
158 | char *argv0; | | 167 | char *argv0; |
159 | { | | 168 | { |
160 | #ifdef DOS | | 169 | #ifdef DOS |
| | | 170 | @@ -887,7 +893,7 @@ int dostdin() |
| | | 171 | |
| | | 172 | if (!quiet) (void) printf("Type `help' or `?' for help\n"); |
| | | 173 | ret = 0; |
| | | 174 | - while ((line = getline())) { |
| | | 175 | + while ((line = get_line())) { |
| | | 176 | if (!strcmp(line, "quit") || !strcmp(line, "exit")) { |
| | | 177 | free(line); |
| | | 178 | return ret; |
161 | @@ -1252,10 +1258,10 @@ char **argv; | | 179 | @@ -1252,10 +1258,10 @@ char **argv; |
162 | #ifdef USE_READLINE | | 180 | #ifdef USE_READLINE |
163 | /* install completion handlers */ | | 181 | /* install completion handlers */ |
164 | rl_attempted_completion_function = (CPPFunction *)attempt_completion; | | 182 | rl_attempted_completion_function = (CPPFunction *)attempt_completion; |
165 | - rl_completion_entry_function = (Function *)keyword_completion; | | 183 | - rl_completion_entry_function = (Function *)keyword_completion; |
166 | + rl_completion_entry_function = keyword_completion; | | 184 | + rl_completion_entry_function = keyword_completion; |
167 | #endif | | 185 | #endif |
168 | | | 186 | |
169 | - setprogname(argv[0]); | | 187 | - setprogname(argv[0]); |
170 | + mysetprogname(argv[0]); | | 188 | + mysetprogname(argv[0]); |
171 | #ifdef DOS | | 189 | #ifdef DOS |
172 | if (strcmp(progname, "cppdecl") == 0) | | 190 | if (strcmp(progname, "cppdecl") == 0) |
173 | #else | | 191 | #else |