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;
41 if ( !defined $completelangiso_var) {
42 print STDERR
"ERROR: No language defined!\n";
48 # if ( "$completelangiso_var" eq "$lastcompletelangiso_var" ) {
49 # print STDERR "No new languages. Keeping old file\n";
53 my @completelangiso = split " +", $completelangiso_var;
55 open OUTFILE
, ">$outfile" or die "$0 ERROR: cannot open $outfile for writing!\n";
56 print OUTFILE
"// generated file, do not edit\n\n";
57 print OUTFILE
"// languages used for last time generation\n";
58 print OUTFILE
"// completelangiso: $completelangiso_var\n\n";
65 print STDERR
"Wrote modules for $globalcounter languages ($globallinecounter lines)!\n";
66 if ( $globalcounter == 0 )
68 print STDERR
"ERROR: No languages found!\n";
72 if ( $globallinecounter == 0 )
74 print STDERR
"ERROR: No lines written!\n";
84 my $linecount = $#infile + 1;
85 # print STDERR "Lines in inputfile: $linecount!\n";
87 foreach $lang (@completelangiso) {
91 $languagebig_ = uc($lang);
92 $languagebig_ =~ s/-/_/;
94 my $sortkey = 100 * $counter;
96 for ( $i = 0; $i <= $#infile; $i++) {
97 my $line = $infile[$i];
98 if (( $line =~ /^\s*\*/ ) || ( $line =~ /^\s*\/\
*/ )) { next; }
99 $line =~ s/\<LANGUAGE\>/$language/g;
100 $line =~ s/\<LANGUAGE_\>/$language_/g;
101 $line =~ s/\<LANGUAGEBIG_\>/$languagebig_/g;
102 $line =~ s/\<SORTKEY\>/$sortkey/g;
110 $globalcounter = $counter;
111 $globallinecounter = $linecounter;
117 for ( $i=0; $i <= $#ARGV; $i++) {
118 if ( "$ARGV[$i]" eq "-o" ) {
119 if ( defined $ARGV[ $i + 1] ) {
120 $outfile = $ARGV[ $i + 1];
123 } elsif ( "$ARGV[$i]" eq "-i" ) {
124 if ( defined $ARGV[ $i + 1] ) {
125 $infile = $ARGV[ $i + 1];
134 usage
() if "$outfile" eq "";
135 usage
() if "$infile" eq "";
137 if ( -f
"$infile" ) {
138 open INFILE
, "$infile" or die "$0 - ERROR: $infile exists but isn't readable.\n";
141 print STDERR
"Reading template file: $infile\n";
142 my $num = $#infile + 1;
143 # print STDERR "Number of lines: $num\n";
145 die "Template file \"$infile\" not found!\n";
149 if ( -f
"$outfile" ) {
150 # changed script - run always
151 return if (stat($0))[9] > (stat("$outfile"))[9] ;
152 # changed template file - run always
153 return if (stat($infile))[9] > (stat("$outfile"))[9] ;
155 open OLDFILE
, "$outfile" or die "$0 - ERROR: $outfile exists but isn't readable.\n";
156 while ( $line = <OLDFILE
> ) {
157 if ( $line =~ /^\/\
/.*completelangiso:/ ) {
158 $lastcompletelangiso_var = $line;
159 chomp $lastcompletelangiso_var;
160 $lastcompletelangiso_var =~ s/^\/\/.*completelangiso
:\s
*//;
171 print STDERR
"Generate language modules from language script particle template (*.sct file)\n";
172 print STDERR
"perl $0 [-verbose] -o outputfile -i inputfile\n";