From 6131988cd82a5f5231fc685bf52f055f8ad347ad Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Tue, 12 Apr 2022 13:07:51 +0200 Subject: [PATCH] Move from svn to github and various fixes: - fix rt.cpan.org#142095:IfDefine refined - fix rt.cpan.org#118746:clarify variable name chars - fix rt.cpan.org#139261: include dirs - fixed license to artistic_2 - fix repo+version --- Changelog | 18 +++++++++++++++ General.pm | 47 +++++++++++++++++++++++---------------- General/Extended.pm | 44 ++++++++++++++++++------------------ General/Interpolated.pm | 29 ++++++++++++++++++------ META.json | 49 +++++++++++++++++++++++++++++++++++++++++ META.yml | 39 ++++++++++++++++++++------------ Makefile.PL | 43 ++++++++++++++++++------------------ README | 8 +++---- 8 files changed, 189 insertions(+), 88 deletions(-) create mode 100644 META.json diff --git a/Changelog b/Changelog index f9629ef..50b5368 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,21 @@ +2.65 - fix rt.cpan.org#132893: clarified license, now licensed + under the Artistic License 2.0. + - fix rt.cpan.org#139261: correctly include directories. + + - fix rt.cpan.org#118746: remove the comma from legal + variable names, added mandatory start characters a-zA-Z0-9, + added a section in the POD to clarify this. + + - fix rt.cpan.org#119160: fix IfDefine code. Thanks for the patch. + +2.64 - fix rt.cpan.org#142095: copy default hash, avoid modification. + + - the Catalyst folks who hosted the source of this module + closed or moved the repository, I have not been informed and + have therefore lost all history of the module. So I moved + to github (https://github.com/TLINDEN/Config-General). + Thanks for nothing, Catalyst. + 2.63 - fix for rt.cpan.org#116340: do only consider a backslash as meta escape char, but not if it appears on it's own, as it happens on windows platforms. Thanks to for finding diff --git a/General.pm b/General.pm index 3f56466..875a24d 100644 --- a/General.pm +++ b/General.pm @@ -5,9 +5,9 @@ # config values from a given file and # return it as hash structure # -# Copyright (c) 2000-2016 Thomas Linden . +# Copyright (c) 2000-2022 Thomas Linden . # All Rights Reserved. Std. disclaimer applies. -# Artistic License, same as perl itself. Have fun. +# Licensed under the Artistic License 2.0. # # namespace package Config::General; @@ -32,7 +32,7 @@ use Carp::Heavy; use Carp; use Exporter; -$Config::General::VERSION = "2.63"; +$Config::General::VERSION = "2.65"; use vars qw(@ISA @EXPORT_OK); use base qw(Exporter); @@ -339,7 +339,8 @@ sub _prepare { if (exists $conf{-DefaultConfig}) { if ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq 'HASH') { - $self->{DefaultConfig} = $conf{-DefaultConfig}; + # copy the hashref so that it is not being modified by subsequent calls, fixes bug#142095 + $self->{DefaultConfig} = $self->_copy($conf{-DefaultConfig}); } elsif ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq q()) { $self->_read($conf{-DefaultConfig}, 'SCALAR'); @@ -516,7 +517,9 @@ sub _open { # A directory was included; include all the files inside that directory in ASCII order local *INCLUDEDIR; opendir INCLUDEDIR, $configfile or croak "Config::General: Could not open directory $configfile!($!)\n"; - my @files = sort grep { -f catfile($configfile, $_) } catfile($configfile, $_), readdir INCLUDEDIR; + #my @files = sort grep { -f catfile($configfile, $_) } catfile($configfile, $_), readdir INCLUDEDIR; + # fixes rt.cpan.org#139261 + my @files = sort grep { -f catfile($configfile, $_) } readdir INCLUDEDIR; closedir INCLUDEDIR; local $this->{CurrentConfigFilePath} = $configfile; for (@files) { @@ -832,29 +835,35 @@ sub _process_apache_ifdefine { my($this, $rawlines) = @_; my @filtered; - my $includeFlag = 1; - my $blockLevel = 0; + my @includeFlag = (1); foreach (@{$rawlines}) { - if (/^<\s*IfDefine\s+([!]*)("[^"]+"|\S+)\s*>/i) { + if (/^\s*<\s*IfDefine\s+([!]*)("[^"]+"|\S+)\s*>/i) { # new IFDEF block, mark following content to be included if # the DEF is known, otherwise skip it til end of IFDEF my ($negate, $define) = ($1 eq '!',$2); - $blockLevel++; - $includeFlag &= ((not $negate) & (exists $this->{Define}{$define})); - } elsif (/^<\s*\/IfDefine\s*>/i) { - $blockLevel--; - $includeFlag = $blockLevel == 0; - } elsif ($includeFlag && /\s*Define\s+("[^"]+"|\S+)/i) { + push(@includeFlag, + $includeFlag[-1] & + ((not $negate) & (exists $this->{Define}{$define})) + ); + } + elsif (/^\s*<\s*\/IfDefine\s*>/i) { + if (scalar(@includeFlag) <= 1) { + croak qq(Config::General: without a !\n); + } + pop(@includeFlag); + } + elsif ($includeFlag[-1] && /^\s*Define\s+("[^"]+"|\S+)/i) { # inline Define, add it to our list $this->{Define}{$1} = 1; - } elsif ($includeFlag) { + } + elsif ($includeFlag[-1]) { push @filtered, $_; } } - if ($blockLevel) { + if (scalar(@includeFlag) > 1) { croak qq(Config::General: Block has no EndBlock statement!\n); } @@ -2845,10 +2854,10 @@ I recommend you to read the following documents, which are supplied with Perl: =head1 LICENSE AND COPYRIGHT -Copyright (c) 2000-2016 Thomas Linden +Copyright (c) 2000-2022 Thomas Linden This library is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. +modify it under the same terms of the Artistic License 2.0. =head1 BUGS AND LIMITATIONS @@ -2874,7 +2883,7 @@ Thomas Linden =head1 VERSION -2.63 +2.65 =cut diff --git a/General/Extended.pm b/General/Extended.pm index 0e9e1c0..f4369c9 100644 --- a/General/Extended.pm +++ b/General/Extended.pm @@ -1,9 +1,9 @@ # # Config::General::Extended - special Class based on Config::General # -# Copyright (c) 2000-2014 Thomas Linden . +# Copyright (c) 2000-2022 Thomas Linden . # All Rights Reserved. Std. disclaimer applies. -# Artistic License, same as perl itself. Have fun. +# Licensed under the Artistic License 2.0. # # namespace @@ -96,33 +96,33 @@ sub obj { elsif (ref($this->{config}->{$key}) eq "ARRAY") { my @objlist; foreach my $element (@{$this->{config}->{$key}}) { - if (ref($element) eq "HASH") { - push @objlist, - $this->SUPER::new( -ExtendedAccess => 1, - -ConfigHash => $element, - %{$this->{Params}} ); - } - else { - if ($this->{StrictObjects}) { - croak "element in list \"$key\" does not point to a hash reference!\n"; - } - # else: skip this element - } + if (ref($element) eq "HASH") { + push @objlist, + $this->SUPER::new( -ExtendedAccess => 1, + -ConfigHash => $element, + %{$this->{Params}} ); + } + else { + if ($this->{StrictObjects}) { + croak "element in list \"$key\" does not point to a hash reference!\n"; + } + # else: skip this element + } } return \@objlist; } elsif (ref($this->{config}->{$key}) eq "HASH") { return $this->SUPER::new( -ExtendedAccess => 1, - -ConfigHash => $this->{config}->{$key}, %{$this->{Params}} ); + -ConfigHash => $this->{config}->{$key}, %{$this->{Params}} ); } else { # nothing supported if ($this->{StrictObjects}) { - croak "key \"$key\" does not point to a hash reference!\n"; + croak "key \"$key\" does not point to a hash reference!\n"; } else { - # be cool, create an empty object! - return $empty; + # be cool, create an empty object! + return $empty; } } } @@ -148,10 +148,10 @@ sub value { } else { if ($this->{StrictObjects}) { - croak "Key \"$key\" does not exist within current object\n"; + croak "Key \"$key\" does not exist within current object\n"; } else { - return ""; + return ""; } } } @@ -640,10 +640,10 @@ values under the given key will be overwritten. =head1 COPYRIGHT -Copyright (c) 2000-2014 Thomas Linden +Copyright (c) 2000-2022 Thomas Linden This library is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. +modify it under the terms of the Artistic License 2.0. =head1 BUGS diff --git a/General/Interpolated.pm b/General/Interpolated.pm index 29d1ad2..acc4740 100644 --- a/General/Interpolated.pm +++ b/General/Interpolated.pm @@ -2,13 +2,13 @@ # Config::General::Interpolated - special Class based on Config::General # # Copyright (c) 2001 by Wei-Hon Chen . -# Copyright (c) 2000-2014 by Thomas Linden . +# Copyright (c) 2000-2022 by Thomas Linden . # All Rights Reserved. Std. disclaimer applies. -# Artistic License, same as perl itself. Have fun. +# Licensed under the terms of the Artistic License 2.0. # package Config::General::Interpolated; -$Config::General::Interpolated::VERSION = "2.15"; +$Config::General::Interpolated::VERSION = "2.16"; use strict; use Carp; @@ -47,7 +47,7 @@ sub _set_regex { # but can't begin with a '\' \$ # dollar sign (\{)? # $2: optional opening curly - ([a-zA-Z0-9_\-\.:\+,]+) # $3: capturing variable name (fix of #33447) + ([a-zA-Z0-9][a-zA-Z0-9_\-\.:\+]*) # $3: capturing variable name (fix of #33447+118746) (?(2) # $4: if there's the opening curly... \} # ... match closing curly ) @@ -327,6 +327,21 @@ behavior as you know of Perl itself. In addition you can surround variable names with curly braces to avoid misinterpretation by the parser. +=head1 NAMING CONVENTIONS + +Variable names must: + +=over + +=item * start with a US-ASCII letter(a-z or A-Z) or a digit (0-9). + +=item * contain only US-ASCII letter(a-z or A-Z), digits (0-9), the dash (-) + colon (:), dot (.), underscore (_) and plus (+) characters. + +=back + +For added clarity variable names can be surrounded by curly braces. + =head1 SEE ALSO L @@ -340,16 +355,16 @@ L =head1 COPYRIGHT Copyright 2001 by Wei-Hon Chen Eplasmaball@pchome.com.twE. -Copyright 2002-2014 by Thomas Linden . +Copyright 2002-2022 by Thomas Linden . This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. +modify it under the terms of the Artistic License 2.0. See L =head1 VERSION -2.15 +2.16 =cut diff --git a/META.json b/META.json new file mode 100644 index 0000000..d79ee7a --- /dev/null +++ b/META.json @@ -0,0 +1,49 @@ +{ + "abstract" : "unknown", + "author" : [ + "unknown" + ], + "dynamic_config" : 1, + "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.130880", + "license" : [ + "artistic_2" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Config-General", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "runtime" : { + "requires" : { + "File::Glob" : "0", + "File::Spec::Functions" : "0", + "FileHandle" : "0", + "IO::File" : "0" + } + } + }, + "release_status" : "stable", + "resources" : { + "repository" : { + "url" : "https://github.com/TLINDEN/Config-General" + } + }, + "version" : "2.65" +} diff --git a/META.yml b/META.yml index be586a7..fdd1587 100644 --- a/META.yml +++ b/META.yml @@ -1,16 +1,27 @@ -name: Config-General -version: 2.58 -version_from: General.pm -installdirs: site +--- +abstract: unknown +author: + - unknown +build_requires: + ExtUtils::MakeMaker: 0 +configure_requires: + ExtUtils::MakeMaker: 0 +dynamic_config: 1 +generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.130880' +license: artistic_2 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Config-General +no_index: + directory: + - t + - inc requires: - File::Glob: 0 - File::Spec::Functions: 0 - FileHandle: 0 - IO::File: 0 + File::Glob: 0 + File::Spec::Functions: 0 + FileHandle: 0 + IO::File: 0 resources: - bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Config-General - homepage: http://search.cpan.org/dist/Config-General/ - license: http://dev.perl.org/licenses/artistic.html - repository: http://dev.catalyst.perl.org/repos/Config-General -distribution_type: module -generated_by: ExtUtils::MakeMaker version 6.30 + repository: https://github.com/TLINDEN/Config-General +version: 2.65 diff --git a/Makefile.PL b/Makefile.PL index 9d65ba1..ee6251b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,31 +1,30 @@ # # Makefile.PL - build file for Config::General # -# Copyright (c) 2000-2014 Thomas Linden . +# Copyright (c) 2000-2022 Thomas Linden . # All Rights Reserved. Std. disclaimer applies. -# Artistic License, same as perl itself. Have fun. +# Licensed under the Artistic License 2.0. # use ExtUtils::MakeMaker; WriteMakefile( - 'NAME' => 'Config::General', - 'VERSION_FROM' => 'General.pm', - 'clean' => { - FILES => 't/*.out t/test.cfg *~ */*~' - }, - 'PREREQ_PM' => { - 'IO::File' => 0, - 'FileHandle' => 0, - 'File::Spec::Functions' => 0, - 'File::Glob' => 0 - }, - 'META_MERGE' => { - resources => { - repository => 'http://dev.catalyst.perl.org/repos/Config-General/trunk/', - }, - }, - ($ExtUtils::MakeMaker::VERSION ge '6.31'? - ('LICENSE' => 'perl', ) : ()), -); - + 'NAME' => 'Config::General', + 'VERSION_FROM' => 'General.pm', + 'clean' => { + FILES => 't/*.out t/test.cfg *~ */*~' + }, + 'PREREQ_PM' => { + 'IO::File' => 0, + 'FileHandle' => 0, + 'File::Spec::Functions' => 0, + 'File::Glob' => 0 + }, + 'META_MERGE' => { + resources => { + repository => 'https://github.com/TLINDEN/Config-General' + }, + }, + ($ExtUtils::MakeMaker::VERSION ge '6.31'? + ('LICENSE' => 'artistic_2', ) : ()), + ); diff --git a/README b/README index f4e88ec..0931c9c 100644 --- a/README +++ b/README @@ -80,14 +80,14 @@ UPDATE COPYRIGHT Config::General Config::General::Extended - Copyright (c) 2000-2015 by Thomas Linden + Copyright (c) 2000-2022 by Thomas Linden Config::General::Interpolated Copyright (c) 2001 by Wei-Hon Chen - Copyright (c) 2002-2014 by Thomas Linden . + Copyright (c) 2002-2022 by Thomas Linden . This library is free software; you can redistribute it - and/or modify it under the same terms as Perl itself. + and/or modify it under the terms of the Artistic 2.0 license. HOMEPAGE @@ -104,4 +104,4 @@ AUTHOR VERSION - 2.63 + 2.65