Skip to content

Commit

Permalink
import Bit-Vector 5.6 from CPAN
Browse files Browse the repository at this point in the history
git-cpan-module:   Bit-Vector
git-cpan-version:  5.6
git-cpan-authorid: STBEY
git-cpan-file:     authors/id/S/ST/STBEY/Bit-Vector-5.6.tar.gz
  • Loading branch information
Steffen Beyer authored and schwern committed Dec 10, 2009
1 parent 6138eae commit 3a8ed13
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 50 deletions.
24 changes: 14 additions & 10 deletions BitVector.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ static wordptr BITMASKTAB;
((*(address+(index>>LOGBITS)) AND BITMASKTAB[index AND MODMASK]) != 0)

#define BIT_VECTOR_FLP_BIT(address,index,mask) \
(((*(addr+(index>>LOGBITS)) ^= (mask = BITMASKTAB[index AND MODMASK])) AND mask) != 0)
(mask = BITMASKTAB[index AND MODMASK]), \
(((*(addr+(index>>LOGBITS)) ^= mask) AND mask) != 0)

#define BIT_VECTOR_DIGITIZE(type,value,digit) \
value = (type) ((digit = value) / 10); \
Expand Down Expand Up @@ -502,7 +503,7 @@ N_word BitVector_Mask(N_int bits) /* bit vector mask (unused bits) */

charptr BitVector_Version(void)
{
return((charptr)"5.5");
return((charptr)"5.6");
}

N_int BitVector_Word_Bits(void)
Expand Down Expand Up @@ -1466,32 +1467,34 @@ Z_int BitVector_Compare(wordptr X, wordptr Y) /* X <,=,> Y ? */

