Bump for 3.6-28
[LibreOffice.git] / soltools / cpp / _mcrvalid.c
blob446f86d316d1596f24b069d3a671572f9235cf1a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #include "cpp.h"
8 void
9 mvl_init(MacroValidatorList * out_pValidators)
11 out_pValidators->pFirst = 0;
12 out_pValidators->nextFreeIdentifier = 1;
15 void
16 mvl_destruct(MacroValidatorList * out_pValidators)
18 MacroValidator * pV = out_pValidators->pFirst;
19 MacroValidator * pDel;
20 for ( pDel = out_pValidators->pFirst;
21 pDel != 0;
22 pDel = pV )
24 pV = pV->pNext;
26 pDel->pMacro->flag &= (~ISACTIVE);
27 dofree(pDel);
32 #define INVALID_TILL_ENDOFROW 32000
34 /* If in_pTokenWhereMacroBecomesValid == 0, the macro is at row end
35 and therefore there does not exist any token, where the macro becomes
36 valid again. It is revalidated, when the row was processed complete.
38 void
39 mvl_add( MacroValidatorList * inout_pValidators,
40 Nlist * in_pMacro,
41 Token * in_pTokenWhereMacroBecomesValid )
44 MacroValidator * pNew = new(MacroValidator);
45 pNew->pMacro = in_pMacro;
47 if (in_pTokenWhereMacroBecomesValid == 0)
49 pNew->nTokenWhereMacroBecomesValid = INVALID_TILL_ENDOFROW;
51 else if (in_pTokenWhereMacroBecomesValid->identifier > 0)
53 pNew->nTokenWhereMacroBecomesValid = in_pTokenWhereMacroBecomesValid->identifier;
55 else
57 pNew->nTokenWhereMacroBecomesValid = inout_pValidators->nextFreeIdentifier;
58 in_pTokenWhereMacroBecomesValid->identifier = inout_pValidators->nextFreeIdentifier;
59 inout_pValidators->nextFreeIdentifier++;
62 pNew->pNext = inout_pValidators->pFirst;
63 inout_pValidators->pFirst = pNew;
66 void
67 mvl_check( MacroValidatorList * inout_pValidators,
68 Token * inout_pTokenToCheck)
70 MacroValidator * pV; /* Running pointer */
71 MacroValidator * pCheckedOnes; /* Here new list is built. */
72 pCheckedOnes = 0;
74 for ( pV = inout_pValidators->pFirst;
75 pV != 0;
76 pV = inout_pValidators->pFirst )
78 inout_pValidators->pFirst = pV->pNext;
80 if (pV->nTokenWhereMacroBecomesValid == inout_pTokenToCheck->identifier)
82 pV->pMacro->flag &= (~ISACTIVE);
83 dofree(pV);
85 else
87 pV->pNext = pCheckedOnes;
88 pCheckedOnes = pV;
90 } /* end for */
92 /* Assign new built list (too old ones were removed) to
93 original list:
95 inout_pValidators->pFirst = pCheckedOnes;
99 void
100 tokenrow_zeroTokenIdentifiers(Tokenrow* trp)
102 Token * tp;
103 for (tp = trp->bp; tp < trp->lp; tp++)
105 tp->identifier = 0;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */