[libuuid-tiny-perl] 01/05: Imported Upstream version 1.0400

Salvatore Bonaccorso carnil at debian.org
Thu Sep 19 18:48:45 UTC 2013


This is an automated email from the git hooks/post-receive script.

carnil pushed a commit to annotated tag debian/1.0400-1
in repository libuuid-tiny-perl.

commit afbac45cf6ce2a1fcdef4630286c2726a8f8ae36
Author: Salvatore Bonaccorso <carnil at debian.org>
Date:   Thu Sep 19 20:40:48 2013 +0200

    Imported Upstream version 1.0400
---
 Changes          |   12 ++++++++
 META.yml         |    3 +-
 Makefile.PL      |    2 +-
 README           |    4 +--
 lib/UUID/Tiny.pm |   83 ++++++++++++++++++++++++++++--------------------------
 t/01-UUID-std.t  |    4 ++-
 6 files changed, 62 insertions(+), 46 deletions(-)

diff --git a/Changes b/Changes
index e7fb224..89f73bc 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,17 @@
 Revision history for UUID-Tiny
 
+1.04    2013-08-22, caugustin.de
+        Fixed typos from bug report #87187.
+        Rejected bug report #83073 (UUID::Tiny correctly sets the variant).
+        Thread-tests still not running (Mac OS X 10.8.x and other machines).
+        Thread-tests removed, bug report #57188 deferred.
+        POD changed to better reflect the new standard interface.
+        Fixed a bug in Makefile.PL reported by Matt Koscica.
+
+1.03_01 2010-05-04, caugustin.de
+        Thread-patches from Michael C. Schwern applied.
+        Test not running on Mac OS X 10.6.3 ...
+
 1.03    2010-01-31, caugustin.de
         Once again clk_seq uniqueness and fixing some small bugs with
         _get_clk_seq() (due to failed CPAN Tester's ID 6750882).
diff --git a/META.yml b/META.yml
index 21ab094..4bb9a58 100644
--- a/META.yml
+++ b/META.yml
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               UUID-Tiny
-version:            1.03
+version:            1.04
 abstract:           Pure Perl UUID Support With Functional Interface
 author:
     - Christian Augustin <mail at caugustin.de>
@@ -13,7 +13,6 @@ build_requires:
 requires:
     Carp:          0
     Digest::MD5:   0
-    Digest::SHA1:  0
     IO::File:      0
     MIME::Base64:  0
     POSIX:         0
diff --git a/Makefile.PL b/Makefile.PL
index 0b9df18..5973bf8 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -19,7 +19,7 @@ WriteMakefile(
 		'POSIX'        => 0,
         'Test::More'   => 0,
         'IO::File'     => 0,
-        ($[ < 5.010000 ? ( 'Digest::SHA1' => 0) :()), # only require Digest::SHA1 on 5.8
+        ($] < 5.010000 ? ( 'Digest::SHA1' => 0) :()), # only require Digest::SHA1 on 5.8
     },
     dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
     clean               => { FILES => 'UUID-Tiny-*' },
diff --git a/README b/README
index 35fd4c3..d8c3afd 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-UUID-Tiny Version 1.03
+UUID-Tiny Version 1.04
 
 This is a Pure Perl module for the creation of UUIDs:
 
@@ -63,7 +63,7 @@ You can also look for information at:
 
 COPYRIGHT AND LICENCE
 
-Copyright (C) 2009, 2010 Christian Augustin
+Copyright (C) 2009, 2010, 2013 Christian Augustin
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.
diff --git a/lib/UUID/Tiny.pm b/lib/UUID/Tiny.pm
index 5a7623d..c3e38df 100644
--- a/lib/UUID/Tiny.pm
+++ b/lib/UUID/Tiny.pm
@@ -9,7 +9,7 @@ use MIME::Base64;
 use Time::HiRes;
 use POSIX;
 
-our $SHA1_CALCULATOR = undef;
+my $SHA1_CALCULATOR = undef;
 
 {
     # Check for availability of SHA-1 ...
@@ -22,7 +22,7 @@ our $SHA1_CALCULATOR = undef;
     };
 };
 
-our $MD5_CALCULATOR = Digest::MD5->new();
+my $MD5_CALCULATOR = Digest::MD5->new();
 
 
 # ToDo:
@@ -37,36 +37,39 @@ UUID::Tiny - Pure Perl UUID Support With Functional Interface
 
 =head1 VERSION
 
-Version 1.03
+Version 1.04
 
 =cut
 
-our $VERSION = '1.03';
+our $VERSION = '1.04';
 
 
 =head1 SYNOPSIS
 
 Create version 1, 3, 4 and 5 UUIDs:
 
-    use UUID::Tiny;
+    use UUID::Tiny ':std';
 
