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
|
--- a/antlr/bits.c
+++ b/antlr/bits.c
@@ -573,15 +573,15 @@
else
fprintf(DefFile, "extern SetWordType zzerr%d[];\n", esetnum);
if ( name!=NULL ) {
- fprintf(ErrFile, "SetWordType %s%s[%d] = {",
+ fprintf(ErrFile, "SetWordType %s%s[%lu] = {",
name,
suffix,
- NumWords(TokenNum-1)*sizeof(unsigned));
+ (unsigned long)(NumWords(TokenNum-1)*sizeof(unsigned)));
}
else {
- fprintf(ErrFile, "SetWordType zzerr%d[%d] = {",
+ fprintf(ErrFile, "SetWordType zzerr%d[%lu] = {",
esetnum,
- NumWords(TokenNum-1)*sizeof(unsigned));
+ (unsigned long)(NumWords(TokenNum-1)*sizeof(unsigned)));
}
while ( p < endp )
{
@@ -641,21 +641,21 @@
esetnum++;
if ( name!=NULL ) {
- fprintf(Parser_h, "\tstatic SetWordType %s%s[%d];\n", name, suffix,
- NumWords(TokenNum-1)*sizeof(unsigned));
- fprintf(Parser_c, "SetWordType %s::%s%s[%d] = {",
+ fprintf(Parser_h, "\tstatic SetWordType %s%s[%lu];\n", name, suffix,
+ (unsigned long)(NumWords(TokenNum-1) * sizeof(unsigned)));
+ fprintf(Parser_c, "SetWordType %s::%s%s[%lu] = {",
CurrentClassName,
name,
suffix,
- NumWords(TokenNum-1)*sizeof(unsigned));
+ (unsigned long)(NumWords(TokenNum-1) * sizeof(unsigned)));
}
else {
- fprintf(Parser_c, "SetWordType %s::err%d[%d] = {",
+ fprintf(Parser_c, "SetWordType %s::err%d[%lu] = {",
CurrentClassName,
esetnum,
- NumWords(TokenNum-1)*sizeof(unsigned));
- fprintf(Parser_h, "\tstatic SetWordType err%d[%d];\n", esetnum,
- NumWords(TokenNum-1)*sizeof(unsigned));
+ (unsigned long)(NumWords(TokenNum-1)*sizeof(unsigned)));
+ fprintf(Parser_h, "\tstatic SetWordType err%d[%lu];\n", esetnum,
+ (unsigned long)(NumWords(TokenNum-1)*sizeof(unsigned)));
}
while ( p < endp )
@@ -787,13 +787,13 @@
/* Build constructors */
fprintf(Parser_c, "\n%s::", CurrentClassName);
- fprintf(Parser_c, "%s(ANTLRTokenBuffer *input) : %s(input,%d,%d,%d,%d)\n",
+ fprintf(Parser_c, "%s(ANTLRTokenBuffer *input) : %s(input,%d,%d,%d,%lu)\n",
CurrentClassName,
(BaseClassName == NULL ? "ANTLRParser" : BaseClassName),
OutputLL_k,
FoundGuessBlk,
DemandLookahead,
- NumWords(TokenNum-1)*sizeof(unsigned));
+ (unsigned long)(NumWords(TokenNum-1)*sizeof(unsigned)));
fprintf(Parser_c, "{\n");
fprintf(Parser_c, "\ttoken_tbl = _token_tbl;\n");
if (TraceGen) {
@@ -912,7 +912,7 @@
#ifdef DUM
if ( LexGen ) fprintf(ErrFile, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));
#endif
- fprintf(ErrFile, "#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));
+ fprintf(ErrFile, "#define zzSET_SIZE %lu\n", (unsigned long)(NumWords(TokenNum-1)*sizeof(unsigned)));
if ( DemandLookahead ) fprintf(ErrFile, "#define DEMAND_LOOK\n");
fprintf(ErrFile, "#include \"antlr.h\"\n");
if ( GenAST ) fprintf(ErrFile, "#include \"ast.h\"\n");
--- a/antlr/fset2.c
+++ b/antlr/fset2.c
@@ -2210,7 +2210,7 @@
if (p->ntype != nToken) continue;
tn=(TokNode *)p;
if (depth != 0) fprintf(stdout," ");
- fprintf(stdout,TerminalString(tn->token));
+ fprintf(stdout,"%s",TerminalString(tn->token));
depth++;
if (! MR_AmbAidMultiple) {
if (set_nil(tn->tset)) {
--- a/antlr/gen.c
+++ b/antlr/gen.c
@@ -159,7 +159,7 @@
#define gen6(s,a,b,c,d,e,f) {tab(); fprintf(output, s,a,b,c,d,e,f);}
#define gen7(s,a,b,c,d,e,f,g) {tab(); fprintf(output, s,a,b,c,d,e,f,g);}
-#define _gen(s) {fprintf(output, s);}
+#define _gen(s) {fprintf(output, "%s", s);}
#define _gen1(s,a) {fprintf(output, s,a);}
#define _gen2(s,a,b) {fprintf(output, s,a,b);}
#define _gen3(s,a,b,c) {fprintf(output, s,a,b,c);}
@@ -3911,7 +3911,7 @@
}
#endif
/* ###WARNING: This will have to change when SetWordSize changes */
- if ( !GenCC ) _gen1("#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));
+ if ( !GenCC ) _gen1("#define zzSET_SIZE %lu\n", (unsigned long)(NumWords(TokenNum-1)*sizeof(unsigned)));
if (TraceGen) {
_gen("#ifndef zzTRACE_RULES\n"); /* MR20 */
_gen("#define zzTRACE_RULES\n"); /* MR20 */
@@ -4125,7 +4125,7 @@
if ( LexGen ) fprintf(f, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));
#endif
/* ###WARNING: This will have to change when SetWordSize changes */
- fprintf(f, "#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));
+ fprintf(f, "#define zzSET_SIZE %lu\n", (unsigned long)NumWords(TokenNum-1)*sizeof(unsigned));
if (TraceGen) {
fprintf(f,"#ifndef zzTRACE_RULES\n"); /* MR20 */
fprintf(f,"#define zzTRACE_RULES\n"); /* MR20 */
--- a/antlr/lex.c
+++ b/antlr/lex.c
@@ -706,7 +706,7 @@
/* MR26 */ if (! (isalpha(*t) || isdigit(*t) || *t == '_' || *t == '$')) break;
/* MR26 */ }
/* MR26 */ }
-/* MR26 */ fprintf(output,strBetween(pSymbol, t, pSeparator));
+/* MR26 */ fprintf(output,"%s",strBetween(pSymbol, t, pSeparator));
*q = p;
return (*pSeparator == 0);
@@ -771,7 +771,7 @@
&pValue,
&pSeparator,
&nest);
- fprintf(f,strBetween(pDataType, pSymbol, pSeparator));
+ fprintf(f,"%s",strBetween(pDataType, pSymbol, pSeparator));
}
/* check to see if string e is a word in string s */
@@ -852,9 +852,9 @@
&pSeparator,
&nest);
fprintf(f,"\t");
- fprintf(f,strBetween(pDataType, pSymbol, pSeparator));
+ fprintf(f,"%s",strBetween(pDataType, pSymbol, pSeparator));
fprintf(f," ");
- fprintf(f,strBetween(pSymbol, pEqualSign, pSeparator));
+ fprintf(f,"%s",strBetween(pSymbol, pEqualSign, pSeparator));
fprintf(f,";\n");
}
fprintf(f,"};\n");
--- a/support/set/set.h
+++ b/support/set/set.h
@@ -55,7 +55,7 @@
/* make arg1 a set big enough to hold max elem # of arg2 */
#define set_new(a,_max) \
if (((a).setword=(unsigned *)calloc(NumWords(_max),BytesPerWord))==NULL) \
- fprintf(stderr, "set_new: Cannot allocate set with max of %d\n", _max); \
+ fprintf(stderr, "set_new: Cannot allocate set with max of %u\n", (unsigned)_max); \
(a).n = NumWords(_max);
#define set_free(a) \
--- a/sorcerer/main.c
+++ b/sorcerer/main.c
@@ -1035,7 +1035,7 @@
id = p; /* here is where id is */
p = s;
while ( p!=id ) {fputc(*p, f); p++;} /* dump until just before variable */
- fprintf(f, prefix);
+ fprintf(f, "%s", prefix);
while ( isspace(*p) ) p++;
while ( *p!='\0' ) /* dump rest */
{
--- a/sorcerer/hash.c
+++ b/sorcerer/hash.c
@@ -141,7 +141,7 @@
if ( q != NULL && low==0 ) low = p-table;
len = 0;
- if ( q != NULL ) fprintf(stderr, "[%d]", p-table);
+ if ( q != NULL ) fprintf(stderr, "[%ld]", (long)(p - table));
while ( q != NULL )
{
len++;
|