LCOV - code coverage report
Current view: top level - soltools/cpp - _mcrvalid.c (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 41 41 100.0 %
Date: 2015-06-13 12:38:46 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <stdio.h>
      21             : #include <stdlib.h>
      22             : #include <string.h>
      23             : 
      24             : #include "cpp.h"
      25             : 
      26             : void
      27      205717 : mvl_init(MacroValidatorList * out_pValidators)
      28             : {
      29      205717 :     out_pValidators->pFirst = 0;
      30      205717 :     out_pValidators->nextFreeIdentifier = 1;
      31      205717 : }
      32             : 
      33             : void
      34      205717 : mvl_destruct(MacroValidatorList * out_pValidators)
      35             : {
      36      205717 :     MacroValidator * pV = out_pValidators->pFirst;
      37             :     MacroValidator * pDel;
      38      430986 :     for ( pDel = out_pValidators->pFirst;
      39             :           pDel != 0;
      40       19552 :           pDel = pV )
      41             :     {
      42       19552 :         pV = pV->pNext;
      43             : 
      44       19552 :         pDel->pMacro->flag &= (~ISACTIVE);
      45       19552 :         dofree(pDel);
      46             :     }
      47      205717 : }
      48             : 
      49             : 
      50             : #define INVALID_TILL_ENDOFROW 32000
      51             : 
      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.
      55             : */
      56             : void
      57       49381 : mvl_add( MacroValidatorList *   inout_pValidators,
      58             :          Nlist *                in_pMacro,
      59             :          Token *                in_pTokenWhereMacroBecomesValid )
      60             : {
      61             : 
      62       49381 :     MacroValidator * pNew = new(MacroValidator);
      63       49381 :     pNew->pMacro = in_pMacro;
      64             : 
      65       49381 :     if (in_pTokenWhereMacroBecomesValid == 0)
      66             :     {
      67       19552 :         pNew->nTokenWhereMacroBecomesValid = INVALID_TILL_ENDOFROW;
      68             :     }
      69       29829 :     else if (in_pTokenWhereMacroBecomesValid->identifier > 0)
      70             :     {
      71       17820 :         pNew->nTokenWhereMacroBecomesValid = in_pTokenWhereMacroBecomesValid->identifier;
      72             :     }
      73             :     else
      74             :     {
      75       12009 :         pNew->nTokenWhereMacroBecomesValid = inout_pValidators->nextFreeIdentifier;
      76       12009 :         in_pTokenWhereMacroBecomesValid->identifier = inout_pValidators->nextFreeIdentifier;
      77       12009 :         inout_pValidators->nextFreeIdentifier++;
      78             :     }
      79             : 
      80       49381 :     pNew->pNext = inout_pValidators->pFirst;
      81       49381 :     inout_pValidators->pFirst = pNew;
      82       49381 : }
      83             : 
      84             : void
      85     1352698 : mvl_check(  MacroValidatorList * inout_pValidators,
      86             :             Token *              inout_pTokenToCheck)
      87             : {
      88             :     MacroValidator * pV;            /* Running pointer */
      89             :     MacroValidator * pCheckedOnes;  /* Here new list is built.  */
      90     1352698 :     pCheckedOnes = 0;
      91             : 
      92     4805239 :     for ( pV = inout_pValidators->pFirst;
      93             :           pV != 0;
      94     2099843 :           pV = inout_pValidators->pFirst )
      95             :     {
      96     2099843 :         inout_pValidators->pFirst = pV->pNext;
      97             : 
      98     2099843 :         if (pV->nTokenWhereMacroBecomesValid == inout_pTokenToCheck->identifier)
      99             :         {
     100       29829 :             pV->pMacro->flag &= (~ISACTIVE);
     101       29829 :             dofree(pV);
     102             :         }
     103             :         else
     104             :         {
     105     2070014 :             pV->pNext = pCheckedOnes;
     106     2070014 :             pCheckedOnes = pV;
     107             :         }
     108             :     }   /* end for  */
     109             : 
     110             :     /* Assign new built list (too old ones were removed) to
     111             :        original list:
     112             :     */
     113     1352698 :     inout_pValidators->pFirst = pCheckedOnes;
     114     1352698 : }
     115             : 
     116             : 
     117             : void
     118      255098 : tokenrow_zeroTokenIdentifiers(Tokenrow* trp)
     119             : {
     120             :     Token * tp;
     121     1608556 :     for (tp = trp->bp; tp < trp->lp; tp++)
     122             :     {
     123     1353458 :         tp->identifier = 0;
     124             :     }
     125      255098 : }
     126             : 
     127             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11