1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
27 mvl_init(MacroValidatorList
* out_pValidators
)
29 out_pValidators
->pFirst
= NULL
;
30 out_pValidators
->nextFreeIdentifier
= 1;
34 mvl_destruct(MacroValidatorList
* out_pValidators
)
36 MacroValidator
* pV
= out_pValidators
->pFirst
;
37 MacroValidator
* pDel
;
38 for ( pDel
= out_pValidators
->pFirst
;
44 pDel
->pMacro
->flag
&= (~ISACTIVE
);
50 #define INVALID_TILL_ENDOFROW 32000
52 /* If in_pTokenWhereMacroBecomesValid == 0, the macro is at row end
53 and therefore there does not exist any token, where the macro becomes
54 valid again. It is revalidated, when the row was processed complete.
57 mvl_add( MacroValidatorList
* inout_pValidators
,
59 Token
* in_pTokenWhereMacroBecomesValid
)
62 MacroValidator
* pNew
= new(MacroValidator
);
63 pNew
->pMacro
= in_pMacro
;
65 if (in_pTokenWhereMacroBecomesValid
== NULL
)
67 pNew
->nTokenWhereMacroBecomesValid
= INVALID_TILL_ENDOFROW
;
69 else if (in_pTokenWhereMacroBecomesValid
->identifier
> 0)
71 pNew
->nTokenWhereMacroBecomesValid
= in_pTokenWhereMacroBecomesValid
->identifier
;
75 pNew
->nTokenWhereMacroBecomesValid
= inout_pValidators
->nextFreeIdentifier
;
76 in_pTokenWhereMacroBecomesValid
->identifier
= inout_pValidators
->nextFreeIdentifier
;
77 inout_pValidators
->nextFreeIdentifier
++;
80 pNew
->pNext
= inout_pValidators
->pFirst
;
81 inout_pValidators
->pFirst
= pNew
;
85 mvl_check( MacroValidatorList
* inout_pValidators
,
86 Token
const * inout_pTokenToCheck
)
88 MacroValidator
* pV
; /* Running pointer */
89 MacroValidator
* pCheckedOnes
; /* Here new list is built. */
92 for ( pV
= inout_pValidators
->pFirst
;
94 pV
= inout_pValidators
->pFirst
)
96 inout_pValidators
->pFirst
= pV
->pNext
;
98 if (pV
->nTokenWhereMacroBecomesValid
== inout_pTokenToCheck
->identifier
)
100 pV
->pMacro
->flag
&= (~ISACTIVE
);
105 pV
->pNext
= pCheckedOnes
;
110 /* Assign new built list (too old ones were removed) to
113 inout_pValidators
->pFirst
= pCheckedOnes
;
118 tokenrow_zeroTokenIdentifiers(Tokenrow
* trp
)
121 for (tp
= trp
->bp
; tp
< trp
->lp
; tp
++)
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */