bugGNU Octave - Bugs: bug #34037, sscanf pads with null when reading...

 
 

bug #34037: sscanf pads with null when reading in %#c from a string

Submitted by:  Ben Barrowes <barrowes>
Submitted on:  Wed 17 Aug 2011 06:28:38 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Ben BarrowesOpen/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Tue 23 Aug 2011 12:33:47 AM UTC, comment #1:

I checked in the following changeset.

http://hg.savannah.gnu.org/hgweb/octave/rev/7626f8934466

This change fixes the problem for me, so I'm closing this report.

John W. Eaton <jwe>
Project Administrator
Wed 17 Aug 2011 06:28:38 PM UTC, original submission:

sscanf (and possible fscanf?) pad a character array with nulls when reading a string with a %#c format specifier. Matlab does not pad with nulls.

This can cause problems when determining the length of a string after sscanf.

In octave:

octave:3> aa=sscanf('123456','%10c')
aa = 123456
octave:4> length(aa)
ans = 10
octave:5> double(aa)
ans =

49 50 51 52 53 54 0 0 0 0

octave:6>

While in matlab:

>> aa=sscanf('123456','%10c')

aa =
123456

>> length(aa)

ans =
6

>> double(aa)

ans =
49 50 51 52 53 54

>>


Ben Barrowes <barrowes>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

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 barrowes (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 23 Aug 2011 12:33:47 AM UTCjweStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1