2 eval 'exec perl -wS $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2000, 2010 Oracle and/or its affiliates.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # This file is part of OpenOffice.org.
14 # OpenOffice.org is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU Lesser General Public License version 3
16 # only, as published by the Free Software Foundation.
18 # OpenOffice.org is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU Lesser General Public License version 3 for more details
22 # (a copy is included in the LICENSE file that accompanied this code).
24 # You should have received a copy of the GNU Lesser General Public License
25 # version 3 along with OpenOffice.org. If not, see
26 # <http://www.openoffice.org/license.html>
27 # for a copy of the LGPLv3 License.
29 #*************************************************************************
44 my $last_localize_file;
50 $SIG{INT
} = 'inthandler';
51 $SIG{QUIT
} = 'quithandler';
65 my $lock_file = $merge_dir."/lock.mk";
67 read_sdf_file_names
();
80 $reference = getNextIdentifier
( );
85 if( $_->module eq $reference->module && $_->dir eq $reference->dir )
92 if( $#current+1 ne 0 )
94 ( $path , $localize_file ) = make_paths
();
96 write_buffer
( $path , $localize_file );
101 ##########################################################################################
106 print "WARNING: Lock file '$lock_file' 'found, waiting ....\n";
108 sleep 10 , while( -e
$lock_file && $cnt++ < 180 );
113 print "Writing lock file '$lock_file'\n";
114 open FILE
, ">$lock_file" or die "Can't create lock file '$lock_file'";
115 print FILE
"L10N_LOCK=YES" ;
121 print "Deleting lock file '$lock_file'\n";
122 unlink $lock_file, if( -e
$lock_file );
127 release_lock
() , if( $state eq "locked" );
132 release_lock
() , if( $state eq "locked" );
138 foreach my $file ( @file_names )
140 my $obj = new sdf_obj
;
141 open my $FILEHANDLE , "<$file" or die "Can't open file '$file'";
142 $obj->FILEHANDLE ( $FILEHANDLE ) ;
143 getNextSdfObj
( $obj );
145 print "Open file '$file'\n";
149 # get the next module/file
150 sub getNextIdentifier
153 return $a->module.$a->dir cmp $b->module.$b->dir;
155 return shift @sorted;
158 # update the obj with the next line
162 my $line = readline ( $obj->FILEHANDLE );
163 if ( $line eq undef )
165 $obj->endoffile( "true" );
169 $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 ;
170 if( defined $1 && defined $2 && defined $3 )
175 $obj->dir ( getDir
( $3 ) );
187 sub getNextSdfObjModule
190 while( !$obj->endoffile )
192 my $line = readline ( $obj->FILEHANDLE );
193 if ( $line eq undef )
195 $obj->endoffile( "true" );
199 $line =~ /^(([^\t]*)\t([^\t]*).*)/o ;
200 if( defined $1 && defined $2 && defined $3 )
205 $obj->dir ( getDir
( $3 ) );
214 return $obj , if( $obj->module eq $module_name )
223 my @tmp_path = split /\\/ , $path;
225 $path = join '\\' , @tmp_path;
235 push @tmpfiles , $_, if( !$_->endoffile );
243 my $localizeFile = $merge_dir."\\".$current[ 0 ]->module."\\".$current[ 0 ]->file;
244 my $path = getDir
( $localizeFile );
247 $localizeFile = $path."/localize.sdf";
249 return ( $path , $localizeFile );
255 my( $path , $localize_file ) = make_paths
();
257 $last_localize_file = $localize_file;
259 write_buffer
( $path , $localize_file );
264 return , if ( $#current+1 eq 0 );
265 my( $path , $localize_file ) = make_paths
();
266 if( $path eq $last_path )
273 write_buffer
( $last_path , $last_localize_file );
276 $last_localize_file = $localize_file;
285 foreach my $elem ( @current )
288 $amodule=$elem->module;
290 $plainline=$elem->line;
291 push @buffer, $plainline;
292 getNextSdfObj
( $elem );
293 } while ( !$elem->endoffile && $amodule eq $elem->module && $afile eq $elem->file );
299 my $localize_file = shift;
300 my $cnt = $#buffer+1;
301 print "Write to $path $cnt lines\n";
302 open FILE
, ">>$localize_file" or die "Can't open file '$localize_file'\n";
311 my $success = GetOptions
( 'sdf_files=s' => \
$sdf_filename , 'merge_dir=s' => \
$merge_dir ); #, 'module=s' => \$module_name );
312 if( ! ( $sdf_filename && $merge_dir && $success ) )
321 print "Usage: fast_merge -sdf_files <file containing sdf file names> -merge_dir <directory>\n" ;
324 sub read_sdf_file_names
326 open FILE
, "<$sdf_filename" or die "Can't open file '$sdf_filename'\n";
329 push @file_names , split " " , $_ ;