Added Cyg-Win

This commit is contained in:
Frank Harris 2026-06-06 18:46:40 -04:00
parent 82cbc206eb
commit 413c315806
10586 changed files with 3806249 additions and 0 deletions

View file

@ -0,0 +1,264 @@
Revision history for Perl module Clone
0.50 2026-03-28 atoomic
- fix: deep-copy HVs past MAX_DEPTH instead of aliasing (GH #93)
- fix: strip macOS xattrs from dist directory before packaging
- cleanup: remove unreachable break and empty magic_ref if-body in Clone.xs
- docs: update MAX_DEPTH limits to reflect actual platform values
- docs: add SECURITY.md policy for vulnerability reporting
- Prefer using gtar in Makefile.PL
0.49 2026-03-24 21:23:44 atoomic
- fix: exclude macOS extended attributes from dist tarball
- fix: suppress DBI STDERR noise in t/13-io-handle.t (GH #82)
- fix: skip DBI fork tests on Windows
- fix: remove spurious warn output in t/03-scalar.t
- Add AI_POLICY.md documenting AI-assisted workflow
0.48 2026-03-02 16:01:53 atoomic
- perf: optimize hot paths in Clone.xs
- fix: replace subtest with SKIP/bare blocks to avoid Test2 warnings
- fix: don't require MGf_DUP flag for ext magic duplication
- fix: lower MAX_DEPTH to 4000 to prevent SEGV on CPAN smokers
- fix: use platform-adaptive depth in t/10-deep_recursion.t for Windows
- Fix t/10-deep_recursion.t for Windows
- Fix C89 declaration-after-statement violations in Clone.xs
- Fix deep recursion stack overflow on Windows
- Fix cloning of Math::BigInt::GMP objects (fixes #16)
- Fix cloning of threads::shared data structures (fixes #18)
- Add thread safety test for Class::DBI-like patterns (fixes #14)
- Add comprehensive documentation with examples and limitations
- Improve README.md structure and installation instructions
- Add DBI + DBD::SQLite as recommended test dependencies
- Fix weakened reference cloning via deferred weakening (fixes #15)
- Fix memory leak when cloning non-existent hash values (fixes #42)
- Fix segfault when cloning DBI database handles (fixes #27)
- Rewrite t/09-circular.t to fix SEGV on CPAN Testers (fixes #54)
- Replace static recursion_depth with stack parameter
- Fix C++ style comments in Clone.xs for C89 portability
- Fix memory leak in Clone.xs (fixes #42)
- Allow a MAX_DEPTH recursion of 32000 calls (fixes #19 aka RT97525)
- Rename tests with more readable names
- Remove TODO from cow test
0.47 2024-08-17 12:31:14 atoomic
- Stop using quote as package separator
0.46 2022-10-18 20:27:26 garu
- fix backwards compatibility with older perls (haarg)
- bump MANIFEST to include extra tests
0.45 2020-04-23 14:44:50 atoomic
- bump B::COW requirement to fix big-endian issue
0.44 2020-04-20 11:33:11 atoomic
- support Perls with COW disabled (plicease)
- bump B::COW requirement for testing
0.43 2019-07-29 13:49:04 atoomic
- fix an issue when cloning a NULL mg_ptr pointer
0.42 2019-07-19 01:38:38 garu
- make handling of mg_ptr safer (ATOOMIC, Harald Jörg)
- change license wording on some test files to
make the entire dist released under the same
terms as Perl itself (fixes GH#20) (GARU)
0.41 2018-10-25 15:08:43 garu
- Check the CowREFCNT of a COWed PV (ATOOMIC)
this should fix some issues people have been
having with 0.40 on DBD drives and DBIx::Class
- Make buildtools files not executable (Mohammad S Anwar)
- Move bugtracker to Github (GARU)
0.40 2018-10-23 20:03:07 garu
- reuse COWed PV when cloning (fixes RT97535) (ATOOMIC)
- extra protection against potential infinite loop (ATOOMIC)
- improved tests
0.39 2017-04-07 13:21:36 garu
- use explicit '.' in tests since it may not be in @INC
anymore in newer perls (fixes RT120648) (PLICEASE, SIMCOP)
0.38 2015-01-18 19:34:45 garu
- typo fixes and improvements to the README (zmughal)
- travis/coveralls integration (zmughal)
0.37 2014-05-15 18:46:04 garu
- removed Carp dependency (GARU)
- silenced some clang warnings (JACQUESG)
- added a README (GARU)
0.36 2013-12-07 17:33:43 garu
- fixed compilation issue on AIX and C89 (GAAS)
0.35 2013-09-05 13:23:20 garu
- SV's can be NULL (shit happens) (fixes RT86217) (HMBRAND)
- making tests compatible with older versions of Test::More (GARU)
0.34 2012-12-09 19:19:02 garu
- making some tests optional (fixes RT81774) (GARU)
- modernizing synopsis (GARU)
0.33 2012-11-24 11:38:31 garu
- fix typo in croak message (Salvatore Bonaccorso)
0.32 2012-11-22 12:42:19 garu
- Stop skipping SvROK handling for all magical scalars. This fixes
RT issues 67105, 79730 and 80201 (FLORA).
- making the Changes file compliant to the CPAN::Changes spec (GARU).
- Fixing tests when Scalar::Util::weaken is not available. As a
result, tests should now pass even in odd OpenBSD versions (GARU).
- removed dubious documentation on the optional parameter until
it is 'fixed'. Right now it just increases the refcount when it's 0,
and clones otherwise (which isn't exactly what it says). This
fixes RT issue 57773 (GARU).
- updated remark on Storable's dclone() to address RT issue 50174 (GARU)
- updated Makefile.PL to include test dependencies (GARU)
0.31 2009-01-20 04:54:37 ray
- Made changes for build failure on Solaris, apparently compiler warnings
from the last patch are errors in Solaris.
- Also, brought Changes file up to date.
0.30 2008-12-14 03:33:14 ray
- Updating log: Applied patches from RT # 40957 and #41551.
0.29 2008-12-14 03:32:41 ray
- Updating log: Applied patches supplied by Andreas Koenig, see RT #34317.
0.28 2008-12-14 03:31:33 ray
- Updating log: Made a change in CLONE_KEY to the way Clone stores refs in
the ref hash.
- Perl no longer uses the SvANY part of the SV struct in the same way which
means the old way of storing the hash key is no longer unique.
Thanks to Slaven Rezic for the patch.
0.27 2008-12-14 03:30:40 ray
- Updating Log: Latest patch from Ruslan Zakirov. Patched another
memory leak.
0.26 2007-10-15 04:52:42 ray
- Made a change in CLONE_KEY to the way Clone stores refs in the ref hash.
- Perl no longer uses the SvANY part of the SV struct in the same way which
means the old way of storing the hash key is no longer unique.
Thanks to Slaven Rezic for the patch.
0.25 2007-07-25 03:41:04 ray
- Latest patch from Ruslan Zakirov. Patched another memory leak.
0.24 2007-07-25 03:33:57 ray
- Bug fix for 5.9.*, for some reason the 'visible' logic is no longer
working. I #if 'ed it out until I figure out what is going on.
- Also removed an old redundant CLONE_STORE, could have been the cause of
some memory leaks.
0.23 2007-04-20 05:40:27 ray
- Applied patch so clone will contiue to work with newer perls.
- Also fixed test to work with older perls.
0.22 2006-10-08 05:35:19 ray
- D'oh! The 0.21 tardist that I just uploaded to CPAN contained the
0.20 Clone.xs file. This release is just in case any of the 0.21
releases get mirrored.
0.21 2006-10-08 04:02:56 ray
- Clone was segfaulting due to a null SV object in a magical reference (a
PERL_MAGIC_utf8).
- 21859: Clone segfault (isolated example)
0.20 2006-03-08 17:15:23 ray
- Commented out VERSION causes errors with DynaLoader in perl 5.6.1 (and
probably all earlier versions. It was removed.
0.19 2006-03-06 07:22:32 ray
- added a test and fix for tainted variables.
- use a static VERSION in Clone.pm.
0.18 2005-05-23 15:34:31 ray
- moved declaration to top of function, M$ (and other) C compilers choke.
0.17 2005-05-05 22:26:01 ray
- Changed PERL_MAGIC_backref to '<' for compatability with 5.6
0.16 2005-04-20 15:49:35 ray
- Bug fix for id 11997, "Clone dies horribly when Scalar::Util::weaken
is around" see http://rt.cpan.org/Ticket/Display.html?id=11997
for details.
0.15.2.1 2005-05-05 21:55:30 ray
- changed PERL_MAGIC_backref to '<' for backward compatibility with 5.6
0.15 2003-09-07 22:02:35 ray
- VERSION 0.15
0.13.2.3 2003-09-07 21:51:03 ray
- added support for unicode hash keys. This is only really a bug in 5.8.0
and the test in t/03scalar supports this.
0.14 2003-09-07 05:48:10 ray
- VERSION 0.14
0.13.2.2 2003-09-07 05:45:52 ray
- bug fix: refs to a qr (regexp) expression was causing a segfault.
0.13.2.1 2003-09-06 20:18:37 ray
- Bug fix on cloning references, only set ROK in clone if it's set in ref.
0.13 2002-02-03 02:12:29 ray
- VERSION 0.13
0.11.2.1 2002-02-03 02:10:30 ray
- removed dependency on Storable for tests.
0.12 2001-09-30 20:35:27 ray
- Version 0.12 release.
0.11 2001-07-29 19:30:27 ray
- VERSION 0.11
0.10.2.3 2001-07-28 21:53:03 ray
- fixed memory leaks on un-blessed references.
0.10.2.2 2001-07-28 21:52:41 ray
- added test cases for circular reference bugs and memory leaks.
0.10.2.1 2001-07-28 21:52:15 ray
- fixed circular reference bugs.
0.10 2001-04-29 21:48:45 ray
- VERSION 0.10
0.09.2.3 2001-03-11 00:54:41 ray
- change call to rv_clone in clone to sv_clone; this allows any scalar to
be cloned.
0.09.2.2 2001-03-11 00:50:01 ray
- version 0.09.3: cleaned up code, consolidated MAGIC.
0.09.2.1 2001-03-05 16:01:52 ray
- added support for double-types.
0.09 2000-08-21 23:05:55 ray
- added support for code refs
0.08 2000-08-11 17:08:24 ray
- Release 0.08.
0.07 2000-08-01 00:31:24 ray
- release 0.07.
0.06.2.3 2000-07-28 20:40:25 ray
- added support for circular references
0.06.2.2 2000-07-28 19:04:14 ray
- first pass at circular references.
0.06.2.1 2000-07-28 18:54:33 ray
- added support for scalar types.
0.06 2000-05-25 17:48:59 ray
- initial release to CPAN.
0.01 2000-05-16 08:55:10 ray
- original version; created by h2xs 1.19

View file

@ -0,0 +1,229 @@
Clone - recursively copy Perl datatypes
=======================================
[![Build Status](https://github.com/garu/Clone/actions/workflows/test.yml/badge.svg)](https://github.com/garu/Clone/actions/workflows/test.yml)
[![CPAN version](https://badge.fury.io/pl/Clone.svg)](https://metacpan.org/pod/Clone)
## Synopsis
## Synopsis
```perl
use Clone 'clone';
my $data = {
set => [ 1 .. 50 ],
foo => {
answer => 42,
object => SomeObject->new,
},
};
my $cloned_data = clone($data);
$cloned_data->{foo}{answer} = 1;
print $cloned_data->{foo}{answer}; # '1'
print $data->{foo}{answer}; # '42'
```
You can also add it to your class:
```perl
package Foo;
use parent 'Clone';
sub new { bless {}, shift }
package main;
my $obj = Foo->new;
my $copy = $obj->clone;
```
## Description
This module provides a `clone()` method which makes recursive
copies of nested hash, array, scalar and reference types,
including tied variables and objects.
`clone()` takes a scalar argument and duplicates it. To duplicate lists,
arrays or hashes, pass them in by reference, e.g.
```perl
my $copy = clone (\@array);
# or
my %copy = %{ clone (\%hash) };
```
## Installation
From CPAN:
```bash
cpanm Clone
```
From source:
```bash
perl Makefile.PL
make
make test
make install
```
## Examples
### Cloning Blessed Objects
```perl
package Person;
sub new {
my ($class, $name) = @_;
bless { name => $name, friends => [] }, $class;
}
package main;
use Clone 'clone';
my $person = Person->new('Alice');
my $clone = clone($person);
# $clone is a separate object with the same data
push @{$person->{friends}}, 'Bob';
print scalar @{$clone->{friends}}; # 0
```
### Handling Circular References
Clone properly handles circular references, preventing infinite loops:
```perl
my $a = { name => 'A' };
my $b = { name => 'B', ref => $a };
$a->{ref} = $b; # circular reference
my $clone = clone($a);
# Circular structure is preserved in the clone
```
### Cloning Weakened References
```perl
use Scalar::Util 'weaken';
my $obj = { data => 'important' };
my $container = { strong => $obj, weak => $obj };
weaken($container->{weak});
my $clone = clone($container);
# Both strong and weak references are preserved correctly
```
### Cloning Tied Variables
```perl
use Tie::Hash;
tie my %hash, 'Tie::StdHash';
%hash = (a => 1, b => 2);
my $clone = clone(\%hash);
# The tied behavior is preserved in the clone
```
## Limitations
* **Maximum Recursion Depth**: Clone uses a recursion depth counter to prevent stack overflow. The default limit is 4000 rdepth units on Linux/macOS and 2000 on Windows/Cygwin. Each nesting level consumes approximately 2 rdepth units, so the effective limits are roughly 2000 nesting levels on Linux/macOS and 1000 on Windows/Cygwin. For arrays, exceeding the limit triggers an iterative fallback. For other types, it produces a warning and a shallow copy. You can override the limit via `clone($data, $depth)`.
* **Filehandles and IO Objects**: Filehandles and IO objects are cloned, but the underlying file descriptor is shared. Both the original and cloned filehandle will refer to the same file position. For DBI database handles and similar objects, Clone attempts to handle them safely, but behavior may vary depending on the object type.
* **Code References**: Code references (subroutines) are cloned by reference, not by value. The cloned coderef points to the same subroutine as the original.
* **Thread Safety**: Clone is not explicitly thread-safe. Use appropriate synchronization when cloning data structures across threads.
## Performance
Clone is implemented in C using Perl's XS interface, making it very fast for most use cases.
**When to use Clone:**
Clone is optimized for speed and works best with:
* Shallow to medium-depth structures (3 levels or fewer)
* Data structures that need fast cloning in hot code paths
* Structures containing blessed objects and tied variables
**When to use Storable::dclone:**
[Storable](https://metacpan.org/pod/Storable)'s `dclone()` may be faster for:
* Very deep structures (4+ levels)
* When you need serialization features
Benchmarking your specific use case is recommended for performance-critical applications.
## Caveats
* **Cloned objects are deep copies**: Changes to the clone do not affect the original, and vice versa. This includes nested references and objects.
* **Object internals**: While Clone handles most blessed objects correctly, objects with XS components or complex internal state may not clone as expected. Test thoroughly with your specific object types.
* **Memory usage**: Cloning large data structures creates a complete copy in memory. Ensure you have sufficient memory available.
## Testing
Run the test suite:
```bash
make test
```
Or with verbose output:
```bash
prove -lv t/
```
## Contributing
Contributions are welcome! Please:
1. Fork the repository on [GitHub](https://github.com/garu/Clone)
2. Create a feature branch
3. Make your changes with tests
4. Submit a pull request
## See Also
[Storable](https://metacpan.org/pod/Storable)'s `dclone()` is a flexible solution for cloning variables,
albeit slower for average-sized data structures. Simple
and naive benchmarks show that Clone is faster for data structures
with 3 or fewer levels, while `dclone()` can be faster for structures
4 or more levels deep.
Other modules that may be of interest:
* [Clone::PP](https://metacpan.org/pod/Clone::PP) - Pure Perl implementation of Clone
* [Scalar::Util](https://metacpan.org/pod/Scalar::Util) - For `weaken()` and other scalar utilities
* [Data::Dumper](https://metacpan.org/pod/Data::Dumper) - For debugging and inspecting data structures
## Support
* **Bug Reports and Feature Requests**: Please report bugs on [GitHub Issues](https://github.com/garu/Clone/issues)
* **Source Code**: Available on [GitHub](https://github.com/garu/Clone)
COPYRIGHT
---------
Copyright 2001-2026 Ray Finch. All Rights Reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
## Author
Ray Finch `<rdf@cpan.org>`
Breno G. de Oliveira `<garu@cpan.org>`,
Nicolas Rochelemagne `<atoomic@cpan.org>` and
Florian Ragwitz `<rafl@debian.org>` perform routine maintenance
releases since 2012.