Skip to content
This repository
Browse code

[configure] Provide an additional pattern by which an entry in the 'g…

…eneral' section of a configuration file can be matched against a double-quoted string containing whitespace. Per git Issue #233.
  • Loading branch information...
commit f7cc9f9a82005046bf3456c160bc4245782226f7 1 parent 9691780
James E Keenan authored December 27, 2011
8  Configure.pl
@@ -459,7 +459,7 @@ =head1 CONFIGURATION-FILE INTERFACE
459 459
 I<=variables> section of the configuration file (as above).
460 460
 
461 461
 In addition, should you wish to use an option whose value contains whitespace
462  
-and would, if presented on the command-line, require quoting, you should
  462
+and would, if presented on the command-line, require quoting, you may
463 463
 assign that string to a variable and then use the variable in the C<general>
464 464
 section below.
465 465
 
@@ -494,6 +494,12 @@ =head1 CONFIGURATION-FILE INTERFACE
494 494
 
495 495
     intval=$LONGLONG
496 496
 
  497
+Alternatively, if assignment of a value to an option on the command-line would
  498
+require quoting due to the presence of whitespace in the value, you may assign
  499
+it to a value in the I<=general> section by double-quoting the value.
  500
+
  501
+    intval="long long"
  502
+
497 503
 =item *
498 504
 
499 505
 You I<may> list options here which are I<conceptually> limited to a single
2  MANIFEST
@@ -524,6 +524,7 @@ examples/c/test_main.c                                      [examples]
524 524
 examples/compilers/Makefile                                 [examples]
525 525
 examples/compilers/japhc.c                                  [examples]
526 526
 examples/config/file/configcompiler                         [examples]
  527
+examples/config/file/configverbose                          [examples]
527 528
 examples/config/file/configwithfatalstep                    [examples]
528 529
 examples/embed/Makefile                                     [examples]
529 530
 examples/embed/Makefile.msvc                                [examples]
@@ -1628,7 +1629,6 @@ t/configure/testlib/init/lambda.pm                          [test]
1628 1629
 t/configure/testlib/init/mu.pm                              [test]
1629 1630
 t/configure/testlib/init/zeta.pm                            [test]
1630 1631
 t/configure/testlib/inter/theta.pm                          [test]
1631  
-t/configure/testlib/verbosefoobar                           [test]
1632 1632
 t/distro/manifest.t                                         [test]
1633 1633
 t/distro/manifest_generated.t                               [test]
1634 1634
 t/dynoplibs/bit.t                                           [test]
1  examples/config/file/configcompiler
@@ -9,6 +9,7 @@ CX=/usr/bin/g++
9 9
 cc=$CC
10 10
 link=$CX
11 11
 ld=/usr/bin/g++
  12
+intval="long long"
12 13
 
13 14
 =steps
14 15
 
0  t/configure/testlib/verbosefoobar → examples/config/file/configverbose
File renamed without changes
12  lib/Parrot/Configure/Options/Conf/File.pm
@@ -90,7 +90,17 @@ sub _set_general {
90 90
     my ($data, $substitutions, $general, $optsref) = @_;
91 91
     my @general = split /\n/, $general;
92 92
     foreach my $g (@general) {
93  
-        next unless $g =~ m/^([-\w]+)(?:=(\$?[^\s\$]+))?$/;
  93
+        next unless ( $g =~ m/^
  94
+            ([-\w]+)
  95
+            (?:=(
  96
+                \S+     # Usual case: regular identifier; no spaces allowed in identifier
  97
+                |
  98
+                \$\S+   # Variable substitution; no spaces allowed in identifier
  99
+                )
  100
+            )?
  101
+           $/x )
  102
+            or
  103
+        ( $g =~ m/^([-\w]+)="([^"]+)"$/ );  # Double-quoted string; spaces allowed
94 104
         my ($k, $v, $prov, $var);
95 105
         if ($2) {
96 106
             ($k, $prov) = ($1, $2);
59  t/configure/008-file_based_configuration.t
... ...
@@ -1,5 +1,5 @@
1 1
 #! perl
2  
-# Copyright (C) 2007-2010, Parrot Foundation.
  2
+# Copyright (C) 2007-2011, Parrot Foundation.
3 3
 # 008-file_based_configuration.t
4 4
 
5 5
 use strict;
@@ -11,7 +11,7 @@ BEGIN {
11 11
     our $topdir = realpath($Bin) . "/../..";
12 12
     unshift @INC, qq{$topdir/lib};
13 13
 }
14  
-use Test::More tests => 30;
  14
+use Test::More tests => 31;
15 15
 use Carp;
16 16
 use Parrot::Configure::Options qw| process_options |;
17 17
 
@@ -20,22 +20,22 @@ use Parrot::Configure::Options qw| process_options |;
20 20
     my ($args, $steps_list_ref) = _test_good_config_file($configfile);
21 21
 
22 22
     ok(! defined $args->{maintainer},
23  
-        "Configuring from testfoobar: 'maintainer' not defined, as expected");
  23
+        "Configuring from $configfile: 'maintainer' not defined, as expected");
24 24
     is($args->{'verbose-step'}, 'init::hints',
25  
-        "Configuring from testfoobar: 'init::hints' is verbose step");
  25
+        "Configuring from $configfile: 'init::hints' is verbose step");
26 26
     is($args->{'fatal-step'}, 'init::hints',
27  
-        "Configuring from testfoobar: 'init::hints' is fatal step");
  27
+        "Configuring from $configfile: 'init::hints' is fatal step");
28 28
     ok($args->{nomanicheck},
29  
-        "Configuring from testfoobar: will omit check of MANIFEST");
  29
