View | Details | Raw Unified | Return to bug 246163 | Differences between
and this patch

Collapse All | Expand All

(-)blocks.c (-1 lines)
Lines 33-37 Link Here
33
33
34
extern List *blocks;
34
extern List *blocks;
35
extern void warnFor(Token*, char*, char*);
36
35
37
Blox *pushBlock(Token *cmd, int infl, int lvl, int cond)
36
Blox *pushBlock(Token *cmd, int infl, int lvl, int cond)
(-)blocks.h (-1 / +1 lines)
Lines 34-38 Link Here
34
extern void delBlock(Blox *);
34
extern void delBlock(Blox *);
35
extern void popBlock(int);
35
extern void popBlock(int);
36
extern int isUnreachable();
36
extern int isUnreachable(void);
37
extern void setUnreachable(int);
37
extern void setUnreachable(int);
38
38
(-)config.c (-19 / +14 lines)
Lines 30-41 Link Here
30
#endif
30
#endif
31
31
32
extern Token *tokenPop(Token **);
33
extern void freeToken(Token *);
34
extern void streamMore(Input *);
35
36
List *config = noList;
32
List *config = noList;
37
33
38
static struct {
34
static struct {
39
	char		*name;
35
	const char	*name;
40
	ParamType	code;
36
	ParamType	code;
41
} pvals[] ={
37
} pvals[] ={
Lines 72-79 Link Here
72
};
68
};
73
69
74
void dumpPdata(ParamData *pt, FILE *op)
70
static void dumpPdata(ParamData *pt, FILE *op)
75
{
71
{
76
    int i;
72
    int i;
77
    char *pad;
73
    const char *pad;
78
    List *lp;
74
    List *lp;
79
75
Lines 105-109 Link Here
105
}
101
}
106
102
107
void dumpConf(ConfigData *cp, FILE *op)
103
void dumpConf(const ConfigData *cp, FILE *op)
108
{
104
{
109
    List *plp;
105
    List *plp;
Lines 119-123 Link Here
119
}
115
}
120
116
121
static void pcode(ParamData *ppt, char *str)
117
static void pcode(ParamData *ppt, const char *str)
122
{
118
{
123
    int i;
119
    int i;
Lines 172-177 Link Here
172
    SeqnData *sd;
168
    SeqnData *sd;
173
    void *dp;
169
    void *dp;
174
    extern void dumpToken(Token *, FILE *);
170
 
175
    
176
    ppt = newpdata();
171
    ppt = newpdata();
177
    switch (tp->type)
172
    switch (tp->type)
Lines 253-257 Link Here
253
}
248
}
254
249
255
static int handle(Token *line)
250
static int confighandle(Token *line)
256
{
251
{
257
    ConfigData *cpt;
252
    ConfigData *cpt;
Lines 307-315 Link Here
307
}
302
}
308
303
309
void readconfig(char *str)
304
void readconfig(const char *str)
310
{
305
{
311
    FILE *fd;
306
    FILE *fd;
312
    Input file;
307
    Input file;
313
    
308
314
    if ((fd = fopen(str, "r")) == NULL)
309
    if ((fd = fopen(str, "r")) == NULL)
315
    {
310
    {
Lines 320-324 Link Here
320
 * use the tokenising mechanism we already have to parse the config file
315
 * use the tokenising mechanism we already have to parse the config file
321
 */
316
 */
322
    file.text = (char *) malloc(64*1024);
317
    file.atext = malloc(64*1024);
323
    file.stream = fd;
318
    file.stream = fd;
324
    file.tcall = file.texpr = 0;
319
    file.tcall = file.texpr = 0;
Lines 326-338 Link Here
326
    file.lineStart = 1;
321
    file.lineStart = 1;
327
    streamMore(&file);
322
    streamMore(&file);
328
    while(handle(collect(&file)))
323
    while(confighandle(collect(&file)))
329
    {
324
    {
330
        /* skip */
325
        /* skip */
331
    }
326
    }
332
    free(file.text);  
327
    free(file.atext);
333
    fclose(fd);
328
    fclose(fd);
334
}
329
}
335
330
336
void stringconfig(char *str)
331
void stringconfig(const char *str)
337
{
332
{
338
    Input file;
333
    Input file;
Lines 347-351 Link Here
347
    file.lineNumber = 1;
342
    file.lineNumber = 1;
348
    file.lineStart = 1;
343
    file.lineStart = 1;
349
    while(handle(collect(&file)))
344
    while(confighandle(collect(&file)))
350
    {
345
    {
351
        /* skip */
346
        /* skip */
(-)flagvars.h (-5 / +5 lines)
Lines 15-19 Link Here
15
15
16
extern int lineNumber;
16
extern int lineNumber;
17
extern char *currentfile;
17
extern const char *currentfile;
18
18
19
extern int compout;
19
extern int compout;
Lines 64-72 Link Here
64
extern int trystrings;
64
extern int trystrings;
65
65
66
extern char *style;
66
extern const char *style;
67
extern char *pstyle;
67
extern const char *pstyle;
68
extern char *contString;
68
extern const char *contString;
69
69
70
extern char *locale;
70
extern const char *locale;
71
extern FILE *msgfile;
71
extern FILE *msgfile;
72
extern FILE *specfile;
72
extern FILE *specfile;
(-)frink.c (-31 / +19 lines)
Lines 29-32 Link Here
29
#include <stdlib.h>
29
#include <stdlib.h>
30
#endif
30
#endif
31
#include <unistd.h>
31
32
32
int failed	= 0;
33
int failed	= 0;
Lines 40-44 Link Here
40
41
41
int compout	= 0;
42
int compout	= 0;
42
int resvsplit	= 0;
43
static int resvsplit = 0;
43
int noquotes	= 0;
44
int noquotes	= 0;
44
int spaceout	= 0;
45
int spaceout	= 0;
Lines 81-89 Link Here
81
int internat	= 0;
82
int internat	= 0;
82
83
83
char *style		= (char *) 0;
84
const char *style	= NULL;
84
char *pstyle		= (char *) 0;
85
const char *pstyle	= NULL;
85
char *contString 	= "";
86
const char *contString 	= "";
86
87
87
char *locale		= (char *) 0;
88
const char *locale	= NULL;
88
FILE *msgfile		= NULL;
89
FILE *msgfile		= NULL;
89
FILE *specfile		= NULL;
90
FILE *specfile		= NULL;
Lines 92-108 Link Here
92
int praghold		= 0;
93
int praghold		= 0;
93
94
94
char *currentfile	= (char *) 0;
95
const char *currentfile	= NULL;
95
96
96
List *skiplist = (List *) 0;
97
List *skiplist = NULL;
97
98
98
#ifndef __FreeBSD__
99
extern int getopt(int, char*const*, const char*);
100
#endif
101
102
extern int optind;
103
extern char *optarg;
104
extern int fclose(FILE*);
105
extern void readconfig(char *);
106
extern void stringconfig(char *);
107
extern void clearState(void);
99
extern void clearState(void);
108
100
Lines 113-117 Link Here
113
}
105
}
114
106
115
static char *languages[] =
107
static const char *languages[] =
116
{
108
{
117
    "aa",	/* Afar	*/
109
    "aa",	/* Afar	*/
Lines 257-261 Link Here
257
};
249
};
258
250
259
static char *countries[] =
251
static const char *countries[] =
260
{
252
{
261
    "AF",	/* AFGHANISTAN */
253
    "AF",	/* AFGHANISTAN */
Lines 501-509 Link Here
501
};
493
};
502
494
503
static void checkLocale(char *v)
495
static void checkLocale(const char *v)
504
{
496
{
505
    int l, i, fnd = 0;;
497
    int l, i, fnd = 0;;
506
498
507
    for (i = 0; languages[i] != (char *) 0; i += 1)
499
    for (i = 0; languages[i] != NULL; i += 1)
508
    {
500
    {
509
	if (strncmp(v, languages[i], 2) == 0)
501
	if (strncmp(v, languages[i], 2) == 0)
Lines 625-629 Link Here
625
}
617
}
626
618
627
void setOption(int flag, char *value)
619
static void setOption(int flag, const char *value)
628
{
620
{
629
    int not;
621
    int not;
Lines 750-756 Link Here
750
}
742
}
751
743
752
static void readrc(char *file)
744
static void readrc(const char *file)
753
{
745
{
754
    char *opts[50], buff[128], *cp;
746
    const char *opts[50];
747
    char buff[128], *cp;
755
    FILE *desc;
748
    FILE *desc;
756
    int leng, i;
749
    int leng, i;
Lines 794-804 Link Here
794
static void process(FILE *desc)
787
static void process(FILE *desc)
795
{
788
{
796
    extern void flushOutput(void);
797
    extern int handle(Token *line);
798
    extern void streamMore(Input *);
799
800
    Input file;
789
    Input file;
801
790
802
    file.text = (char *) malloc(64*1024);
791
    file.atext = malloc(64*1024);
803
    file.stream = desc;
792
    file.stream = desc;
804
    file.tcall = file.texpr = 0;
793
    file.tcall = file.texpr = 0;
Lines 810-819 Link Here
810
    }
799
    }
811
    flushOutput();
800
    flushOutput();
812
    free(file.text);
801
    free(file.atext);
813
}
802
}
814
803
815
static void initCmds(void)
804
static void initCmds(void)
816
{
805
{
817
    static char *cmdspec =
806
    static const char *cmdspec =
818
	"set {{var 0x0017} {ctype? 0x0001}}\n"
807
	"set {{var 0x0017} {ctype? 0x0001}}\n"
819
	"global {{varlist 0x0150}}\n"
808
	"global {{varlist 0x0150}}\n"
Lines 970-974 Link Here
970
{
959
{
971
    FILE  *desc;
960
    FILE  *desc;
972
    extern void initOutput(void);
973
961
974
    initCmds();
962
    initCmds();
(-)frink.h (+14 lines)
Lines 100-101 Link Here
100
extern List *skiplist;
100
extern List *skiplist;
101
extern List *blocks;
101
extern List *blocks;
102
103
void dumpConf(const ConfigData *, FILE*);
104
void readconfig(const char *fileName);
105
void stringconfig(const char *line);
106
void initOutput(void);
107
void setIndent(void);
108
void outdent(void);
109
int isVarToken(const Token *);
110
int isSwitch(const Token *);
111
int isSingleCall(const Token *, const char *);
112
int tokEqual(const Token *, const char *);
113
void flushOutput(void);
114
void clearState(void);
115
void warnFor(const Token *token, const char *cmd, const char *txt);
(-)output.c (-12 / +12 lines)
Lines 44-51 Link Here
44
static TokenType olast	= HEAD;
44
static TokenType olast	= HEAD;
45
45
46
static Token nlToken	= {BLANK, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
46
static Token nlToken	= {.type = BLANK, .ckind = CNSTWORD};
47
static Token startToken	= {START, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
47
static Token startToken	= {.type = START, .ckind = CNSTWORD};
48
static Token contToken	= {CONT, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
48
static Token contToken	= {.type = CONT, .ckind = CNSTWORD};
49
static Token spToken	= {SP, CNSTWORD, 0, " ", 1, (Token *) 0, (Token *) 0};
49
static Token spToken	= {.type = SP, .ckind = CNSTWORD, .text = " ", .length = 1};
50
50
51
void initOutput(void)
51
void initOutput(void)
Lines 227-231 Link Here
227
}
227
}
228
228
229
static void printkn(char *txt, int length, int keepnl)
229
static void printkn(const char *txt, int length, int keepnl)
230
{
230
{
231
    char *cp;
231
    char *cp;
Lines 252-256 Link Here
252
}
252
}
253
253
254
static void printn(char *txt, int len)
254
static void printn(const char *txt, int len)
255
{
255
{
256
    if (!testonly)
256
    if (!testonly)
Lines 260-269 Link Here
260
}
260
}
261
261
262
static void print(char *txt)
262
static void print(const char *txt)
263
{
263
{
264
    printn(txt, strlen(txt));
264
    printn(txt, strlen(txt));
265
}
265
}
266
266
267
static void brace(char *t)
267
static void brace(const char *t)
268
{
268
{
269
    char *cp, *bp;
269
    char *cp, *bp;
Lines 378-385 Link Here
378
}
378
}
379
379
380
static Token dollarToken = {DOLLAR, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
380
static Token dollarToken = {.type = DOLLAR, .ckind = CNSTWORD};
381
static Token endlineToken = {ENDLINE, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
381
static Token endlineToken = {.type = ENDLINE, .ckind = CNSTWORD};
382
static Token lbrackToken = {LBRACK, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
382
static Token lbrackToken = {.type = LBRACK, .ckind = CNSTWORD};
383
static Token rbrackToken = {RBRACK, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
383
static Token rbrackToken = {.type = RBRACK, .ckind = CNSTWORD};
384
384
385
void output(Token *token, int compress)
385
void output(Token *token, int compress)
(-)tcl.c (-114 / +103 lines)
Lines 27-74 Link Here
27
static int inproc = 0;
27
static int inproc = 0;
28
28
29
static Token lbraceToken	= {LBRACE, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
29
static Token lbraceToken	= {.type = LBRACE, .ckind = CNSTWORD};
30
static Token rbraceToken	= {RBRACE, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
30
static Token rbraceToken	= {.type = RBRACE, .ckind = CNSTWORD};
31
static Token xcontToken		= {XCONT, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
31
static Token xcontToken		= {.type = XCONT, .ckind = CNSTWORD};
32
static Token ostartToken	= {OSTART, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
32
static Token ostartToken	= {.type = OSTART, .ckind = CNSTWORD};
33
static Token startToken		= {START, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
33
static Token startToken		= {.type = START, .ckind = CNSTWORD};
34
static Token contToken		= {CONT, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
34
static Token contToken		= {.type = CONT, .ckind = CNSTWORD};
35
static Token econtToken		= {ECONT, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
35
static Token econtToken		= {.type = ECONT, .ckind = CNSTWORD};
36
static Token emToken		= {EM, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
36
static Token emToken		= {.type = EM, .ckind = CNSTWORD};
37
static Token nospToken		= {NOSP, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
37
static Token nospToken		= {.type = NOSP, .ckind = CNSTWORD};
38
static Token *olsToken		= &emToken;
38
static Token *olsToken		= &emToken;
39
static Token spToken		= {SP, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
39
static Token spToken		= {.type = SP, .ckind = CNSTWORD};
40
static Token lbrackToken	= {LBRACK, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
40
static Token lbrackToken	= {.type = LBRACK, .ckind = CNSTWORD};
41
static Token rbrackToken	= {RBRACK, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0};
41
static Token rbrackToken	= {.type = RBRACK, .ckind = CNSTWORD};
42
static Token msgcatToken	= {CONST, CNSTWORD, 0, "::msgcat::mc", 12, (Token *) 0, (Token *) 0};
42
static Token msgcatToken	= {.type = CONST, .ckind = CNSTWORD, .text = "::msgcat::mc", .length = 12};
43
43
44
static Token dqStart		= {DQSTART, CNSTWORD, 0, (char *) 0, 0, noToken, noToken};
44
static Token dqStart		= {.type = DQSTART, .ckind = CNSTWORD};
45
static Token dqEnd		= {DQEND, CNSTWORD, 0, (char *) 0, 0, noToken, noToken};
45
static Token dqEnd		= {.type = DQEND, .ckind = CNSTWORD};
46
static Token thenToken		= {CONST, CNSTWORD, 0, "then", 4, noToken, noToken};
46
static Token thenToken		= {.type = CONST, .ckind = CNSTWORD, .text = "then", .length = 4};
47
static Token procToken		= {CONST, CNSTWORD, 0, "proc", 4, noToken, noToken};
47
static Token procToken		= {.type = CONST, .ckind = CNSTWORD, .text = "proc", .length = 4};
48
static Token elseToken		= {CONST, CNSTWORD, 0, "else", 4, noToken, noToken};
48
static Token elseToken		= {.type = CONST, .ckind = CNSTWORD, .text = "else", .length = 4};
49
static Token elseifToken	= {CONST, CNSTWORD, 0, "elseif", 6, noToken, noToken};
49
static Token elseifToken	= {.type = CONST, .ckind = CNSTWORD, .text = "elseif", .length = 6};
50
static Token methodToken	= {CONST, CNSTWORD, 0, "method", 6, noToken, noToken};
50
static Token methodToken	= {.type = CONST, .ckind = CNSTWORD, .text = "method", .length = 6};
51
static Token semiToken		= {SEMI, CNSTWORD, 0, ";", 1, noToken, noToken};
51
static Token semiToken		= {.type = SEMI, .ckind = CNSTWORD, .text = ";", .length = 1};
52
static Token argsToken		= {SEMI, CNSTWORD, 0, "args", 4, noToken, noToken};
52
static Token argsToken		= {.type = SEMI, .ckind = CNSTWORD, .text = "args", .length = 4};
53
static Token argvToken		= {SEMI, CNSTWORD, 0, "argv", 4, noToken, noToken};
53
static Token argvToken		= {.type = SEMI, .ckind = CNSTWORD, .text = "argv", .length = 4};
54
static Token argv0Token		= {SEMI, CNSTWORD, 0, "argv0", 5, noToken, noToken};
54
static Token argv0Token		= {.type = SEMI, .ckind = CNSTWORD, .text = "argv0", .length = 5};
55
static Token platfToken		= {SEMI, CNSTWORD, 0, "tcl_platform", 12, noToken, noToken};
55
static Token platfToken		= {.type = SEMI, .ckind = CNSTWORD, .text = "tcl_platform", .length = 12};
56
56
57
List *blocks  = noList;
57
List *blocks  = noList;
58
58
59
static CheckIt **noChecks = (CheckIt **) 0;
60
61
extern void setIndent(void);
62
extern void outdent(void);
63
extern int isVarToken(Token *);
64
extern int isSwitch(Token *);
65
extern int isSingleCall(Token *, char *);
66
extern int tokEqual(Token *, char *);
67
68
/*
59
/*
69
 * If there are no more tokens, print a useful message to the user and
60
 * If there are no more tokens, print a useful message to the user and
70
 * exit.
61
 * exit.
71
 */
62
 */
72
void failIfNullToken(Token *token, char *part, char *command, int ln)
63
static void failIfNullToken(const Token *token, const char *part,
64
    const char *command, int ln)
73
{
65
{
74
    char msg[1024];
66
    char msg[1024];
Lines 78-86 Link Here
78
	if (ln == 0)
70
	if (ln == 0)
79
	{
71
	{
80
	    sprintf(msg, "Missing \"%s\" part in call of %s", part, command);
72
	    snprintf(msg, sizeof msg, "Missing \"%s\" part in call of %s", part, command);
81
	}
73
	}
82
	else
74
	else
83
	{
75
	{
84
	    sprintf(msg, "Missing \"%s\" part in call of %s, starting line %d",
76
	    snprintf(msg, sizeof msg, "Missing \"%s\" part in call of %s, starting line %d",
85
	      part, command, ln);
77
	      part, command, ln);
86
	}
78
	}
Lines 93-97 Link Here
93
 * the user.
85
 * the user.
94
 */
86
 */
95
void warnIfArgsAfter(Token *token, char *part, char *command)
87
static void warnIfArgsAfter(const Token *token, const char *part,
88
    const char *command)
96
{
89
{
97
    char msg[1024];
90
    char msg[1024];
Lines 107-116 Link Here
107
	    if (*part != '\0')
100
	    if (*part != '\0')
108
	    {
101
	    {
109
		sprintf(msg, "Extra arguments after \"%s\" part in call of %s",
102
		snprintf(msg, sizeof msg, "Extra arguments after \"%s\" part in call of %s",
110
		  part, command);
103
		  part, command);
111
	    }
104
	    }
112
	    else
105
	    else
113
	    {
106
	    {
114
		sprintf(msg, "Extra arguments in call of `%s'", command);
107
		snprintf(msg, sizeof msg, "Extra arguments in call of `%s'", command);
115
	    }
108
	    }
116
	    warn(token, msg);
109
	    warn(token, msg);
Lines 118-122 Link Here
118
	      token->next->text[0] != '\0')
111
	      token->next->text[0] != '\0')
119
	    {
112
	    {
120
		sprintf(msg, "Extra token is `%s'", token->next->text);
113
		snprintf(msg, sizeof msg, "Extra token is `%s'", token->next->text);
121
		warn(token->next, msg);
114
		warn(token->next, msg);
122
	    }
115
	    }
Lines 125-129 Link Here
125
}
118
}
126
119
127
void warnExpr(Token *cmd, char *txt)
120
static void warnExpr(const Token *cmd, const char *txt)
128
{
121
{
129
    if (doTest(HEXPR) && cmd != noToken && cmd->type != LIST)
122
    if (doTest(HEXPR) && cmd != noToken && cmd->type != LIST)
Lines 133-151 Link Here
133
}
126
}
134
127
135
void warnFor(Token *token, char *cmd, char *txt)
128
void warnFor(const Token *token, const char *cmd, const char *txt)
136
{
129
{
137
    char msg[1024];
130
    char msg[1024];
138
131
139
    sprintf(msg, txt, cmd);
132
    snprintf(msg, sizeof msg, txt, cmd);
140
    warn(token, msg);
133
    warn(token, msg);
141
}
134
}
142
135
143
static void warnIFor(Token *token, int val, char *txt)
144
{
145
    char msg[1024];
146
147
    sprintf(msg, txt, val);
148
    warn(token, msg);
149
}
150
/*
136
/*
151
 * reset various variables so that multiple file processing doesn't get
137
 * reset various variables so that multiple file processing doesn't get
Lines 171-175 Link Here
171
}
157
}
172
158
173
static int isNumber(char *cp)
159
static int isNumber(const char *cp)
174
{
160
{
175
    if (*cp == '-' || *cp == '+')
161
    if (*cp == '-' || *cp == '+')
Lines 188-194 Link Here
188
}
174
}
189
175
190
static int tokIsLevel(Token *tp)
176
static int tokIsLevel(const Token *tp)
191
{
177
{
192
    char *cp;
178
    const char *cp;
193
    if (tp == noToken || !(tp->type == CONST || tp->type == LIST) || tp->text == (char *) 0)
179
    if (tp == noToken || !(tp->type == CONST || tp->type == LIST) || tp->text == (char *) 0)
194
    {
180
    {
Lines 208-212 Link Here
208
}
194
}
209
195
210
static int oneLine(Token *seq, int semis)
196
static int oneLine(const Token *seq, int semis)
211
{
197
{
212
    while (seq != noToken)
198
    while (seq != noToken)
Lines 222-226 Link Here
222
}
208
}
223
209
224
static int checkSpecial(char *val)
210
static int checkSpecial(const char *val)
225
{
211
{
226
    char ch;
212
    char ch;
Lines 239-253 Link Here
239
}
225
}
240
226
241
static void checkUnquoted(Token *str)
227
static void checkUnquoted(const Token *str)
242
{
228
{
243
    char msg[128];
229
    char msg[128];
244
    if (noquotes && str->type == CONST && str->ckind == CNSTWORD && !isNumber(str->text))
230
    if (noquotes && str->type == CONST && str->ckind == CNSTWORD && !isNumber(str->text))
245
    {
231
    {
246
        sprintf(msg, "Unquoted constant - \"%s\"", str->text);
232
        snprintf(msg, sizeof msg, "Unquoted constant - \"%s\"", str->text);
247
        warn(str, msg);
233
        warn(str, msg);
248
    }
234
    }
249
}
235
}
250
236
251
static void checkType(Token *cmd, int flags)
237
static void checkType(const Token *cmd, int flags)
252
{
238
{
253
    if (cmd->type == CONST)
239
    if (cmd->type == CONST)
Lines 267-271 Link Here
267
}
253
}
268
254
269
static int single(Token * tp)
255
static int single(const Token * tp)
270
{
256
{
271
    if (tp != noToken && tp->next == noToken)
257
    if (tp != noToken && tp->next == noToken)
Lines 286-290 Link Here
286
}
272
}
287
273
288
static int sconstant(Token *tp)
274
static int sconstant(const Token *tp)
289
{
275
{
290
    return (tp != noToken && tp->next == noToken
276
    return (tp != noToken && tp->next == noToken
Lines 292-296 Link Here
292
}
278
}
293
279
294
static int constantString(Token * tp, int any)
280
static int constantString(const Token * tp, int any)
295
{
281
{
296
    Token *sq;
282
    Token *sq;
Lines 313-322 Link Here
313
}
299
}
314
300
315
void loopstart(int inf, int cond)
301
static void loopstart(int inf, int cond)
316
{
302
{
317
    pushBlock(noToken, inf, -1, cond);
303
    pushBlock(noToken, inf, -1, cond);
318
}
304
}
319
305
320
void loopend(void)
306
static void loopend(void)
321
{
307
{
322
    Blox *bp = lpeek(blocks);
308
    Blox *bp = lpeek(blocks);
Lines 330-334 Link Here
330
}
316
}
331
317
332
static void msgsave(Token *tp, int any)
318
static void msgsave(const Token *tp, int any)
333
{
319
{
334
    char filename[128];
320
    char filename[128];
Lines 363-370 Link Here
363
}
349
}
364
350
365
void sptclop(Token *hd)
351
static void doUser(Token *hd, Token *cmd, const ConfigData *cpt, int nostart);
352
353
static void sptclop(Token *hd)
366
{
354
{
367
    List *cpt = config;
355
    List *cpt = config;
368
    extern void doUser(Token *hd, Token *cmd, ConfigData *cpt, int nostart);
369
    ConfigData *cdp;
356
    ConfigData *cdp;
370
357
Lines 529-533 Link Here
529
} PressFlags;
516
} PressFlags;
530
517
531
static void press(Token *v , PressFlags flags, CheckIt **checkp)
518
static void press(Token *v , PressFlags flags)
532
{
519
{
533
    Input *idx;
520
    Input *idx;
Lines 602-606 Link Here
602
		{
589
		{
603
		case SEMI :
590
		case SEMI :
604
		    if (flags && SEMIS)
591
		    if (flags & SEMIS)
605
		    {
592
		    {
606
			output(&semiToken, 1);
593
			output(&semiToken, 1);
Lines 641-645 Link Here
641
}
628
}
642
629
643
void etcetera(Token *cmd, int v)
630
static void etcetera(Token *cmd, int v)
644
{
631
{
645
    while (cmd != noToken)
632
    while (cmd != noToken)
Lines 650-654 Link Here
650
}
637
}
651
638
652
void catbin(Token *tp)
639
static void catbin(Token *tp)
653
{
640
{
654
    int sem, oln;
641
    int sem, oln;
Lines 693-697 Link Here
693
    VarData *vp = (VarData *) 0;
680
    VarData *vp = (VarData *) 0;
694
    char msg[1024];
681
    char msg[1024];
695
    Token *ap = noToken, *ac;
682
    Token *ap = noToken;
683
    const Token *ac;
696
    int array = 0;
684
    int array = 0;
697
685
Lines 829-833 Link Here
829
}
817
}
830
818
831
Token *doswitch(Token *cmd, Token *leadin)
819
static Token *doswitch(Token *cmd, Token *leadin)
832
{
820
{
833
    Token *tp, *bod;
821
    Token *tp, *bod;
Lines 952-956 Link Here
952
}
940
}
953
941
954
Token *doif(Token *cmd, Token *leadin)
942
static Token *doif(Token *cmd, Token *leadin)
955
{
943
{
956
    Token *tp, *then;
944
    Token *tp, *then;
Lines 964-968 Link Here
964
	cfl |= SPACEOUT;
952
	cfl |= SPACEOUT;
965
    }
953
    }
966
    press(cmd, cfl, noChecks);
954
    press(cmd, cfl);
967
    if (putThen) { output(&thenToken, 0); }
955
    if (putThen) { output(&thenToken, 0); }
968
    then = cmd->next;
956
    then = cmd->next;
Lines 980-984 Link Here
980
	failIfNullToken(tp, "condition", "elseif", ln);
968
	failIfNullToken(tp, "condition", "elseif", ln);
981
        warnExpr(tp, "elseif condition not braced.");
969
        warnExpr(tp, "elseif condition not braced.");
982
	press(tp, efl | PAREN, noChecks);
970
	press(tp, efl | PAREN);
983
	tp = tp->next;
971
	tp = tp->next;
984
	failIfNullToken(tp, "body", "elseif", ln);
972
	failIfNullToken(tp, "body", "elseif", ln);
Lines 1020-1026 Link Here
1020
1008
1021
1009
1022
int isNSName(Token *cmd)
1010
static int isNSName(const Token *cmd)
1023
{
1011
{
1024
    char *cp;
1012
    const char *cp;
1025
    int cols = 0;
1013
    int cols = 0;
1026
1014
Lines 1054-1058 Link Here
1054
}
1042
}
1055
1043
1056
static Token *doProc(Token *tag, Token *cmd, Token *leadin, int checkNS)
1044
static Token *doProc(Token *tag, Token *cmd, Token *leadin)
1057
{
1045
{
1058
    int ln = leadin->lineNo, inns;
1046
    int ln = leadin->lineNo, inns;
Lines 1177-1189 Link Here
1177
static Token *doproc(Token *cmd, Token *leadin)
1165
static Token *doproc(Token *cmd, Token *leadin)
1178
{
1166
{
1179
    return doProc(&procToken, cmd, leadin, 1);
1167
    return doProc(&procToken, cmd, leadin);
1180
}
1168
}
1181
1169
1182
static Token *domethod(Token *cmd, Token *leadin)
1170
static Token *domethod(Token *cmd, Token *leadin)
1183
{
1171
{
1184
    return doProc(&methodToken, cmd, leadin, 0);
1172
    return doProc(&methodToken, cmd, leadin);
1185
}
1173
}
1186
1174
1187
static Token *dodestructor(Token *cmd, Token *leadin)
1175
static Token *dodestructor(Token *cmd, Token *leadin __attribute__((__unused__)))
1188
{
1176
{
1189
    if (!nest[0])
1177
    if (!nest[0])
Lines 1200-1204 Link Here
1200
}
1188
}
1201
1189
1202
Token *doconstructor(Token *cmd, Token *leadin)
1190
static Token *doconstructor(Token *cmd, Token *leadin __attribute__((__unused__)))
1203
{
1191
{
1204
    if (!nest[0])
1192
    if (!nest[0])
Lines 1209-1213 Link Here
1209
    {
1197
    {
1210
	failIfNullToken(cmd, "args", "constructor", 0);
1198
	failIfNullToken(cmd, "args", "constructor", 0);
1211
	press(cmd, NOBRACE | ADDBRACES, noChecks);
1199
	press(cmd, NOBRACE | ADDBRACES);
1212
	cmd = cmd->next;
1200
	cmd = cmd->next;
1213
	failIfNullToken(cmd, "body", "constructor", 0);
1201
	failIfNullToken(cmd, "body", "constructor", 0);
Lines 1218-1222 Link Here
1218
}
1206
}
1219
1207
1220
Token *doreturn(Token *cmd, Token *leadin)
1208
static Token *doreturn(Token *cmd, Token *leadin)
1221
{
1209
{
1222
    Blox *pr = (Blox *) lpeek(blocks);
1210
    Blox *pr = (Blox *) lpeek(blocks);
Lines 1267-1271 Link Here
1267
}
1255
}
1268
1256
1269
Token *doregexp(Token *cmd, Token *leadin)
1257
static Token *doregexp(Token *cmd, Token *leadin)
1270
{
1258
{
1271
    int eopt = 0;
1259
    int eopt = 0;
Lines 1312-1316 Link Here
1312
}
1300
}
1313
1301
1314
Token *doregsub(Token *cmd, Token *leadin)
1302
static Token *doregsub(Token *cmd, Token *leadin)
1315
{
1303
{
1316
    int eopt = 0;
1304
    int eopt = 0;
Lines 1361-1365 Link Here
1361
}
1349
}
1362
1350
1363
Token *dobind(Token *cmd, Token *leadin)
1351
static Token *dobind(Token *cmd, Token *leadin __attribute__((__unused__)))
1364
{
1352
{
1365
    Token *np;
1353
    Token *np;
Lines 1387-1391 Link Here
1387
}
1375
}
1388
1376
1389
Token *doitcl_class(Token *cmd, Token *leadin)
1377
static Token *doitcl_class(Token *cmd, Token *leadin __attribute__((__unused__)))
1390
{
1378
{
1391
    failIfNullToken(cmd, "className", "itcl_class", 0);
1379
    failIfNullToken(cmd, "className", "itcl_class", 0);
Lines 1400-1404 Link Here
1400
}
1388
}
1401
1389
1402
Token *docvar(Token *cmd, Token *prt)
1390
static Token *docvar(Token *cmd, Token *prt)
1403
{
1391
{
1404
    if (!nest[0])
1392
    if (!nest[0])
Lines 1412-1416 Link Here
1412
	if ((cmd = cmd->next) != noToken)
1400
	if ((cmd = cmd->next) != noToken)
1413
	{
1401
	{
1414
	    press(cmd, NOBRACE | ADDBRACES, noChecks);
1402
	    press(cmd, NOBRACE | ADDBRACES);
1415
	    warnIfArgsAfter(cmd, "init", prt->text);
1403
	    warnIfArgsAfter(cmd, "init", prt->text);
1416
	}
1404
	}
Lines 1419-1423 Link Here
1419
}
1407
}
1420
1408
1421
Token *dopublic(Token *cmd, Token *leadin)
1409
static Token *dopublic(Token *cmd, Token *leadin __attribute__((__unused__)))
1422
{
1410
{
1423
    if (!nest[0])
1411
    if (!nest[0])
Lines 1431-1435 Link Here
1431
	if ((cmd = cmd->next) != noToken)
1419
	if ((cmd = cmd->next) != noToken)
1432
	{
1420
	{
1433
	    press(cmd, NOBRACE | ADDBRACES, noChecks);
1421
	    press(cmd, NOBRACE | ADDBRACES);
1434
	    if ((cmd = cmd->next) != noToken)
1422
	    if ((cmd = cmd->next) != noToken)
1435
	    {
1423
	    {
Lines 1442-1450 Link Here
1442
}
1430
}
1443
1431
1444
Token *doprotected(Token *cmd, Token *leadin) { return docvar(cmd, leadin); }
1432
static Token *doprotected(Token *cmd, Token *leadin) { return docvar(cmd, leadin); }
1445
1433
1446
Token *docommon(Token *cmd, Token *leadin) { return docvar(cmd, leadin); }
1434
static Token *docommon(Token *cmd, Token *leadin) { return docvar(cmd, leadin); }
1447
1435
1448
static void checkVar(Token *cmd, char *nm)
1436
static void checkVar(Token *cmd, const char *nm)
1449
{
1437
{
1450
    List *bp = blocks;
1438
    List *bp = blocks;
Lines 1525-1529 Link Here
1525
}
1513
}
1526
1514
1527
Token *doforeach(Token *cmd, Token *leadin)
1515
static Token *doforeach(Token *cmd, Token *leadin __attribute__((__unused__)))
1528
{
1516
{
1529
    failIfNullToken(cmd, "varName", "foreach", 0);
1517
    failIfNullToken(cmd, "varName", "foreach", 0);
Lines 1535-1539 Link Here
1535
	cmd = cmd->next;
1523
	cmd = cmd->next;
1536
	failIfNullToken(cmd, "list", "foreach", 0);
1524
	failIfNullToken(cmd, "list", "foreach", 0);
1537
	press(cmd, NOBRACE, noChecks);
1525
	press(cmd, NOBRACE);
1538
	cmd = cmd->next;
1526
	cmd = cmd->next;
1539
    }
1527
    }
Lines 1547-1551 Link Here
1547
}
1535
}
1548
1536
1549
Token *doloop(Token *cmd, Token *leadin)
1537
static Token *doloop(Token *cmd, Token *leadin __attribute__((__unused__)))
1550
{
1538
{
1551
    Token *tp;
1539
    Token *tp;
Lines 1557-1569 Link Here
1557
    {
1545
    {
1558
	failIfNullToken(cmd, "var", "loop", 0);
1546
	failIfNullToken(cmd, "var", "loop", 0);
1559
	press(cmd, NOBRACE | ADDBRACES, noChecks);	/* var */
1547
	press(cmd, NOBRACE | ADDBRACES);	/* var */
1560
	tp = cmd->next;
1548
	tp = cmd->next;
1561
	failIfNullToken(tp, "first", "loop", 0);
1549
	failIfNullToken(tp, "first", "loop", 0);
1562
	warnExpr(cmd, "Unbracketed loop \"first\"");
1550
	warnExpr(cmd, "Unbracketed loop \"first\"");
1563
	press(tp, ADDBRACES, noChecks);			/* first */
1551
	press(tp, ADDBRACES);			/* first */
1564
	tp = tp->next;
1552
	tp = tp->next;
1565
	failIfNullToken(tp, "limit", "loop", 0);
1553
	failIfNullToken(tp, "limit", "loop", 0);
1566
	warnExpr(cmd, "Unbracketed loop \"limit\"");
1554
	warnExpr(cmd, "Unbracketed loop \"limit\"");
1567
	press(tp, ADDBRACES, noChecks);			/* limit */
1555
	press(tp, ADDBRACES);			/* limit */
1568
1556
1569
	tp = tp->next;
1557
	tp = tp->next;
Lines 1573-1577 Link Here
1573
	{
1561
	{
1574
	    warnExpr(cmd, "Unbracketed loop \"incr\"");
1562
	    warnExpr(cmd, "Unbracketed loop \"incr\"");
1575
	    press(tp, NOBRACE | ADDBRACES, noChecks);		/* incr */
1563
	    press(tp, NOBRACE | ADDBRACES);		/* incr */
1576
	    tp = tp->next;
1564
	    tp = tp->next;
1577
	}
1565
	}
Lines 1585-1589 Link Here
1585
} 
1573
} 
1586
1574
1587
Token *doexpr(Token *cmd, Token *leadin)
1575
static Token *doexpr(Token *cmd, Token *leadin __attribute__((__unused__)))
1588
{
1576
{
1589
    if (!doExpr)
1577
    if (!doExpr)
Lines 1600-1604 Link Here
1600
	{
1588
	{
1601
	    warnExpr(cmd, "expr body not braced.");
1589
	    warnExpr(cmd, "expr body not braced.");
1602
	    press(cmd, ADDBRACES | PAREN, noChecks); /* */
1590
	    press(cmd, ADDBRACES | PAREN); /* */
1603
	}
1591
	}
1604
	else
1592
	else
Lines 1611-1615 Link Here
1611
}
1599
}
1612
1600
1613
Token *dounset(Token *cmd, Token *leadin)
1601
static Token *dounset(Token *cmd, Token *leadin)
1614
{
1602
{
1615
    int pCount = 1;
1603
    int pCount = 1;
Lines 1642-1646 Link Here
1642
}
1630
}
1643
1631
1644
Token *doupvar(Token *cmd, Token *leadin)
1632
static Token *doupvar(Token *cmd, Token *leadin)
1645
{
1633
{
1646
    int paramCount = 0;
1634
    int paramCount = 0;
Lines 1673-1677 Link Here
1673
}
1661
}
1674
1662
1675
Token *dovariable(Token *cmd, Token *leadin)
1663
static Token *dovariable(Token *cmd, Token *leadin)
1676
{
1664
{
1677
    int paramCount = 1;
1665
    int paramCount = 1;
Lines 1777-1781 Link Here
1777
}
1765
}
1778
1766
1779
void doBasic(ConfigData *cpt, Token *hd, Token *cmd)
1767
static void doBasic(const ConfigData *cpt, Token *hd, Token *cmd)
1780
{
1768
{
1781
    List *sp, *llp, *lp;
1769
    List *sp, *llp, *lp;
Lines 1851-1855 Link Here
1851
	    else
1839
	    else
1852
	    {
1840
	    {
1853
		press(cmd, NOBRACE | ADDBRACES | SEMIS, noChecks); /* */
1841
		press(cmd, NOBRACE | ADDBRACES | SEMIS); /* */
1854
	    }
1842
	    }
1855
	    break;
1843
	    break;
Lines 1863-1867 Link Here
1863
	    {
1851
	    {
1864
		warnExpr(cmd, "Unbracketed expression");
1852
		warnExpr(cmd, "Unbracketed expression");
1865
		press(cmd, ptpar, noChecks); /* */
1853
		press(cmd, ptpar); /* */
1866
	    }
1854
	    }
1867
	    break;
1855
	    break;
Lines 1884-1888 Link Here
1884
		    ptpar |= SPACEOUT;
1872
		    ptpar |= SPACEOUT;
1885
		}
1873
		}
1886
		press(cmd, ptpar, noChecks);
1874
		press(cmd, ptpar);
1887
		loopstart(infloop, 1);
1875
		loopstart(infloop, 1);
1888
	    }
1876
	    }
Lines 2141-2145 Link Here
2141
}
2129
}
2142
2130
2143
void doUser(Token *hd, Token *cmd, ConfigData *cpt, int nostart)
2131
static void doUser(Token *hd, Token *cmd,
2132
    const ConfigData *cpt, int nostart)
2144
{
2133
{
2145
    if (isUnreachable())
2134
    if (isUnreachable())
(-)token.c (-60 / +38 lines)
Lines 32-37 Link Here
32
#endif
32
#endif
33
33
34
extern char *currentfile;
35
36
typedef struct tbuff_s
34
typedef struct tbuff_s
37
{
35
{
Lines 78-82 Link Here
78
}
76
}
79
77
80
static void catTB(TBuff *tp, char *str)
78
static void catTB(TBuff *tp, const char *str)
81
{
79
{
82
    while (*str)
80
    while (*str)
Lines 87-91 Link Here
87
}
85
}
88
86
89
static char *tokenName[] =
87
static const char *tokenName[] =
90
{
88
{
91
    "ENDF",
89
    "ENDF",
Lines 137-141 Link Here
137
static Token *varToken(Input *);
135
static Token *varToken(Input *);
138
136
139
Token *newToken(TokenType t)
137
static Token *newToken(TokenType t)
140
{
138
{
141
    Token *tp = malloc(sizeof(Token));
139
    Token *tp = malloc(sizeof(Token));
Lines 150-156 Link Here
150
}
148
}
151
149
152
void dumpToken(Token *tk, FILE *ops)
150
void dumpToken(const Token *tk, FILE *ops)
153
{
151
{
154
    static char *cval [] =
152
    static const char *cval [] =
155
    {
153
    {
156
        "word", "string", "list"
154
        "word", "string", "list"
Lines 195-199 Link Here
195
}
193
}
196
194
197
void fail(Token *tp, char *msg)
195
void fail(const Token *tp, const char *msg)
198
{
196
{
199
    if (!compout)
197
    if (!compout)
Lines 325-329 Link Here
325
}
323
}
326
324
327
void warn(Token *tp, char *msg)
325
void warn(const Token *tp, const char *msg)
328
{
326
{
329
    Blox *blp = (Blox *) lpeek(blocks);
327
    Blox *blp = (Blox *) lpeek(blocks);
Lines 334-338 Link Here
334
        fprintf(stderr, "***");
332
        fprintf(stderr, "***");
335
    }
333
    }
336
    if (currentfile != (char *) 0)
334
    if (currentfile != NULL)
337
    {
335
    {
338
        fprintf(stderr, " %s", currentfile);
336
        fprintf(stderr, " %s", currentfile);
Lines 377-381 Link Here
377
}
375
}
378
376
379
static void bwarn(int ln, char *msg)
377
static void bwarn(int ln, const char *msg)
380
{
378
{
381
    Token *tp = newToken(SP);
379
    Token *tp = newToken(SP);
Lines 391-395 Link Here
391
    if (file->stream != NULL)
389
    if (file->stream != NULL)
392
    {
390
    {
393
	file->remaining = fread(file->text, 1, 64*1024, file->stream);
391
	file->remaining = fread(file->atext, 1, 64*1024, file->stream);
394
    }
392
    }
395
}
393
}
Lines 400-404 Link Here
400
}
398
}
401
399
402
static char *skipblank(char *cp)
400
static const char *skipblank(const char *cp)
403
{
401
{
404
    while (isBlank(*cp))
402
    while (isBlank(*cp))
Lines 497-503 Link Here
497
    if (tp != noToken)
495
    if (tp != noToken)
498
    {
496
    {
499
	if (tp->text != (char *) 0 && tp->text != tp->little)
497
	if (tp->atext != tp->little)
500
	{
498
	{
501
	    free(tp->text);
499
	    free(tp->atext);
502
	}
500
	}
503
	if (tp->sequence) freeToken(tp->sequence);
501
	if (tp->sequence) freeToken(tp->sequence);
Lines 507-511 Link Here
507
}
505
}
508
506
509
static char *filterString(Token *tp, char *txt)
507
static char *filterString(Token *tp, const char *txt)
510
{
508
{
511
    char *cp = malloc(strlen(txt) + 1), *pt;
509
    char *cp = malloc(strlen(txt) + 1), *pt;
Lines 556-578 Link Here
556
}
554
}
557
555
558
Input *ftokenise(char *txt, int length, int lineNo, int expr)
559
{
560
    Token *tmp = newToken(CONST); /* gash token for filterstring */
561
    Input *file = (Input *) malloc(sizeof(Input));
562
    file->remaining = length;
563
    file->pushed = 0;
564
    file->stream = NULL;
565
    file->position = file->text = filterString(tmp, txt);
566
    file->tcall = 0;
567
    file->texpr = expr;
568
    file->lineNumber = lineNo;
569
    file->lineStart = 1;
570
    freeToken(tmp); 
571
    return file;
572
}
573
574
void untokenise(Input *file)
556
void untokenise(Input *file)
575
{
557
{
576
    free(file->text);
558
    free(file->atext);
577
    free(file);
559
    free(file);
578
}
560
}
Lines 607-615 Link Here
607
}
589
}
608
590
609
static Token *createToken(TokenType t, char *text, Token *nxt)
591
static Token *createToken(TokenType t, const char *text, size_t len, Token *nxt)
610
{
592
{
611
    Token *tp = newToken(t);
593
    Token *tp = newToken(t);
612
594
613
    if ((tp->length = strlen(text)) < (sizeof(tp->little) - 1))
595
    if ((tp->length = len) < (sizeof(tp->little) - 1))
614
    {
596
    {
615
	tp->text = strcpy(tp->little, text);
597
	tp->text = strcpy(tp->little, text);
Lines 617-621 Link Here
617
    else
599
    else
618
    {
600
    {
619
	tp->text = newString(text);
601
	tp->text = strndup(text, len);
620
    }
602
    }
621
    tp->next = nxt;
603
    tp->next = nxt;
Lines 720-724 Link Here
720
static Token *handleSemi(Input*, char);
702
static Token *handleSemi(Input*, char);
721
703
722
Token *stringToken(Input *file, char lst, TokenType res, int term)
704
static Token *stringToken(Input *file, char lst, TokenType res, int term)
723
{
705
{
724
    int bufSize = 16*1024;
706
    int bufSize = 16*1024;
Lines 837-841 Link Here
837
819
838
820
839
int tokEqual(Token *tp, char *val)
821
int tokEqual(const Token *tp, const char *val)
840
{
822
{
841
    if (tp != noToken)
823
    if (tp != noToken)
Lines 845-849 Link Here
845
	case CONST:
827
	case CONST:
846
	case LIST :
828
	case LIST :
847
	    return (tp->text != (char *) 0 && strcmp(tp->text, val) == 0);
829
	    return (tp->text != NULL && strcmp(tp->text, val) == 0);
848
	default:
830
	default:
849
	    break;
831
	    break;
Lines 853-857 Link Here
853
}
835
}
854
836
855
int tokNEqual(Token *tp, char *val, int n)
837
static int tokNEqual(const Token *tp, const char *val, int n)
856
{
838
{
857
    if (tp != noToken)
839
    if (tp != noToken)
Lines 871-875 Link Here
871
static int isPragma(TBuff *tp)
853
static int isPragma(TBuff *tp)
872
{
854
{
873
    char *cp;
855
    const char *cp;
874
    
856
    
875
    cp = skipblank(tp->buff + 1); /* start after # character */
857
    cp = skipblank(tp->buff + 1); /* start after # character */
Lines 1252-1256 Link Here
1252
    static struct pragma_s
1234
    static struct pragma_s
1253
    {
1235
    {
1254
        char		*text;
1236
        const char	*text;
1255
	enum Pragmas	value;
1237
	enum Pragmas	value;
1256
	int		nextmode;
1238
	int		nextmode;
Lines 1264-1272 Link Here
1264
	{ "unused",		0,		3},
1246
	{ "unused",		0,		3},
1265
	{ "array",		0,		4},
1247
	{ "array",		0,		4},
1266
	{ (char *) 0,		0,		1},
1248
	{ NULL,			0,		1},
1267
    };
1249
    };
1268
    struct pragma_s *prp;
1250
    struct pragma_s *prp;
1269
    int label, mode = 1;
1251
    int label, mode = 1;
1270
    char *cp;
1252
    const char *cp;
1271
    Token *token, *chars = newToken(CONST);
1253
    Token *token, *chars = newToken(CONST);
1272
    Input *pfile;
1254
    Input *pfile;
Lines 1348-1354 Link Here
1348
    Token *hd;
1330
    Token *hd;
1349
1331
1350
    extern int tclop(Token*, Token*);
1351
    extern void comment(Token *);
1352
1353
    if (line == noToken)
1332
    if (line == noToken)
1354
    {
1333
    {
Lines 1576-1580 Link Here
1576
}
1555
}
1577
1556
1578
Token *accumulate(Input *file, int nl)
1557
static Token *accumulate(Input *file, int nl)
1579
{
1558
{
1580
    Token *line = noToken, *hd = noToken;
1559
    Token *line = noToken, *hd = noToken;
Lines 1653-1657 Link Here
1653
}
1632
}
1654
1633
1655
static int chkVarToken(Token *token)
1634
static int chkVarToken(const Token *token)
1656
{
1635
{
1657
    return (token != noToken &&
1636
    return (token != noToken &&
Lines 1660-1666 Link Here
1660
}
1639
}
1661
1640
1662
int isVarToken(Token *token)
1641
int isVarToken(const Token *token)
1663
{
1642
{
1664
    char *cp;
1643
    const char *cp;
1665
    TBuff *tb;
1644
    TBuff *tb;
1666
1645
Lines 1695-1699 Link Here
1695
}
1674
}
1696
1675
1697
int isSingleCall(Token *token, char *proc)
1676
int isSingleCall(const Token *token, const char *proc)
1698
{
1677
{
1699
    if (token != noToken)
1678
    if (token != noToken)
Lines 1716-1720 Link Here
1716
}
1695
}
1717
1696
1718
int isSwitch(Token *token)
1697
int isSwitch(const Token *token)
1719
{
1698
{
1720
    if (token != noToken)
1699
    if (token != noToken)
Lines 1740-1751 Link Here
1740
}
1719
}
1741
1720
1742
Token *isArray(Token *tp)
1721
Token *isArray(const Token *tp)
1743
{
1722
{
1744
    Token *res = noToken;
1723
    Token *res = noToken;
1745
    TBuff *tbp = (TBuff *) 0;
1724
    TBuff *tbp = (TBuff *) 0;
1746
    char *txt, *cp, ch;
1725
    const char *txt, *cp;
1726
    char ch;
1747
    int len;
1727
    int len;
1748
1728
1749
    if (tp != noToken && (tp->text != (char *) 0 || tp->type == CONC))
1729
    if (tp != noToken && (tp->text != NULL || tp->type == CONC))
1750
    {
1730
    {
1751
	switch (tp->type)
1731
	switch (tp->type)
Lines 1777-1783 Link Here
1777
	        if (ch == '(')
1757
	        if (ch == '(')
1778
		{
1758
		{
1779
		    *cp = '\0';
1759
		    res = createToken(CONST, txt, cp - txt, noToken);
1780
		    res = createToken(CONST, txt, noToken);
1781
		    *cp = '(';
1782
		    break;
1760
		    break;
1783
		}
1761
		}
Lines 1791-1795 Link Here
1791
}
1769
}
1792
1770
1793
int constant(Token *tp)
1771
int constant(const Token *tp)
1794
{
1772
{
1795
    return (tp != noToken && (tp->type == CONST || tp->type == LIST));
1773
    return (tp != noToken && (tp->type == CONST || tp->type == LIST));
(-)token.h (-8 / +23 lines)
Lines 19-27 Link Here
19
typedef struct input_s
19
typedef struct input_s
20
{
20
{
21
    char *position;
21
    const char *position;
22
    int	 remaining;
22
    int	 remaining;
23
    int  pushed;
23
    int  pushed;
24
    char back[16];
24
    char back[16];
25
    char *text;
25
    union {
26
        const char *text; /* Use const in most cases */
27
	char *atext;
28
    };
26
    FILE *stream;
29
    FILE *stream;
27
    int tcall;
30
    int tcall;
Lines 49-54 Link Here
49
    ConstType ckind;
52
    ConstType ckind;
50
    int isconc;
53
    int isconc;
51
    char *text;
54
    union {
52
    int length;
55
        const char *text;
56
        char *atext;
57
    };
58
    size_t length;
53
    struct token_s *sequence;
59
    struct token_s *sequence;
54
    struct token_s *next;
60
    struct token_s *next;
Lines 70-80 Link Here
70
extern void makeCall(Token*, Token*);
76
extern void makeCall(Token*, Token*);
71
extern void body(Token *, int, int);
77
extern void body(Token *, int, int);
78
extern void comment(Token *);
72
79
73
extern void output(Token *, int);
80
extern void output(Token *, int);
74
extern void blank(void);
81
extern void blank(void);
75
extern void warn(Token *, char *);
82
extern void warn(const Token *, const char *);
76
extern void fail(Token *, char *);
83
extern void fail(const Token *, const char *);
84
85
extern Token *isArray(const Token *);
86
extern int constant(const Token *tp);
87
extern int tclop(Token *hd, Token *line);
88
extern void streamMore(Input *file);
89
extern int handle(Token *line);
90
extern void sprocess(Token *lst, int nls);
91
extern void dumpToken(const Token *tk, FILE *ops);
92
extern Token *tokenPop(Token **);
93
extern void freeToken(Token *);
77
94
78
extern Token *isArray(Token *);
79
extern int constant(Token *tp);
80
#endif
95
#endif
(-)vars.c (-10 / +9 lines)
Lines 33-41 Link Here
33
#endif
33
#endif
34
34
35
extern void warnFor(Token*, char*, char*);
36
37
void checkName(Token *cmd, int dynm)
35
void checkName(Token *cmd, int dynm)
38
{
36
{
39
    static char *badNames[] =
37
    static const char *badNames[] =
40
    {
38
    {
41
	".",
39
	".",
Lines 159-163 Link Here
159
        (char *) 0
157
        (char *) 0
160
    };
158
    };
161
    char **bnp = badNames, msgb[256];
159
    const char **bnp = badNames;
160
    char msgb[256];
162
161
163
    if (cmd != noToken)
162
    if (cmd != noToken)
Lines 199-203 Link Here
199
}
198
}
200
199
201
static VarData *newVar(char *name, enum VarType type)
200
static VarData *newVar(const char *name, enum VarType type)
202
{
201
{
203
    VarData *blp = (VarData *) malloc(sizeof(VarData));
202
    VarData *blp = (VarData *) malloc(sizeof(VarData));
Lines 212-216 Link Here
212
}
211
}
213
212
214
static VarData *addVar(char *name, enum VarType type, int array)
213
static VarData *addVar(const char *name, enum VarType type, int array)
215
{
214
{
216
    VarData *vp = newVar(name, type);
215
    VarData *vp = newVar(name, type);
Lines 221-225 Link Here
221
}
220
}
222
221
223
VarData *varKnown(char *name)
222
VarData *varKnown(const char *name)
224
{
223
{
225
    List *blp = blocks;
224
    List *blp = blocks;
Lines 246-250 Link Here
246
}
245
}
247
246
248
VarData *declareVar(Token *nm, enum VarType type, int array)
247
VarData *declareVar(const Token *nm, enum VarType type, int array)
249
{
248
{
250
    VarData *vp = varKnown(nm->text);
249
    VarData *vp = varKnown(nm->text);
Lines 269-273 Link Here
269
}
268
}
270
269
271
VarData *useVar(Token *nm, enum VarType type, int array)
270
VarData *useVar(const Token *nm, enum VarType type, int array)
272
{
271
{
273
    VarData *vp;
272
    VarData *vp;
Lines 299-303 Link Here
299
}
298
}
300
299
301
VarData *setVar(Token *nm, enum VarType type, int array)
300
VarData *setVar(const Token *nm, enum VarType type, int array)
302
{
301
{
303
    VarData *vp;
302
    VarData *vp;
(-)vars.h (-5 / +5 lines)
Lines 12-16 Link Here
12
 */
12
 */
13
13
14
#ifndef FRINK_VARS_h
14
#ifndef FRINK_VARS_H
15
#define FRINK_VARS_H
15
#define FRINK_VARS_H
16
16
Lines 47-54 Link Here
47
47
48
extern void checkName(Token *, int);
48
extern void checkName(Token *, int);
49
extern VarData *varKnown(char *);
49
extern VarData *varKnown(const char *);
50
extern VarData *declareVar(Token *, enum VarType, int);
50
extern VarData *declareVar(const Token *, enum VarType, int);
51
extern VarData *useVar(Token *, enum VarType, int);
51
extern VarData *useVar(const Token *, enum VarType, int);
52
extern VarData *setVar(Token *, enum VarType, int);
52
extern VarData *setVar(const Token *, enum VarType, int);
53
53
54
#endif
54
#endif

Return to bug 246163