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: leconvert.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 my $target_format = "";
39 parameter_parse
(@ARGV);
40 print "@filelist\n" if ( $debug );
41 foreach my $onefile ( @filelist ) {
42 convert_file
( $onefile );
49 if ( $target_format eq "dos" ) {
54 open INFILE
, "$filename"or die "ERROR: Couldn\'t open $filename for reading.\n";
58 foreach my $oneline ( @lines ) {
59 $oneline =~ s/\r*\n*$/$lineend/;
62 open OUTFILE
, ">$filename" or die "ERROR: Couldn\'t open $filename for writing.\n";
63 syswrite OUTFILE
, join "", @lines;
70 if ( $target_format eq "" ) {
71 $target_format = shift ;
72 usage
() if ( $target_format ne "unix" && $target_format ne "dos" );
73 usage
() if ( $#_ == -1 );
75 foreach my $param ( @_ ) {
76 if ( $param =~ "^@" ) {
77 my $filename = $param;
79 open CMDFILE
, "$filename" or die "ERROR: Couldn\'t open $filename for reading.\n";
80 my @filelist = <CMDFILE
>;
82 parameter_parse
( @filelist );
84 push @filelist, $param;
91 print "Convert text files to the desired lineend convention:\n";
92 print "$0 <unix|dos> <FILE|\@filelist> [more files/lists]\n";