@@ -353,6 +353,7 @@ sub new {
353353 $self -> {' escape_spaces' } = $self -> escape_spaces();
354354 $self -> {' current_template' } = undef ;
355355 $self -> {' make_coexistence' } = $makeco ;
356+ $self -> {' forcount' } = 0;
356357
357358 $self -> add_default_matching_assignments();
358359 $self -> reset_generating_types();
@@ -4673,14 +4674,24 @@ sub get_custom_value {
46734674 }
46744675 elsif ($cmd eq ' commands' ) { # only used with 'combined_custom'
46754676 $value = [];
4677+
4678+ # # Clear out the previous custom_multi_details hash map so that we don't
4679+ # # have extraneous data associated with commands from previous iterations.
4680+ $self -> {' custom_multi_details' } = {};
4681+
46764682 my %details = (' flags' => ' commandflags' ,
46774683 ' outopt' => ' output_option' ,
46784684 ' gdir' => ' gendir' );
46794685 for my $tag (@{$self -> {' custom_multi_cmd' }-> {$based }}) {
46804686 my $command = $self -> get_custom_assign_or_override(' command' , $tag ,
46814687 $based , @params );
4682- push (@$value , $command );
4683- my $det = $self -> {' custom_multi_details' }-> {$command } = {};
4688+
4689+ # # Use $tag as the key for custom_multi_details and store the command as
4690+ # # a data member that we can access later. $command shouldn't be used
4691+ # # as the key because it is not guaranteed to be unique.
4692+ my $det = $self -> {' custom_multi_details' }-> {$tag } = {' _cmd' => $command ,
4693+ ' type' => $tag ,
4694+ ' outfile' => ' ' };
46844695 for my $k (keys %details ) {
46854696 $det -> {$k } = $self -> get_custom_assign_or_override($details {$k }, $tag ,
46864697 $based , @params );
@@ -4702,11 +4713,16 @@ sub get_custom_value {
47024713 }
47034714 }
47044715 }
4705- }
4706- elsif ($cmd eq ' flags' || $cmd eq ' outopt' || $cmd eq ' outfile' ||
4707- $cmd eq ' gdir' ) {
4708- # only used with 'combined_custom'
4709- $value = $self -> {' custom_multi_details' }-> {$based }-> {$cmd } || ' ' ;
4716+
4717+ # # Sort the list of types so that generated projects are reproducable.
4718+ # # Additionally, we need them to be ordered (and numbered) so that we can
4719+ # # match the command with the right tag when iterating in the template.
4720+ my $det = $self -> {' custom_multi_details' };
4721+ my $i = 0;
4722+ foreach my $key (sort { $a cmp $b } keys %$det ) {
4723+ $det -> {$key }-> {' _order' } = $i ++;
4724+ push (@$value , $det -> {$key }-> {' _cmd' });
4725+ }
47104726 }
47114727 elsif (defined $customDefined {$cmd }) {
47124728 $value = $self -> get_assignment($cmd ,
@@ -4715,6 +4731,30 @@ sub get_custom_value {
47154731 $value = $self -> convert_command_parameters($based , $value , @params );
47164732 }
47174733 }
4734+ else {
4735+ # # This is only used with 'combined_custom'.
4736+ # #
4737+ # # $based - The command for the original define custom.
4738+ # # $cmd - The member after the arrow operator.
4739+ # #
4740+ # # We cannot use a direct lookup because the command is no longer the
4741+ # # key for custom_multi_details. It is possible to have two or more custom
4742+ # # types that use the same command. Therefore, we have to use the custom
4743+ # # type name ($tag) as the key. Since this code can only be called within
4744+ # # a foreach, we have to rely on the fact that the values created above
4745+ # # (during the processing of 'commands') are sorted to correlate the
4746+ # # command, stored in $base, with the correct tag in order to get the
4747+ # # correct command flags and other associated values.
4748+ foreach my $tag (keys %{$self -> {' custom_multi_details' }}) {
4749+ my $det = $self -> {' custom_multi_details' }-> {$tag };
4750+ if ($det -> {' _cmd' } eq $based && $det -> {' _order' } == $self -> {' forcount' }) {
4751+ if (exists $det -> {$cmd }) {
4752+ $value = $det -> {$cmd };
4753+ }
4754+ last ;
4755+ }
4756+ }
4757+ }
47184758
47194759 return $value ;
47204760}
@@ -5819,7 +5859,7 @@ sub combine_custom_types {
58195859 # synthetic type.
58205860 foreach my $in (keys %input ) {
58215861 next if scalar @{$input {$in }} < 2;
5822- my $combo_tag = join (' _and_' , map {/ (.+)_files$ / ; $1 } @{$input {$in }})
5862+ my $combo_tag = join (' _and_' , map {/ (.+)_files$ / ; $1 } sort ( @{$input {$in }}) )
58235863 . ' _files' ;
58245864 if (!$self -> {' combined_custom' }-> {$combo_tag }) {
58255865 $self -> {' combined_custom' }-> {$combo_tag } = $input {$in };
@@ -5883,6 +5923,10 @@ sub combine_custom_types {
58835923 return 1;
58845924}
58855925
5926+ sub set_forcount {
5927+ my ($self , $count ) = @_ ;
5928+ $self -> {' forcount' } = $count ;
5929+ }
58865930
58875931# ************************************************************
58885932# Accessors used by support scripts
0 commit comments