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 #*************************************************************************
30 # Description: Wrapper script to change '/' to '\' in command-line
33 #---------------------------------------------------------------------------
40 #---------------------------------------------------------------------------
44 #----------------------------------------------------------
45 # Function name: WinFormat
46 # Description: Format variables to Windows Format.
47 # Arguments: 1. Variable (string) with one token
48 # Return value: Reformatted String
49 #----------------------------------------------------------
51 my $variable = shift @_;
53 $variable =~ s!(.)/!$1\\!g; # Replace all but the leading slashes with backslashes
55 if ( defined $debug ) {
56 print(STDERR
"WinFormat:\nresult:$variable\n");
62 #----------------------------------------------------------
63 # Function name: replace_cyg
64 # Description: Process all arguments and change them to Windows Format.
65 # Arguments: Reference to array with arguments
67 #----------------------------------------------------------
70 my( @cmd_file, @cmd_temp );
72 foreach my $para ( @
$args ) {
73 if ( $para =~ "^@" ) {
75 if ( defined $debug ) {
76 print(STDERR
"----------------------------\n");
79 # Workaround, iz28717, keep number of @'s.
83 if ( defined $debug ) {
84 print(STDERR
"filename = $filename \n");
87 # open this command file for reading
88 open(CMD
, "$filename");
90 # Remove DOS lineendings. Bug in Cygwin / Perl?
92 # Remove lineendings and trailing spaces. ( Needed by &parse_line )
95 # Fill all tokens into array
96 @cmd_temp = &parse_line
('\s+', 1, $_ );
97 if ( $#cmd_temp > -1 ) {
98 push( @cmd_file, @cmd_temp);
102 # reformat all tokens
103 replace_cyg
(\
@cmd_file);
104 if ( defined $debug ) {
105 print(STDERR
"Tokens processed:\n");
108 foreach $i (@cmd_file) {
109 if ( defined $debug ) {
110 print(STDERR
"!".$i."!\n");
114 # open this filename for writing (truncate) Textmode?
115 open(CMD
, '>', $filename);
116 # write all tokens back into this file
117 print(CMD
join(' ', @cmd_file));
119 # convert '@filename' to dos style
120 $para = WinFormat
( $para );
121 if ( defined $debug ) {
122 print(STDERR
"----------------------------\n");
125 if ( (defined $debug_light) or (defined $debug) ) {
126 print(STDERR
"\nParameter in File:".join(' ', @cmd_file).":\n");
128 $para = $atchars.$para;
130 # it's just a parameter
131 if ( defined $debug ) {
132 print(STDERR
"\nParameter:---${para}---\n");
135 # If $tmp1 is empty then $para is a parameter.
137 # remove .exe and convert to lower case
138 $shortcommand = lc $command ;
139 $shortcommand =~ s/\.exe$//;
140 $shortcommand =~ /([^\/]+$)/;
143 $para = WinFormat
($para);
145 if ( defined $debug ) {
146 print(STDERR
"Converted line:${para}:\n" );
153 #---------------------------------------------------------------------------
157 $command = shift(@params);
159 while ( $command =~ /^-/ )
161 if ( $command eq "-dbg" ) {
164 elsif ( $command eq "-ldbg" ) {
168 $command = shift(@params);
171 if ( (defined $debug_light) or (defined $debug) ) { print( STDERR
"Command: $command\n" ); }
173 replace_cyg
(\
@params);
174 if ( (defined $debug_light) or (defined $debug) ) { print(STDERR
"\n---------------------\nExecute: $command @params\n----------------\n");};
175 exec( "$command", @params) or die( "\nError: slfl.pl: executing $command failed!\n" );