diff --git a/devel/frink/Makefile b/devel/frink/Makefile index 8b8cca039c50..a065ec0a4900 100644 --- a/devel/frink/Makefile +++ b/devel/frink/Makefile @@ -1,29 +1,29 @@ # Created by: Mikhail Teterin PORTNAME= frink PORTVERSION= 2.2.2p4 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= devel MASTER_SITES= https://BSDforge.COM/projects/source/devel/frink/ MAINTAINER= portmaster@bsdforge.com COMMENT= Tcl formatter and static tester LICENSE= COPYRIGHT LICENSE_NAME= The University of Newcastle upon Tyne LICENSE_FILE= ${WRKSRC}/COPYRIGHT LICENSE_PERMS= auto-accept USES= uidfix MAKEFILE= ${FILESDIR}/Makefile.bsd WRKSRC= ${WRKDIR}/${PORTNAME}-2.2.2 OPTIONS_DEFINE= DOCS post-install: ${MKDIR} ${STAGEDIR}${DOCSDIR} ${INSTALL_DATA} ${WRKSRC}/ChangeLog ${WRKSRC}/README \ ${STAGEDIR}${DOCSDIR} .include diff --git a/devel/frink/files/patch-tcl.c b/devel/frink/files/patch-tcl.c index 669c4fcbb2c2..d968fbd54514 100644 --- a/devel/frink/files/patch-tcl.c +++ b/devel/frink/files/patch-tcl.c @@ -1,680 +1,718 @@ --- tcl.c.orig 2004-01-22 13:25:48 UTC +++ tcl.c @@ -26,50 +26,42 @@ static int nest[32]; /* = = class, 1 = namespace */ static int inproc = 0; -static Token lbraceToken = {LBRACE, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token rbraceToken = {RBRACE, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token xcontToken = {XCONT, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token ostartToken = {OSTART, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token startToken = {START, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token contToken = {CONT, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token econtToken = {ECONT, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token emToken = {EM, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token nospToken = {NOSP, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; +static Token lbraceToken = {.type = LBRACE, .ckind = CNSTWORD}; +static Token rbraceToken = {.type = RBRACE, .ckind = CNSTWORD}; +static Token xcontToken = {.type = XCONT, .ckind = CNSTWORD}; +static Token ostartToken = {.type = OSTART, .ckind = CNSTWORD}; +static Token startToken = {.type = START, .ckind = CNSTWORD}; +static Token contToken = {.type = CONT, .ckind = CNSTWORD}; +static Token econtToken = {.type = ECONT, .ckind = CNSTWORD}; +static Token emToken = {.type = EM, .ckind = CNSTWORD}; +static Token nospToken = {.type = NOSP, .ckind = CNSTWORD}; static Token *olsToken = &emToken; -static Token spToken = {SP, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token lbrackToken = {LBRACK, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token rbrackToken = {RBRACK, CNSTWORD, 0, (char *) 0, 0, (Token *) 0, (Token *) 0}; -static Token msgcatToken = {CONST, CNSTWORD, 0, "::msgcat::mc", 12, (Token *) 0, (Token *) 0}; +static Token spToken = {.type = SP, .ckind = CNSTWORD}; +static Token lbrackToken = {.type = LBRACK, .ckind = CNSTWORD}; +static Token rbrackToken = {.type = RBRACK, .ckind = CNSTWORD}; +static Token msgcatToken = {.type = CONST, .ckind = CNSTWORD, .text = "::msgcat::mc", .length = 12}; -static Token dqStart = {DQSTART, CNSTWORD, 0, (char *) 0, 0, noToken, noToken}; -static Token dqEnd = {DQEND, CNSTWORD, 0, (char *) 0, 0, noToken, noToken}; -static Token thenToken = {CONST, CNSTWORD, 0, "then", 4, noToken, noToken}; -static Token procToken = {CONST, CNSTWORD, 0, "proc", 4, noToken, noToken}; -static Token elseToken = {CONST, CNSTWORD, 0, "else", 4, noToken, noToken}; -static Token elseifToken = {CONST, CNSTWORD, 0, "elseif", 6, noToken, noToken}; -static Token methodToken = {CONST, CNSTWORD, 0, "method", 6, noToken, noToken}; -static Token semiToken = {SEMI, CNSTWORD, 0, ";", 1, noToken, noToken}; -static Token argsToken = {SEMI, CNSTWORD, 0, "args", 4, noToken, noToken}; -static Token argvToken = {SEMI, CNSTWORD, 0, "argv", 4, noToken, noToken}; -static Token argv0Token = {SEMI, CNSTWORD, 0, "argv0", 5, noToken, noToken}; -static Token platfToken = {SEMI, CNSTWORD, 0, "tcl_platform", 12, noToken, noToken}; +static Token dqStart = {.type = DQSTART, .ckind = CNSTWORD}; +static Token dqEnd = {.type = DQEND, .ckind = CNSTWORD}; +static Token thenToken = {.type = CONST, .ckind = CNSTWORD, .text = "then", .length = 4}; +static Token procToken = {.type = CONST, .ckind = CNSTWORD, .text = "proc", .length = 4}; +static Token elseToken = {.type = CONST, .ckind = CNSTWORD, .text = "else", .length = 4}; +static Token elseifToken = {.type = CONST, .ckind = CNSTWORD, .text = "elseif", .length = 6}; +static Token methodToken = {.type = CONST, .ckind = CNSTWORD, .text = "method", .length = 6}; +static Token semiToken = {.type = SEMI, .ckind = CNSTWORD, .text = ";", .length = 1}; +static Token argsToken = {.type = SEMI, .ckind = CNSTWORD, .text = "args", .length = 4}; +static Token argvToken = {.type = SEMI, .ckind = CNSTWORD, .text = "argv", .length = 4}; +static Token argv0Token = {.type = SEMI, .ckind = CNSTWORD, .text = "argv0", .length = 5}; +static Token platfToken = {.type = SEMI, .ckind = CNSTWORD, .text = "tcl_platform", .length = 12}; List *blocks = noList; -static CheckIt **noChecks = (CheckIt **) 0; - -extern void setIndent(void); -extern void outdent(void); -extern int isVarToken(Token *); -extern int isSwitch(Token *); -extern int isSingleCall(Token *, char *); -extern int tokEqual(Token *, char *); - /* * If there are no more tokens, print a useful message to the user and * exit. */ -void failIfNullToken(Token *token, char *part, char *command, int ln) +static void failIfNullToken(const Token *token, const char *part, + const char *command, int ln) { char msg[1024]; @@ -77,11 +69,11 @@ void failIfNullToken(Token *token, char *part, char *c { if (ln == 0) { - sprintf(msg, "Missing \"%s\" part in call of %s", part, command); + snprintf(msg, sizeof msg, "Missing \"%s\" part in call of %s", part, command); } else { - sprintf(msg, "Missing \"%s\" part in call of %s, starting line %d", + snprintf(msg, sizeof msg, "Missing \"%s\" part in call of %s, starting line %d", part, command, ln); } fail(token, msg); @@ -92,7 +84,8 @@ void failIfNullToken(Token *token, char *part, char *c * If there are more tokens after this one, print a useful warning to * the user. */ -void warnIfArgsAfter(Token *token, char *part, char *command) +static void warnIfArgsAfter(const Token *token, const char *part, + const char *command) { char msg[1024]; @@ -106,25 +99,25 @@ void warnIfArgsAfter(Token *token, char *part, char *c { if (*part != '\0') { - sprintf(msg, "Extra arguments after \"%s\" part in call of %s", + snprintf(msg, sizeof msg, "Extra arguments after \"%s\" part in call of %s", part, command); } else { - sprintf(msg, "Extra arguments in call of `%s'", command); + snprintf(msg, sizeof msg, "Extra arguments in call of `%s'", command); } warn(token, msg); if (token->next != noToken && token->next->text != (char *) 0 && token->next->text[0] != '\0') { - sprintf(msg, "Extra token is `%s'", token->next->text); + snprintf(msg, sizeof msg, "Extra token is `%s'", token->next->text); warn(token->next, msg); } } } } -void warnExpr(Token *cmd, char *txt) +static void warnExpr(const Token *cmd, const char *txt) { if (doTest(HEXPR) && cmd != noToken && cmd->type != LIST) { @@ -132,21 +125,14 @@ void warnExpr(Token *cmd, char *txt) } } -void warnFor(Token *token, char *cmd, char *txt) +void warnFor(const Token *token, const char *cmd, const char *txt) { char msg[1024]; - sprintf(msg, txt, cmd); + snprintf(msg, sizeof msg, txt, cmd); warn(token, msg); } -static void warnIFor(Token *token, int val, char *txt) -{ - char msg[1024]; - - sprintf(msg, txt, val); - warn(token, msg); -} /* * reset various variables so that multiple file processing doesn't get * screwed up @@ -170,7 +156,7 @@ void clearState(void) setVar(&platfToken, VGLOBAL, 1); } -static int isNumber(char *cp) +static int isNumber(const char *cp) { if (*cp == '-' || *cp == '+') { @@ -187,9 +173,9 @@ static int isNumber(char *cp) return 1; } -static int tokIsLevel(Token *tp) +static int tokIsLevel(const Token *tp) { - char *cp; + const char *cp; if (tp == noToken || !(tp->type == CONST || tp->type == LIST) || tp->text == (char *) 0) { return 0; @@ -207,7 +193,7 @@ static int tokIsLevel(Token *tp) return isNumber(cp); } -static int oneLine(Token *seq, int semis) +static int oneLine(const Token *seq, int semis) { while (seq != noToken) { @@ -221,7 +207,7 @@ static int oneLine(Token *seq, int semis) return 1; } -static int checkSpecial(char *val) +static int checkSpecial(const char *val) { char ch; @@ -238,17 +224,17 @@ static int checkSpecial(char *val) return 1; } -static void checkUnquoted(Token *str) +static void checkUnquoted(const Token *str) { char msg[128]; if (noquotes && str->type == CONST && str->ckind == CNSTWORD && !isNumber(str->text)) { - sprintf(msg, "Unquoted constant - \"%s\"", str->text); + snprintf(msg, sizeof msg, "Unquoted constant - \"%s\"", str->text); warn(str, msg); } } -static void checkType(Token *cmd, int flags) +static void checkType(const Token *cmd, int flags) { if (cmd->type == CONST) { @@ -266,7 +252,7 @@ static void checkType(Token *cmd, int flags) } } -static int single(Token * tp) +static int single(const Token * tp) { if (tp != noToken && tp->next == noToken) { @@ -285,13 +271,13 @@ static int single(Token * tp) return 0; } -static int sconstant(Token *tp) +static int sconstant(const Token *tp) { return (tp != noToken && tp->next == noToken && (tp->type == CONST || tp->type == LIST) && !checkSpecial(tp->text)); } -static int constantString(Token * tp, int any) +static int constantString(const Token * tp, int any) { Token *sq; if (tp == noToken) return 0; @@ -312,12 +298,12 @@ static int constantString(Token * tp, int any) } } -void loopstart(int inf, int cond) +static void loopstart(int inf, int cond) { pushBlock(noToken, inf, -1, cond); } -void loopend(void) +static void loopend(void) { Blox *bp = lpeek(blocks); int il = bp->infloop, su = (bp->breaks == 0); @@ -329,7 +315,7 @@ void loopend(void) } } -static void msgsave(Token *tp, int any) +static void msgsave(const Token *tp, int any) { char filename[128]; @@ -362,10 +348,11 @@ static void msgsave(Token *tp, int any) } } -void sptclop(Token *hd) +static void doUser(Token *hd, Token *cmd, const ConfigData *cpt, int nostart); + +static void sptclop(Token *hd) { List *cpt = config; - extern void doUser(Token *hd, Token *cmd, ConfigData *cpt, int nostart); ConfigData *cdp; while (cpt != noList) @@ -528,7 +515,7 @@ typedef enum flags_e { SPACEOUT = 020 } PressFlags; -static void press(Token *v , PressFlags flags, CheckIt **checkp) +static void press(Token *v , PressFlags flags) { Input *idx; Token *token = noToken, *lst = noToken; @@ -601,7 +588,7 @@ done : switch (token->type) { case SEMI : - if (flags && SEMIS) + if (flags & SEMIS) { output(&semiToken, 1); } @@ -640,7 +627,7 @@ done : } } -void etcetera(Token *cmd, int v) +static void etcetera(Token *cmd, int v) { while (cmd != noToken) { @@ -649,7 +636,7 @@ void etcetera(Token *cmd, int v) } } -void catbin(Token *tp) +static void catbin(Token *tp) { int sem, oln; Token *sols; @@ -692,7 +679,8 @@ static void handleVar(Token *hd, Token *cmd, int flags enum VarType vt; VarData *vp = (VarData *) 0; char msg[1024]; - Token *ap = noToken, *ac; + Token *ap = noToken; + const Token *ac; int array = 0; if (isVarToken(cmd)) @@ -828,7 +816,7 @@ void makeCall (Token *prc, Token *arg) } } -Token *doswitch(Token *cmd, Token *leadin) +static Token *doswitch(Token *cmd, Token *leadin) { Token *tp, *bod; int ln = leadin->lineNo, eopt = 0, dflt = 0, srtp = 1; @@ -951,7 +939,7 @@ Token *doswitch(Token *cmd, Token *leadin) return noToken; } -Token *doif(Token *cmd, Token *leadin) +static Token *doif(Token *cmd, Token *leadin) { Token *tp, *then; int efl = ADDBRACES, ln = leadin->lineNo, cfl = ADDBRACES | PAREN; @@ -963,7 +951,7 @@ Token *doif(Token *cmd, Token *leadin) { cfl |= SPACEOUT; } - press(cmd, cfl, noChecks); + press(cmd, cfl); if (putThen) { output(&thenToken, 0); } then = cmd->next; if (tokEqual(then, "then")) { then = then->next; } @@ -979,7 +967,7 @@ Token *doif(Token *cmd, Token *leadin) tp = tp->next; failIfNullToken(tp, "condition", "elseif", ln); warnExpr(tp, "elseif condition not braced."); - press(tp, efl | PAREN, noChecks); + press(tp, efl | PAREN); tp = tp->next; failIfNullToken(tp, "body", "elseif", ln); body(tp, 0, 0); @@ -1019,9 +1007,9 @@ Token *doif(Token *cmd, Token *leadin) } -int isNSName(Token *cmd) +static int isNSName(const Token *cmd) { - char *cp; + const char *cp; int cols = 0; if (!constant(cmd) || cmd->text == (char *) 0) { return 0; } @@ -1053,7 +1041,7 @@ int isNSName(Token *cmd) return 0; } -static Token *doProc(Token *tag, Token *cmd, Token *leadin, int checkNS) +static Token *doProc(Token *tag, Token *cmd, Token *leadin) { int ln = leadin->lineNo, inns; Token *token, *tok2, *tok3; @@ -1176,15 +1164,15 @@ static Token *doProc(Token *tag, Token *cmd, Token *le static Token *doproc(Token *cmd, Token *leadin) { - return doProc(&procToken, cmd, leadin, 1); + return doProc(&procToken, cmd, leadin); } static Token *domethod(Token *cmd, Token *leadin) { - return doProc(&methodToken, cmd, leadin, 0); + return doProc(&methodToken, cmd, leadin); } -static Token *dodestructor(Token *cmd, Token *leadin) +static Token *dodestructor(Token *cmd, Token *leadin __attribute__((__unused__))) { if (!nest[0]) { @@ -1199,7 +1187,7 @@ static Token *dodestructor(Token *cmd, Token *leadin) return noToken; } -Token *doconstructor(Token *cmd, Token *leadin) +static Token *doconstructor(Token *cmd, Token *leadin __attribute__((__unused__))) { if (!nest[0]) { @@ -1208,7 +1196,7 @@ Token *doconstructor(Token *cmd, Token *leadin) else { failIfNullToken(cmd, "args", "constructor", 0); - press(cmd, NOBRACE | ADDBRACES, noChecks); + press(cmd, NOBRACE | ADDBRACES); cmd = cmd->next; failIfNullToken(cmd, "body", "constructor", 0); body(cmd, 0, 0); @@ -1217,7 +1205,7 @@ Token *doconstructor(Token *cmd, Token *leadin) return noToken; } -Token *doreturn(Token *cmd, Token *leadin) +static Token *doreturn(Token *cmd, Token *leadin) { Blox *pr = (Blox *) lpeek(blocks); @@ -1266,7 +1254,7 @@ Token *doreturn(Token *cmd, Token *leadin) return noToken; } -Token *doregexp(Token *cmd, Token *leadin) +static Token *doregexp(Token *cmd, Token *leadin) { int eopt = 0; int ln = cmd->lineNo, paramCount = 0; @@ -1311,7 +1299,7 @@ Token *doregexp(Token *cmd, Token *leadin) return noToken; } -Token *doregsub(Token *cmd, Token *leadin) +static Token *doregsub(Token *cmd, Token *leadin) { int eopt = 0; int ln = cmd->lineNo, paramCount = 0; @@ -1360,7 +1348,7 @@ Token *doregsub(Token *cmd, Token *leadin) return cmd->next; } -Token *dobind(Token *cmd, Token *leadin) +static Token *dobind(Token *cmd, Token *leadin __attribute__((__unused__))) { Token *np; if (!doBind || pragma & NOFORMAT) @@ -1386,7 +1374,7 @@ Token *dobind(Token *cmd, Token *leadin) return noToken; } -Token *doitcl_class(Token *cmd, Token *leadin) +static Token *doitcl_class(Token *cmd, Token *leadin __attribute__((__unused__))) { failIfNullToken(cmd, "className", "itcl_class", 0); output(cmd, 1); @@ -1399,7 +1387,7 @@ Token *doitcl_class(Token *cmd, Token *leadin) return noToken; } -Token *docvar(Token *cmd, Token *prt) +static Token *docvar(Token *cmd, Token *prt) { if (!nest[0]) { @@ -1411,14 +1399,14 @@ Token *docvar(Token *cmd, Token *prt) output(cmd, 1); if ((cmd = cmd->next) != noToken) { - press(cmd, NOBRACE | ADDBRACES, noChecks); + press(cmd, NOBRACE | ADDBRACES); warnIfArgsAfter(cmd, "init", prt->text); } } return noToken; } -Token *dopublic(Token *cmd, Token *leadin) +static Token *dopublic(Token *cmd, Token *leadin __attribute__((__unused__))) { if (!nest[0]) { @@ -1430,7 +1418,7 @@ Token *dopublic(Token *cmd, Token *leadin) output(cmd, 1); if ((cmd = cmd->next) != noToken) { - press(cmd, NOBRACE | ADDBRACES, noChecks); + press(cmd, NOBRACE | ADDBRACES); if ((cmd = cmd->next) != noToken) { body(cmd, 0, 0); @@ -1441,11 +1429,11 @@ Token *dopublic(Token *cmd, Token *leadin) return noToken; } -Token *doprotected(Token *cmd, Token *leadin) { return docvar(cmd, leadin); } +static Token *doprotected(Token *cmd, Token *leadin) { return docvar(cmd, leadin); } -Token *docommon(Token *cmd, Token *leadin) { return docvar(cmd, leadin); } +static Token *docommon(Token *cmd, Token *leadin) { return docvar(cmd, leadin); } -static void checkVar(Token *cmd, char *nm) +static void checkVar(Token *cmd, const char *nm) { List *bp = blocks; Blox *xp; -@@ -1524,7 +1512,7 @@ static void addForVars(Token *cmd) +@@ -1476,7 +1464,6 @@ static void checkVar(Token *cmd, char *nm) + static void addForVars(Token *cmd) + { + Token *vr, *vp, *ap; +- VarData *rp; + + switch (cmd->type) + { +@@ -1484,12 +1471,12 @@ static void addForVars(Token *cmd) + checkVar(cmd, cmd->text); + if ((ap = isArray(cmd)) != noToken) + { +- rp = setVar(ap, VFOR, 1); ++ setVar(ap, VFOR, 1); + freeToken(ap); + } + else + { +- rp = setVar(cmd, VFOR, 0); ++ setVar(cmd, VFOR, 0); + } + break; + +@@ -1506,12 +1493,12 @@ static void addForVars(Token *cmd) + checkVar(vp, vp->text); + if ((ap = isArray(vp)) != noToken) + { +- rp = setVar(ap, VFOR, 1); ++ setVar(ap, VFOR, 1); + freeToken(ap); + } + else + { +- rp = setVar(vp, VFOR, 0); ++ setVar(vp, VFOR, 0); + } + } + vp = vp->next; +@@ -1524,7 +1511,7 @@ static void addForVars(Token *cmd) } } -Token *doforeach(Token *cmd, Token *leadin) +static Token *doforeach(Token *cmd, Token *leadin __attribute__((__unused__))) { failIfNullToken(cmd, "varName", "foreach", 0); loopstart(0, 0); -@@ -1534,7 +1522,7 @@ Token *doforeach(Token *cmd, Token *leadin) +@@ -1534,7 +1521,7 @@ Token *doforeach(Token *cmd, Token *leadin) addForVars(cmd); cmd = cmd->next; failIfNullToken(cmd, "list", "foreach", 0); - press(cmd, NOBRACE, noChecks); + press(cmd, NOBRACE); cmd = cmd->next; } while (cmd != noToken && cmd->next != noToken && cmd->next->type != SCOMMENT); -@@ -1546,7 +1534,7 @@ Token *doforeach(Token *cmd, Token *leadin) +@@ -1546,7 +1533,7 @@ Token *doforeach(Token *cmd, Token *leadin) return noToken; } -Token *doloop(Token *cmd, Token *leadin) +static Token *doloop(Token *cmd, Token *leadin __attribute__((__unused__))) { Token *tp; if (!tclX) -@@ -1556,15 +1544,15 @@ Token *doloop(Token *cmd, Token *leadin) +@@ -1556,15 +1543,15 @@ Token *doloop(Token *cmd, Token *leadin) else { failIfNullToken(cmd, "var", "loop", 0); - press(cmd, NOBRACE | ADDBRACES, noChecks); /* var */ + press(cmd, NOBRACE | ADDBRACES); /* var */ tp = cmd->next; failIfNullToken(tp, "first", "loop", 0); warnExpr(cmd, "Unbracketed loop \"first\""); - press(tp, ADDBRACES, noChecks); /* first */ + press(tp, ADDBRACES); /* first */ tp = tp->next; failIfNullToken(tp, "limit", "loop", 0); warnExpr(cmd, "Unbracketed loop \"limit\""); - press(tp, ADDBRACES, noChecks); /* limit */ + press(tp, ADDBRACES); /* limit */ tp = tp->next; failIfNullToken(tp, "body", "loop", 0); -@@ -1572,7 +1560,7 @@ Token *doloop(Token *cmd, Token *leadin) +@@ -1572,7 +1559,7 @@ Token *doloop(Token *cmd, Token *leadin) if (tp->next != noToken) { warnExpr(cmd, "Unbracketed loop \"incr\""); - press(tp, NOBRACE | ADDBRACES, noChecks); /* incr */ + press(tp, NOBRACE | ADDBRACES); /* incr */ tp = tp->next; } loopstart(0, 0); -@@ -1584,7 +1572,7 @@ Token *doloop(Token *cmd, Token *leadin) +@@ -1584,7 +1571,7 @@ Token *doloop(Token *cmd, Token *leadin) return noToken; } -Token *doexpr(Token *cmd, Token *leadin) +static Token *doexpr(Token *cmd, Token *leadin __attribute__((__unused__))) { if (!doExpr) { -@@ -1599,7 +1587,7 @@ Token *doexpr(Token *cmd, Token *leadin) +@@ -1599,7 +1586,7 @@ Token *doexpr(Token *cmd, Token *leadin) else if (cmd->next == noToken) { warnExpr(cmd, "expr body not braced."); - press(cmd, ADDBRACES | PAREN, noChecks); /* */ + press(cmd, ADDBRACES | PAREN); /* */ } else { -@@ -1610,7 +1598,7 @@ Token *doexpr(Token *cmd, Token *leadin) +@@ -1610,7 +1597,7 @@ Token *doexpr(Token *cmd, Token *leadin) return noToken; } -Token *dounset(Token *cmd, Token *leadin) +static Token *dounset(Token *cmd, Token *leadin) { int pCount = 1; -@@ -1641,7 +1629,7 @@ Token *dounset(Token *cmd, Token *leadin) +@@ -1641,7 +1628,7 @@ Token *dounset(Token *cmd, Token *leadin) return noToken; } -Token *doupvar(Token *cmd, Token *leadin) +static Token *doupvar(Token *cmd, Token *leadin) { int paramCount = 0; int ln = leadin->lineNo; -@@ -1672,7 +1660,7 @@ Token *doupvar(Token *cmd, Token *leadin) +@@ -1672,7 +1659,7 @@ Token *doupvar(Token *cmd, Token *leadin) return noToken; } -Token *dovariable(Token *cmd, Token *leadin) +static Token *dovariable(Token *cmd, Token *leadin) { int paramCount = 1; -@@ -1776,7 +1764,7 @@ static int valuecheck(ParamData *pdp, Token *cmd) +@@ -1776,7 +1763,7 @@ static int valuecheck(ParamData *pdp, Token *cmd) return 0; } -void doBasic(ConfigData *cpt, Token *hd, Token *cmd) +static void doBasic(const ConfigData *cpt, Token *hd, Token *cmd) { List *sp, *llp, *lp; ParamData *pt, *pdp; -@@ -1793,7 +1781,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) +@@ -1793,7 +1780,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) pt = (ParamData *) lpeek(lp); if (pt != (ParamData *) 0 && pt->values != noList) { - ptpar = (int) lpeek(pt->values); + ptpar = (int)(size_t) lpeek(pt->values); } else { -@@ -1850,7 +1838,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) +@@ -1850,7 +1837,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) } else { - press(cmd, NOBRACE | ADDBRACES | SEMIS, noChecks); /* */ + press(cmd, NOBRACE | ADDBRACES | SEMIS); /* */ } break; -@@ -1862,7 +1850,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) +@@ -1862,7 +1849,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) else { warnExpr(cmd, "Unbracketed expression"); - press(cmd, ptpar, noChecks); /* */ + press(cmd, ptpar); /* */ } break; -@@ -1883,7 +1871,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) +@@ -1883,7 +1870,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) { ptpar |= SPACEOUT; } - press(cmd, ptpar, noChecks); + press(cmd, ptpar); loopstart(infloop, 1); } break; -@@ -2085,7 +2073,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) +@@ -2085,7 +2072,7 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) pt = (ParamData *) lpeek(lp); if ((sp = pt->values) != noList) { - ptpar = (int) lpeek(sp); + ptpar = (int)(size_t) lpeek(sp); } else { -@@ -2140,7 +2128,8 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) +@@ -2140,7 +2127,8 @@ void doBasic(ConfigData *cpt, Token *hd, Token *cmd) } } -void doUser(Token *hd, Token *cmd, ConfigData *cpt, int nostart) +static void doUser(Token *hd, Token *cmd, + const ConfigData *cpt, int nostart) { if (isUnreachable()) { diff --git a/devel/frink/files/patch-token.c b/devel/frink/files/patch-token.c index e62544dc6b49..396c124a4f62 100644 --- a/devel/frink/files/patch-token.c +++ b/devel/frink/files/patch-token.c @@ -1,337 +1,356 @@ --- token.c.orig 2004-01-22 13:58:48 UTC +++ token.c @@ -31,8 +31,6 @@ #include #endif -extern char *currentfile; - typedef struct tbuff_s { char *buff; @@ -77,7 +75,7 @@ static void capTB(TBuff *tp) tp->buff[tp->length] ='\0'; } -static void catTB(TBuff *tp, char *str) +static void catTB(TBuff *tp, const char *str) { while (*str) { @@ -86,7 +84,7 @@ static void catTB(TBuff *tp, char *str) capTB(tp); } -static char *tokenName[] = +static const char *tokenName[] = { "ENDF", "ENDLINE", @@ -136,7 +134,7 @@ static Token *concToken(char, char, Input *); static Token *callToken(Input *); static Token *varToken(Input *); -Token *newToken(TokenType t) +static Token *newToken(TokenType t) { Token *tp = malloc(sizeof(Token)); tp->type = t; @@ -149,9 +147,9 @@ Token *newToken(TokenType t) return tp; } -void dumpToken(Token *tk, FILE *ops) +void dumpToken(const Token *tk, FILE *ops) { - static char *cval [] = + static const char *cval [] = { "word", "string", "list" }; @@ -194,7 +192,7 @@ void dumpToken(Token *tk, FILE *ops) } } -void fail(Token *tp, char *msg) +void fail(const Token *tp, const char *msg) { if (!compout) { @@ -324,7 +322,7 @@ void makeTB(Token *hd, TBuff *tb) if (hd != noToken) { makeTB(hd->next, tb); } } -void warn(Token *tp, char *msg) +void warn(const Token *tp, const char *msg) { Blox *blp = (Blox *) lpeek(blocks); TBuff *tbp = newTB(32); @@ -333,7 +331,7 @@ void warn(Token *tp, char *msg) { fprintf(stderr, "***"); } - if (currentfile != (char *) 0) + if (currentfile != NULL) { fprintf(stderr, " %s", currentfile); } @@ -376,7 +374,7 @@ void warn(Token *tp, char *msg) failed = 1; } -static void bwarn(int ln, char *msg) +static void bwarn(int ln, const char *msg) { Token *tp = newToken(SP); tp->lineNo = ln; @@ -390,7 +388,7 @@ void streamMore(Input *file) file->position = file->text; if (file->stream != NULL) { - file->remaining = fread(file->text, 1, 64*1024, file->stream); + file->remaining = fread(file->atext, 1, 64*1024, file->stream); } } @@ -399,7 +397,7 @@ static int isBlank(char ch) return ch == ' ' || ch == '\t'; } -static char *skipblank(char *cp) +static const char *skipblank(const char *cp) { while (isBlank(*cp)) { @@ -496,9 +494,9 @@ void freeToken(Token *tp) { if (tp != noToken) { - if (tp->text != (char *) 0 && tp->text != tp->little) + if (tp->atext != tp->little) { - free(tp->text); + free(tp->atext); } if (tp->sequence) freeToken(tp->sequence); if (tp->next) freeToken(tp->next); @@ -506,7 +504,7 @@ void freeToken(Token *tp) } } -static char *filterString(Token *tp, char *txt) +static char *filterString(Token *tp, const char *txt) { char *cp = malloc(strlen(txt) + 1), *pt; @@ -555,25 +553,9 @@ Input *tokenise(Token *tp, int expr) return file; } -Input *ftokenise(char *txt, int length, int lineNo, int expr) -{ - Token *tmp = newToken(CONST); /* gash token for filterstring */ - Input *file = (Input *) malloc(sizeof(Input)); - file->remaining = length; - file->pushed = 0; - file->stream = NULL; - file->position = file->text = filterString(tmp, txt); - file->tcall = 0; - file->texpr = expr; - file->lineNumber = lineNo; - file->lineStart = 1; - freeToken(tmp); - return file; -} - void untokenise(Input *file) { - free(file->text); + free(file->atext); free(file); } @@ -606,17 +588,17 @@ void tokenPush(Token **tp, Token *v) } } -static Token *createToken(TokenType t, char *text, Token *nxt) +static Token *createToken(TokenType t, const char *text, size_t len, Token *nxt) { Token *tp = newToken(t); - if ((tp->length = strlen(text)) < (sizeof(tp->little) - 1)) + if ((tp->length = len) < (sizeof(tp->little) - 1)) { tp->text = strcpy(tp->little, text); } else { - tp->text = newString(text); + tp->text = strndup(text, len); } tp->next = nxt; return tp; @@ -719,7 +701,7 @@ done: static Token *handleSemi(Input*, char); -Token *stringToken(Input *file, char lst, TokenType res, int term) +static Token *stringToken(Input *file, char lst, TokenType res, int term) { int bufSize = 16*1024; Token *tp = newToken(res), *nt; @@ -836,7 +818,7 @@ done: } -int tokEqual(Token *tp, char *val) +int tokEqual(const Token *tp, const char *val) { if (tp != noToken) { @@ -844,7 +826,7 @@ int tokEqual(Token *tp, char *val) { case CONST: case LIST : - return (tp->text != (char *) 0 && strcmp(tp->text, val) == 0); + return (tp->text != NULL && strcmp(tp->text, val) == 0); default: break; } @@ -852,7 +834,7 @@ int tokEqual(Token *tp, char *val) return 0; } -int tokNEqual(Token *tp, char *val, int n) +static int tokNEqual(const Token *tp, const char *val, int n) { if (tp != noToken) { @@ -870,7 +852,7 @@ int tokNEqual(Token *tp, char *val, int n) static int isPragma(TBuff *tp) { - char *cp; + const char *cp; cp = skipblank(tp->buff + 1); /* start after # character */ return (strncmp(cp, "PRAGMA", 6) == 0 || strncmp(cp, "FRINK", 5) == 0); @@ -1251,7 +1233,7 @@ static void handlePragma(Token *tp) { static struct pragma_s { - char *text; + const char *text; enum Pragmas value; int nextmode; } pragmas[] = @@ -1263,11 +1245,11 @@ static void handlePragma(Token *tp) { "set", 0, 2}, { "unused", 0, 3}, { "array", 0, 4}, - { (char *) 0, 0, 1}, + { NULL, 0, 1}, }; struct pragma_s *prp; - int label, mode = 1; +- int label, mode = 1; - char *cp; ++ int mode = 1; + const char *cp; Token *token, *chars = newToken(CONST); Input *pfile; -@@ -1347,9 +1329,6 @@ int handle(Token *line) +@@ -1277,16 +1259,8 @@ static void handlePragma(Token *tp) + chars->length = strlen(cp); + pfile=tokenise(chars, 0); + token = getToken(pfile); +- if (tokNEqual(token, "PRAGMA", 6)) ++ if (!tokNEqual(token, "PRAGMA", 6) && !tokNEqual(token, "FRINK", 5)) + { +- label = 1; +- } +- else if (tokNEqual(token, "FRINK", 5)) +- { +- label = 2; +- } +- else +- { + warn(tp, "Pragma syntax weirdness"); + } + freeToken(token); +@@ -1347,9 +1321,6 @@ int handle(Token *line) { Token *hd; - extern int tclop(Token*, Token*); - extern void comment(Token *); - if (line == noToken) { if (!minimise) -@@ -1575,7 +1554,7 @@ void lprocess(Token *lst, int nls) +@@ -1575,7 +1546,7 @@ void lprocess(Token *lst, int nls) if (line != noToken) { handle(line); } } -Token *accumulate(Input *file, int nl) +static Token *accumulate(Input *file, int nl) { Token *line = noToken, *hd = noToken; TokenType last = NL; -@@ -1652,16 +1631,16 @@ Token *tokacc(Token *tp, int flag, int nl) +@@ -1652,16 +1623,16 @@ Token *tokacc(Token *tp, int flag, int nl) return lp; } -static int chkVarToken(Token *token) +static int chkVarToken(const Token *token) { return (token != noToken && (token->type == VAR || token->type == CALL || token->type == CONC || token->type == STRING)); } -int isVarToken(Token *token) +int isVarToken(const Token *token) { - char *cp; + const char *cp; TBuff *tb; if (token != noToken && token->type == CONC) -@@ -1694,7 +1673,7 @@ int isVarToken(Token *token) +@@ -1694,7 +1665,7 @@ int isVarToken(Token *token) return chkVarToken(token); } -int isSingleCall(Token *token, char *proc) +int isSingleCall(const Token *token, const char *proc) { if (token != noToken) { -@@ -1715,7 +1694,7 @@ int isSingleCall(Token *token, char *proc) +@@ -1715,7 +1686,7 @@ int isSingleCall(Token *token, char *proc) return 0; } -int isSwitch(Token *token) +int isSwitch(const Token *token) { if (token != noToken) { -@@ -1739,14 +1718,15 @@ int isSwitch(Token *token) +@@ -1739,14 +1710,15 @@ int isSwitch(Token *token) return 0; } -Token *isArray(Token *tp) +Token *isArray(const Token *tp) { Token *res = noToken; TBuff *tbp = (TBuff *) 0; - char *txt, *cp, ch; + const char *txt, *cp; + char ch; int len; - if (tp != noToken && (tp->text != (char *) 0 || tp->type == CONC)) + if (tp != noToken && (tp->text != NULL || tp->type == CONC)) { switch (tp->type) { -@@ -1776,9 +1756,7 @@ Token *isArray(Token *tp) +@@ -1776,9 +1748,7 @@ Token *isArray(Token *tp) ch = *cp; if (ch == '(') { - *cp = '\0'; - res = createToken(CONST, txt, noToken); - *cp = '('; + res = createToken(CONST, txt, cp - txt, noToken); break; } if (ch == '\0') { break; } -@@ -1790,7 +1768,7 @@ Token *isArray(Token *tp) +@@ -1790,7 +1760,7 @@ Token *isArray(Token *tp) return res; } -int constant(Token *tp) +int constant(const Token *tp) { return (tp != noToken && (tp->type == CONST || tp->type == LIST)); }