fixed a minor problem with unstacking
This commit is contained in:
parent
50b73dc023
commit
9dd87881e1
2 changed files with 21 additions and 9 deletions
|
@ -45,6 +45,7 @@ struct mlist {
|
|||
struct mlist *next;
|
||||
struct macro *m_mac;
|
||||
char *m_repl;
|
||||
char m_unstack;
|
||||
};
|
||||
|
||||
/* allocation definitions of struct mlist */
|
||||
|
|
|
@ -190,25 +190,36 @@ macro2buffer(idef, actpars, siztext)
|
|||
EXPORT
|
||||
DoUnstack()
|
||||
{
|
||||
register struct mlist *p = ReplaceList;
|
||||
|
||||
while (p->m_unstack) p = p->next;
|
||||
p->m_unstack = 1;
|
||||
Unstacked++;
|
||||
}
|
||||
|
||||
EXPORT
|
||||
EnableMacros()
|
||||
{
|
||||
register struct mlist *p = ReplaceList;
|
||||
register struct mlist *p = ReplaceList, *prev = 0;
|
||||
int cnt = 0;
|
||||
|
||||
assert(Unstacked > 0);
|
||||
while (Unstacked > 0) {
|
||||
while (p) {
|
||||
struct mlist *nxt = p->next;
|
||||
|
||||
assert(p != 0);
|
||||
p->m_mac->mc_flag &= ~NOREPLACE;
|
||||
if (p->m_mac->mc_count) p->m_mac->mc_count--;
|
||||
if (p->m_repl) free(p->m_repl);
|
||||
free_mlist(p);
|
||||
if (p->m_unstack) {
|
||||
p->m_mac->mc_flag &= ~NOREPLACE;
|
||||
if (p->m_mac->mc_count) p->m_mac->mc_count--;
|
||||
if (p->m_repl) free(p->m_repl);
|
||||
if (! prev) ReplaceList = nxt;
|
||||
else prev->next = nxt;
|
||||
free_mlist(p);
|
||||
cnt++;
|
||||
}
|
||||
else prev = p;
|
||||
p = nxt;
|
||||
Unstacked--;
|
||||
}
|
||||
ReplaceList = p;
|
||||
assert(cnt == Unstacked);
|
||||
Unstacked = 0;
|
||||
}
|
||||
#endif NOPP
|
||||
|
|
Loading…
Reference in a new issue