Changeset 33429

Show
Ignore:
Timestamp:
20.08.2019 11:04:13 (4 weeks ago)
Author:
kjdon
Message:

fixed a bug in get_or_create_shortname where it wasn't storing the new shortname against the original name, but against working version. so next time come in there, the real name didn't have a shortname stored, so had to go through the process again. eventually it ran out of letters and hung in an infinite loop

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/mgppbuildproc.pm

    r33369 r33429  
    404404sub get_or_create_shortname { 
    405405    my $self = shift(@_); 
    406      
    407406    my ($realname) = @_; 
    408407    if (defined $self->{'fieldnamemap'}->{$realname}) { 
     
    420419    } else { 
    421420    # we can't use the quick map, so join all fields back together (without namespaces), and try sets of two characters. 
    422     $realname = join ("", @realnamelist); 
     421    my $fullname = join ("", @realnamelist); 
    423422    #try the first two chars 
    424     if ($realname =~ /^[^\w]*(\w)[^\w]*(\w)/) { 
     423    if ($fullname =~ /^[^\w]*(\w)[^\w]*(\w)/) { 
    425424        $shortname = "$1$2"; 
    426425    } else { 
    427426        # there aren't two letdig's in the field - try arbitrary combinations 
    428         $realname = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
     427        $fullname = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
    429428        $shortname = "AB"; 
    430429    } 
     
    433432    #if already used, take the first and third letdigs and so on 
    434433    my $count = 1; 
    435     while (defined $self->{'fieldnamemap'}->{$shortname} || defined $static_indexfield_map{$shortname}) { 
    436         if ($realname =~ /^[^\w]*(\w)([^\w]*\w){$count}[^\w]*(\w)/) { 
     434     while (defined $self->{'fieldnamemap'}->{$shortname} || defined $static_indexfield_map{$shortname}) { 
     435         if ($fullname =~ /^[^\w]*(\w)([^\w]*\w){$count}[^\w]*(\w)/) { 
    437436        $shortname = "$1$3"; 
    438437        $count++; 
     
    440439         
    441440        } 
    442         else { 
    443         #remove up to and incl the first letdig 
    444         $realname =~ s/^[^\w]*\w//; 
     441         else { 
     442         #remove up to and incl the first letdig 
     443         $fullname =~ s/^[^\w]*\w//; 
     444         if ($fullname !~ /^[^\w]*(\w)[^\w]*(\w)/) { 
     445             $fullname = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
     446         } 
    445447        $count = 0; 
    446448        } 
     
    451453    $self->{'fieldnamemap'}->{$realname} = $shortname; 
    452454    $self->{'fieldnamemap'}->{$shortname} = 1; 
    453  
    454455    return $shortname; 
    455456}