@@ -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();
@@ -4679,8 +4680,13 @@ sub get_custom_value {
46794680 for my $tag (@{$self -> {' custom_multi_cmd' }-> {$based }}) {
46804681 my $command = $self -> get_custom_assign_or_override(' command' , $tag ,
46814682 $based , @params );
4682- push (@$value , $command );
4683- my $det = $self -> {' custom_multi_details' }-> {$command } = {};
4683+
4684+ # # Use $tag as the key for custom_multi_details and store the command as
4685+ # # a data member that we can access later. $command shouldn't be used
4686+ # # as the key because it is not guaranteed to be unique.
4687+ my $det = $self -> {' custom_multi_details' }-> {$tag } = {' _cmd' => $command ,
4688+ ' type' => $tag ,
4689+ ' outfile' => ' ' };
46844690 for my $k (keys %details ) {
46854691 $det -> {$k } = $self -> get_custom_assign_or_override($details {$k }, $tag ,
46864692 $based , @params );
@@ -4702,11 +4708,16 @@ sub get_custom_value {
47024708 }
47034709 }
47044710 }
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 } || ' ' ;
4711+
4712+ # # Sort the list of types so that generated projects are reproducable.
4713+ # # Additionally, we need them to be ordered (and numbered) so that we can
4714+ # # match the command with the right tag when iterating in the template.
4715+ my $det = $self -> {' custom_multi_details' };
4716+ my $i = 0;
4717+ foreach my $key (sort { $a cmp $b } keys %$det ) {
4718+ $det -> {$key }-> {' _order' } = $i ++;
4719+ push (@$value , $det -> {$key }-> {' _cmd' });
4720+ }
47104721 }
47114722 elsif (defined $customDefined {$cmd }) {
47124723 $value = $self -> get_assignment($cmd ,
@@ -4715,6 +4726,30 @@ sub get_custom_value {
47154726 $value = $self -> convert_command_parameters($based , $value , @params );
47164727 }
47174728 }
4729+ else {
4730+ # # This is only used with 'combined_custom'.
4731+ # #
4732+ # # $based - The command for the original define custom.
4733+ # # $cmd - The member after the arrow operator.
4734+ # #
4735+ # # We cannot use a direct lookup because the command is no longer the
4736+ # # key for custom_multi_details. It is possible to have two or more custom
4737+ # # types that use the same command. Therefore, we have to use the custom
4738+ # # type name ($tag) as the key. Since this code can only be called within
4739+ # # a foreach, we have to rely on the fact that the values created above
4740+ # # (during the processing of 'commands') are sorted to correlate the
4741+ # # command, stored in $base, with the correct tag in order to get the
4742+ # # correct command flags and other associated values.
4743+ foreach my $tag (keys %{$self -> {' custom_multi_details' }}) {
4744+ my $det = $self -> {' custom_multi_details' }-> {$tag };
4745+ if ($det -> {' _cmd' } eq $based && $det -> {' _order' } == $self -> {' forcount' }) {
4746+ if (exists $det -> {$cmd }) {
4747+ $value = $det -> {$cmd };
4748+ }
4749+ last ;
4750+ }
4751+ }
4752+ }
47184753
47194754 return $value ;
47204755}
@@ -5819,7 +5854,7 @@ sub combine_custom_types {
58195854 # synthetic type.
58205855 foreach my $in (keys %input ) {
58215856 next if scalar @{$input {$in }} < 2;
5822- my $combo_tag = join (' _and_' , map {/ (.+)_files$ / ; $1 } @{$input {$in }})
5857+ my $combo_tag = join (' _and_' , map {/ (.+)_files$ / ; $1 } sort ( @{$input {$in }}) )
58235858 . ' _files' ;
58245859 if (!$self -> {' combined_custom' }-> {$combo_tag }) {
58255860 $self -> {' combined_custom' }-> {$combo_tag } = $input {$in };
@@ -5883,6 +5918,10 @@ sub combine_custom_types {
58835918 return 1;
58845919}
58855920
5921+ sub set_forcount {
5922+ my ($self , $count ) = @_ ;
5923+ $self -> {' forcount' } = $count ;
5924+ }
58865925
58875926# ************************************************************
58885927# Accessors used by support scripts
0 commit comments