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