3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 # langwrap - language wrapper for building resources
34 print "langwrap -- Version: 1.2\n";
40 &parse_commandfile
($opt_c);
42 # create list with command lines
45 # finally execute commands
46 foreach $cmd (@command) {
53 print "langwrap: command execution failed with exitcode $res.\n";
61 ###### routines ######
63 ### parse_commandfile()
64 sub parse_commandfile
{
68 open(COMMAND
, "<$file") or die "canĀ“t open $file";
73 if ( ($line =~ //) || ($line =~ /^\r/) || ($line =~ /^#/) ) {
77 @field = split " ", $line;
80 $nfield = $#field + 1;
82 if ( $nfield != ($#field + 1) ) {
83 print "langwrap: error in <cmdfile>: every row must ";
84 print "have the same # of columns.\n";
94 sub create_commands
() {
95 my($cmd, $cmdline, $arg_string, $ntempl);
98 $arg_string = join(" ", @ARGV);
99 # just count the number of templates
100 $ntempl = ($arg_string =~ s/@\d+@/$&/eg);
101 if ( $ntempl >= $nfield ) {
102 print "lnagwrap: # of templates > # of fields in <cmdfile>.\n";
106 # create command lines
108 $cmdline = $arg_string;
109 $cmdline =~ s/@(\d+)@/$LoL[$i][$1]/eg;
110 push @command, $cmd . " " . $cmdline;
117 if ( !getopts
('c:') ) {
126 print "langwrap: $opt_c is not a readable file.\n";
131 print "langwrap: empty <template_string>.\n";
138 print "Usage: langwrap -c cmdfile tool <template_string>\n";
139 print "<template_string> is of form: ...\@1\@ .... \@2\@...\n";
140 print "with \@<n>\@ template #n\n";