Last change
on this file since 8f395c8 was
3a2ae91,
checked in by Mateusz Hromada <ruanda@…>, 15 years ago
|
Migration to new build system.
|
-
Property mode set to
100644
|
File size:
2.0 KB
|
Rev | Line | |
---|
[25ae32e] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
[20b4e44] | 3 | #package: UAM Text Tools |
---|
| 4 | #component: kot |
---|
| 5 | #version: 1.0 |
---|
| 6 | #author: Tomasz Obrebski |
---|
| 7 | |
---|
[25ae32e] | 8 | use strict; |
---|
| 9 | use Getopt::Long; |
---|
[20b4e44] | 10 | use File::HomeDir; |
---|
[25ae32e] | 11 | |
---|
| 12 | my $help=0; |
---|
| 13 | my $gap_fill="\n-----\n"; |
---|
| 14 | my $spaces=0; |
---|
| 15 | |
---|
[246900a] | 16 | my $systemconfigfile='/usr/local/etc/utt/kot.conf'; |
---|
[20b4e44] | 17 | #my $userconfigfile="$ENV{'HOME'}/.utt/kot.conf"; |
---|
| 18 | my $userconfigfile=home()."/.utt/kot.conf"; |
---|
[25ae32e] | 19 | |
---|
| 20 | #read configuration files########################### |
---|
| 21 | my $file; |
---|
[246900a] | 22 | foreach $file ($systemconfigfile, $userconfigfile){ |
---|
[25ae32e] | 23 | if(open(CONFIG, $file)){ |
---|
| 24 | while (<CONFIG>) { |
---|
[246900a] | 25 | chomp; |
---|
| 26 | s/#.*//; |
---|
| 27 | s/^\s+//; |
---|
| 28 | s/\s+$//; |
---|
| 29 | next unless length; |
---|
[25ae32e] | 30 | my ($name, $value) = split(/\s*=\s*/, $_, 2); |
---|
| 31 | if(($name eq "gap-fill")or($name eq "g")){ |
---|
| 32 | $gap_fill=$value; |
---|
| 33 | } |
---|
| 34 | elsif(($name eq "spaces")or($name eq "s")){ |
---|
| 35 | $spaces=1; |
---|
| 36 | } |
---|
| 37 | elsif(($name eq "help")or($name eq "h")){ |
---|
| 38 | $help=1; |
---|
| 39 | } |
---|
[246900a] | 40 | |
---|
| 41 | } |
---|
[25ae32e] | 42 | close CONFIG; |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | ######################################################### |
---|
| 46 | |
---|
| 47 | GetOptions("gap-fill|g=s" => \$gap_fill, |
---|
| 48 | "spaces|r" => \$spaces, |
---|
| 49 | "help|h" => \$help); |
---|
| 50 | |
---|
| 51 | if($help) |
---|
| 52 | { |
---|
| 53 | print <<'END' |
---|
| 54 | Usage: ser [OPTIONS] [file ..] |
---|
| 55 | |
---|
| 56 | Options: |
---|
| 57 | --gap-fill -g Help. |
---|
[246900a] | 58 | --spaces -r |
---|
[25ae32e] | 59 | --define=FILE Read macrodefinitions from FILE. |
---|
| 60 | --flex-template=FILE Read flex code template from FILE. |
---|
| 61 | --only-matching -m Print only fragments matching PATTERN. |
---|
| 62 | --flex Print only the generated flex code and exit. |
---|
| 63 | END |
---|
| 64 | ; |
---|
| 65 | exit 0; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | $gap_fill =~ s/\\t/\t/g; |
---|
| 70 | $gap_fill =~ s/\\n/\n/g; |
---|
| 71 | $gap_fill =~ s/\\r/\r/g; |
---|
| 72 | $gap_fill =~ s/\\f/\f/g; |
---|
| 73 | |
---|
| 74 | my $prevend=-1; |
---|
| 75 | my $count=0; |
---|
| 76 | |
---|
| 77 | while(<>) |
---|
| 78 | { |
---|
| 79 | my ($start,$len,$type,$form) = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(\S+)/; |
---|
[246900a] | 80 | |
---|
[25ae32e] | 81 | if($start > $prevend) |
---|
| 82 | { |
---|
| 83 | print $gap_fill unless $count++ == 0; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | $prevend=$start+$len; |
---|
[246900a] | 87 | |
---|
[25ae32e] | 88 | next if $len==0;# || $form eq "*"; |
---|
| 89 | |
---|
| 90 | $form =~ s/\\\*/*/g; |
---|
| 91 | |
---|
| 92 | if($type eq 'S' && ! $spaces) |
---|
| 93 | { |
---|
| 94 | $form =~ s/_/ /g; |
---|
| 95 | $form =~ s/\\t/\t/g; |
---|
| 96 | $form =~ s/\\n/\n/g; |
---|
| 97 | $form =~ s/\\r/\r/g; |
---|
| 98 | $form =~ s/\\f/\f/g; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | print $form; |
---|
| 102 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.