bugGNU Octave - Bugs: bug #33722, sscanf inconsistent behaviour with...

 
 

bug #33722: sscanf inconsistent behaviour with strings containing 'I'

Submitted by:  Pascal Dupuis <cdemills>
Submitted on:  Wed 06 Jul 2011 01:01:10 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Pascal DupuisOpen/Closed: Closed
Release: 3.4.2Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 24 Aug 2011 04:33:05 PM UTC, comment #2:

Thanks for the patch. I checked it in on the stable branch:

http://hg.savannah.gnu.org/hgweb/octave/rev/b12e2cffaa2f

The default branch has diverged here, but still had the problem, so I checked in a separate changeset for that:

http://hg.savannah.gnu.org/hgweb/octave/rev/7872afb42fab

We no longer maintain ChangeLogs by hand. ChangeLog information should now go in the commit message. Take a look at other changesets to see the preferred format. Are you using the sources from the Mercurial archive? If so, it would be helpful if you would prepare changesets instead of sending simple diffs.

John W. Eaton <jwe>
Project Administrator
Wed 06 Jul 2011 02:02:58 PM UTC, comment #1:

The problem lies in src/oct-stream.cc. Patch attached. There is no Changelog in my source tree ? Here's the entry

2011-07-06 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
* oct-stream.cc (octave_scan): Completed the branch in charge to detect constructs like 'Inf'. Strings like 'I2' should not be interpreted as floats.

(file #23626)

Pascal Dupuis <cdemills>
Project Member
Wed 06 Jul 2011 01:01:10 PM UTC, original submission:

Hello,
working in the context of electrical measurements, my colleagues often produce file whose first line contains 'I' (for current). I then observed this strange behaviour of sscanf:
[val, count]=sscanf("1L2", "%f")
val = 1.0000e+00
count = 1.0000e+00
OK: the parser stops at 'L'
[val, count]=sscanf("L2", "%f")
val = [](0x1)
count = 0.0000e+00
OK: 'L' is not the beginning of a number
[val, count]=sscanf("3I2", "%f")
val =

3.0000e+00
3.0000e+00
count = 2.0000e+00
Where thus the second value (3) come from ?

[val, count]=sscanf("I2", "%f")
val = 0.0000e+00
count = 1.0000e+00
why does it produce a zero ?

The expected behavior should be:
- returns a single value for "3I2"
- returns an empty value for "I2"

Regards

Pasca

Pascal Dupuis <cdemills>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #23626:  oscanf.cc.pat added by cdemills (3KiB - image/x-coreldrawpattern)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by cdemills (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 24 Aug 2011 04:33:05 PM UTCjweStatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Tue 02 Aug 2011 01:24:02 AM UTCrik5StatusNone=>Patch Submitted
    Wed 06 Jul 2011 02:02:58 PM UTCcdemillsAttached File-=>Added oscanf.cc.pat, #23626

    Back to the top


    Powered by Savane 3.1-cleanup1