charptr BitVector_to_Hex(wordptr addr)
{
N_word bits = bits_(addr);
N_word size = size_(addr);
N_word value;
N_word count;
N_word digit;
N_word length;
charptr string;

length = (size * (BITS >> 2)) + 1;
string = (charptr) malloc((size_t) length);
length = bits >> 2;
if (bits AND 0x0003) length++;
string = (charptr) malloc((size_t) (length+1));
if (string == NULL) return(NULL);
string += length;
*(--string) = (N_char) '\0';
*string = (N_char) '\0';
if (size > 0)
{
*(addr+size-1) &= mask_(addr);
while (size-- > 0)
while ((size-- > 0) and (length > 0))
{
value = *addr++;
count = BITS >> 2;
while (count-- > 0)
while ((count-- > 0) and (length > 0))
{
digit = value AND 0x000F;
if (digit > 9) digit += (N_word) 'A' - 10;
else digit += (N_word) '0';
*(--string) = (N_char) digit;
if (count > 0) value >>= 4;
*(--string) = (N_char) digit; length--;
if ((count > 0) and (length > 0)) value >>= 4;
}
}
}
Expand Down Expand Up @@ -3254,11 +3257,12 @@ void Matrix_Transpose(wordptr X, N_int rowsX, N_int colsX,
}

/*****************************************************************************/
/* VERSION: 5.5 */
/* VERSION: 5.6 */
/*****************************************************************************/
/* VERSION HISTORY: */
/*****************************************************************************/
/* */
/* Version 5.6 02.11.98 Leading zeros eliminated in "to_Hex()". */
/* Version 5.5 21.09.98 Fixed bug of uninitialized "error" in Multiply. */
/* Version 5.4 07.09.98 Fixed bug of uninitialized "error" in Divide. */
/* Version 5.3 12.05.98 Improved Norm. Completed history. */
Expand Down
3 changes: 2 additions & 1 deletion BitVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,12 @@ void Matrix_Transpose (wordptr X, N_int rowsX, N_int colsX,
/*****************************************************************************/

/*****************************************************************************/
/* VERSION: 5.5 */
/* VERSION: 5.6 */
/*****************************************************************************/
/* VERSION HISTORY: */
/*****************************************************************************/
/* */
/* Version 5.6 02.11.98 Leading zeros eliminated in "to_Hex()". */
/* Version 5.5 21.09.98 Fixed bug of uninitialized "error" in Multiply. */
/* Version 5.4 07.09.98 Fixed bug of uninitialized "error" in Divide. */
/* Version 5.3 12.05.98 Improved Norm. Completed history. */
Expand Down
29 changes: 14 additions & 15 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
=====================================
Package "Bit::Vector" Version 5.5
Package "Bit::Vector" Version 5.6
=====================================


Copyright (c) 1995, 1996, 1997, 1998 by Steffen Beyer.
All rights reserved.


What's new in version 5.5:
What's new in version 5.6:
--------------------------

Version 5.5 is a bugfix release.
The leading zeros in the output of "to_Hex()" have been suppressed.

The same bug (uninitialized return code) as in the method "Divide()"
(fixed in version 5.4) was fixed in the method "Multiply()".
A warning produced by some compilers on line 2067 of "BitVector.c" has been fixed.

Moreover, the failure of tests 96-131 of test script "t/01________new.t"
under HP-UX 10 was fixed; this was due to Perl calling the C function
"pow()" internally for the "**" operator, which returns non-integers
for powers of two larger than 2**4 under HP-UX (i.e., 2**5 != 32).


Migration strategy to version 5.5:
Migration strategy to version 5.6:
----------------------------------

Step 1:
Expand Down Expand Up @@ -88,11 +82,11 @@ Step 2:
-------

To upgrade your application(s) from "Bit::Vector" version 4.x
to "Bit::Vector" version 5.5, simply issue the following command:
to "Bit::Vector" version 5.6, simply issue the following command:

> perl ./tools/upgrade_BV55.pl app1.pl app2.pl app3.pl ...
> perl ./tools/upgrade_BV56.pl app1.pl app2.pl app3.pl ...
or
> perl .\tools\upgrade_BV55.pl app1.pl app2.pl app3.pl ...
> perl .\tools\upgrade_BV56.pl app1.pl app2.pl app3.pl ...

Note that this utility renames the original file "app<i>.pl" to
"app<i>.pl.bak" before creating a fresh copy of this file (again
Expand Down Expand Up @@ -159,7 +153,7 @@ the method name and the opening parenthesis are optional, though.

The substitutions performed by this upgrade utility are the following:

use Bit::Vector 4.x ==> use Bit::Vector 5.5
use Bit::Vector 4.x ==> use Bit::Vector 5.6
to_ASCII ==> to_Enum
from_ASCII ==> from_Enum
to_String ==> to_Hex
Expand Down Expand Up @@ -187,6 +181,11 @@ the new method "Lexicompare()" instead!
Version history:
----------------

Version 5.6 02.11.98

+ Removed the leading zeros from the output of "to_Hex()".
+ Fixed compiler warning on line 2067 of "BitVector.c".

Version 5.5 21.09.98

+ Fixed the bug of the uninitialized return code in method "Multiply()".
Expand Down
12 changes: 11 additions & 1 deletion CREDITS.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=====================================
Package "Bit::Vector" Version 5.5
Package "Bit::Vector" Version 5.6
=====================================


Expand Down Expand Up @@ -117,4 +117,14 @@ Paul J. Schinder <schinder@pobox.com> for reporting and helping to investigate
the error of the failed tests 96-131 of test script "t/01________new.t" under
HP-UX 10! This was fixed in version 5.5.

Many thanks to the "CPAN testers" (http://www.connect.net/gbarr/cpan-test/)
in general and to Jarkko Hietaniemi <jhi@iki.fi> in particular for testing
this module and for reporting the compiler warning which occurred on line
2067 of "BitVector.c" with the native "cc" compiler under Digital Unix,
which has been fixed in version 5.6.

Also many thanks to Matt Knecht <hex@voicenet.com> for pushing me hard
enough ;-) to suppress those annoying leading zeros in the output from
"to_Hex()" in version 5.6!


10 changes: 5 additions & 5 deletions INSTALL.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=====================================
Package "Bit::Vector" Version 5.5
Package "Bit::Vector" Version 5.6
=====================================


Expand All @@ -21,7 +21,7 @@ Edit the file "Makefile.PL" and change the line

'VERSION_FROM' => 'Vector.pm',
to
'VERSION' => '5.5',
'VERSION' => '5.6',

Then edit the file "Vector.pm" and change the line

Expand All @@ -31,7 +31,7 @@ to

Also edit the file "t/00____version.t" and change the line

use Bit::Vector 5.5;
use Bit::Vector 5.6;
to
use Bit::Vector;

Expand Down Expand Up @@ -78,7 +78,7 @@ Detailed installation guide:
----------------------------

1) Change directory to the directory that has been created by unpacking this
package ("cd Bit-Vector-5.5").
package ("cd Bit-Vector-5.6").

2) Type "perl Makefile.PL" (or whatever the name and path of your Perl 5
binary is).
Expand Down Expand Up @@ -162,7 +162,7 @@ Detailed installation guide:
t/28__chunklist.....ok
t/30_overloaded.....ok
All tests successful.
Files=19, Tests=67081, 173 secs (116.80 cusr 5.01 csys = 121.80 cpu)
Files=19, Tests=67211, 43 secs (29.09 cusr + 1.38 csys = 30.47 CPU)

(Note that the exact number of tests will depend on the number of bits
of a machine word/an unsigned long on your system!)
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ t/16___subtract.t
t/28__chunklist.t
t/30_overloaded.t
tools/upgrade_BV42.pl
tools/upgrade_BV55.pl
tools/upgrade_BV56.pl
typemap
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=====================================
Package "Bit::Vector" Version 5.5
Package "Bit::Vector" Version 5.6
=====================================


Expand Down
12 changes: 4 additions & 8 deletions Vector.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require DynaLoader;

@EXPORT_OK = qw();

$VERSION = '5.5';
$VERSION = '5.6';

$CONFIG[0] = 0;
$CONFIG[1] = 0;
Expand Down Expand Up @@ -2834,17 +2834,13 @@ C<$string = $vector-E<gt>to_Hex();>
Returns a hexadecimal string representing the given bit vector.
Note that this representation is quite compact, in that it only
needs twice the number of bytes needed to store the bit vector
itself, internally.
needs at most twice the number of bytes needed to store the bit
vector itself, internally.
Note also that since a hexadecimal digit is always worth four bits,
the length of the resulting string is always a multiple of four bits,
regardless of the true length (in bits) of the given bit vector.
Moreover, in order to simplify the conversion, the unused bits in
the bit vector (if any) are also converted, which may produce some
extra (but innocuous) leading hexadecimal zeros.
Finally, note that the B<LEAST> significant hexadecimal digit is
located at the B<RIGHT> end of the resulting string, and the B<MOST>
significant digit at the B<LEFT> end.
Expand Down Expand Up @@ -5287,7 +5283,7 @@ perltoot(1), perlxs(1), perlxstut(1), perlguts(1), overload(3).
=head1 VERSION
This man page documents "Bit::Vector" version 5.5.
This man page documents "Bit::Vector" version 5.6.
=head1 AUTHOR
Expand Down
8 changes: 4 additions & 4 deletions t/00____version.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use strict;
no strict "vars";

use Bit::Vector 5.5;
use Bit::Vector 5.6;

# ======================================================================
# $ver = $Bit::Vector::VERSION;
Expand All @@ -18,11 +18,11 @@ use Bit::Vector 5.5;
print "1..10\n";

$n = 1;
if ($Bit::Vector::VERSION eq "5.5")
if ($Bit::Vector::VERSION eq "5.6")
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

if (Bit::Vector::Version() eq "5.5")
if (Bit::Vector::Version() eq "5.6")
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if (Bit::Vector::Word_Bits() >= 32)
Expand All @@ -32,7 +32,7 @@ if (Bit::Vector::Long_Bits() >= 32)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

if (Bit::Vector->Version() eq "5.5")
if (Bit::Vector->Version() eq "5.6")
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if (Bit::Vector->Word_Bits() >= 32)
Expand Down
13 changes: 12 additions & 1 deletion t/12_____string.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $Bit::Vector::CONFIG[2] = 3;
# $vector->from_Enum();
# ======================================================================

print "1..62\n";
print "1..192\n";

$limit = 100;

Expand Down Expand Up @@ -350,5 +350,16 @@ if ($@ =~ /index out of range/)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

@first = ('', '1', '3', '7');

for ( $bits = 0; $bits <= 129; $bits++ )
{
$vec = Bit::Vector->new($bits);
$vec->Fill();
if ($vec->to_Hex() eq $first[$bits & 3] . ('F' x ($bits >> 2)))
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
}

__END__
4 changes: 2 additions & 2 deletions tools/upgrade_BV55.pl → tools/upgrade_BV56.pl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
print "\nUsage: perl $self <filename> [<filename>]*\n\n";
print "This utility tries to upgrade your Perl application(s) \"<filename>\"\n";
print "from \"Bit::Vector\" version 4.x to \"Bit::Vector\" version 5.5.\n\n";
print "from \"Bit::Vector\" version 4.x to \"Bit::Vector\" version 5.6.\n\n";
exit(0);
}

Expand Down Expand Up @@ -51,7 +51,7 @@
print "$self: upgrading \"$file\"...\n";
while (<INPUT>)
{
s/\buse\s+Bit::Vector\s+4\.\d\b/use Bit::Vector 5.5/g;
s/\buse\s+Bit::Vector\s+4\.\d\b/use Bit::Vector 5.6/g;
s/\bto_ASCII\b/to_Enum/g;
s/\bfrom_ASCII\b/from_Enum/g;
s/\bto_String\b/to_Hex/g;
Expand Down
2 changes: 1 addition & 1 deletion typemap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

###############################################################################
## ##
## Typemap for module "Bit::Vector" version 5.5. ##
## Typemap for module "Bit::Vector" version 5.6. ##
## ##
## Copyright (c) 1995, 1996, 1997, 1998 by Steffen Beyer. ##
## All rights reserved. ##
Expand Down

0 comments on commit 3a8ed13

Please sign in to comment.