LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/python3/Parser - bitset.c (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 28 0.0 %
Date: 2012-12-17 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : 
       2             : /* Bitset primitives used by the parser generator */
       3             : 
       4             : #include "pgenheaders.h"
       5             : #include "bitset.h"
       6             : 
       7             : bitset
       8           0 : newbitset(int nbits)
       9             : {
      10           0 :     int nbytes = NBYTES(nbits);
      11           0 :     bitset ss = (char *)PyObject_MALLOC(sizeof(BYTE) *  nbytes);
      12             : 
      13           0 :     if (ss == NULL)
      14           0 :         Py_FatalError("no mem for bitset");
      15             : 
      16           0 :     ss += nbytes;
      17           0 :     while (--nbytes >= 0)
      18           0 :         *--ss = 0;
      19           0 :     return ss;
      20             : }
      21             : 
      22             : void
      23           0 : delbitset(bitset ss)
      24             : {
      25           0 :     PyObject_FREE(ss);
      26           0 : }
      27             : 
      28             : int
      29           0 : addbit(bitset ss, int ibit)
      30             : {
      31           0 :     int ibyte = BIT2BYTE(ibit);
      32           0 :     BYTE mask = BIT2MASK(ibit);
      33             : 
      34           0 :     if (ss[ibyte] & mask)
      35           0 :         return 0; /* Bit already set */
      36           0 :     ss[ibyte] |= mask;
      37           0 :     return 1;
      38             : }
      39             : 
      40             : #if 0 /* Now a macro */
      41             : int
      42             : testbit(bitset ss, int ibit)
      43             : {
      44             :     return (ss[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0;
      45             : }
      46             : #endif
      47             : 
      48             : int
      49           0 : samebitset(bitset ss1, bitset ss2, int nbits)
      50             : {
      51             :     int i;
      52             : 
      53           0 :     for (i = NBYTES(nbits); --i >= 0; )
      54           0 :         if (*ss1++ != *ss2++)
      55           0 :             return 0;
      56           0 :     return 1;
      57             : }
      58             : 
      59             : void
      60           0 : mergebitset(bitset ss1, bitset ss2, int nbits)
      61             : {
      62             :     int i;
      63             : 
      64           0 :     for (i = NBYTES(nbits); --i >= 0; )
      65           0 :         *ss1++ |= *ss2++;
      66           0 : }

Generated by: LCOV version 1.10