pnkfelix / larceny-test

test import of trac db
Other
2 stars 0 forks source link

fencepost error in get-string-n #523

Closed larceny-trac-import closed 11 years ago

larceny-trac-import commented 11 years ago

_Reported by: will on Thu Feb 7 10:16:52 2008 _ As reported by Ray Racine.

There is a fence post bug in get-string-n in portio.sch. The do loop reads a char on loop initialization and then one for count iterations. Therefore one more then count chars are consumed in the call to get-string-n.

See sample below. Notice '5' was skipped.

Larceny v0.961 "Fluoridation" (Feb  4 2008 23:49:20,
precise:Linux:unified)
larceny.heap, built on Mon Feb  4 23:53:29 EST 2008
ERR5RS mode (no libraries have been imported)

> (import (rnrs))
Autoloading (rnrs)
Autoloading (rnrs enums)
Autoloading (rnrs lists)
Autoloading (rnrs syntax-case)
Autoloading (rnrs hashtables)
Autoloading (rnrs arithmetic bitwise)
Autoloading (rnrs programs)
Autoloading (rnrs files)
Autoloading (rnrs io ports)
Autoloading (larceny deprecated)
Autoloading (rnrs conditions)
Autoloading (rnrs exceptions)
Autoloading (rnrs records syntactic)
Autoloading (err5rs records procedural)
Autoloading (rnrs records procedural)
Autoloading (rnrs control)
Autoloading (rnrs sorting)
Autoloading (rnrs bytevectors)
Autoloading (rnrs unicode)

> (import (rnrs io ports))

> (define ip (open-string-input-port "12345678"))

> (get-string-n ip 4)
"1234"

> (get-string-n ip 4)
"678"

Notice '5' was skipped.

larceny-trac-import commented 11 years ago

Author: will Fixed by changeset:5490.