Scnaf Patch?

It seems pos is undefined for STDIN.
In order to use scanf for console input I had to change the line
       start_position = pos
in class IO, def scanf(str, &b) in lib/ruby/1.8/scanf.rb into
       if self == STDIN
   start_position = 0
       else
   start_position = pos
       end

Any ideas?

Hi --

It seems pos is undefined for STDIN.
In order to use scanf for console input I had to change the line
       start_position = pos
in class IO, def scanf(str, &b) in lib/ruby/1.8/scanf.rb into
       if self == STDIN
   start_position = 0
       else
   start_position = pos
       end

Any ideas?

I believe this broke some time after 1.6.8, when pos was removed from
STDIN. It was subsequently fixed, though:

  wobblini:~$ ruby -vrscanf -e 'p STDIN.scanf("%d%s")'
  ruby 1.8.2 (2004-07-29) [i686-linux]
  123 abc
  ^D
  [123, "abc"]

(The line you quoted is now:

   start_position = pos rescue 0

:slight_smile:

David

···

On Thu, 11 Nov 2004, Takao Ueda wrote:

--
David A. Black
dblack@wobblini.net