Kaydet (Commit) 4a519107 authored tarafından Andras Timar's avatar Andras Timar

remove 3 unused Perl scripts from l10ntools

Change-Id: Ie2e8fa776b5a7a7293498607fe55dcdfce273594
üst 7e8cc51f
helpcontent2 @ 66abeb18
Subproject commit bfe8b1eea5e372ff7198d841caa20c72a57610e0 Subproject commit 66abeb18556b468ea3d97cea78dcd8e9f0c94380
:
eval 'exec perl -S $0 ${1+"$@"}'
if 0;
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Andras Timar <atimar@suse.com>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
#
# add keyids to pot files
#
use File::Find;
sub keyidgen
{
my $key = shift;
my $crc = crc24($key);
my $symbols="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#_";
my $keyid = "";
while ( length($keyid) < 4 )
{
$keyid .= substr($symbols, $crc & 63, 1);
$crc = $crc >> 6;
}
return $keyid;
}
sub crc24
{
my $CRC24_INIT = 0x00b704ce;
my $CRC24_POLY = 0x00864cfb;
my $key = shift;
my $key_length = length($key);
my $crc = $CRC24_INIT;
my $position = 0;
while ( $position < $key_length )
{
$crc ^= (unpack("C", substr($key, $position, 1)) << 16);
my $i;
for ($i = 0; $i < 8; $i++)
{
$crc <<= 1;
$crc ^= $CRC24_POLY if ($crc & 0x01000000)
}
$position++;
}
return $crc & 0x00ffffff;
}
my $potdir = $ARGV[0];
if (!$potdir) {die "Usage_ $0 <directory of pot files>\n";}
my @potfiles = ();
File::Find::find( sub {/^.*\.pot\z/s && push @potfiles, $File::Find::name;}, $potdir );
foreach $f (@potfiles)
{
open OLDPOT , "< $f" || die("Cannot open source pot file: $f\n");
$fnew = $f . ".new";
@path = split ("/",$f);
$keypart1 = pop @path;
$keypart1 =~ s/.pot//;
$keypart1 .= "_";
$keypart2 = pop @path;
$keypart1 = $keypart2 . "_" . $keypart1;
open NEWPOT , "> $fnew" || die("Cannot open target pot file: $f\n");
while ( <OLDPOT> )
{
chomp;
if( /^#: (.*)$/ )
{
print NEWPOT "#. " . keyidgen($keypart1 . $1) . "\n";
}
print NEWPOT $_ . "\n";
}
close OLDPOT;
close NEWPOT;
rename $fnew,$f;
}
exit 0;
:
eval 'exec perl -wS $0 ${1+"$@"}'
if 0;
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
use strict;
use Class::Struct;
use Getopt::Long;
use File::Temp;
use File::Path;
my @files;
my @file_names;
my $module_name = '';
my @current;
my @buffer;
my $last_file;
my $last_path;
my $last_localize_file;
my $first_run = "1";
my $sdf_filename;
my $merge_dir;
my $state = "none";
$SIG{INT} = 'inthandler';
$SIG{QUIT} = 'quithandler';
struct ( sdf_obj =>
{
module => '$',
file => '$',
dir => '$',
FILEHANDLE => '$',
line => '$',
endoffile => '$'
}
);
parse_options();
my $lock_file = $merge_dir."/lock.mk";
acquire_lock();
read_sdf_file_names();
init();
my $reference;
my $path ;
my $localize_file;
while( hasLines() )
{
@current = ();
foreach ( @files )
{
push @current , $_;
}
$reference = getNextIdentifier( );
@current = ();
foreach ( @files )
{
if( $_->module eq $reference->module && $_->dir eq $reference->dir )
{
push @current , $_ ;
}
}
write_lines();
}
# write content of the last localize.sdf file
if( $#buffer ge 0 )
{
write_buffer( $last_path , $last_localize_file );
}
release_lock();
exit( 0 );
##########################################################################################
sub acquire_lock
{
if( -e $lock_file ){
$state = "blocked";
print "WARNING: Lock file '$lock_file' 'found, waiting ....\n";
my $cnt = 0;
sleep 10 , while( -e $lock_file && $cnt++ < 180 );
exit( 0 );
}else
{
$state = "locked";
print "Writing lock file '$lock_file'\n";
open FILE, ">$lock_file" or die "Can't create lock file '$lock_file'";
print FILE "L10N_LOCK=YES" ;
close ( FILE );
}
}
sub release_lock
{
print "Deleting lock file '$lock_file'\n";
unlink $lock_file, if( -e $lock_file );
$state = "none";
}
sub inthandler
{
release_lock() , if( $state eq "locked" );
exit( -1 );
}
sub quithandler
{
release_lock() , if( $state eq "locked" );
exit( 0 );
}
sub init
{
foreach my $file ( @file_names )
{
my $obj = new sdf_obj;
open my $FILEHANDLE , "<$file" or die "Can't open file '$file'";
$obj->FILEHANDLE ( $FILEHANDLE ) ;
getNextSdfObj( $obj );
push @files, $obj ;
print "Open file '$file'\n";
}
}
# get the next module/file
sub getNextIdentifier
{
my @sorted = sort {
return $a->module.$a->dir cmp $b->module.$b->dir;
} @current ;
return shift @sorted;
}
# update the obj with the next line
sub getNextSdfObj
{
my $obj = shift;
my $line = readline ( $obj->FILEHANDLE );
if ( $line eq undef )
{
$obj->endoffile( "true" );
}
else
{
$line =~ /^(([^\t]*)\t([^\t]*)[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t*)/o ;
if( defined $1 && defined $2 && defined $3 )
{
$obj->line ( $1 );
$obj->module( $2 );
$obj->file ( $3 );
$obj->dir ( getDir( $3 ) );
}
else
{
$obj->line ( "" );
$obj->module( "" );
$obj->file ( "" );
$obj->dir ( "" );
}
}
return $obj;
}
sub getNextSdfObjModule
{
my $obj = shift;
while( !$obj->endoffile )
{
my $line = readline ( $obj->FILEHANDLE );
if ( $line eq undef )
{
$obj->endoffile( "true" );
}
else
{
$line =~ /^(([^\t]*)\t([^\t]*).*)/o ;
if( defined $1 && defined $2 && defined $3 )
{
$obj->line ( $1 );
$obj->module( $2 );
$obj->file ( $3 );
$obj->dir ( getDir( $3 ) );
}
else
{
$obj->line ( "" );
$obj->module( "" );
$obj->file ( "" );
$obj->dir ( "" );
}
return $obj , if( $obj->module eq $module_name )
}
}
#return $obj;
}
sub getDir
{
my $path = shift ;
$path =~ s/\//\\/g;
my @tmp_path = split /\\/ , $path;
pop @tmp_path;
$path = join '\\' , @tmp_path;
return $path;
}
sub hasLines
{
my $hasLines = "";
my @tmpfiles;
foreach ( @files )
{
push @tmpfiles , $_, if( !$_->endoffile );
}
@files = @tmpfiles;
return $#files+1;
}
sub make_paths
{
my $localizeFile = $merge_dir."\\".$current[ 0 ]->module."\\".$current[ 0 ]->file;
my $path = getDir( $localizeFile );
$path =~ s/\\/\//g;
$localizeFile = $path."/localize.sdf";
return ( $path , $localizeFile );
}
sub write_lines
{
if( $first_run ){
my( $path , $localize_file ) = make_paths();
$last_path = $path;
$last_localize_file = $localize_file;
add_to_buffer();
$first_run = '';
}
else
{
return , if ( $#current+1 eq 0 );
my( $path , $localize_file ) = make_paths();
if( $path eq $last_path )
{
add_to_buffer();
}
else
{
write_buffer( $last_path , $last_localize_file );
add_to_buffer();
$last_path = $path;
$last_localize_file = $localize_file;
}
}
}
# Adds all lines that contain strings from one source file from every input file.
# TODO: Would it not be better to add lines for all files from a directory (i.e., replace
# "$afile eq $elem->file" by "$adir eq $elem->dir")? We could get rid of the delayed
# writing then. But maybe there is a reason for doing it this way...
sub add_to_buffer
{
my $plainline;
my $afile;
my $amodule;
foreach my $elem ( @current )
{
do {
$amodule=$elem->module;
$afile=$elem->file;
$plainline=$elem->line;
push @buffer, $plainline;
getNextSdfObj( $elem );
} while ( !$elem->endoffile && $amodule eq $elem->module && $afile eq $elem->file );
}
}
# Writes the buffer to currently selected localize.sdf file.
sub write_buffer
{
my $path = shift;
my $localize_file = shift;
my $cnt = $#buffer+1;
print "Write to $path $cnt lines\n";
mkpath $path;
open FILE , ">>$localize_file" or die "Can't open file '$localize_file'\n";
foreach ( @buffer )
{
print FILE $_."\n";
}
close ( FILE );
@buffer = ();
}
sub parse_options
{
my $success = GetOptions( 'sdf_files=s' => \$sdf_filename , 'merge_dir=s' => \$merge_dir ); #, 'module=s' => \$module_name );
if( ! ( $sdf_filename && $merge_dir && $success ) )
{
usage();
exit( -1 );
}
}
sub usage
{
print "Usage: fast_merge -sdf_files <file containing sdf file names> -merge_dir <directory>\n" ;
}
sub read_sdf_file_names
{
open FILE , "<$sdf_filename" or die "Can't open file '$sdf_filename'\n";
while ( <FILE> )
{
push @file_names , split " " , $_ ;
}
close ( FILE );
}
:
eval 'exec perl -S $0 ${1+"$@"}'
if 0;
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
#
# add keyids to sdf file
#
my $infile = $ARGV[0];
if ( !$infile ) {die "Usage: $0 <infile> [<outfile>]\n";}
my $outfile = $ARGV[1];
if ( ! defined $outfile )
{
$outfile = $infile;
$outfile =~ s/\.sdf$//i;
$outfile .= "_KeyID.sdf";
}
print "writing to $outfile\n";
open INFILE,"<$infile" || die "could not open $infile $! $^E\n";
open OUTFILE,">$outfile" || die "could not open $outfile $! $^E\n";
while ( <INFILE> )
{
chomp;
if ( /^([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)$/ )
{
my $prj = defined $1 ? $1 : '';
my $file = defined $2 ? $2 : '';
my $dummy = defined $3 ? $3 : '';
my $type = defined $4 ? $4 : '';
my $gid = defined $5 ? $5 : '';
my $lid = defined $6 ? $6 : '';
my $helpid = defined $7 ? $7 : '';
my $platform = defined $8 ? $8 : '';
my $width = defined $9 ? $9 : '';
my $lang = defined $10 ? $10 : '';
my $text = defined $11 ? $11 : '';
my $helptext = defined $12 ? $12 : '';
my $quickhelptext = defined $13 ? $13 : '';
my $title = defined $14 ? $14 : '';
my $timestamp = defined $15 ? $15 : '';
@path = split ( "\\\\" , $file );
if (defined $path[-3])
{
$key = $path[-3] . "_" . $path[-2] . "_" . $path[-1] . "#" . $gid . ".";
}
else
{
$key = $prj . "_" . $path[-2] . "_" . $path[-1] . "#" . $gid . ".";
}
if (length($lid)) {$key .= $lid . ".";}
if (length($type)) {$key .= $type . ".";}
# replace non-word characters to _ just as in po files in source keys
$key =~ s|[^\w#\./]|_|g;
# ISO 639 private use code
$lang = "qtz";
if ( $text ne "") {$text = makekeyidstr(keyidgen($key . "text"),$text);}
if ( $quickhelptext ne "") {$quickhelptext = makekeyidstr(keyidgen($key . "quickhelptext"),$quickhelptext);}
if ( $title ne "") {$title = makekeyidstr(keyidgen($key . "title"),$title);}
print OUTFILE "$prj\t$file\t$dummy\t$type\t$gid\t$lid\t$helpid\t$platform\t$width\t$lang\t$text\t$helptext\t$quickhelptext\t$title\t$timestamp\n";
}
}
close INFILE;
close OUTFILE;
sub keyidgen
{
my $key = shift;
my $crc = crc24($key);
my $symbols="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#_";
my $keyid = "";
while ( length($keyid) < 4 )
{
$keyid .= substr($symbols, $crc & 63, 1);
$crc = $crc >> 6;
}
return $keyid;
}
sub crc24
{
my $CRC24_INIT = 0x00b704ce;
my $CRC24_POLY = 0x00864cfb;
my $key = shift;
my $key_length = length($key);
my $crc = $CRC24_INIT;
my $position = 0;
while ( $position < $key_length )
{
$crc ^= (unpack("C", substr($key, $position, 1)) << 16);
my $i;
for ($i = 0; $i < 8; $i++)
{
$crc <<= 1;
$crc ^= $CRC24_POLY if ($crc & 0x01000000)
}
$position++;
}
return $crc & 0x00ffffff;
}
sub makekeyidstr
{
my $keyid = shift;
my $str = shift;
if ( $str ne "" )
{
# special handling for strings starting with font descriptions like {&Tahoma8} (win system integration)
if ( $str =~ s/^(\{[\&\\][^\}]+\})// )
{
return "$1$keyid‖$str";
}
else
{
return "$keyid‖$str";
}
}
else
{
return "";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment