Changeset 33429 for main/trunk/greenstone2/perllib/mgppbuildproc.pm
- Timestamp:
- 2019-08-20T11:04:13+12:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/mgppbuildproc.pm
r33369 r33429 404 404 sub get_or_create_shortname { 405 405 my $self = shift(@_); 406 407 406 my ($realname) = @_; 408 407 if (defined $self->{'fieldnamemap'}->{$realname}) { … … 420 419 } else { 421 420 # 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); 423 422 #try the first two chars 424 if ($ realname =~ /^[^\w]*(\w)[^\w]*(\w)/) {423 if ($fullname =~ /^[^\w]*(\w)[^\w]*(\w)/) { 425 424 $shortname = "$1$2"; 426 425 } else { 427 426 # there aren't two letdig's in the field - try arbitrary combinations 428 $ realname = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";427 $fullname = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 429 428 $shortname = "AB"; 430 429 } … … 433 432 #if already used, take the first and third letdigs and so on 434 433 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)/) { 437 436 $shortname = "$1$3"; 438 437 $count++; … … 440 439 441 440 } 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 } 445 447 $count = 0; 446 448 } … … 451 453 $self->{'fieldnamemap'}->{$realname} = $shortname; 452 454 $self->{'fieldnamemap'}->{$shortname} = 1; 453 454 455 return $shortname; 455 456 }
Note:
See TracChangeset
for help on using the changeset viewer.