merge the formfield patch from ooo-build
[ooovba.git] / soltools / cpp / _mcrvalid.c
blobb8e129525df36b3fd53ffb5f402e7e91ae665e27
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "cpp.h"
7 /*
8 Nlist * pMacro;
9 Token * pTokenWhereMacroBecomesValid;
10 struct macroValidator *
11 pNext;
14 void
15 mvl_init(MacroValidatorList * out_pValidators)
17 out_pValidators->pFirst = 0;
18 out_pValidators->nextFreeIdentifier = 1;
21 void
22 mvl_destruct(MacroValidatorList * out_pValidators)
24 MacroValidator * pV = out_pValidators->pFirst;
25 MacroValidator * pDel;
26 for ( pDel = out_pValidators->pFirst;
27 pDel != 0;
28 pDel = pV )
30 pV = pV->pNext;
32 pDel->pMacro->flag &= (~ISACTIVE);
33 dofree(pDel);
38 #define INVALID_TILL_ENDOFROW 32000
40 /* If in_pTokenWhereMacroBecomesValid == 0, the macro is at row end
41 and therefore there does not exist any token, where the macro becomes
42 valid again. It is revalidated, when the row was processed complete.
44 void
45 mvl_add( MacroValidatorList * inout_pValidators,
46 Nlist * in_pMacro,
47 Token * in_pTokenWhereMacroBecomesValid )
50 MacroValidator * pNew = new(MacroValidator);
51 pNew->pMacro = in_pMacro;
53 if (in_pTokenWhereMacroBecomesValid == 0)
55 pNew->nTokenWhereMacroBecomesValid = INVALID_TILL_ENDOFROW;
57 else if (in_pTokenWhereMacroBecomesValid->identifier > 0)
59 pNew->nTokenWhereMacroBecomesValid = in_pTokenWhereMacroBecomesValid->identifier;
61 else
63 pNew->nTokenWhereMacroBecomesValid = inout_pValidators->nextFreeIdentifier;
64 in_pTokenWhereMacroBecomesValid->identifier = inout_pValidators->nextFreeIdentifier;
65 inout_pValidators->nextFreeIdentifier++;
68 pNew->pNext = inout_pValidators->pFirst;
69 inout_pValidators->pFirst = pNew;
73 void
74 mvl_move( MacroValidatorList * inout_pValidators,
75 int in_nSpace )
77 MacroValidator * pV;
78 for ( pV = inout_pValidators->pFirst;
79 pV != 0;
80 pV = pV->pNext )
82 pV->pTokenWhereMacroBecomesValid += in_nSpace;
87 void
88 mvl_check( MacroValidatorList * inout_pValidators,
89 Token * inout_pTokenToCheck)
91 MacroValidator * pV; /* Running pointer */
92 MacroValidator * pCheckedOnes; /* Here new list is built. */
93 pCheckedOnes = 0;
95 for ( pV = inout_pValidators->pFirst;
96 pV != 0;
97 pV = inout_pValidators->pFirst )
99 inout_pValidators->pFirst = pV->pNext;
101 if (pV->nTokenWhereMacroBecomesValid == inout_pTokenToCheck->identifier)
103 pV->pMacro->flag &= (~ISACTIVE);
104 dofree(pV);
106 else
108 pV->pNext = pCheckedOnes;
109 pCheckedOnes = pV;
111 } /* end for */
113 /* Assign new built list (too old ones were removed) to
114 original list:
116 inout_pValidators->pFirst = pCheckedOnes;
120 void
121 tokenrow_zeroTokenIdentifiers(Tokenrow* trp)
123 Token * tp;
124 for (tp = trp->bp; tp < trp->lp; tp++)
126 tp->identifier = 0;