From: helly Date: Thu, 29 Dec 2005 01:19:24 +0000 (+0000) Subject: - MSVC cannot handle struct CharSet on stack (even not with /F switch and X-Git-Tag: 0.13.6~563 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de1d9439a7c75ee1f8387813bce11cac73a2e00a;p=re2c - MSVC cannot handle struct CharSet on stack (even not with /F switch and enough stack size), possibly other compilers have the same problem --- diff --git a/actions.cc b/actions.cc index f697e1d7..8da09918 100644 --- a/actions.cc +++ b/actions.cc @@ -844,36 +844,36 @@ void optimize(Ins *i) void genCode(std::ostream& o, RegExp *re) { - CharSet cs; + CharSet *cs = new CharSet(); uint j; - memset(&cs, 0, sizeof(cs)); + memset(cs, 0, sizeof(CharSet)); for (j = 0; j < nRealChars; ++j) { - cs.rep[j] = &cs.ptn[0]; - cs.ptn[j].nxt = &cs.ptn[j + 1]; + cs->rep[j] = &cs->ptn[0]; + cs->ptn[j].nxt = &cs->ptn[j + 1]; } - cs.freeHead = &cs.ptn[1]; - *(cs.freeTail = &cs.ptn[nChars - 1].nxt) = NULL; - cs.ptn[0].card = nChars; - cs.ptn[0].nxt = NULL; - re->split(cs); + cs->freeHead = &cs->ptn[1]; + *(cs->freeTail = &cs->ptn[nChars - 1].nxt) = NULL; + cs->ptn[0].card = nChars; + cs->ptn[0].nxt = NULL; + re->split(*cs); /* for(uint k = 0; k < nChars;){ - for(j = k; ++k < nChars && cs.rep[k] == cs.rep[j];); + for(j = k; ++k < nChars && cs->rep[k] == cs->rep[j];); printSpan(cerr, j, k); - cerr << "\t" << cs.rep[j] - &cs.ptn[0] << endl; + cerr << "\t" << cs->rep[j] - &cs->ptn[0] << endl; } */ Char rep[nChars]; for (j = 0; j < nRealChars; ++j) { - if (!cs.rep[j]->nxt) - cs.rep[j]->nxt = &cs.ptn[j]; + if (!cs->rep[j]->nxt) + cs->rep[j]->nxt = &cs->ptn[j]; - rep[j] = (Char) (cs.rep[j]->nxt - &cs.ptn[0]); + rep[j] = (Char) (cs->rep[j]->nxt - &cs->ptn[0]); } re->calcSize(rep); @@ -904,6 +904,7 @@ void genCode(std::ostream& o, RegExp *re) dfa->emit(o); delete dfa; delete [] ins; + delete cs; } } // end namespace re2c