From e94fdd0fbe26b8a9e14bb0c9d1d5f057182c86d8 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 13 Jul 2018 22:38:40 +0200 Subject: [PATCH] exclude line from .control sections case sensitive safe check for the poly token being exactly the fourth token --- src/frontend/translatepoly.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/frontend/translatepoly.c b/src/frontend/translatepoly.c index 809680e72..6e23aa4c3 100644 --- a/src/frontend/translatepoly.c +++ b/src/frontend/translatepoly.c @@ -302,14 +302,34 @@ char * expressionfrompoly(Poly_t input) struct card * translatepoly(struct card * input_deck) { struct card *input_line; + bool found_control = FALSE; + /* scan through the deck and find poly sources */ for (input_line = input_deck; input_line; input_line = input_line->nextcard) { char *linestr = input_line->line; - if (*linestr == '*') + /* exclude lines between .control and .endc from getting quotes changed */ + if (ciprefix(".control", linestr)) + found_control = TRUE; + if (ciprefix(".endc", linestr)) + found_control = FALSE; + if (found_control) + continue; + + /* check for e g f h sources */ + if (*linestr != 'e' && *linestr != 'g' && *linestr != 'f' && *linestr != 'h') continue; // check if translation needed - if (strstr(linestr, "poly") == NULL) { + char *tmpstr = linestr; + /* skip the first three tokens */ + tmpstr = nexttok(tmpstr); + tmpstr = nexttok(tmpstr); + tmpstr = nexttok(tmpstr); + /* do a case insensitive compare of the fourth token */ + tmpstr = gettok_noparens(&tmpstr); + if (cieq(tmpstr, "poly") == 0) { + tfree(tmpstr); continue; } + tfree(tmpstr); // not returned from function so translate char controlchar = '\0', sourcechar = '\0'; switch (linestr[0]) {