/usr/share/perl5/Cz/Cstocs/Getopt.pm is in cstocs 1:3.42-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | package Cz::Cstocs::Getopt;
use strict;
use Cz::Cstocs;
use Getopt::Long;
sub usage {
print_version();
print STDERR <<EOF;
Usage: cstocs [options] inputencoding outputencoding [ files ... ]
where options can be
-i[.ext] In-place substitution; must be the first parameter.
--dir=string Alternate directory with encoding and accent files.
--fillstring=str String that will replace unconvertable characters,
the default is one space.
--null Equivalent to --fillstring=""
--nofillstring Keep unconvertable unconverted.
--onebymore Use all entries from the accent file (the default).
--onebyone Use only one-by-one character rules from accent file.
--nochange, --noaccent Do not use accent file at all.
--version Print out the version information.
--debug Print out debugging info while processing.
Input and output encodings can also be specified using --inputencoding
and --outputencoding options. See man page for detailed description.
Available encodings are:
@{[ &Cz::Cstocs::available_enc() ]}
EOF
exit;
}
sub print_version {
print STDERR "This is cstocs version $Cz::Cstocs::VERSION.\n";
}
sub process_argv {
my $getopt_config_hashref = shift;
my %options;
my $options = \%options;
$getopt_config_hashref = {} unless defined $getopt_config_hashref;
for my $key (keys %$getopt_config_hashref) {
my $value = $getopt_config_hashref->{$key};
### print "Key $key -> $value\n";
$getopt_config_hashref->{$key} = \$options{$value}
unless ref $value;
}
my %getopt_config = (
'null' => sub { $options{'fillstring'} = ''; },
'fillstring=s' => \$options{'fillstring'},
'nofillstring' => sub { $options{'nofillstring'} = 1 },
'usefillstring' => sub { $options{'nofillstring'} = 0 },
'onebyone' => sub { $options{'one_by_one'} = 1; },
'onebymore' => sub { $options{'one_by_one'} = 0; },
'noaccent', sub { $options{'use_accent'} = 0; },
'nochange', sub { $options{'use_accent'} = 0; },
'dir=s' => \$options{'cstocsdir'},
'inputencoding=s' => \$options{'inputenc'},
'outputencoding=s' => \$options{'outputenc'},
'help' => \&usage,
'version' => sub { print_version(); exit 0; },
'debug' => sub { $Cz::Cstocs::DEBUG = 1; },
%$getopt_config_hashref
);
if (grep { /--/ } @ARGV) {
Getopt::Long::GetOptions(%getopt_config);
} elsif (@ARGV < 2) {
usage();
}
my ($inputenc, $outputenc);
if (defined $options{'inputenc'}) {
$inputenc = $options{'inputenc'};
delete $options{'inputenc'};
} else {
$inputenc = shift @ARGV;
}
if (defined $options{'outputenc'}) {
$outputenc = $options{'outputenc'};
delete $options{'outputenc'};
} else {
$outputenc = shift @ARGV;
}
my $tag;
for $tag (keys %options) {
delete $options{$tag} unless defined $options{$tag};
}
print STDERR "Calling new Cz::Cstocs $inputenc, $outputenc\n" if Cz::Cstocs::DEBUG;
my $convert = new Cz::Cstocs $inputenc, $outputenc, %options;
$options{'inputenc'} = $inputenc;
$options{'outputenc'} = $outputenc;
if (wantarray) {
return ($convert, $options);
}
return $convert;
}
1;
|