update credits
[LibreOffice.git] / solenv / bin / leconvert.pl
blob04333058c40d2885b6d52008c047ddc9a930f76d
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
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 = "";
22 my @filelist;
23 #my $debug=1;
24 my $debug=0;
26 parameter_parse(@ARGV);
27 print "@filelist\n" if ( $debug );
28 foreach my $onefile ( @filelist ) {
29 convert_file( $onefile );
33 sub convert_file
35 my $filename = shift;
36 if ( $target_format eq "dos" ) {
37 $lineend = "\r\n";
38 } else {
39 $lineend = "\n";
41 open INFILE, "$filename"or die "ERROR: Couldn\'t open $filename for reading.\n";
42 my @lines = <INFILE>;
43 close INFILE;
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;
51 close OUTFILE;
55 sub parameter_parse
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;
65 $filename =~ s/^@//;
66 open CMDFILE, "$filename" or die "ERROR: Couldn\'t open $filename for reading.\n";
67 my @filelist = <CMDFILE>;
68 close CMDFILE;
69 parameter_parse( @filelist );
70 } else {
71 push @filelist, $param;
76 sub usage
78 print "Convert text files to the desired lineend convention:\n";
79 print "$0 <unix|dos> <FILE|\@filelist> [more files/lists]\n";
80 exit 1;