diff options
author | Larry Wall <lwall@jpl-devvax.jpl.nasa.gov> | 1990-02-28 21:55:09 +0000 |
---|---|---|
committer | Larry Wall <lwall@jpl-devvax.jpl.nasa.gov> | 1990-02-28 21:55:09 +0000 |
commit | ac58e20f744208e9bff2115708a2f1c4e2e2175f (patch) | |
tree | 1610ffeb1ed9dc24b5bf864c012a6d9fe7ac6720 /lib | |
parent | afd9f252e30d37007c653bd21680f0b5f6c32608 (diff) | |
download | perl-ac58e20f744208e9bff2115708a2f1c4e2e2175f.tar.gz |
perl 3.0 patch #11 patch #9, continued
See patch #9.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/getopt.pl | 3 | ||||
-rw-r--r-- | lib/getopts.pl | 7 | ||||
-rw-r--r-- | lib/look.pl | 14 |
3 files changed, 14 insertions, 10 deletions
diff --git a/lib/getopt.pl b/lib/getopt.pl index b85b643e22..93acafc5bf 100644 --- a/lib/getopt.pl +++ b/lib/getopt.pl @@ -1,4 +1,4 @@ -;# $Header: getopt.pl,v 3.0 89/10/18 15:19:26 lwall Locked $ +;# $Header: getopt.pl,v 3.0.1.1 90/02/28 17:41:59 lwall Locked $ ;# Process single-character switches with switch clustering. Pass one argument ;# which is a string containing all switches that take an argument. For each @@ -12,6 +12,7 @@ sub Getopt { local($argumentative) = @_; local($_,$first,$rest); + local($[) = 0; while (($_ = $ARGV[0]) =~ /^-(.)(.*)/) { ($first,$rest) = ($1,$2); diff --git a/lib/getopts.pl b/lib/getopts.pl index 7effafa195..4ed3a053f9 100644 --- a/lib/getopts.pl +++ b/lib/getopts.pl @@ -6,7 +6,8 @@ sub Getopts { local($argumentative) = @_; - local(@args,$_,$first,$rest); + local(@args,$_,$first,$rest,$errs); + local($[) = 0; @args = split( / */, $argumentative ); while(($_ = $ARGV[0]) =~ /^-(.)(.*)/) { @@ -31,7 +32,8 @@ sub Getopts { } } else { - print stderr "Unknown option: $first\n"; + print STDERR "Unknown option: $first\n"; + ++$errs; if($rest ne '') { $ARGV[0] = "-$rest"; } @@ -40,6 +42,7 @@ sub Getopts { } } } + $errs == 0; } 1; diff --git a/lib/look.pl b/lib/look.pl index ebbaa73a3d..6eef43983b 100644 --- a/lib/look.pl +++ b/lib/look.pl @@ -11,13 +11,11 @@ sub look { $blksize = 8192 unless $blksize; $key =~ s/[^\w\s]//g if $dict; $key =~ y/A-Z/a-z/ if $fold; - $max = $size + $blksize - 1; - $max -= $size % $blksize; - while ($max - $min > $blksize) { - $mid = ($max + $min) / 2; - die "look: internal error" if $mid % $blksize; - seek(FH,$mid,0); - $_ = <FH>; # probably a partial line + $max = int($size / $blksize); + while ($max - $min > 1) { + $mid = int(($max + $min) / 2); + seek(FH,$mid * $blksize,0); + $_ = <FH> if $mid; # probably a partial line $_ = <FH>; chop; s/[^\w\s]//g if $dict; @@ -29,7 +27,9 @@ sub look { $max = $mid; } } + $min *= $blksize; seek(FH,$min,0); + <FH> if $min; while (<FH>) { chop; s/[^\w\s]//g if $dict; |