1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: modules.pl,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 my $completelangiso_var = $ENV{COMPLETELANGISO_VAR
};
33 my $lastcompletelangiso_var = "";
37 my $globalcounter = 0;
38 my $globallinecounter = 0;
40 if ( !defined $completelangiso_var) {
41 print STDERR
"ERROR: No language defined!\n";
47 # if ( "$completelangiso_var" eq "$lastcompletelangiso_var" ) {
48 # print STDERR "No new languages. Keeping old file\n";
52 my @completelangiso = split " +", $completelangiso_var;
54 open OUTFILE
, ">$outfile" or die "$0 ERROR: cannot open $outfile for writing!\n";
55 print OUTFILE
"// generated file, do not edit\n\n";
56 print OUTFILE
"// languages used for last time generation\n";
57 print OUTFILE
"// completelangiso: $completelangiso_var\n\n";
64 print STDERR
"Wrote modules for $globalcounter languages ($globallinecounter lines)!\n";
65 if ( $globalcounter == 0 )
67 print STDERR
"ERROR: No languages found!\n";
71 if ( $globallinecounter == 0 )
73 print STDERR
"ERROR: No lines written!\n";
83 my $linecount = $#infile + 1;
84 # print STDERR "Lines in inputfile: $linecount!\n";
86 foreach $lang (@completelangiso) {
90 $languagebig_ = uc($lang);
91 $languagebig_ =~ s/-/_/;
93 my $sortkey = 100 * $counter;
95 for ( $i = 0; $i <= $#infile; $i++) {
96 my $line = $infile[$i];
97 if (( $line =~ /^\s*\*/ ) || ( $line =~ /^\s*\/\
*/ )) { next; }
98 $line =~ s/\<LANGUAGE\>/$language/g;
99 $line =~ s/\<LANGUAGE_\>/$language_/g;
100 $line =~ s/\<LANGUAGEBIG_\>/$languagebig_/g;
101 $line =~ s/\<SORTKEY\>/$sortkey/g;
109 $globalcounter = $counter;
110 $globallinecounter = $linecounter;
116 for ( $i=0; $i <= $#ARGV; $i++) {
117 if ( "$ARGV[$i]" eq "-o" ) {
118 if ( defined $ARGV[ $i + 1] ) {
119 $outfile = $ARGV[ $i + 1];
122 } elsif ( "$ARGV[$i]" eq "-i" ) {
123 if ( defined $ARGV[ $i + 1] ) {
124 $infile = $ARGV[ $i + 1];
133 usage
() if "$outfile" eq "";
134 usage
() if "$infile" eq "";
136 if ( -f
"$infile" ) {
137 open INFILE
, "$infile" or die "$0 - ERROR: $infile exists but isn't readable.\n";
140 print STDERR
"Reading template file: $infile\n";
141 my $num = $#infile + 1;
142 # print STDERR "Number of lines: $num\n";
144 die "Template file \"$infile\" not found!\n";
148 if ( -f
"$outfile" ) {
149 # changed script - run always
150 return if (stat($0))[9] > (stat("$outfile"))[9] ;
151 # changed template file - run always
152 return if (stat($infile))[9] > (stat("$outfile"))[9] ;
154 open OLDFILE
, "$outfile" or die "$0 - ERROR: $outfile exists but isn't readable.\n";
155 while ( $line = <OLDFILE
> ) {
156 if ( $line =~ /^\/\
/.*completelangiso:/ ) {
157 $lastcompletelangiso_var = $line;
158 chomp $lastcompletelangiso_var;
159 $lastcompletelangiso_var =~ s/^\/\/.*completelangiso
:\s
*//;
170 print STDERR
"Generate language modules from language script particle template (*.sct file)\n";
171 print STDERR
"perl $0 -o outputfile -i inputfile\n";