octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #45808] fscanf odd behavior with newlines


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #45808] fscanf odd behavior with newlines
Date: Wed, 26 Aug 2015 16:37:58 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.1.0

Follow-up Comment #3, bug #45808 (project octave):

I don't think the problem is really with newlines.  It's that a limit on the
number of requested values is specified but Octave is cycling through the
format string again.  So it skips the whitespace (newline) and then the ";" on
the second line of the file matches the beginning of the format string but
there is a failure to read the "y" with "%d".  Only when that format element
fails to match does it return and move on to the next call to fscanf.

So I think the solution is to not recycle a format string if a fixed limit on
the number of requested values is supplied.  But I'm not sure of exactly what
is supposed to happen.  For example, does


fscanf (fid, "x %d y %d", 1)


stop reading immediately after the first "%d" conversion, or does it also grab
any literal text and whitespace following that conversion?  What about
something like


fscanf (fid, "%d %*d", 1)


Does the limit apply immediately to values read or does it also process the
second (skipped) number?

I don't quite understand the rules yet.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45808>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]