bugGNU Octave - Bugs: bug #34183, 'save' inside function fills...

 
 

bug #34183: 'save' inside function fills 'argn' with binary 0

Submitter:  Andreas Weber <andy1978>
Submitted:  Wed 31 Aug 2011 04:57:23 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  1 - Later Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 27 Jun 2013 03:30:09 AM UTC, comment #2: 

Fixed in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/787de2f144d9).  Pull from Mercurial to get the latest code or wait for the 3.8 release of Octave.

Rik <rik5>
Group administrator
Sat 03 Sep 2011 04:11:23 AM UTC, comment #1: 

Wow, what an esoteric issue.  I can confirm this on a recent development tip.  One would hope that automatic variables created by Octave would respect the string_fill_char() setting (default = space) but I guess that isn't always true.

I'm going to lower the priority since there are many possible workarounds.  Some possible suggestions

1) Use a more powerful text editor
2) save only the variables you need
3) save in a binary format, re-read into Octave and delete any variables like argn that you dislike, save in text format again

Rik <rik5>
Group administrator
Wed 31 Aug 2011 04:57:23 PM UTC, original submission:  

hg id
b646413c3d0e+ tip

A call of 'save' without arguments even saves the automatic generated var 'argn'.
The problem with this is: If there is a string parameter present, the remaining space is filled with binary zeros (see hd output at the end) and some text editors (for ex. gedit) doesn't open the file.


function ret=myfunction(a,b,c)
  save mylog.log
endfunction

myfunction(pi,"hi octave",5)


=== cat output===

$ cat mylog.log
# Created by Octave 3.5.0+, Wed Aug 31 18:31:08 2011 CEST <andy@PhenomBabe>
# name: a
# type: scalar
3.141592653589793


# name: argn
# type: sq_string
# elements: 3
# length: 11
pi
# length: 11
"hi octave"
# length: 11
5


# name: b
# type: string
# elements: 1
# length: 9
hi octave


# name: c
# type: scalar
5


hd output


$ hd mylog.log
00000000  23 20 43 72 65 61 74 65  64 20 62 79 20 4f 63 74  |# Created by Oct|
00000010  61 76 65 20 33 2e 35 2e  30 2b 2c 20 57 65 64 20  |ave 3.5.0+, Wed |
00000020  41 75 67 20 33 31 20 31  38 3a 33 31 3a 30 38 20  |Aug 31 18:31:08 |
00000030  32 30 31 31 20 43 45 53  54 20 3c 61 6e 64 79 40  |2011 CEST <andy@|
00000040  50 68 65 6e 6f 6d 42 61  62 65 3e 0a 23 20 6e 61  |PhenomBabe>.# na|
00000050  6d 65 3a 20 61 0a 23 20  74 79 70 65 3a 20 73 63  |me: a.# type: sc|
00000060  61 6c 61 72 0a 33 2e 31  34 31 35 39 32 36 35 33  |alar.3.141592653|
00000070  35 38 39 37 39 33 0a 0a  0a 23 20 6e 61 6d 65 3a  |589793...# name:|
00000080  20 61 72 67 6e 0a 23 20  74 79 70 65 3a 20 73 71  | argn.# type: sq|
00000090  5f 73 74 72 69 6e 67 0a  23 20 65 6c 65 6d 65 6e  |_string.# elemen|
000000a0  74 73 3a 20 33 0a 23 20  6c 65 6e 67 74 68 3a 20  |ts: 3.# length: |
000000b0  31 31 0a 70 69 00 00 00  00 00 00 00 00 00 0a 23  |11.pi..........#|
000000c0  20 6c 65 6e 67 74 68 3a  20 31 31 0a 22 68 69 20  | length: 11."hi |
000000d0  6f 63 74 61 76 65 22 0a  23 20 6c 65 6e 67 74 68  |octave".# length|
000000e0  3a 20 31 31 0a 35 00 00  00 00 00 00 00 00 00 00  |: 11.5..........|
000000f0  0a 0a 0a 23 20 6e 61 6d  65 3a 20 62 0a 23 20 74  |...# name: b.# t|
00000100  79 70 65 3a 20 73 74 72  69 6e 67 0a 23 20 65 6c  |ype: string.# el|
00000110  65 6d 65 6e 74 73 3a 20  31 0a 23 20 6c 65 6e 67  |ements: 1.# leng|
00000120  74 68 3a 20 39 0a 68 69  20 6f 63 74 61 76 65 0a  |th: 9.hi octave.|
00000130  0a 0a 23 20 6e 61 6d 65  3a 20 63 0a 23 20 74 79  |..# name: c.# ty|
00000140  70 65 3a 20 73 63 61 6c  61 72 0a 35 0a 0a 0a     |pe: scalar.5...|
0000014f



Andreas Weber <andy1978>
Group Member

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by andy1978 (Submitted the item)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-06-27 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2011-09-03 rik5 StatusNone Confirmed
    2011-09-03 rik5 Priority5 - Normal 1 - Later

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code