Fixes bug 162436: Off-by-one in substring

This commit is contained in:
Abdulaziz Ghuloum 2007-11-13 12:21:27 -05:00
parent 820d1716be
commit a0ba3d3d4f
5 changed files with 33 additions and 10 deletions

View File

@ -8534,3 +8534,23 @@ Words allocated: 36171538
Words reclaimed: 0
Elapsed time...: 5849 ms (User: 5815 ms; System: 31 ms)
Elapsed GC time: 83 ms (CPU: 86 in 138 collections.)
****************************
Benchmarking Larceny-r6rs on Tue Nov 13 03:44:36 EST 2007 under Darwin Vesuvius.local 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386 i386 i386
Testing ray under Larceny-r6rs
Compiling...
Larceny v0.95 "First Safety" (Nov 8 2007 04:30:20, precise:BSD Unix:unified)
larceny.heap, built on Thu Nov 8 04:39:44 EST 2007
>
>
Running...
Larceny v0.95 "First Safety" (Nov 8 2007 04:30:20, precise:BSD Unix:unified)
larceny.heap, built on Thu Nov 8 04:39:44 EST 2007
>
Words allocated: 220925448
Words reclaimed: 0
Elapsed time...: 20757 ms (User: 10967 ms; System: 9775 ms)
Elapsed GC time: 179 ms (CPU: 176 in 843 collections.)

View File

@ -163,7 +163,7 @@
(define peval-iters 400)
(define pi-iters 3)
(define primes-iters 180000)
(define ray-iters 3)
(define ray-iters 5)
(define scheme-iters 40000)
(define simplex-iters 160000)
(define slatex-iters 30)

View File

@ -64,16 +64,16 @@ foreach my $bench (@benchmarks){
foreach my $time (@times){
defined $runtimes{$bench}{$time} or next;
my @times = @{$runtimes{$bench}{$time}};
my $avg = average(@times);
my $t = min(@times);
if($prev){
my $diff = (($avg - $prev) / $prev) * 100;
my $diff = (($t - $prev) / $prev) * 100;
printf " %6d %6s on $time\n",
$avg,
$t,
sprintf("(%s%d%%)", ($diff>0) ? "+" : ($diff<0) ? "-" : "", abs $diff);
} else {
printf " %6d on $time\n", $avg;
printf " %6d on $time\n", $t;
}
$prev = $avg;
$prev = $t;
}
}

View File

@ -191,6 +191,7 @@
(fx> b0 127)))
(define ($flonum->exact x)
;;; this really needs to get optimized.
(let-values ([(pos? be m) (flonum-parts x)])
(cond
[(<= 1 be 2046) ; normalized flonum

View File

@ -125,16 +125,18 @@
(let ([len ($string-length s)])
(unless (and (fixnum? n)
($fx>= n 0)
($fx< n len))
($fx<= n len))
(error 'substring "not a valid start index" n s))
(unless (and (fixnum? m)
($fx>= m 0)
($fx<= m len))
(error 'substring "not a valid end index" m s))
(unless ($fx<= n m)
(error 'substring "indices are in decreasing order" n m))
(let ([len ($fx- m n)])
(if ($fx<= len 0)
""
(fill s ($make-string len) n m 0)))))))
(if ($fx> len 0)
(fill s ($make-string len) n m 0)
""))))))
(define string-copy
(lambda (s)