2 eval 'exec perl -wS $0 ${1+"$@"}'
5 # This file is part of the LibreOffice project.
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # This file incorporates work covered by the following license notice:
13 # Licensed to the Apache Software Foundation (ASF) under one or more
14 # contributor license agreements. See the NOTICE file distributed
15 # with this work for additional information regarding copyright
16 # ownership. The ASF licenses this file to you under the Apache
17 # License, Version 2.0 (the "License"); you may not use this file
18 # except in compliance with the License. You may obtain a copy of
19 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 my $target_format = "";
26 parameter_parse
(@ARGV);
27 print "@filelist\n" if ( $debug );
28 foreach my $onefile ( @filelist ) {
29 convert_file
( $onefile );
36 if ( $target_format eq "dos" ) {
41 open INFILE
, "$filename"or die "ERROR: Couldn\'t open $filename for reading.\n";
45 foreach my $oneline ( @lines ) {
46 $oneline =~ s/\r*\n*$/$lineend/;
49 open OUTFILE
, ">$filename" or die "ERROR: Couldn\'t open $filename for writing.\n";
50 syswrite OUTFILE
, join "", @lines;
57 if ( $target_format eq "" ) {
58 $target_format = shift ;
59 usage
() if ( $target_format ne "unix" && $target_format ne "dos" );
60 usage
() if ( $#_ == -1 );
62 foreach my $param ( @_ ) {
63 if ( $param =~ "^@" ) {
64 my $filename = $param;
66 open CMDFILE
, "$filename" or die "ERROR: Couldn\'t open $filename for reading.\n";
67 my @filelist = <CMDFILE
>;
69 parameter_parse
( @filelist );
71 push @filelist, $param;
78 print "Convert text files to the desired lineend convention:\n";
79 print "$0 <unix|dos> <FILE|\@filelist> [more files/lists]\n";