-    my $v1_mc_UUID         = create_UUID();
-    my $v3_md5_UUID        = create_UUID(UUID_V3, $str);
-    my $v3_md5_UUID        = create_UUID(UUID_V3, UUID_NS_DNS, 'caugustin.de');
-    my $v4_rand_UUID       = create_UUID(UUID_V4);
-    my $v5_sha1_UUID       = create_UUID(UUID_V5, $str);
-    my $v5_with_NS_UUID    = create_UUID(UUID_V5, UUID_NS_DNS, 'caugustin.de');
+    my $v1_mc_UUID      = create_uuid();
+    my $v1_mc_UUID_2    = create_uuid(UUID_V1);
+    my $v1_mc_UUID_3    = create_uuid(UUID_TIME);
+    my $v3_md5_UUID     = create_uuid(UUID_V3, $str);
+    my $v3_md5_UUID_2   = create_uuid(UUID_MD5, UUID_NS_DNS, 'caugustin.de');
+    my $v4_rand_UUID    = create_uuid(UUID_V4);
+    my $v4_rand_UUID_2  = create_uuid(UUID_RANDOM);
+    my $v5_sha1_UUID    = create_uuid(UUID_V5, $str);
+    my $v5_with_NS_UUID = create_uuid(UUID_SHA1, UUID_NS_DNS, 'caugustin.de');
 
-    my $v1_mc_UUID_string  = create_UUID_as_string(UUID_V1);
-    my $v3_md5_UUID_string = UUID_to_string($v3_md5_UUID);
+    my $v1_mc_UUID_string  = create_uuid_as_string(UUID_V1);
+    my $v3_md5_UUID_string = uuid_to_string($v3_md5_UUID);
 
-    if ( version_of_UUID($v1_mc_UUID) == 1   ) { ... };
-    if ( version_of_UUID($v5_sha1_UUID) == 5 ) { ... };
-    if ( is_UUID_string($v1_mc_UUID_string)  ) { ... };
-    if ( equal_UUIDs($uuid1, $uuid2)         ) { ... };
+    if ( version_of_uuid($v1_mc_UUID) == 1   ) { ... };
+    if ( version_of_uuid($v5_sha1_UUID) == 5 ) { ... };
+    if ( is_uuid_string($v1_mc_UUID_string)  ) { ... };
+    if ( equal_uuids($uuid1, $uuid2)         ) { ... };
 
-    my $uuid_time    = time_of_UUID($v1_mc_UUID);
-    my $uuid_clk_seq = clk_seq_of_UUID($v1_mc_UUID);
+    my $uuid_time    = time_of_uuid($v1_mc_UUID);
+    my $uuid_clk_seq = clk_seq_of_uuid($v1_mc_UUID);
 
 =cut
 
@@ -86,8 +89,8 @@ and transformations - just string and binary. Conversion, test and time
 functions equally accept UUIDs and UUID strings, so don't bother to convert
 UUIDs for them!
 
-All constants and public functions are exported by default, because if you
-didn't need/want them, you wouldn't use this module ...
+Continuing with 1.0x versions all constants and public functions are exported
+by default, but this will change in the future (see below). 
 
 UUID::Tiny deliberately uses a minimal functional interface for UUID creation
 (and conversion/testing), because in this case OO looks like overkill to me
@@ -101,9 +104,10 @@ modules like L<Data::UUID>.
 This module is "fork safe", especially for random UUIDs (it works around
 Perl's rand() problem when forking processes).
 
-This module should be "thread safe," because its global variables
-are locked in the functions that access them. (Not tested - if you can provide
-some tests, please tell me!)
+This module is currently B<not> "thread safe". Even though I've incorporated
+some changes proposed by Michael G. Schwern (thanks!), Digest::MD5 and
+Digest::SHA seem so have trouble with threads. There is a test file for
+threads, but it is de-activated. So use at your own risk!
 
 =cut
 
@@ -127,7 +131,7 @@ Digest::SHA1 installed, you can use Digest::SHA::PurePerl instead.
 =cut
 
 
-=head1 ATTENTION! NEW STANDARD INTERFACE (IN PREPARATION FOR V2.00)
+=head1 ATTENTION! NEW STANDARD INTERFACE
 
 After some debate I'm convinced that it is more Perlish (and far easier to
 write) to use all-lowercase function names - without exceptions. And that it
@@ -140,8 +144,8 @@ import from version 1.02 on:
     use UUID::Tiny ':std';
     my $md5_uuid = create_uuid(UUID_MD5, $str);
 
-In preparation for the upcoming version 2.00 of UUID::Tiny you should use the
-C<:legacy> tag if you want to stay with the version 1.0x interface:
+In preparation for future version of UUID::Tiny you have to use the
+C<:legacy> tag if you want to stay with the version 1.0 interface:
 
     use UUID::Tiny ':legacy';
     my $md5_uuid = create_UUID(UUID_V3, $str);
@@ -279,7 +283,7 @@ other functions).
 
 C<create_UUID()> creates standard binary UUIDs in network byte order
 (MSB first), C<create_UUID_as_string()> creates the standard string
-represantion of UUIDs.
+representation of UUIDs.
 
 All query and test functions (except C<is_UUID_string>) accept both
 representations.
