|
Last change
on this file since b30c30d was
5f4d9c3,
checked in by Maciej Prill <mprill@…>, 14 years ago
|
|
Rewritten the build system, added lem UTF-8 version.
|
-
Property mode set to
100755
|
|
File size:
2.0 KB
|
| Line | |
|---|
| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | #package: UAM Text Tools |
|---|
| 4 | #component: kot |
|---|
| 5 | #version: 1.0 |
|---|
| 6 | #author: Tomasz Obrebski |
|---|
| 7 | |
|---|
| 8 | use strict; |
|---|
| 9 | use Getopt::Long; |
|---|
| 10 | use File::HomeDir; |
|---|
| 11 | |
|---|
| 12 | my $help=0; |
|---|
| 13 | my $gap_fill="\n-----\n"; |
|---|
| 14 | my $spaces=0; |
|---|
| 15 | |
|---|
| 16 | my $systemconfigfile='/usr/local/etc/utt/kot.conf'; |
|---|
| 17 | #my $userconfigfile="$ENV{'HOME'}/.utt/kot.conf"; |
|---|
| 18 | my $userconfigfile=home()."/.utt/kot.conf"; |
|---|
| 19 | |
|---|
| 20 | #read configuration files########################### |
|---|
| 21 | my $file; |
|---|
| 22 | foreach $file ($systemconfigfile, $userconfigfile){ |
|---|
| 23 | if(open(CONFIG, $file)){ |
|---|
| 24 | while (<CONFIG>) { |
|---|
| 25 | chomp; |
|---|
| 26 | s/#.*//; |
|---|
| 27 | s/^\s+//; |
|---|
| 28 | s/\s+$//; |
|---|
| 29 | next unless length; |
|---|
| 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 | } |
|---|
| 40 | |
|---|
| 41 | } |
|---|
| 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. |
|---|
| 58 | --spaces -r |
|---|
| 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+)/; |
|---|
| 80 | |
|---|
| 81 | if($start > $prevend) |
|---|
| 82 | { |
|---|
| 83 | print $gap_fill unless $count++ == 0; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | $prevend=$start+$len; |
|---|
| 87 | |
|---|
| 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.