[racket] line and column numbers lost after (relocate-input-port )

From: Dmitry Pavlov (dpavlov at ipa.nw.ru)
Date: Wed Nov 27 13:47:10 EST 2013

Hello,

Here is a piece of code that essentially shows my problem:


#lang racket

(define port (open-input-file "anyfile.txt"))

(port-count-lines! port)

(let-values (((line col pos) (port-next-location port)))
   (printf "before: ~a ~a ~a\n" line col pos)
   (set! port (relocate-input-port
               (reencode-input-port port "cp1251")
               line col pos)))

;; (port-count-lines! port) ;; does not change anything

(let-values (((line col pos) (port-next-location port)))
   (printf "after: ~a ~a ~a\n" line col pos))


Output:

before: 1 0 1
after: #f #f 1

So the position is still there (good), but the
line/column numbers are lost (bad). What did I miss?


Best regards,

Dmitry

Posted on the users mailing list.