@@ -453,7 +453,8 @@ sub OutputResult {
453453 # --man reserved
454454 # INPUT_FILENAME assigned by parse_command_line_into
455455 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
457458 # --usage reserved
458459 # -? reserved
459460);
@@ -526,7 +527,7 @@ sub Main {
526527
527528 # Transfer parameters from the command line (-D) to the processed file,
528529 # 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.
530531 print " my %D = (\n " ;
531532 for my $defname (keys %{$opts {DEFS }}) {
532533 my $val = ${$opts {DEFS }}{$defname } // ' true' ;
@@ -563,6 +564,20 @@ sub Main {
563564 keys %{$opts {DEFS }};
564565 }
565566
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+
566581 # Initial code from the command line, if any
567582 print $opts {EVAL }, " \n " if $opts {EVAL };
568583
0 commit comments