+        "Configuring from $configfile: will omit check of MANIFEST");
30 30
     is($args->{file}, $configfile,
31  
-        "Configuring from testfoobar: config file correctly stored");
  31
+        "Configuring from $configfile: config file correctly stored");
32 32
     ok($args->{debugging},
33  
-        "Configuring from testfoobar: debugging turned on");
  33
+        "Configuring from $configfile: debugging turned on");
34 34
     my %steps_seen = map {$_ => 1} @{ $steps_list_ref };
35 35
     ok(exists $steps_seen{'init::manifest'},
36  
-        "Configuring from testfoobar: init::manifest is in list even though it will be skipped");
  36
+        "Configuring from $configfile: init::manifest is in list even though it will be skipped");
37 37
     ok(! exists $steps_seen{'auto::perldoc'},
38  
-        "Configuring from testfoobar: auto::perldoc not in list");
  38
+        "Configuring from $configfile: auto::perldoc not in list");
39 39
 }
40 40
 
41 41
 {
@@ -44,52 +44,55 @@ use Parrot::Configure::Options qw| process_options |;
44 44
 
45 45
     my $c_compiler = '/usr/bin/gcc';
46 46
     my $cplusplus_compiler = '/usr/bin/g++';
  47
+    my $intval_setting = 'long long';
47 48
     ok(! defined $args->{maintainer},
48  
-        "Configuring from yourfoobar: 'maintainer' not defined as expected");
  49
+        "Configuring from $configfile: 'maintainer' not defined as expected");
49 50
     is($args->{'verbose-step'}, 'init::hints',
50  
-        "Configuring from yourfoobar: 'init::hints' is verbose step");
  51
+        "Configuring from $configfile: 'init::hints' is verbose step");
51 52
     ok($args->{nomanicheck},
52  
-        "Configuring from yourfoobar: will omit check of MANIFEST");
  53
+        "Configuring from $configfile: will omit check of MANIFEST");
53 54
     is($args->{file}, $configfile,
54  
-        "Configuring from yourfoobar: config file correctly stored");
  55
+        "Configuring from $configfile: config file correctly stored");
55 56
     ok($args->{debugging},
56  
-        "Configuring from yourfoobar: debugging turned on");
  57
+        "Configuring from $configfile: debugging turned on");
57 58
     is($args->{cc}, $c_compiler,
58  
-        "Configuring from yourfoobar: C compiler is $c_compiler");
  59
+        "Configuring from $configfile: C compiler is $c_compiler");
59 60
     is($args->{link}, $cplusplus_compiler,
60  
-        "Configuring from yourfoobar: linker is $cplusplus_compiler");
  61
+        "Configuring from $configfile: linker is $cplusplus_compiler");
61 62
     is($args->{ld}, $cplusplus_compiler,
62  
-        "Configuring from yourfoobar: shared library loader is $cplusplus_compiler");
  63
+        "Configuring from $configfile: shared library loader is $cplusplus_compiler");
  64
+    is($args->{intval}, $intval_setting,
  65
+        "Configuring from $configfile: 'intval' setting is $intval_setting");
63 66
 
64 67
     my %steps_seen = map {$_ => 1} @{ $steps_list_ref };
65 68
 
66 69
     ok(exists $steps_seen{'init::manifest'},
67  
-        "Configuring from yourfoobar: init::manifest is in list even though it will be skipped");
  70
+        "Configuring from $configfile: init::manifest is in list even though it will be skipped");
68 71
     ok(! exists $steps_seen{'auto::perldoc'},
69  
-        "Configuring from yourfoobar: auto::perldoc not in list");
  72
+        "Configuring from $configfile: auto::perldoc not in list");
70 73
 }
71 74
 
72 75
 {
73  
-    my $configfile = q{t/configure/testlib/verbosefoobar};
  76
+    my $configfile = q{examples/config/file/configverbose};
74 77
     my ($args, $steps_list_ref) = _test_good_config_file($configfile);
75 78
 
76 79
     ok(! defined $args->{maintainer},
77  
-        "Configuring from verbosefoobar: 'maintainer' not defined as expected");
  80
+        "Configuring from $configfile: 'maintainer' not defined as expected");
78 81
     ok($args->{nomanicheck},
79  
-        "Configuring from verbosefoobar: will omit check of MANIFEST");
  82
+        "Configuring from $configfile: will omit check of MANIFEST");
80 83
     is($args->{file}, $configfile,
81  
-        "Configuring from verbosefoobar: config file correctly stored");
  84
+        "Configuring from $configfile: config file correctly stored");
82 85
     ok($args->{debugging},
83  
-        "Configuring from verbosefoobar: debugging turned on");
  86
+        "Configuring from $configfile: debugging turned on");
84 87
     is($args->{verbose}, 1,
85  
-        "Configuring from verbosefoobar: verbose output is on");
  88
+        "Configuring from $configfile: verbose output is on");
86 89
 
87 90
     my %steps_seen = map {$_ => 1} @{ $steps_list_ref };
88 91
 
89 92
     ok(exists $steps_seen{'init::manifest'},
90  
-        "Configuring from verbosefoobar: init::manifest is in list even though it will be skipped");
  93
+        "Configuring from $configfile: init::manifest is in list even though it will be skipped");
91 94
     ok(! exists $steps_seen{'auto::perldoc'},
92  
-        "Configuring from verbosefoobar: auto::perldoc not in list");
  95
+        "Configuring from $configfile: auto::perldoc not in list");
93 96
 }
94 97
 
95 98
 {

0 notes on commit f7cc9f9

Please sign in to comment.
Something went wrong with that request. Please try again.