From a49de35c818daf86529ed4d131c44ab7fe62cfb6 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Fri, 8 Jul 2016 08:46:02 +0000 Subject: [PATCH] fix rt.cpan.org#115326, added IFDefine support, fix POD indentation git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@111 be1acefe-a474-0410-9a34-9b3221f2030f --- Changelog | 1227 ++++++++++++++++++++++++++-------------------------- General.pm | 616 ++++++++++++++------------ MANIFEST | 1 + README | 2 +- TODO | 5 - t/cfg.58 | 3 + t/run.t | 19 +- 7 files changed, 990 insertions(+), 883 deletions(-) create mode 100644 t/cfg.58 diff --git a/Changelog b/Changelog index 1c47908..4e817a4 100644 --- a/Changelog +++ b/Changelog @@ -1,56 +1,72 @@ +2.62 - fix rt.cpan.org#115326: Callback on 'pre_open' not called + when glob expands to one include file + + - added patch by Niels van Dijke, which adds apache IFDefine + support. Use -UseApacheIfDefine=>1 to enable, add defines + with -Define and add to your config, see + pod for details. + + - added test case for the code. + + - fixed unindented half of the pod, which was largely no + readable because of this. However, I wonder why this hasn't + reported, seems nobody reads the docs :) + + - fixed tab/space issues here and there + 2.61 - fix rt.cpan.org#113671: ignore utf BOM, if any and turn on - UTF8 support if not yet enabled. + UTF8 support if not yet enabled. 2.60 - fix rt.cpan.org#107929: added missing test config. 2.59 - fix rt.cpan.org#107108 by adding support for IncludeOptional. - - clarified documentation on StoreDelimiter. + - clarified documentation on StoreDelimiter. 2.58 - bumbp version -2.57 - fix rt.cpan.org#104548, dont allow special chars like newline - or < in keys, which leads to faile when saving. +2.57 - fix rt.cpan.org#104548, dont allow special chars like newline + or < in keys, which leads to faile when saving. -2.56 - fix rt.cpan.org#95325 +2.56 - fix rt.cpan.org#95325 -2.55 - fix rt.cpan.org#95314 +2.55 - fix rt.cpan.org#95314 -2.54 - fixed rt.cpan.org#39814. changed the order of pre-processing - in _read(): 1) remove comments, 2) check for continuation, - 3) remove empty lines. +2.54 - fixed rt.cpan.org#39814. changed the order of pre-processing + in _read(): 1) remove comments, 2) check for continuation, + 3) remove empty lines. 2.53 - applied patch rt.cpan.org#68153, which adds a find() method to - Config::General::Extended. + Config::General::Extended. - - fixed rt.cpan.org#79869 (in fact it has been fixed in 2.52 - but I forgot to mention it here). + - fixed rt.cpan.org#79869 (in fact it has been fixed in 2.52 + but I forgot to mention it here). - - applied spelling fixes rt.cpan.org 87072+87080. + - applied spelling fixes rt.cpan.org 87072+87080. - - fixed rt.cpan.org#89379 + - fixed rt.cpan.org#89379 2.52 - applied pod patch rt.cpan.org#79603 - fixed rt.cpan.org#80006, it tolerates now whitespaces - after the block closing > + after the block closing > - - added -Plug parameter, which introduces plugin closures. - idea from rt.cpan.org#79694. - Currently available hooks are: - pre_open, pre_read, post_read, pre_parse_value, post_parse_value + - added -Plug parameter, which introduces plugin closures. + idea from rt.cpan.org#79694. + Currently available hooks are: + pre_open, pre_read, post_read, pre_parse_value, post_parse_value - - applied patch by Ville Skyttä, spelling fixes. + - applied patch by Ville Skyttä, spelling fixes. - - fixed rt.cpan.org#85080, more spelling fixes. + - fixed rt.cpan.org#85080, more spelling fixes. - - applied patch rt.cpan.org#85132, which fixes a deprecation - warning in perl 5.18 and above. Fixes #85668 as well. + - applied patch rt.cpan.org#85132, which fixes a deprecation + warning in perl 5.18 and above. Fixes #85668 as well. - - applied patch rt.cpan.org#85538, c-style comments - are ignored inside here-docs. + - applied patch rt.cpan.org#85538, c-style comments + are ignored inside here-docs. - - fixed rt.cpan.org#82637, don't use indirect object syntax - in pod and code. + - fixed rt.cpan.org#82637, don't use indirect object syntax + in pod and code. 2.51 - fixed rt.cpan.org#77667 which resulted in invalid configs written to file when using save_file() and a named block, @@ -68,641 +84,641 @@ 2.50 - - fixed rt.cpan.org#63487 documentation error. + - fixed rt.cpan.org#63487 documentation error. - - fixed rt.cpan.org#61302, now croak if the config file - parameter is a directory and directory include is not - turned on. + - fixed rt.cpan.org#61302, now croak if the config file + parameter is a directory and directory include is not + turned on. - - fixed rt.cpan.org#60429 META.yml typo + - fixed rt.cpan.org#60429 META.yml typo - - added new option -AllowSingleQuoteInterpolation, which - turns on interpolation for variables inside single quotes. + - added new option -AllowSingleQuoteInterpolation, which + turns on interpolation for variables inside single quotes. - - added test case for the new option + - added test case for the new option 2.49 - - fixed rt.cpan.org#56532, '#' missed during fix for - 56370 in 2.45. + - fixed rt.cpan.org#56532, '#' missed during fix for + 56370 in 2.45. - - added test case for this too + - added test case for this too 2.48 - - arg, uploaded the wrong file to pause, so another version - bump up. + - arg, uploaded the wrong file to pause, so another version + bump up. - - fixed typos in pod section for -ForceArray. + - fixed typos in pod section for -ForceArray. 2.47 - - fixed rt.cpan.org#53759 by adding new option -ForceArray. - when enabled a single config value enclosed in [] will become - an array forcefully. + - fixed rt.cpan.org#53759 by adding new option -ForceArray. + when enabled a single config value enclosed in [] will become + an array forcefully. - - fixed typo in license: it is "artistic", not "artificial". + - fixed typo in license: it is "artistic", not "artificial". 2.46 - - fixed rt.cpan.org#56370: there was a sort() call in _store() - left, which lead to sorted arrays even if -SaveSorted were - turned off. + - fixed rt.cpan.org#56370: there was a sort() call in _store() + left, which lead to sorted arrays even if -SaveSorted were + turned off. 2.45 - - fixed rt.cpan.org#50647 escaping bug. Now escaped $ or - backslash characters are handled correctly (across save too) + - fixed rt.cpan.org#50647 escaping bug. Now escaped $ or + backslash characters are handled correctly (across save too) - - fixed rt.cpan.org#52047, tied hash will remain tied - when savong to a file. + - fixed rt.cpan.org#52047, tied hash will remain tied + when savong to a file. - - fixed rt.cpan.org#54580, preserve single quotes during - variable interpolation corrected. No more using rand() - to mark single quotes but an incrementor instead. + - fixed rt.cpan.org#54580, preserve single quotes during + variable interpolation corrected. No more using rand() + to mark single quotes but an incrementor instead. - - fixed rt.cpan.org#42721+54583, empty config values will no - more handed over to interpreting methods (as interpolate - or autotrue and the like) but returned as undef untouched. + - fixed rt.cpan.org#42721+54583, empty config values will no + more handed over to interpreting methods (as interpolate + or autotrue and the like) but returned as undef untouched. 2.44 - - fixed rt.cpan.org#49023 by rolling back change in 2.43 - in line 158, regarding GLOB support. - + - fixed rt.cpan.org#49023 by rolling back change in 2.43 + in line 158, regarding GLOB support. + 2.43 - - fixed rt.cpan.org#40925, $indichar replaced by internal - configuration variable EOFseparator, which contains - a 256 bit SHA checksum of the date I fixed the bug. - This will prevent future conflicts hopefully. In addition - it makes it possible to make it customizable, if necessary, - in a future release. + - fixed rt.cpan.org#40925, $indichar replaced by internal + configuration variable EOFseparator, which contains + a 256 bit SHA checksum of the date I fixed the bug. + This will prevent future conflicts hopefully. In addition + it makes it possible to make it customizable, if necessary, + in a future release. - - fixed rt.cpan.org#42721, return undef for empty values + - fixed rt.cpan.org#42721, return undef for empty values - - fixed rt.cpan.org#42331, return undef for empty objects + - fixed rt.cpan.org#42331, return undef for empty objects - - fixed rt.cpan.org#44600, comments after blockname - causes parser failure. + - fixed rt.cpan.org#44600, comments after blockname + causes parser failure. - - fixed rt.cpan.org#42287, whitespace at beginning or end - of a quoted value gets lost after save(). + - fixed rt.cpan.org#42287, whitespace at beginning or end + of a quoted value gets lost after save(). - - fixed rt.cpan.org#46184, variables that were not previously - defined are deleted when -InterPolateEnv is enabled. + - fixed rt.cpan.org#46184, variables that were not previously + defined are deleted when -InterPolateEnv is enabled. - - fixed bug in config loader for FileHandle objects, it - supports now any compatible object. Hint by Ingo Schmiegel. + - fixed bug in config loader for FileHandle objects, it + supports now any compatible object. Hint by Ingo Schmiegel. - - applied spelling- and speedup patches by Ville Skyttä. + - applied spelling- and speedup patches by Ville Skyttä. - - applied documentation patch by Jordan Macdonald. + - applied documentation patch by Jordan Macdonald. 2.42 - - dist tarball for 2.41 missed t/Tie/LxHash.pm. Dammit. + - dist tarball for 2.41 missed t/Tie/LxHash.pm. Dammit. the File to the MANIFEST. 2.41 - - fixed rt.cpan.org#38635. apache-like include now supports - quoted strings. + - fixed rt.cpan.org#38635. apache-like include now supports + quoted strings. - fixed rt.cpan.org#41748. saving config with -tie enabled - now keeps the tie as documented. + now keeps the tie as documented. - - added unit test for -tie. For this to work, a copy of - Tie::LxHash module is delivered with Config::General - source, but will not installed, in fact, it is only - used for 'make test' (number 50) + - added unit test for -tie. For this to work, a copy of + Tie::LxHash module is delivered with Config::General + source, but will not installed, in fact, it is only + used for 'make test' (number 50) - - fixed rt.cpan.org#39159. documentation of functional interface + - fixed rt.cpan.org#39159. documentation of functional interface now reflects that qw$method) is now required. - - applied patch by AlexK fixing rt.cpan.org#41030: - if files are included by means of a glob pattern having the -IncludeGlob - option activated, paths specified by the -ConfigPath option are being - neglected when trying to spot the files. This patch fixes this + - applied patch by AlexK fixing rt.cpan.org#41030: + if files are included by means of a glob pattern having the -IncludeGlob + option activated, paths specified by the -ConfigPath option are being + neglected when trying to spot the files. This patch fixes this - - applied patch by fbicknel, fixes rt.cpan.org#41570: - An array of scalars (eg: option = [1,2,3]) cannot - be used for interpolation (which element shall we use?!), so - we ignore those types of lists and don't build a __stack for them. + - applied patch by fbicknel, fixes rt.cpan.org#41570: + An array of scalars (eg: option = [1,2,3]) cannot + be used for interpolation (which element shall we use?!), so + we ignore those types of lists and don't build a __stack for them. 2.40 - - fixed SplitDelimiter parser regex, it does no more consider - non-whitespaces (\S+?) as the option name but anything - before the delimiter (.+?), this fixes bug rt.cpan.org#36607, - the fix of 2.39 were not sufficient. Thanks to - Jeffrey Ratcliffe for pointing it out. + - fixed SplitDelimiter parser regex, it does no more consider + non-whitespaces (\S+?) as the option name but anything + before the delimiter (.+?), this fixes bug rt.cpan.org#36607, + the fix of 2.39 were not sufficient. Thanks to + Jeffrey Ratcliffe for pointing it out. - - added new parameter -SaveSorted. The default value is 0, - that means configs will be saved unsorted (as always), - however if you want to save it sorted, turn this parameter - to 1. Thanks to Herbert Breunung for the hint. + - added new parameter -SaveSorted. The default value is 0, + that means configs will be saved unsorted (as always), + however if you want to save it sorted, turn this parameter + to 1. Thanks to Herbert Breunung for the hint. - - added complexity test, which checks a combination - of various complex features of the parser. + - added complexity test, which checks a combination + of various complex features of the parser. 2.39 - - fixed rt.cpan.org#35122. This one was one of the most - intriguing bugs I've ever observed in my own code. The - internal temporary __stack hashref were copied from one - subhash to another to enable inheritance of variables. - However, the hashes were copied by reference, so once a - value changed later, that value were overwritten because - the __stack in question were just a reference. I introduced - a simple function _copy() which copies the contents of - the __stack by value, which solved the bug. - Conclusion: beware of perl hash refs! + - fixed rt.cpan.org#35122. This one was one of the most + intriguing bugs I've ever observed in my own code. The + internal temporary __stack hashref were copied from one + subhash to another to enable inheritance of variables. + However, the hashes were copied by reference, so once a + value changed later, that value were overwritten because + the __stack in question were just a reference. I introduced + a simple function _copy() which copies the contents of + the __stack by value, which solved the bug. + Conclusion: beware of perl hash refs! - - fixed rt.cpan.org#36607, accept whitespaces in heredoc - names if split delimiter is gues (equalsign or whitespace) + - fixed rt.cpan.org#36607, accept whitespaces in heredoc + names if split delimiter is gues (equalsign or whitespace) - - fixed rt.cpan.org#34080 (typo) + - fixed rt.cpan.org#34080 (typo) - - fixed rt.cpan.org#35766. Variables inside single quoted - strings will no more interpolated (as the docu states). - Also added test case for this. + - fixed rt.cpan.org#35766. Variables inside single quoted + strings will no more interpolated (as the docu states). + Also added test case for this. - - fixed bug rt.cpan.org#33766. Checking for defined not true - in ::Extended::AUTOLOAD(). + - fixed bug rt.cpan.org#33766. Checking for defined not true + in ::Extended::AUTOLOAD(). - - added -UTF8 flag, which opens files in utf8 mode - (suggested by KAORU, rt.cpan.org#35583) - I decided not to add a test case for this, since perls - utf8 support is not stable with all versions. + - added -UTF8 flag, which opens files in utf8 mode + (suggested by KAORU, rt.cpan.org#35583) + I decided not to add a test case for this, since perls + utf8 support is not stable with all versions. 2.38 - - fixed rt.cpan.org#31529 variable inheritance failed - with multiple named blocks. + - fixed rt.cpan.org#31529 variable inheritance failed + with multiple named blocks. - - fixed rt.cpan.org#33447, regex to catch variable - names were too strict, now - . + or : are allowed too. + - fixed rt.cpan.org#33447, regex to catch variable + names were too strict, now - . + or : are allowed too. - - fixed rt.cpan.org#33385 and #32978 - using arrayrefs - as param to -String didn't work anymore (sic) + - fixed rt.cpan.org#33385 and #32978 - using arrayrefs + as param to -String didn't work anymore (sic) - - fixed rt.cpan.org#33216 - variable stack were not properly - re-constructed for pre-existing variables if - -MergeDuplicateOptions is turned on. - + - fixed rt.cpan.org#33216 - variable stack were not properly + re-constructed for pre-existing variables if + -MergeDuplicateOptions is turned on. + 2.37 - - "fixed" rt.cpan.org#30199 - check for invalid and - unsupported structures, especially mixing blocks - and scalars with identical names. + - "fixed" rt.cpan.org#30199 - check for invalid and + unsupported structures, especially mixing blocks + and scalars with identical names. - - added checks to 'make test' to test for the above - checks. + - added checks to 'make test' to test for the above + checks. - - revoked patch of rt.cpan.org#27225, it broke running - code. + - revoked patch of rt.cpan.org#27225, it broke running + code. - - fixed rt.cpan.org#30063 (and #27225!) by reimplementing - the whole interpolation code. The internal stack is - no more a class variable of the module but stored - directly within the generated config hash and cleaned - before returning to the user. + - fixed rt.cpan.org#30063 (and #27225!) by reimplementing + the whole interpolation code. The internal stack is + no more a class variable of the module but stored + directly within the generated config hash and cleaned + before returning to the user. - - added (modified) patch rt.cpan.org#30063 to check - if interpolation works with supplied default config - works. + - added (modified) patch rt.cpan.org#30063 to check + if interpolation works with supplied default config + works. 2.36 - - oh my goodness! For some unknown reason I deleted the - Makefile.PL before packaging. Dammit. So, here it is - again. + - oh my goodness! For some unknown reason I deleted the + Makefile.PL before packaging. Dammit. So, here it is + again. 2.35 - - 'make test' failed under perl 5.5 because some prequisite - modules were not found. So now I added all requirements - to Makefile.PL, even if those modules are part of - recent perls (beginning with 5.6). I could have also - added a 'use 5.6' to the code but this would users - of perl5 exclude. This way they have the possibility - to fix their installation. Hopefully. + - 'make test' failed under perl 5.5 because some prequisite + modules were not found. So now I added all requirements + to Makefile.PL, even if those modules are part of + recent perls (beginning with 5.6). I could have also + added a 'use 5.6' to the code but this would users + of perl5 exclude. This way they have the possibility + to fix their installation. Hopefully. - No code changes otherwise. + No code changes otherwise. 2.34 - fixed rt.cpan.org#27271 - removed output file from manifest. - - fixed rt.cpan.org#27225 - clear vars off the stack + - fixed rt.cpan.org#27225 - clear vars off the stack if entering a new block, so old vars get not re-used. - - fixed rt.cpan.org#27110 - re-implemented support + - fixed rt.cpan.org#27110 - re-implemented support for arrayref as -String parameter. - - fixed rt.cpan.org#24155 - relative include bug fixed. + - fixed rt.cpan.org#24155 - relative include bug fixed. - - applied patch by GWYN, (see fixed rt.cpan.org#27622) - which allows the same file included multiple times. - there is no loop detection if turned on. new option - introduced: -IncludeAgain => 1 (default turned off). + - applied patch by GWYN, (see fixed rt.cpan.org#27622) + which allows the same file included multiple times. + there is no loop detection if turned on. new option + introduced: -IncludeAgain => 1 (default turned off). - - added support for -IncludeAgain to directory include - code too. + - added support for -IncludeAgain to directory include + code too. - - the directory globbing code used slashes to join - directory and file names. changed this to use catfile() - instead. + - the directory globbing code used slashes to join + directory and file names. changed this to use catfile() + instead. 2.33 - - fixed rt.cpan.org#26333 - just return $con if env var - is undefined. + - fixed rt.cpan.org#26333 - just return $con if env var + is undefined. - - applied part of a patch supplied by Vincent Rivellino - which turns off explicit empty block support if in - apache compatibility mode, see next. + - applied part of a patch supplied by Vincent Rivellino + which turns off explicit empty block support if in + apache compatibility mode, see next. - - added new option -ApacheCompatible, which makes the - module behave really apache compatible by setting the - required options. + - added new option -ApacheCompatible, which makes the + module behave really apache compatible by setting the + required options. - - a little bit re-organized the code, most of the stuff - in new() is now outsourced into several extra subs to - make maintenance of the code easier. The old new() sub - in fact was a nightmare. + - a little bit re-organized the code, most of the stuff + in new() is now outsourced into several extra subs to + make maintenance of the code easier. The old new() sub + in fact was a nightmare. - - fixed a bug reported by Otto Hirr : - the _store() sub used sort() to sort the keys, which conflicts - with sorted hashes (eg. tied using Tie::IxHash). + - fixed a bug reported by Otto Hirr : + the _store() sub used sort() to sort the keys, which conflicts + with sorted hashes (eg. tied using Tie::IxHash). - - fixed tie bug reported by King, Jason , - loading of the tie module didn't work. + - fixed tie bug reported by King, Jason , + loading of the tie module didn't work. 2.32 - - fixed rt.cpan.org#24232 - import ENV vars only if defined + - fixed rt.cpan.org#24232 - import ENV vars only if defined - - fixed rt.cpan.org#20742 - dont' overwrite a var if re-defined - in current scope, interpolation failed for re-defined vars and used - the value of the var defined in outer scope, not the current one. + - fixed rt.cpan.org#20742 - dont' overwrite a var if re-defined + in current scope, interpolation failed for re-defined vars and used + the value of the var defined in outer scope, not the current one. - - fixed rt.cpan.org#17852 - a 0 as blockname were ignored. applied - patch by SCOP to t/run.t to test for 0 in blocks. + - fixed rt.cpan.org#17852 - a 0 as blockname were ignored. applied + patch by SCOP to t/run.t to test for 0 in blocks. - - applied most hints Perl::Critic had about Config::General: - o the functions ParseConfig SaveConfig SaveConfigString must - now imported implicitly. This might break existing code, but - is easily to fix. - o using IO::File instead of open(). - o General.pm qualifies for "stern" level after all. + - applied most hints Perl::Critic had about Config::General: + o the functions ParseConfig SaveConfig SaveConfigString must + now imported implicitly. This might break existing code, but + is easily to fix. + o using IO::File instead of open(). + o General.pm qualifies for "stern" level after all. - - added much more tests to t/run.t for 'make test'. + - added much more tests to t/run.t for 'make test'. - - using Test::More now. + - using Test::More now. 2.31 - - applied patches by Jason Rhinelander : - o bugfix: multiple levels if include files didn't - work properly. + - applied patches by Jason Rhinelander : + o bugfix: multiple levels if include files didn't + work properly. - o new option -IncludeDirectories, which allows - to include all files of a directory. The directory - must be specified by -ConfigFile as usual. + o new option -IncludeDirectories, which allows + to include all files of a directory. The directory + must be specified by -ConfigFile as usual. - o new option -IncludeGlob, which allows to - use globs (wildcards) to include multiple files. + o new option -IncludeGlob, which allows to + use globs (wildcards) to include multiple files. - o -ConfigPath can be speciefied using a single - scalar value instead of an array if there is only - one path. + o -ConfigPath can be speciefied using a single + scalar value instead of an array if there is only + one path. - o bugfix: quotes from quoted block names were - not removed properly. + o bugfix: quotes from quoted block names were + not removed properly. - o fixes and updates for tests (make test) for - the above patches. - - Thanks a lot Jason. + o fixes and updates for tests (make test) for + the above patches. + + Thanks a lot Jason. - - fixed number of tests in run.t + - fixed number of tests in run.t - - applied suggestion by Eric Kisiel : - ::Extended::keys() returns an empty hash if the - referring object is not hash. + - applied suggestion by Eric Kisiel : + ::Extended::keys() returns an empty hash if the + referring object is not hash. - - fixed bug #14770, "Use of uninitialized value.." during - environment variable interpolation. + - fixed bug #14770, "Use of uninitialized value.." during + environment variable interpolation. 2.30 - - applied patch by Branislav Zahradnik - which adds -InterPolateEnv. - This allows to use environment variables too. It - implies -InterPolateVars. + - applied patch by Branislav Zahradnik + which adds -InterPolateEnv. + This allows to use environment variables too. It + implies -InterPolateVars. - - added object list capability for the ::Extended::obj() - method. If a certain key points to an array of - hashrefs, then the whole arrayref is returned. - Suggested by Alan Hodgkinson . + - added object list capability for the ::Extended::obj() + method. If a certain key points to an array of + hashrefs, then the whole arrayref is returned. + Suggested by Alan Hodgkinson . 2.29 - - applied patch by brian@kronos.com via rt.cpan.org - #11211. - - - applied patch by plasmaball@pchome.com.tw via - rt.cpan.org #5846 + - applied patch by brian@kronos.com via rt.cpan.org + #11211. + + - applied patch by plasmaball@pchome.com.tw via + rt.cpan.org #5846 - - added new files to MANIFEST file. + - added new files to MANIFEST file. - - added example.cfg to show the config format. + - added example.cfg to show the config format. 2.28 - - fixed bug in save(), now blocks containing whitespaces - will be saved using quotes, in addition the parser observes - the quoting feature, added portion about this to the pod - doc. pointed out by Jeff Murphy . + - fixed bug in save(), now blocks containing whitespaces + will be saved using quotes, in addition the parser observes + the quoting feature, added portion about this to the pod + doc. pointed out by Jeff Murphy . - - added internal list of files opened so far to avoid - reading in the same file multiple times. - Suggested by Michael Graham. + - added internal list of files opened so far to avoid + reading in the same file multiple times. + Suggested by Michael Graham. - - added new method files() which returns the above list. + - added new method files() which returns the above list. - - added workaround for foolish perl installation on - debian systems (croak() doesn't work anymore as of - 5.8.4, it's a shame!) + - added workaround for foolish perl installation on + debian systems (croak() doesn't work anymore as of + 5.8.4, it's a shame!) - - applied patch by Michael Graham which fixes IncludeRelative - feature, now an included file is being included relative - to the calling config file, not the first one. + - applied patch by Michael Graham which fixes IncludeRelative + feature, now an included file is being included relative + to the calling config file, not the first one. - - added 'make test' targets for files() and include - stuff. (by Michael too) + - added 'make test' targets for files() and include + stuff. (by Michael too) 2.27 - bugfix in _store, which caused warning when saving - a config containing empty hashes. Reported by - herbert breunung . + a config containing empty hashes. Reported by + herbert breunung . - - removed applied patch (added in 2.20), there are no more - calls to binmode(), this destroys portability, because - perls determines itself wether it uses \n or \r\n as newline. - Reported by herbert breunung too. - - - applied patch by Danial Pearce , - scalars containing a backslash as the last character will - be written out as here-doc when storing a config to disk. + - removed applied patch (added in 2.20), there are no more + calls to binmode(), this destroys portability, because + perls determines itself wether it uses \n or \r\n as newline. + Reported by herbert breunung too. + + - applied patch by Danial Pearce , + scalars containing a backslash as the last character will + be written out as here-doc when storing a config to disk. 2.26 - - fixed invalid regexp in _open() which circumvented - explicit empty block to work when the block statement - included whitespaces. - - - more finetuning in Makefile.PL for cleaning emacs' - ~ files. + - fixed invalid regexp in _open() which circumvented + explicit empty block to work when the block statement + included whitespaces. + + - more finetuning in Makefile.PL for cleaning emacs' + ~ files. 2.25 - - fixed bug with not working -IncludeRelative setting when - including a config file. It were only included from the - location relative to the underlying config if it were - non-existent. reported by Dmitry Koteroff . + - fixed bug with not working -IncludeRelative setting when + including a config file. It were only included from the + location relative to the underlying config if it were + non-existent. reported by Dmitry Koteroff . - - applied patch by Danial Pearce - which adds the -BackslashEscape parameter to enable - general escaping of special characters using the - backslash. + - applied patch by Danial Pearce + which adds the -BackslashEscape parameter to enable + general escaping of special characters using the + backslash. - - fixed bug reported by Harold van Oostrom : - according to the documentation one can call new() with - a hash-ref as its single parameter which would then - used as the config. This didn't work and were fixed. + - fixed bug reported by Harold van Oostrom : + according to the documentation one can call new() with + a hash-ref as its single parameter which would then + used as the config. This didn't work and were fixed. - - added feature suggested by Eric Andreychek : - now block statements like this are allowed: "" - which is called an explicit empty block. This generates just - an empty hash-ref and saves writing. In fact, internally it - will be converted to: - - + - added feature suggested by Eric Andreychek : + now block statements like this are allowed: "" + which is called an explicit empty block. This generates just + an empty hash-ref and saves writing. In fact, internally it + will be converted to: + + - - fixed Makefile.PL: it cleans now files generated by 'make test' - properly. reported by: Dagfinn Ilmari Mannsåker + - fixed Makefile.PL: it cleans now files generated by 'make test' + properly. reported by: Dagfinn Ilmari Mannsåker - - updated MANIFEST (in fact I did this some years ago the last time!) - also reported by: Dagfinn Ilmari Mannsåker + - updated MANIFEST (in fact I did this some years ago the last time!) + also reported by: Dagfinn Ilmari Mannsåker 2.24 - - fixed Bug #3869 (rt.cpan.org) reported by - "Mike Depot" + - fixed Bug #3869 (rt.cpan.org) reported by + "Mike Depot" - - applied patch by Roland Huss , - which fixes a bug with the -Tie option, sub-hashes of - named blocks were not properly created (in fact, not - tied). + - applied patch by Roland Huss , + which fixes a bug with the -Tie option, sub-hashes of + named blocks were not properly created (in fact, not + tied). - - added documentation to Interpolated.pm that it does not - interpolate variables in keys, see bug #3773 (rt.cpan.org). - + - added documentation to Interpolated.pm that it does not + interpolate variables in keys, see bug #3773 (rt.cpan.org). + 2.23 - still versioning problem, stupid white man ;-) - Extended.pm is now 2.00 which *is* higher than 1.10. + Extended.pm is now 2.00 which *is* higher than 1.10. 2.22 - incremented all version numbers because of cpan problem. - no further changes. See Bug #3347 (rt.cpan.org). + no further changes. See Bug #3347 (rt.cpan.org). 2.21 - - fixed bug in new() used $this instead of $self for empty - hashref creation if no config file given. + - fixed bug in new() used $this instead of $self for empty + hashref creation if no config file given. 2.20 - - fixed bug reported by Stefano di Sandro : in - OOP mode (extended access) the obj() method returned the whole - config object if the given key does not exist. Now it returns - a new empty object. + - fixed bug reported by Stefano di Sandro : in + OOP mode (extended access) the obj() method returned the whole + config object if the given key does not exist. Now it returns + a new empty object. - - added patch by David Dick which - sets $/ if it is unset. + - added patch by David Dick which + sets $/ if it is unset. - - added patch by David Dick which - calls the binmode() function in case the modules is being - used under win32 systems. Read perldoc -f binmode for more - informations on this issue. + - added patch by David Dick which + calls the binmode() function in case the modules is being + used under win32 systems. Read perldoc -f binmode for more + informations on this issue. - - added feature suggested by Chase Phillips : - the new() method has a new parameter -Tie which takes the - name of a Tie class that each new hash should be based off - of. This makes it possible to create a config hash with - ordered contents across nested structures. + - added feature suggested by Chase Phillips : + the new() method has a new parameter -Tie which takes the + name of a Tie class that each new hash should be based off + of. This makes it possible to create a config hash with + ordered contents across nested structures. 2.19 - - forgot to import 'catfile' from File::Spec. Bug reported by - various people. + - forgot to import 'catfile' from File::Spec. Bug reported by + various people. - - applied patch by Peter Tandler - which adds a search-path feature for include files. + - applied patch by Peter Tandler + which adds a search-path feature for include files. - - applied patch by David Dick which - adds an auto launder capability to the module which makes it - possible to use variables read by Config::General in a - tainted perlscript (executed with -T) for open(), backtick calls - or something which the taintmode considers to be dangerous. + - applied patch by David Dick which + adds an auto launder capability to the module which makes it + possible to use variables read by Config::General in a + tainted perlscript (executed with -T) for open(), backtick calls + or something which the taintmode considers to be dangerous. 2.18 - - fixed Bug #2325 (rt.cpan.org). The subs exported by File::Spec - will now imported explicitly. - - fixed warning about double my'ed variable $dummi, changed it - to undef because it was unused anyway. + - fixed Bug #2325 (rt.cpan.org). The subs exported by File::Spec + will now imported explicitly. + - fixed warning about double my'ed variable $dummi, changed it + to undef because it was unused anyway. 2.17 - - added File::Spec support which makes the modules more portable - (i.e. on win32 systems), - as suggested by Peter Tandler . + - added File::Spec support which makes the modules more portable + (i.e. on win32 systems), + as suggested by Peter Tandler . 2.16 - - applied patch by Michael Gray which - fixes a bug in the Interpolate.pm submodule. A second variable, - when immediately following the first, did not get interpolated, - i.e. ${var1}${var2}. + - applied patch by Michael Gray which + fixes a bug in the Interpolate.pm submodule. A second variable, + when immediately following the first, did not get interpolated, + i.e. ${var1}${var2}. 2.15 - fixed Bug in SaveConfig***, which didn't work. - applied patch by Robb Canfield , - which fixes a bug in the variable interpolation - scheme. It did not interpolate blocks nor - blocknames. This patch fixes this. Patch slightly - modified by me(interpolation on block and blocknames). - - enhanced test for variable interpolation to - reflect this. - - added check if a named block occurs after the underlying - block is already an array, which is not possible. - perl cannot add a hashref to an array. i.e.: - - a = 1 - - - b = 1 - - - c = 1 - - As you can see, "" will be an array, and "blubber" - cannot be stored in any way on this array. - The module croaks now if such construct occurs. + which fixes a bug in the variable interpolation + scheme. It did not interpolate blocks nor + blocknames. This patch fixes this. Patch slightly + modified by me(interpolation on block and blocknames). + - enhanced test for variable interpolation to + reflect this. + - added check if a named block occurs after the underlying + block is already an array, which is not possible. + perl cannot add a hashref to an array. i.e.: + + a = 1 + + + b = 1 + + + c = 1 + + As you can see, "" will be an array, and "blubber" + cannot be stored in any way on this array. + The module croaks now if such construct occurs. 2.14 - fixed bug reported by Francisco Olarte Sanz - , which caused _parse to - ignore blocks with the name "0": - <0> .. , because it checked just if $block (the name - between < and >) is true, and from the perl point - of view "0" is not. Changed it to check for defined. - Normally I avoid using 'defined' but in this case - it will not be possible that $block contains the - empty string, so defined is ok here. + , which caused _parse to + ignore blocks with the name "0": + <0> .. , because it checked just if $block (the name + between < and >) is true, and from the perl point + of view "0" is not. Changed it to check for defined. + Normally I avoid using 'defined' but in this case + it will not be possible that $block contains the + empty string, so defined is ok here. 2.13 - fixed bug reported by Steffen Schwigon . - the parser was still active inside a here-doc, which - cause weird results if the here-doc contained - multiple < reported this - mis-behavior. The problem was that the whole hash - was feeded to ::Interpolated.pm, but as we all - know, perl hashes doesn't preserve the order. So, - in our case the module sometimes was unable to - resolve variablenames, because they were stored - in a different location as it occurred in the config. - The change is, that Config::General now calls - ::Interpolate.pm (new sub: _interpolate()) itself - directly on a per-key/value pair basis. The internal - varstack is now stored on $this globally. So, now - a variable will be known when it occurs. period :-) + 2.11 - heavy change in the variable interpolation code. + Peter Sergeant reported this + mis-behavior. The problem was that the whole hash + was feeded to ::Interpolated.pm, but as we all + know, perl hashes doesn't preserve the order. So, + in our case the module sometimes was unable to + resolve variablenames, because they were stored + in a different location as it occurred in the config. + The change is, that Config::General now calls + ::Interpolate.pm (new sub: _interpolate()) itself + directly on a per-key/value pair basis. The internal + varstack is now stored on $this globally. So, now + a variable will be known when it occurs. period :-) 2.10 - added -StrictVars documentation section to the POD, - which was missing. + which was missing. - fixed a formatting error in the POD documentation. 2.09 - added bugfix in '#' comment parsing. If current state - was within a block, then /^ #/ was not ignored as - comment but instead added as variable. Reported by - Lupe Christoph + was within a block, then /^ #/ was not ignored as + comment but instead added as variable. Reported by + Lupe Christoph - - added -StrictObjects parameter support in the following - ::Extended methods: hash() and value(). + - added -StrictObjects parameter support in the following + ::Extended methods: hash() and value(). - - added better parameter checks in the ::Extended::obj() - method. Its now no more possible to create a new (sub-) - object from an undefined key or a key which does not - point to a hash reference. + - added better parameter checks in the ::Extended::obj() + method. Its now no more possible to create a new (sub-) + object from an undefined key or a key which does not + point to a hash reference. - - simplified storing of ConfigFile and ConfigHash in new() - removed my variable $configfile. + - simplified storing of ConfigFile and ConfigHash in new() + removed my variable $configfile. - - the original parameter list will now be saved, which is - required for ::Extended to create new objects with the - same config as their parents. + - the original parameter list will now be saved, which is + required for ::Extended to create new objects with the + same config as their parents. 2.08 - added option -StrictVars, which causes Interpolate.pm to - ignore undefined variables and replaces such occurrences - with the emppty string. + ignore undefined variables and replaces such occurrences + with the emppty string. - - applied patch by Stefan Moser , which fixes - some weird bevavior if -MergeDuplicateOptions was turned - on, the parser croaked regardless -MergeDuplicateBlocks - was set or not. Now the two options behave almost independent - from each other, which allows one to merge duplicate - blocks but duplicate options not. + - applied patch by Stefan Moser , which fixes + some weird bevavior if -MergeDuplicateOptions was turned + on, the parser croaked regardless -MergeDuplicateBlocks + was set or not. Now the two options behave almost independent + from each other, which allows one to merge duplicate + blocks but duplicate options not. - - changed behavior of setting -MergeDuplicateOptions which - implied in previous versions -AllowMultiOptions to be - false. Now this will only be done if the user does not - set -AllowMultiOptions by himself. This allows one to - have duplicate blocks which will be turned into an - array but duplicate options to be merged. + - changed behavior of setting -MergeDuplicateOptions which + implied in previous versions -AllowMultiOptions to be + false. Now this will only be done if the user does not + set -AllowMultiOptions by himself. This allows one to + have duplicate blocks which will be turned into an + array but duplicate options to be merged. - - applied patch by Matthias Pitzl , which - fixes a bug at parsing apache-like include directive - (Include ...). It did not properly trim unnecessary whitespaces - so that the filename to be included became invalid. This - bug espessially occurred if one saved a hash containing - a key/value pair like this: "Include" => "/etc/grs.cfg", - which was then saved as "Include /etc/grs.cfg", the - parser returned " /etc/grs.cfg" which, of course, does - not exists. odd... + - applied patch by Matthias Pitzl , which + fixes a bug at parsing apache-like include directive + (Include ...). It did not properly trim unnecessary whitespaces + so that the filename to be included became invalid. This + bug espessially occurred if one saved a hash containing + a key/value pair like this: "Include" => "/etc/grs.cfg", + which was then saved as "Include /etc/grs.cfg", the + parser returned " /etc/grs.cfg" which, of course, does + not exists. odd... 2.07 - fixed cpan bugid #1351, SaveConfig contained a deprecated function call which caused the module to croak. - added feature request, if in extended mode (OOP turned - on with -ExtendedAccess => 1 access to non-existent keys + on with -ExtendedAccess => 1 access to non-existent keys caused a croak. While this is still the default behavior it is now possible to turn this off using -StrictObjects => 0. - added this to the related pod section in ::Extended. @@ -715,42 +731,42 @@ mentioned below arrived). 2.06 - added -SplitPolicy, -SplitDelimiter and -StoreDelimiter - - removed whitespace support in keys in the default parser - SplitPolicy 'guess', which was introduced in 2.02. Now - I (re-)use the old regex I used before. if you need - whitespaces in keys, use 'equalsign' as SplitPolicy. - - the write_scalar() method uses the StoreDelimiter for - separating options from values. - - added -CComments to make it possible to turn c-comment - parsing off. - - added support for FileHandle objects as parameter to the - -ConfigFile parameter. This makes it possible to use locking. + - removed whitespace support in keys in the default parser + SplitPolicy 'guess', which was introduced in 2.02. Now + I (re-)use the old regex I used before. if you need + whitespaces in keys, use 'equalsign' as SplitPolicy. + - the write_scalar() method uses the StoreDelimiter for + separating options from values. + - added -CComments to make it possible to turn c-comment + parsing off. + - added support for FileHandle objects as parameter to the + -ConfigFile parameter. This makes it possible to use locking. 2.05 - fixed bug in ::Extended. It exported for some weird reason I can't remember all of its methods. This included - keys() exists() and delete(), which are perl internals. - If one used keys() on a normal hash, then the ::Extended - own keys() were used instead of perls own one. I removed - the export line. + keys() exists() and delete(), which are perl internals. + If one used keys() on a normal hash, then the ::Extended + own keys() were used instead of perls own one. I removed + the export line. 2.04 - added RFE from rt.cpan.org (ID: 1218). the ::Interpolate - module populates now uses of uninitialized variables in - config files itself instead of just letting perl die(). - The other suggestion of the RFE was declined. + module populates now uses of uninitialized variables in + config files itself instead of just letting perl die(). + The other suggestion of the RFE was declined. 2.03 - fixed bug in the _parse() routine (better: design flaw). after the last patch for allowing whitespaces in - option names, it had a problem with here-docs which - contained equal signs. option/value splitting resulted - in weird output. + option names, it had a problem with here-docs which + contained equal signs. option/value splitting resulted + in weird output. - - as a side effect of the bug fix below it is now - possible to use equal signs inside quoted values, which - will then be ignored, thus not used for splitting - the line into an option/value assignment. + - as a side effect of the bug fix below it is now + possible to use equal signs inside quoted values, which + will then be ignored, thus not used for splitting + the line into an option/value assignment. - - added a new test, which tests for all possible notations - of option/value lines. + - added a new test, which tests for all possible notations + of option/value lines. 2.02 - added patch by Jens Heunemann, which allows to use whitespaces in option names. @@ -758,176 +774,176 @@ - changed the save() calls in the test script (t/run.t) to save_file() - - removed new() from ::Interpolated and ::Extended. - This may break existing code (they will need to - move to the flags of Config::General::new() ), but - this decision must be made. The problem was that - both the old way of directly using the subclasses - and the enw way did not work together. So, now - subclasses are only method holders and used by - Config::General on request. Direct use of subclasses - is prohibited. (you receive a warning if you do). + - removed new() from ::Interpolated and ::Extended. + This may break existing code (they will need to + move to the flags of Config::General::new() ), but + this decision must be made. The problem was that + both the old way of directly using the subclasses + and the enw way did not work together. So, now + subclasses are only method holders and used by + Config::General on request. Direct use of subclasses + is prohibited. (you receive a warning if you do). 2.01 - added -ConfigFile (in replace for -file) and -ConfigHash (in replace for -hash) to get a consistent - parameter naming scheme. The old names are still - supported for backward compatibility, but no more - documented. + parameter naming scheme. The old names are still + supported for backward compatibility, but no more + documented. - the parameter -BaseHash has been dropped because - -DefaultConfig already has the capabilities of + -DefaultConfig already has the capabilities of defining a custom backing hash. The pod section for - -DefaultConfig has been enhanced to reflect this. + -DefaultConfig has been enhanced to reflect this. - - README changed something. Removed the 'small' keyword, - because the module isn't really small anymore :-) - At least IMHO. + - README changed something. Removed the 'small' keyword, + because the module isn't really small anymore :-) + At least IMHO. 2.00 - fixed a bug in the ::Extended::keys() method, which - caused a beloved "use of uninitialized ..." message. - Reported by Danial Pearce . + caused a beloved "use of uninitialized ..." message. + Reported by Danial Pearce . - Removed all deprecated methods (in fact, they are still - there for shouting out a warn that its deprecated. But - the pod sections are removed. These are NoMultiOptions() - and save(). + there for shouting out a warn that its deprecated. But + the pod sections are removed. These are NoMultiOptions() + and save(). - - added two new parameters to new(): -InterPolateVars and - -ExtendedAccess, which allows one to use the functionalites - of the supplied submodules without the need to decide - for one of them. This makes it possible to use variable - interpolation and oop access in the same time. Suggested - by Jared Rhine . + - added two new parameters to new(): -InterPolateVars and + -ExtendedAccess, which allows one to use the functionalites + of the supplied submodules without the need to decide + for one of them. This makes it possible to use variable + interpolation and oop access in the same time. Suggested + by Jared Rhine . - - added new parameter -BaseHash which makes it possible - to supply your own hash which stores the parsed contents - of the config. This can be a tied hash o the like. - Suggested by Jared Rhine too. + - added new parameter -BaseHash which makes it possible + to supply your own hash which stores the parsed contents + of the config. This can be a tied hash o the like. + Suggested by Jared Rhine too. - - switched to release 2.00 because the above is a major - change. + - switched to release 2.00 because the above is a major + change. 1.36 - simplified new() parameter parsing, should be now a little - bit better to understand. + bit better to understand. - - added new parameter -DefaultConfig, which can hold a hashref - or a string, which will be used to pre-define values - of the resulting hash after parsing a config. - Thanks to Mark Hampton for the - suggestion. + - added new parameter -DefaultConfig, which can hold a hashref + or a string, which will be used to pre-define values + of the resulting hash after parsing a config. + Thanks to Mark Hampton for the + suggestion. - - added new parameter -MergeDuplicateOptions, which allows - one to overwrite duplicate options, which is required, - if you turn on -DefaultConfig, because otherwise a - array would be created, which is probably not what you - wanted. + - added new parameter -MergeDuplicateOptions, which allows + one to overwrite duplicate options, which is required, + if you turn on -DefaultConfig, because otherwise a + array would be created, which is probably not what you + wanted. - - added patch by Danial Pearce - to Config::General::Extended::keys(), which allows to - retrieve the keys of the object itself (which was not - directly possible before) + - added patch by Danial Pearce + to Config::General::Extended::keys(), which allows to + retrieve the keys of the object itself (which was not + directly possible before) - - added patch by Danial Pearce - to Config::General::Extended::value(), which allows to - set a value to a (perlish-) nontrue value. This was a - bug. + - added patch by Danial Pearce + to Config::General::Extended::value(), which allows to + set a value to a (perlish-) nontrue value. This was a + bug. - - added patch by Danial Pearce - to Config::General::_parse_value, which fixes a bug in - this method, which in prior versions caused values of - "0" (zero digit) to be wiped out of the config. + - added patch by Danial Pearce + to Config::General::_parse_value, which fixes a bug in + this method, which in prior versions caused values of + "0" (zero digit) to be wiped out of the config. - - added tests in t/run.t for the new default config feature. - - + - added tests in t/run.t for the new default config feature. + + 1.35 - the here-doc identifier in saved configs will now created in a way which avoids the existence of this identifier - inside the here-doc, which if it happens results in + inside the here-doc, which if it happens results in weird behavior in the resulting config. 1.34 - Danial Pearce reported a bug in _store(), which caused the module to create scalar - entries even if the entry contained newlines. While - Danial supplied a patch to fix this - thx(TM) - I - did not apply it, because I "outsourced" this kind of - stuff to the subroutine _write_scalar(), see next. + entries even if the entry contained newlines. While + Danial supplied a patch to fix this - thx(TM) - I + did not apply it, because I "outsourced" this kind of + stuff to the subroutine _write_scalar(), see next. - added internal methods _write_scalar() and _write_hash() - to simplify _store(), which did the same thing more - than once, which is a good time to create a sub which - does the job. + to simplify _store(), which did the same thing more + than once, which is a good time to create a sub which + does the job. - fixed cut'n paste bug in General/Extended.pm reported by - Danial Pearce , which caused - Config::General::Extended::is_scalar() to return true even - when the key you pass in is an array. + Danial Pearce , which caused + Config::General::Extended::is_scalar() to return true even + when the key you pass in is an array. - added new method Config::General::Extended::delete() suggested - by Danial Pearce , which deletes - the given key from the config. + by Danial Pearce , which deletes + the given key from the config. 1.33 - fixed bug in _parse_value() which caused perl to complain - with "Use of uninitialized value in..." if a value was - empty. + with "Use of uninitialized value in..." if a value was + empty. 1.32 - *argl* ... I forgot Interpolated.pm, don't know how that could happen, in 1.29 it was "lost". However - - I added it again now. - - added patch by Peder Stray to - the _store() method, which makes it possible to catch - arrays of hashes to be stored correctly. - - cleaned up the t/run.t testscript to reflect the - changes (in fact I did not touch it since 1.18 or so). - - added test number 16 to test variable interpolation - using ::Interpolated in t/run.t. - - fixed bug with new() parameter -AllowMultiOptions which - generated a croak() if set to something other than "no". - - changed Extended::save() to reflect the API change, - it calls now save_file(). + I added it again now. + - added patch by Peder Stray to + the _store() method, which makes it possible to catch + arrays of hashes to be stored correctly. + - cleaned up the t/run.t testscript to reflect the + changes (in fact I did not touch it since 1.18 or so). + - added test number 16 to test variable interpolation + using ::Interpolated in t/run.t. + - fixed bug with new() parameter -AllowMultiOptions which + generated a croak() if set to something other than "no". + - changed Extended::save() to reflect the API change, + it calls now save_file(). 1.31: - i'm such a moron ... I forgot to do a make clean in 1.30, pf. So this is 1.31, which is clean. 1.30: - fixed typo, which made 1.29 unusable (undefined var %config) - added code to check if unknown parameters to new() - has been supplied. + has been supplied. 1.29: - - added 2 procedural functions ParseConf and SaveConf - - added new parameters -AutoTrue and -FlagBits - - added save_file() which replaces save(), which was - weird implemented. If the user only supplied a hash + - added 2 procedural functions ParseConf and SaveConf + - added new parameters -AutoTrue and -FlagBits + - added save_file() which replaces save(), which was + weird implemented. If the user only supplied a hash as parameter to save(), then the first key was - used as the filename and the rest was used - as a config hash (which was then of an uneven size). - - save_file() takes now instead of a hash a hash-ref - and a filename. And the hashref is optional, since - the object already contains a complete hash. - - new method save_string() added, which returns the - ready generated string instead of writing it to - disk. The user can then save it himself. - - POD updated. + used as the filename and the rest was used + as a config hash (which was then of an uneven size). + - save_file() takes now instead of a hash a hash-ref + and a filename. And the hashref is optional, since + the object already contains a complete hash. + - new method save_string() added, which returns the + ready generated string instead of writing it to + disk. The user can then save it himself. + - POD updated. 1.28: - - added contributed sub module Config::General::Interpolated - by "Wei-Hon Chen" with - help from "Autrijus Tang" - which makes it possible to use variables inside - config files. - - _read() accepts now c-comments inside c-comments if - they are on a single line. - - _read() is now more tolerant to here-identifiers - (the ends of here-docs), whitespaces right after - such an identifier are allowed (i.e. "EOF "). - - _read() does now behave somewhat different with - C-comments, they will be the first thing being - processed in a config, so the parser really - ignores everything inside C-comments. Previously - it did not do that, for example here-docs has - not been ignored. + - added contributed sub module Config::General::Interpolated + by "Wei-Hon Chen" with + help from "Autrijus Tang" + which makes it possible to use variables inside + config files. + - _read() accepts now c-comments inside c-comments if + they are on a single line. + - _read() is now more tolerant to here-identifiers + (the ends of here-docs), whitespaces right after + such an identifier are allowed (i.e. "EOF "). + - _read() does now behave somewhat different with + C-comments, they will be the first thing being + processed in a config, so the parser really + ignores everything inside C-comments. Previously + it did not do that, for example here-docs has + not been ignored. 1.27: - "make test" complained about uninitialized value in :146, which is now fixed. @@ -936,19 +952,19 @@ - added -String parameter to new(), which allows one to supply the whole config as a string. - added -MergeDuplicateBlocks option, which causes - duplicate blocks to be merged. + duplicate blocks to be merged. 1.25: - include statements are now case insensitive - - include statements may now also being used with - indentation(leading and following whitespaces are - allowed) - - changed the end here-doc regexp from .+? to \S+? - so " < - and Anton Luht :-) - This allows to include files from the location of - the configfile instead from the working directory. + - include statements may now also being used with + indentation(leading and following whitespaces are + allowed) + - changed the end here-doc regexp from .+? to \S+? + so " < + and Anton Luht :-) + This allows to include files from the location of + the configfile instead from the working directory. 1.24: - AllowMultiOptions printed out the value and not the option itself, if more than one of this particular @@ -959,11 +975,11 @@ work with blocks or named blocks. Pointed out by Thomas Klausner , who meant it being feature request, but in fact it was a bug (IMHO). - - Config::General does now contain also it's OO-sister - Config::General::Extended, which is from now on - no more available as an extra module, because it - lived a shadowy existence. - - finally(!) created a Changelog file (this one, yes). + - Config::General does now contain also it's OO-sister + Config::General::Extended, which is from now on + no more available as an extra module, because it + lived a shadowy existence. + - finally(!) created a Changelog file (this one, yes). 1.23: - fixed bug, which removed trailing or leading " even no matching " was there. @@ -990,7 +1006,6 @@ older history logs (stripped from CVS): revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 -An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** diff --git a/General.pm b/General.pm index 1a5975d..867af12 100644 --- a/General.pm +++ b/General.pm @@ -32,7 +32,7 @@ use Carp::Heavy; use Carp; use Exporter; -$Config::General::VERSION = "2.61"; +$Config::General::VERSION = "2.62"; use vars qw(@ISA @EXPORT_OK); use base qw(Exporter); @@ -95,7 +95,9 @@ sub new { NormalizeBlock => 0, NormalizeOption => 0, NormalizeValue => 0, - Plug => {} + Plug => {}, + UseApacheIfDefine => 0, + Define => {} }; # create the class instance @@ -174,13 +176,13 @@ sub _process { # open the file and read the contents in $self->{configfile} = $self->{ConfigFile}; if ( file_name_is_absolute($self->{ConfigFile}) ) { - # look if this is an absolute path and save the basename if it is absolute - my ($volume, $path, undef) = splitpath($self->{ConfigFile}); - $path =~ s#/$##; # remove eventually existing trailing slash - if (! $self->{ConfigPath}) { - $self->{ConfigPath} = []; - } - unshift @{$self->{ConfigPath}}, catpath($volume, $path, q()); + # look if this is an absolute path and save the basename if it is absolute + my ($volume, $path, undef) = splitpath($self->{ConfigFile}); + $path =~ s#/$##; # remove eventually existing trailing slash + if (! $self->{ConfigPath}) { + $self->{ConfigPath} = []; + } + unshift @{$self->{ConfigPath}}, catpath($volume, $path, q()); } $self->_open($self->{configfile}); # now, we parse immediately, getall simply returns the whole hash @@ -234,7 +236,6 @@ sub _blessvars { # pre-compile the variable regexp $self->{regex} = $self->_set_regex(); } -# return $self; } @@ -246,18 +247,18 @@ sub _splitpolicy { if ($self->{SplitPolicy} eq 'whitespace') { $self->{SplitDelimiter} = '\s+'; if (!$self->{StoreDelimiter}) { - $self->{StoreDelimiter} = q( ); + $self->{StoreDelimiter} = q( ); } } elsif ($self->{SplitPolicy} eq 'equalsign') { $self->{SplitDelimiter} = '\s*=\s*'; if (!$self->{StoreDelimiter}) { - $self->{StoreDelimiter} = ' = '; + $self->{StoreDelimiter} = ' = '; } } elsif ($self->{SplitPolicy} eq 'custom') { if (! $self->{SplitDelimiter} ) { - croak "Config::General: SplitPolicy set to 'custom' but no SplitDelimiter set.\n"; + croak "Config::General: SplitPolicy set to 'custom' but no SplitDelimiter set.\n"; } } else { @@ -304,10 +305,9 @@ sub _prepare { # handle options which contains values we need (strings, hashrefs or the like) if (exists $conf{-String} ) { - #if (ref(\$conf{-String}) eq 'SCALAR') { if (not ref $conf{-String}) { if ( $conf{-String}) { - $self->{StringContent} = $conf{-String}; + $self->{StringContent} = $conf{-String}; } delete $conf{-String}; } @@ -386,6 +386,33 @@ sub _prepare { $self->{SlashIsDirectory} = 1; $self->{SplitPolicy} = 'whitespace'; $self->{CComments} = 0; + $self->{UseApacheIfDefine} = 1; + } + + if ($self->{UseApacheIfDefine}) { + if (exists $conf{-Define}) { + my $ref = ref($conf{-Define}); + + if ($ref eq '') { + $self->{Define} = {$conf{-Define} => 1}; + } + elsif ($ref eq 'SCALAR') { + $self->{Define} = {${$conf{-Define}} = 1}; + } + elsif ($ref eq 'ARRAY') { + my %h = map { $_ => 1 } @{$conf{-Define}}; + $self->{Define} = \%h; + } + elsif ($ref eq 'HASH') { + $self->{Define} = $conf{-Define}; + } + else { + croak qq{Config::General: Unsupported ref '$ref' for 'Define'}; + } + + delete $conf{-Define}; + } + } } @@ -443,18 +470,13 @@ sub _open { } } - if (@include == 1) { - $configfile = $include[0]; - } - else { - # Multiple results or no expansion results (which is fine, - # include foo/* shouldn't fail if there isn't anything matching) - # rt.cpan.org#79869: local $this->{IncludeGlob}; - for (@include) { - $this->_open($_); - } - return; + # Multiple results or no expansion results (which is fine, + # include foo/* shouldn't fail if there isn't anything matching) + # rt.cpan.org#79869: local $this->{IncludeGlob}; + for (@include) { + $this->_open($_); } + return; } if (!-e $configfile) { @@ -576,6 +598,10 @@ sub _read { ($cont, $fh, @stuff) = $this->_hook('pre_read', $fh, @stuff); return if(!$cont); + if ($this->{UseApacheIfDefine}) { + $this->_process_apache_ifdefine(\@stuff); + } + foreach (@stuff) { if ($this->{AutoLaunder}) { if (m/^(.*)$/) { @@ -642,8 +668,6 @@ sub _read { # Remove comments and empty lines s/(? .* bugfix rt.cpan.org#44600 next if /^\s*#/; - #next if /^\s*$/; - # look for multiline option, indicated by a trailing backslash if (/(?/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) { + # inline Define, add it to our list + $this->{Define}{$1} = 1; + } elsif ($includeFlag) { + push @filtered, $_; + } + } + + if ($blockLevel) { + croak qq(Config::General: Block has no EndBlock statement!\n); + } + + @$rawlines = @filtered; # replace caller array +} sub _parse { @@ -805,12 +866,11 @@ sub _parse { $chunk++; $_ =~ s/^\s+//; # strip spaces @ end and begin $_ =~ s/\s+$//; - ###### bad $_ =~ s/^\x{ef}\x{bb}\x{bf}//; # strip utf BOM, if any, fix rt.cpan.org#113671 -# -# build option value assignment, split current input -# using whitespace, equal sign or optionally here-doc -# separator EOFseparator + # + # build option value assignment, split current input + # using whitespace, equal sign or optionally here-doc + # separator EOFseparator my ($option,$value); if (/$this->{EOFseparator}/) { ($option,$value) = split /\s*$this->{EOFseparator}\s*/, $_, 2; # separated by heredoc-finding in _open() @@ -1133,12 +1193,12 @@ sub _parse_value { if (exists $this->{FlagBitsFlags}->{$option}) { my %__flags = map { $_ => 1 } split /\s*\|\s*/, $value; foreach my $flag (keys %{$this->{FlagBitsFlags}->{$option}}) { - if (exists $__flags{$flag}) { - $__flags{$flag} = $this->{FlagBitsFlags}->{$option}->{$flag}; - } - else { - $__flags{$flag} = undef; - } + if (exists $__flags{$flag}) { + $__flags{$flag} = $this->{FlagBitsFlags}->{$option}->{$flag}; + } + else { + $__flags{$flag} = undef; + } } $value = \%__flags; } @@ -1150,7 +1210,7 @@ sub _parse_value { } ($cont, $option, $value) = $this->_hook('post_parse_value', $option, $value); - + return $value; } @@ -1168,21 +1228,6 @@ sub _hook { - - - - - -sub NoMultiOptions { - # - # turn AllowMultiOptions off, still exists for backward compatibility. - # Since we do parsing from within new(), we must - # call it again if one turns NoMultiOptions on! - # - croak q(Config::General: The NoMultiOptions() method is deprecated. Set 'AllowMultiOptions' to 'no' instead!); -} - - sub save { # # this is the old version of save() whose API interface @@ -1220,18 +1265,18 @@ sub save_file { if ($this->{UTF8}) { $fh = IO::File->new; open($fh, ">:utf8", $file) - or croak "Config::General: Could not open $file in UTF8 mode!($!)\n"; + or croak "Config::General: Could not open $file in UTF8 mode!($!)\n"; } else { $fh = IO::File->new( "$file", 'w') - or croak "Config::General: Could not open $file!($!)\n"; + or croak "Config::General: Could not open $file!($!)\n"; } if (!$config) { if (exists $this->{config}) { - $config_string = $this->_store(0, $this->{config}); + $config_string = $this->_store(0, $this->{config}); } else { - croak "Config::General: No config hash supplied which could be saved to disk!\n"; + croak "Config::General: No config hash supplied which could be saved to disk!\n"; } } else { @@ -1341,10 +1386,10 @@ sub _write_scalar { while (!$delimiter) { # create a unique here-doc identifier if ($line =~ /$tmplimiter/s) { - $tmplimiter .= '%'; + $tmplimiter .= '%'; } else { - $delimiter = $tmplimiter; + $delimiter = $tmplimiter; } } my @lines = split /\n/, $line; @@ -1432,7 +1477,6 @@ sub _hashref { } - # # Procedural interface # @@ -1487,13 +1531,12 @@ sub SaveConfigString { # keep this one -1; + 1; __END__ - =head1 NAME Config::General - Generic Config Module @@ -1965,6 +2008,35 @@ Please note that this is a new option (incorporated in version 2.30), it may lead to various unexpected side effects or other failures. You've been warned. +=item B<-UseApacheIfDefine> + +Enables support for Apache ... . See -Define. + +=item B<-Define> + +Defines the symbols to be used for conditional configuration files. +Allowed arguments: scalar, scalar ref, array ref or hash ref. + +Examples: + + -Define => 'TEST' + -Define => \$testOrProduction + -Define => [qw(TEST VERBOSE)] + -Define => {TEST => 1, VERBOSE => 1} + +Sample configuration: + + + + Level Debug + include test/*.cfg + + + Level Notice + include production/*.cfg + + + =item B<-ApacheCompatible> Over the past years a lot of options has been incorporated @@ -1986,6 +2058,7 @@ The following options will be set: SlashIsDirectory = 1 SplitPolicy = 'whitespace' CComments = 0 + UseApacheIfDefine = 1 Take a look into the particular documentation sections what those options are doing. @@ -2129,80 +2202,80 @@ A block start and end cannot be on the same line. An example: - -host = muli -user = moare -dbname = modb -dbpass = D4r_9Iu - + + host = muli + user = moare + dbname = modb + dbpass = D4r_9Iu + Blocks can also be nested. Here is a more complicated example: -user = hans -server = mc200 -db = maxis -passwd = D3rf$ - -user = tom -db = unknown -host = mila - -index int(100000) -name char(100) -prename char(100) -city char(100) -status int(10) -allowed moses -allowed ingram -allowed joice - - + user = hans + server = mc200 + db = maxis + passwd = D3rf$ + + user = tom + db = unknown + host = mila + + index int(100000) + name char(100) + prename char(100) + city char(100) + status int(10) + allowed moses + allowed ingram + allowed joice + + The hash which the method B returns look like that: -print Data::Dumper(\%hash); -$VAR1 = { -'passwd' => 'D3rf$', -'jonas' => { -'tablestructure' => { -'prename' => 'char(100)', -'index' => 'int(100000)', -'city' => 'char(100)', -'name' => 'char(100)', -'status' => 'int(10)', -'allowed' => [ -'moses', -'ingram', -'joice', -] -}, -'host' => 'mila', -'db' => 'unknown', -'user' => 'tom' -}, -'db' => 'maxis', -'server' => 'mc200', -'user' => 'hans' -}; + print Data::Dumper(\%hash); + $VAR1 = { + 'passwd' => 'D3rf$', + 'jonas' => { + 'tablestructure' => { + 'prename' => 'char(100)', + 'index' => 'int(100000)', + 'city' => 'char(100)', + 'name' => 'char(100)', + 'status' => 'int(10)', + 'allowed' => [ + 'moses', + 'ingram', + 'joice', + ] + }, + 'host' => 'mila', + 'db' => 'unknown', + 'user' => 'tom' + }, + 'db' => 'maxis', + 'server' => 'mc200', + 'user' => 'hans' + }; If you have turned on B<-LowerCaseNames> (see new()) then blocks as in the following example: - - -Owner root - - + + + Owner root + + would produce the following hash structure: -$VAR1 = { -'dir' => { -'attributes' => { -'owner => "root", -} -} -}; + $VAR1 = { + 'dir' => { + 'attributes' => { + 'owner' => "root", + } + } + }; As you can see, the keys inside the config hash are normalized. @@ -2225,28 +2298,29 @@ one or more hashrefs with the right part of the block as key containing everythi inside the block(which may again be nested!). As examples says more than words: # given the following sample - -Limit Deny -Options ExecCgi Index - - -Limit DenyAll -Options None - + + Limit Deny + Options ExecCgi Index + + + Limit DenyAll + Options None + # you will get: -$VAR1 = { -'Directory' => { -'/usr/frik' => { -'Options' => 'None', -'Limit' => 'DenyAll' -}, -'/usr/frisco' => { -'Options' => 'ExecCgi Index', -'Limit' => 'Deny' -} -} -}; + + $VAR1 = { + 'Directory' => { + '/usr/frik' => { + 'Options' => 'None', + 'Limit' => 'DenyAll' + }, + '/usr/frisco' => { + 'Options' => 'ExecCgi Index', + 'Limit' => 'Deny' + } + } + }; You cannot have more than one named block with the same name because it will be stored in a hashref and therefore be overwritten if a block occurs once more. @@ -2262,28 +2336,28 @@ Sometimes you may need blocknames which have whitespace in their names. With named blocks this is no problem, as the module only looks for the first whitespace: - - + + would be parsed to: -$VAR1 = { -'person' => { -'hugo gera' => { -}, -} -}; + $VAR1 = { + 'person' => { + 'hugo gera' => { + }, + } + }; The problem occurs, if you want to have a simple block containing whitespace: - - + + This would be parsed as a named block, which is not what you wanted. In this very case you may use quotation marks to indicate that it is not a named block: -<"hugo gera"> - + <"hugo gera"> + The save() method of the module inserts automatically quotation marks in such cases. @@ -2297,12 +2371,12 @@ explicit empty blocks. Normally you would write this in your config to define an empty block: - - + + To save writing you can also write: - + which is the very same as above. This works for normal blocks and for named blocks. @@ -2312,47 +2386,48 @@ for named blocks. =head1 IDENTICAL OPTIONS (ARRAYS) You may have more than one line of the same option with different values. - Example: -log log1 -log log2 -log log2 + + log log1 + log log2 + log log2 You will get a scalar if the option occurred only once or an array if it occurred more than once. If you expect multiple identical options, then you may need to check if an option occurred more than once: -$allowed = $hash{jonas}->{tablestructure}->{allowed}; -if(ref($allowed) eq "ARRAY") { -@ALLOWED = @{$allowed}; -else { -@ALLOWED = ($allowed); -} + $allowed = $hash{jonas}->{tablestructure}->{allowed}; + if (ref($allowed) eq "ARRAY") { + @ALLOWED = @{$allowed}; + else { + @ALLOWED = ($allowed); + } + } The same applies to blocks and named blocks too (they are described in more detail below). For example, if you have the following config: - -user max - - -user hannes - + + user max + + + user hannes + then you would end up with a data structure like this: -$VAR1 = { -'dir' => { -'blah' => [ -{ -'user' => 'max' -}, -{ -'user' => 'hannes' -} -] -} -}; + $VAR1 = { + 'dir' => { + 'blah' => [ + { + 'user' => 'max' + }, + { + 'user' => 'hannes' + } + ] + } + }; As you can see, the two identical blocks are stored in a hash which contains an array(-reference) of hashes. @@ -2363,16 +2438,17 @@ both identical blocks, then you need to turn the B parameter B<-MergeDupl on (see above). The parsed structure of the example above would then look like this: -$VAR1 = { -'dir' => { -'blah' => { -'user' => [ -'max', -'hannes' -] -} -} -}; + + $VAR1 = { + 'dir' => { + 'blah' => { + 'user' => [ + 'max', + 'hannes' + ] + } + } + }; As you can see, there is only one hash "dir->{blah}" containing multiple "user" entries. As you can also see, turning on B<-MergeDuplicateBlocks> @@ -2390,7 +2466,7 @@ You may also force a single config line to get parsed into an array by turning on the option B<-ForceArray> and by surrounding the value of the config entry by []. Example: -hostlist = [ foo.bar ] + hostlist = [ foo.bar ] Will be a singlevalue array entry if the option is turned on. If you want it to remain to be an array you have to turn on B<-ForceArray> during save too. @@ -2403,9 +2479,9 @@ of the line. The Config::General module will concatenate those lines to one sing Example: -command = cat /var/log/secure/tripwire | \ -mail C<-s> "report from tripwire" \ -honey@myotherhost.nl + command = cat /var/log/secure/tripwire | \ + mail C<-s> "report from tripwire" \ + honey@myotherhost.nl command will become: "cat /var/log/secure/tripwire | mail C<-s> 'report from twire' honey@myotherhost.nl" @@ -2419,12 +2495,12 @@ identifier must follow a "<<". Example: -message <. @@ -2435,19 +2511,19 @@ amount of spaces from every line inside the here-document. Example: -message <> + <> If you turned on B<-UseApacheInclude> (see B), then you can also use the following statement to include an external file: -include externalconfig.rc + include externalconfig.rc This file will be inserted at the position where it was found as if the contents of this file were directly at this position. @@ -2478,22 +2554,23 @@ working directory. Under some circumstances it maybe possible to open included files from the directory, where the configfile resides. You need to turn on the option B<-IncludeRelative> (see B) if you want that. An example: -my $conf = Config::General( --ConfigFile => "/etc/crypt.d/server.cfg" --IncludeRelative => 1 -); + my $conf = Config::General( + -ConfigFile => "/etc/crypt.d/server.cfg" + -IncludeRelative => 1 + ); /etc/crypt.d/server.cfg: -<> + + <> In this example Config::General will try to include I from I: -/etc/crypt.d/acl.cfg + /etc/crypt.d/acl.cfg The default behavior (if B<-IncludeRelative> is B set!) will be to open just I, wherever it is, i.e. if you did a chdir("/usr/local/etc"), then Config::General will include: -/usr/local/etc/acl.cfg + /usr/local/etc/acl.cfg Include statements can be case insensitive (added in version 1.25). @@ -2506,21 +2583,21 @@ so make sure, you're not including the same file from within itself! Example: -# main.cfg - -class=Some::Class - -include printers.cfg - -# ... - - -class=Another::Class - -include printers.cfg - -# ... - + # main.cfg + + class=Some::Class + + include printers.cfg + + # ... + + + class=Another::Class + + include printers.cfg + + # ... + Now C will be include in both the C and C objects. @@ -2536,18 +2613,18 @@ tab stops in front of the #. A comment can also occur after a config statement. Example: -username = max # this is the comment + username = max # this is the comment If you want to comment out a large block you can use C-style comments. A B signals the begin of a comment block and the B<*/> signals the end of the comment block. Example: -user = max # valid option -db = tothemax -/* -user = andors -db = toand -*/ + user = max # valid option + db = tothemax + /* + user = andors + db = toand + */ In this example the second options of user and db will be ignored. Please beware of the fact, if the Module finds a B string which is the start of a comment block, but no matching @@ -2556,7 +2633,7 @@ end block, it will ignore the whole rest of the config file! B If you require the B<#> character (number sign) to remain in the option value, then you can use a backslash in front of it, to escape it. Example: -bgcolor = \#ffffcc + bgcolor = \#ffffcc In this example the value of $config{bgcolor} will be "#ffffcc", Config::General will not treat the number sign as the begin of a comment because of the leading backslash. @@ -2572,26 +2649,25 @@ and parsing. The general aproach works like this: -sub ck { -my($file, $base) = @_; -print "_open() tries $file ... "; -if($file =~ /blah/) { -print "ignored\n"; -return (0); -} -else { -print "allowed\n"; -return (1, @_); -} -} - -my %c = ParseConfig( --IncludeGlob => 1, --UseApacheInclude => 1, --ConfigFile => shift, --Plug => { pre_open => *ck } -); + sub ck { + my($file, $base) = @_; + print "_open() tries $file ... "; + if ($file =~ /blah/) { + print "ignored\n"; + return (0); + } else { + print "allowed\n"; + return (1, @_); + } + } + my %c = ParseConfig( + -IncludeGlob => 1, + -UseApacheInclude => 1, + -ConfigFile => shift, + -Plug => { pre_open => *ck } + ); + Output: _open() tries cfg ... allowed @@ -2789,7 +2865,7 @@ Thomas Linden =head1 VERSION -2.61 +2.62 =cut diff --git a/MANIFEST b/MANIFEST index 34d3655..1ac74ee 100644 --- a/MANIFEST +++ b/MANIFEST @@ -53,3 +53,4 @@ t/Tie/README t/cfg.51 t/utf8_bom/bar.cfg t/utf8_bom/foo.cfg +t/cfg.58 diff --git a/README b/README index 30c72f2..796a195 100644 --- a/README +++ b/README @@ -104,4 +104,4 @@ AUTHOR VERSION - 2.59 + 2.62 diff --git a/TODO b/TODO index 179f719..e69de29 100644 --- a/TODO +++ b/TODO @@ -1,5 +0,0 @@ - - - o need separate methods like ::String or ::File to fill - module parameters, and ::Parse and/or ::Read for manually - invocation of the parser diff --git a/t/cfg.58 b/t/cfg.58 new file mode 100644 index 0000000..709a180 --- /dev/null +++ b/t/cfg.58 @@ -0,0 +1,3 @@ + + level debug + diff --git a/t/run.t b/t/run.t index a969fb9..4dbf233 100644 --- a/t/run.t +++ b/t/run.t @@ -8,7 +8,7 @@ use Data::Dumper; -use Test::More tests => 75; +use Test::More tests => 78; #use Test::More qw(no_plan); # ahem, we deliver the test code with a local copy of @@ -774,3 +774,20 @@ for my $bool (0, 1) { my %hash = $conf->getall; is_deeply \%hash, $expected57, "-UTF8 => $bool"; } + +# IFDEF tests +my $cfg58 = "t/cfg.58"; +my $expected58 = { level => "debug" }; +my %defs = ( + scalar => 'TEST', + array => ['TEST'], + hash => {'TEST' => 1} + ); + +foreach my $def (keys %defs) { + my $conf = Config::General->new(-ConfigFile => $cfg58, + -UseApacheIfDefine => 1, + -Define => $defs{$def}); + my %hash = $conf->getall(); + is_deeply \%hash, $expected58, "UseApacheIfDefine, -Define => $def"; +}