help
| Line | |
|---|
| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use Getopt::Long; |
|---|
| 5 | |
|---|
| 6 | my $help=0; |
|---|
| 7 | my $gap_fill="\n-----\n"; |
|---|
| 8 | my $spaces=0; |
|---|
| 9 | |
|---|
| 10 | my $configfile1="../../conf/kot.conf"; |
|---|
| 11 | my $configfile2="../conf/kot.conf"; |
|---|
| 12 | |
|---|
| 13 | #read configuration files########################### |
|---|
| 14 | my $file; |
|---|
| 15 | foreach $file ($configfile1, $configfile2){ |
|---|
| 16 | if(open(CONFIG, $file)){ |
|---|
| 17 | while (<CONFIG>) { |
|---|
| 18 | chomp; |
|---|
| 19 | s/#.*//; |
|---|
| 20 | s/^\s+//; |
|---|
| 21 | s/\s+$//; |
|---|
| 22 | next unless length; |
|---|
| 23 | my ($name, $value) = split(/\s*=\s*/, $_, 2); |
|---|
| 24 | if(($name eq "gap-fill")or($name eq "g")){ |
|---|
| 25 | $gap_fill=$value; |
|---|
| 26 | } |
|---|
| 27 | elsif(($name eq "spaces")or($name eq "s")){ |
|---|
| 28 | $spaces=1; |
|---|
| 29 | } |
|---|
| 30 | elsif(($name eq "help")or($name eq "h")){ |
|---|
| 31 | $help=1; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | } |
|---|
| 35 | close CONFIG; |
|---|
| 36 | } |
|---|
| 37 | } |
|---|
| 38 | ######################################################### |
|---|
| 39 | |
|---|
| 40 | GetOptions("gap-fill|g=s" => \$gap_fill, |
|---|
| 41 | "spaces|r" => \$spaces, |
|---|
| 42 | "help|h" => \$help); |
|---|
| 43 | |
|---|
| 44 | if($help) |
|---|
| 45 | { |
|---|
| 46 | print <<'END' |
|---|
| 47 | Usage: ser [OPTIONS] [file ..] |
|---|
| 48 | |
|---|
| 49 | Options: |
|---|
| 50 | --gap-fill -g Help. |
|---|
| 51 | --spaces -r |
|---|
| 52 | --define=FILE Read macrodefinitions from FILE. |
|---|
| 53 | --flex-template=FILE Read flex code template from FILE. |
|---|
| 54 | --only-matching -m Print only fragments matching PATTERN. |
|---|
| 55 | --flex Print only the generated flex code and exit. |
|---|
| 56 | END |
|---|
| 57 | ; |
|---|
| 58 | exit 0; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | $gap_fill =~ s/\\t/\t/g; |
|---|
| 63 | $gap_fill =~ s/\\n/\n/g; |
|---|
| 64 | $gap_fill =~ s/\\r/\r/g; |
|---|
| 65 | $gap_fill =~ s/\\f/\f/g; |
|---|
| 66 | |
|---|
| 67 | my $prevend=-1; |
|---|
| 68 | my $count=0; |
|---|
| 69 | |
|---|
| 70 | while(<>) |
|---|
| 71 | { |
|---|
| 72 | my ($start,$len,$type,$form) = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(\S+)/; |
|---|
| 73 | |
|---|
| 74 | if($start > $prevend) |
|---|
| 75 | { |
|---|
| 76 | print $gap_fill unless $count++ == 0; |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | $prevend=$start+$len; |
|---|
| 80 | |
|---|
| 81 | next if $len==0;# || $form eq "*"; |
|---|
| 82 | |
|---|
| 83 | $form =~ s/\\\*/*/g; |
|---|
| 84 | |
|---|
| 85 | if($type eq 'S' && ! $spaces) |
|---|
| 86 | { |
|---|
| 87 | $form =~ s/_/ /g; |
|---|
| 88 | $form =~ s/\\t/\t/g; |
|---|
| 89 | $form =~ s/\\n/\n/g; |
|---|
| 90 | $form =~ s/\\r/\r/g; |
|---|
| 91 | $form =~ s/\\f/\f/g; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | print $form; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | #print $gap_fill; |
|---|
| 98 | |
|---|
| 99 | # print "\n"; |
|---|
Note: See
TracBrowser
for help on using the repository browser.