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

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

[Octave-bug-tracker] [bug #32066] textscan error


From: Ben Abbott
Subject: [Octave-bug-tracker] [bug #32066] textscan error
Date: Tue, 18 Jan 2011 18:08:00 +0000
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10

Follow-up Comment #2, bug #32066 (project octave):

Unfortunately, using your suggestion the tests for strread and textscan
produce failures for me.


octave:8> test textscan
warning: division by zero
  ***** test
 str = "1,  2,  3,  4n 5,  ,  ,  8n 9, 10, 11, 12";
 fmtstr = "%f %d %f %s";
 c = textscan (str, fmtstr, 2, "delimiter", ",", "emptyvalue", -Inf);
 assert (isequal (c{1}, [1;5]))
 assert (length (c{1}), 2);
 assert (iscellstr (c{4}))
 assert (isequal (c{3}, [3; -Inf]))
!!!!! test failed
some elements undefined in return list
octave:9> test strread
warning: division by zero
  ***** test
 [a, b] = strread ("1 2", "%f%f");
 assert (a == 1 && b == 2);
!!!!! test failed
element number 1 undefined in return list


Using the developers sources, all tests for strread and textscan pass.

For the original problem


octave:11> t = textscan('aaa.bbb','%s','delimiter','.') 
t = 
{
  [1,1] = 
  {
    [1,1] = aaa
    [2,1] = bbb
  }
}
octave:12> whos t
Variables in the current scope:

  Attr Name        Size                     Bytes  Class
  ==== ====        ====                     =====  ===== 
       t           1x1                          6  cell

Total is 1 element using 6 bytes

octave:13> t = textscan('aaa.bbb','%s','delimiter','.'){1}
t = 
{
  [1,1] = aaa
  [2,1] = bbb
}
octave:14> whos t
Variables in the current scope:

  Attr Name        Size                     Bytes  Class
  ==== ====        ====                     =====  ===== 
       t           2x1                          6  cell

Total is 2 elements using 6 bytes


This is parsing the data correctly, but is not returning it in the proper
format.

I haven't studied this bug, but the fix might be quite simple. For example,
see the attached changeset.

(file #22439)
    _______________________________________________________

Additional Item Attachment:

File name: changeset.patch                Size:1 KB


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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