@@ -453,7 +453,8 @@ sub OutputResult {
453
453
# --man reserved
454
454
# INPUT_FILENAME assigned by parse_command_line_into
455
455
OUTPUT_FILENAME => [' o' ,' |output=s' , " " ],
456
- DEFS => [' D' ,' |define:s%' ],
456
+ DEFS => [' D' ,' |define:s%' ], # In %D, and text substitution
457
+ SETS => [' s' ,' |set:s%' ], # Extra data in %S, without text substitution
457
458
# --usage reserved
458
459
# -? reserved
459
460
);
@@ -526,7 +527,7 @@ sub Main {
526
527
527
528
# Transfer parameters from the command line (-D) to the processed file,
528
529
# as textual representations of expressions.
529
- # The parameters are in %D at runtime, by analogy with -S and %S .
530
+ # The parameters are in %D at runtime.
530
531
print " my %D = (\n " ;
531
532
for my $defname (keys %{$opts {DEFS }}) {
532
533
my $val = ${$opts {DEFS }}{$defname } // ' true' ;
@@ -563,6 +564,20 @@ sub Main {
563
564
keys %{$opts {DEFS }};
564
565
}
565
566
567
+ # Now do SETS: -s or --set, into %S by analogy with -D and %D.
568
+ print " my %S = (\n " ;
569
+ for my $defname (keys %{$opts {SETS }}) {
570
+ my $val = ${$opts {SETS }}{$defname };
571
+ if (!defined ($val )) {
572
+ }
573
+ $val = ' true' if $val eq ' ' ;
574
+ # "-s foo" (without a value) sets it to _true_ so
575
+ # "if($S{foo})" will work. Getopt::Long gives us '' as the
576
+ # value in that situation.
577
+ print " $defname => $val ,\n " ;
578
+ }
579
+ print " );\n " ;
580
+
566
581
# Initial code from the command line, if any
567
582
print $opts {EVAL }, " \n " if $opts {EVAL };
568
583
0 commit comments