Commit Graph

1 Commits

Author SHA1 Message Date
Peter Wang
a59a8bbe1d Fix bitmap predicates which did not work correctly with empty bitmaps.
Branches: main

Fix bitmap predicates which did not work correctly with empty bitmaps.

Note that `bitmap.to_string' now returns "<0:>" for an empty bitmap instead
of "<0:00>".

library/bitmap.m:
        Add `in_range_rexcl' to check an index is in the range [0, num_bits).

        Fix bounds checks on empty bitmaps in `^ bits' and `copy_bytes'.

        Simplify other bounds checks using `in_range_rexcl'.

        Make `byte_index_for_bit' return -1 if its argument is negative,
        instead of 0.  `byte_index_for_bit(NumBits - 1)' is used to get the
        last byte index, so now loops over empty bitmaps will stop immediately
        as the initial index must be greater than -1.

        Make some code neater.

tests/hard_coded/Mmakefile:
tests/hard_coded/bitmap_empty.exp:
tests/hard_coded/bitmap_empty.m:
        Add a test case.

NEWS:
        Mention changed behaviour of `bitmap.to_string'.
2010-03-02 00:32:37 +00:00