bugGNU Octave - Bugs: bug #51794, fscanf / sscanf unable to read...

 
 

bug #51794: fscanf / sscanf unable to read long integers in "C-like" form

Submitter:  None
Submitted:  Sat 19 Aug 2017 06:17:02 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.0.3
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 29 Aug 2017 06:03:25 PM UTC, comment #4: 

I pushed this change:

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

Closing as fixed.

John W. Eaton <jwe>
Group administrator
Tue 29 Aug 2017 05:27:43 PM UTC, comment #3: 

Yeah this seems like the right thing to do, change looks good and works for me, thank you. Please do update the docs.

Mike Miller <mtmiller>
Group Member
Tue 29 Aug 2017 04:32:01 PM UTC, comment #2: 

Mike:  It seems like we should do the same thing that you did here

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

for the default scanf functions, so I pushed the following changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/6f0c2963674b

If you agree, then I can also update the docs.  If not, I could revert the change.

John W. Eaton <jwe>
Group administrator
Mon 21 Aug 2017 07:13:29 PM UTC, comment #1: 

Note that the documentation explicitly says

> Unlike the C language ‘scanf’, Octave ignores the ‘h’, ‘l’, and ‘L’ modifiers.


This might be a consideration for an enhancement, but is not incorrect when it is behaving according to the docs.

In Octave 4.2 an integer value is returned, but it is limited to the maximum signed 32-bit value.

Mike Miller <mtmiller>
Group Member
Sat 19 Aug 2017 06:17:02 PM UTC, original submission:  

fscanf(stdin, "%ld", 1) will read integers exceeding 2^32 correctly. For example with 9007199254740991 it'll return:
ans =    9.0072e+15

while fscanf(stdin, "%ld", "C") will return ans = [](0x0).

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-08-29 jwe StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2017-08-29 jwe StatusNone Ready For Test
    2017-08-21 mtmiller Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low
        Item GroupIncorrect Result Feature Request
        Summaryfscanf return empty result when trying to read long ints in &quot;C-like&quot; form fscanf / sscanf unable to read long integers in "C-like" form

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code