2 eval 'exec perl -wS $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: slfl.pl,v $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
34 # Description: Wrapper script to change '/' to '\' in command-line
37 #---------------------------------------------------------------------------
44 #---------------------------------------------------------------------------
48 #----------------------------------------------------------
49 # Function name: WinFormat
50 # Description: Format variables to Windows Format.
51 # Arguments: 1. Variable (string) with one token
52 # Return value: Reformatted String
53 #----------------------------------------------------------
55 my $variable = shift @_;
57 $variable =~ s!(.)/!$1\\!g; # Replace all but the leading slashes with backslashes
59 if ( defined $debug ) {
60 print(STDERR
"WinFormat:\nresult:$variable\n");
66 #----------------------------------------------------------
67 # Function name: replace_cyg
68 # Description: Process all arguments and change them to Windows Format.
69 # Arguments: Reference to array with arguments
71 #----------------------------------------------------------
74 my( @cmd_file, @cmd_temp );
76 foreach my $para ( @
$args ) {
77 if ( $para =~ "^@" ) {
79 if ( defined $debug ) {
80 print(STDERR
"----------------------------\n");
83 # Workaround, iz28717, keep number of @'s.
87 if ( defined $debug ) {
88 print(STDERR
"filename = $filename \n");
91 # open this command file for reading
92 open(CMD
, "$filename");
94 # Remove DOS lineendings. Bug in Cygwin / Perl?
96 # Remove lineendings and trailing spaces. ( Needed by &parse_line )
99 # Fill all tokens into array
100 @cmd_temp = &parse_line
('\s+', 1, $_ );
101 if ( $#cmd_temp > -1 ) {
102 push( @cmd_file, @cmd_temp);
106 # reformat all tokens
107 replace_cyg
(\
@cmd_file);
108 if ( defined $debug ) {
109 print(STDERR
"Tokens processed:\n");
112 foreach $i (@cmd_file) {
113 if ( defined $debug ) {
114 print(STDERR
"!".$i."!\n");
118 # open this filename for writing (truncate) Textmode?
119 open(CMD
, '>', $filename);
120 # write all tokens back into this file
121 print(CMD
join(' ', @cmd_file));
123 # convert '@filename' to dos style
124 $para = WinFormat
( $para );
125 if ( defined $debug ) {
126 print(STDERR
"----------------------------\n");
129 if ( (defined $debug_light) or (defined $debug) ) {
130 print(STDERR
"\nParameter in File:".join(' ', @cmd_file).":\n");
132 $para = $atchars.$para;
134 # it's just a parameter
135 if ( defined $debug ) {
136 print(STDERR
"\nParameter:---${para}---\n");
139 # If $tmp1 is empty then $para is a parameter.
141 # remove .exe and convert to lower case
142 $shortcommand = lc $command ;
143 $shortcommand =~ s/\.exe$//;
144 $shortcommand =~ /([^\/]+$)/;
147 $para = WinFormat
($para);
149 if ( defined $debug ) {
150 print(STDERR
"Converted line:${para}:\n" );
157 #---------------------------------------------------------------------------
161 $command = shift(@params);
163 while ( $command =~ /^-/ )
165 if ( $command eq "-dbg" ) {
168 elsif ( $command eq "-ldbg" ) {
172 $command = shift(@params);
175 if ( (defined $debug_light) or (defined $debug) ) { print( STDERR
"Command: $command\n" ); }
177 replace_cyg
(\
@params);
178 if ( (defined $debug_light) or (defined $debug) ) { print(STDERR
"\n---------------------\nExecute: $command @params\n----------------\n");};
179 exec( "$command", @params) or die( "\nError: slfl.pl: executing $command failed!\n" );