@@ -388,8 +392,6 @@ sub _create_v3_uuid {
     my $name    = shift;
     my $uuid    = '';
 
-    lock $MD5_CALCULATOR;
-
     # Create digest in UUID ...
     $MD5_CALCULATOR->reset();
     $MD5_CALCULATOR->add($ns_uuid);
@@ -441,8 +443,6 @@ sub _create_v5_uuid {
             ;
     }
 
-    lock $SHA1_CALCULATOR;
-
     $SHA1_CALCULATOR->reset();
     $SHA1_CALCULATOR->add($ns_uuid);
 
@@ -543,7 +543,7 @@ strings, variants with different positions of C<-> and Base64 encoded UUIDs.
 
 Throws an exception if string can't be interpreted as a UUID.
 
-If you want to make shure to have a "pure" standard UUID representation, check
+If you want to make sure to have a "pure" standard UUID representation, check
 with C<is_UUID_string>!
 
 =cut
@@ -681,7 +681,7 @@ sub equal_uuids {
 # Private functions ...
 #
 my $Last_Pid;
-my $Clk_Seq;
+my $Clk_Seq :shared;
 
 # There is a problem with $Clk_Seq and rand() on forking a process using
 # UUID::Tiny, because the forked process would use the same basic $Clk_Seq and
@@ -690,7 +690,6 @@ my $Clk_Seq;
 # time before using $Clk_Seq or rand() ...
 
 sub _init_globals {
-    lock $Last_Pid;
     lock $Clk_Seq;
 
     if (!defined $Last_Pid || $Last_Pid != $$) {
@@ -714,7 +713,7 @@ sub _init_globals {
     return;
 }
 
-my $Last_Timestamp;
+my $Last_Timestamp :shared;
 
 sub _get_clk_seq {
     my $ts = shift;
@@ -727,7 +726,7 @@ sub _get_clk_seq {
     if (defined $Last_Timestamp && $ts <= $Last_Timestamp) {
         #$Clk_Seq = ($Clk_Seq + 1) % 65536;
         # The old variant used modulo, but this looks unnecessary,
-        # because we should only use the signigicant part of the
+        # because we should only use the significant part of the
         # number, and that also lets the counter circle around:
         $Clk_Seq = ($Clk_Seq + 1) & 0x3fff;
     }
@@ -821,7 +820,7 @@ address with Perl is really dirty (and slow);
 
 =item B<Should version 3 or version 5 be used?>
 
-Using SHA-1 reduces the probabillity of collisions and provides a better
+Using SHA-1 reduces the probability of collisions and provides a better
 "randomness" of the resulting UUID compared to MD5. Version 5 is recommended
 in RFC 4122 if backward compatibility is not an issue.
 
@@ -834,7 +833,8 @@ creating UUIDs from file content rather than names.
 =head1 UUID DEFINITION
 
 See RFC 4122 (L<http://www.ietf.org/rfc/rfc4122.txt>) for technical details on
-UUIDs.
+UUIDs. Wikipedia gives a more palatable description at
+L<http://en.wikipedia.org/wiki/Universally_unique_identifier>.
 
 
 =head1 AUTHOR
@@ -854,6 +854,9 @@ parts with a functional interface ...
 Jesse Vincent, C<< <jesse at bestpractical.com> >>, improved version 1.02 with
 his tips and a heavy refactoring.
 
+Michael G. Schwern provided a patch for better thread support (as far as
+UUID::Tiny can be improved itself) that is incorporated in version 1.04. 
+
 
 
 =head1 BUGS
@@ -905,7 +908,7 @@ Thanks to Jesse Vincent (C<< <jesse at bestpractical.com> >>) for his feedback,
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2009, 2010 Christian Augustin, all rights reserved.
+Copyright 2009, 2010, 2013 Christian Augustin, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.
diff --git a/t/01-UUID-std.t b/t/01-UUID-std.t
index 92c07c4..22be8bc 100644
--- a/t/01-UUID-std.t
+++ b/t/01-UUID-std.t
@@ -107,7 +107,7 @@ is(
 
 my $test_data = do {
     local $/;
-    open my $fh, '<', 't/data/test.jpg';
+    open my $fh, '<', 't/data/test.jpg' or croak "Open failed!";
     <$fh>;
 };
 
@@ -192,6 +192,7 @@ ok(
 #
 my $now = time();
 my $v1_uuid = create_uuid();
+#diag uuid_to_string($v1_uuid);
 ok( version_of_uuid($v1_uuid) == 1, 'create_uuid creates v1 UUID' );
 
 # Check time_of_uuid() ...
@@ -254,6 +255,7 @@ for (my $i = 0; $i < 10000; $i++) {
 # Generate v4 UUIDs ...
 #
 my $v4_uuid = create_uuid(UUID_RANDOM);
+#diag uuid_to_string($v4_uuid);
 ok( version_of_uuid($v4_uuid) == 4, 'create_uuid creates v4 UUID' );
 
 # Check for uniqueness of random UUIDs ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libuuid-tiny-perl.git



More information about the Pkg-perl-cvs-commits mailing list