bugGNU Octave - Bugs: bug #39288, strjoin ignores trailing spaces in...

 
 

bug #39288: strjoin ignores trailing spaces in prefixstr

Submitter:  None
Submitted:  Wed 19 Jun 2013 01:45:25 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.2
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 24 Jun 2013 12:24:38 AM UTC, comment #8: 

strjoin() has been removed from the strings package.  The version included in Octave core works correctly.  I'm closing this report.

Ben Abbott <bpabbott>
Group Member
Sun 23 Jun 2013 04:00:44 PM UTC, comment #7: 

I searched for that error message (appears in pt-mat.cc) and through the log (for "pt-mat.cc"), and I believe it is this bug fix that accounts for your current error.

http://hg.savannah.gnu.org/hgweb/octave/rev/797ac81586d1

author Julien Bect <julien.bect@supelec.fr>
date Tue, 26 Feb 2013 12:06:45 +0100 (3 months ago)

This explains why "sprintf()" was being used in the strjoin.m routine before this recent optimization:

https://savannah.gnu.org/patch/?8066

Unless you want to rebuild to the latest code which includes the above fix (there was a scheduled release coming up, but I'm not sure if that will be met, so I don't think it pays to wait a week or two), you might be able to work from the less efficient version of strjoin() prior to the patch, which would be this one:

http://hg.savannah.gnu.org/hgweb/octave/file/424463a80134/scripts/strings/strjoin.m

(Again, use the "raw" button to download the file.)

Whether the above is the same script file that originally caused you errors, I'm not sure.

Dan Sebald <sebald>
Sun 23 Jun 2013 12:46:40 PM UTC, comment #6: 

Dan, the size of the array is correct:


octave:1> size({"Octave", "Scilab", "Lush", "Yorick"})
ans =

   1   4


I did some debugging right before line 80:


debug> delimiter
delimiter =
{
  [1,1] = *
  [1,2] = *
  [1,3] = *
  [1,4] =
}
debug> cstr
cstr =
{
  [1,1] = Octave
  [1,2] = Scilab
  [1,3] = Lush
  [1,4] = Yorick
}
debug> size(delimiter)
ans =

   1   4

debug> size(cstr)
ans =

   1   4

debug> cstr(:).'
ans =
{
  [1,1] = Octave
  [1,2] = Scilab
  [1,3] = Lush
  [1,4] = Yorick
}
debug> delimiter(:).'
ans =
{
  [1,1] = *
  [1,2] = *
  [1,3] = *
  [1,4] =
}
debug> [cstr(:).'; delimiter(:).']
ans =
{
  [1,1] = Octave
  [2,1] = *
  [1,2] = Scilab
  [2,2] = *
  [1,3] = Lush
  [2,3] = *
  [1,4] = Yorick
  [2,4] =
}
debug> [cstr(:).'; delimiter(:).']{:}
ans = Octave
ans = *
ans = Scilab
ans = *
ans = Lush
ans = *
ans = Yorick
ans =
debug> [[cstr(:).'; delimiter(:).']{:}]
error: horizontal dimensions mismatch (2x4 vs 1x1)


As noted in the original submission, I'm using Octave 3.6.2.

Anonymous
Sun 23 Jun 2013 04:54:26 AM UTC, comment #5: 

I would think so.  Send to maintainers list (which now also handles packages).  C.D. usually handles the package changes.

Dan Sebald <sebald>
Sun 23 Jun 2013 01:18:18 AM UTC, comment #4: 

Dan, the function strjoin() wasn't present in Octave core for 3.6.2.

The error being reported is for the strings package.  Should strjoin be removed from the package?

http://octave.sourceforge.net/strings/overview.html




Ben Abbott <bpabbott>
Group Member
Sat 22 Jun 2013 04:42:39 PM UTC, comment #3: 

Your examples works for me on my system:


>> strjoin ({"Octave", "Scilab", "Lush", "Yorick"}, "*")
ans = Octave*Scilab*Lush*Yorick


Are you using the latest (or at least a very recent) version of Octave?  The error message you are seeing is indicating that {"Octave", "Scilab", "Lush", "Yorick"} is a 2x4 matrix.  But I'm seeing it as a 1x4 array.


>> size ({"Octave", "Scilab", "Lush", "Yorick"})
ans =

   1   4


Also, I don't see how the size of the delimiter matrix at that point in the function could be 1x1.  There is an if/elseif/else statement for which at least one of those must happen.  It's not the second case, and the other two cases would increase the size of the delimiter cell string which it is converted to.

All I can think of is that you might have an old Octave version that has buggy cell string behavior.

This may have lead to uncovering a problem, though.  The command strjoin ({}, "*") produces an odd result.  I will note this here:

https://savannah.gnu.org/patch/?8066

Dan Sebald <sebald>
Sat 22 Jun 2013 02:31:03 PM UTC, comment #2: 

Firstly, I noticed that this version of strjoin uses a completely different syntax than what the function reference says: it takes the strings to join in the first parameter as a cell array and the delimiter as the second. But it's probably good to change that, since MATLAB's strjoin function does the same thing.

Secondly, it throws a dimension mismatch error if I pass more than one string in the cell array:


octave:5> strjoin({'marie'}, ', ')
ans = marie
octave:6> strjoin ({"Octave", "Scilab", "Lush", "Yorick"}, "*")
error: horizontal dimensions mismatch (2x4 vs 1x1)
error: called from:
error:   /path/strjoin.m at line 80, column 8


Anonymous
Fri 21 Jun 2013 06:37:05 PM UTC, comment #1: 

There have been some recent changes to strjoin.m:

http://hg.savannah.gnu.org/hgweb/octave/rev/c6d61dca5acd
http://hg.savannah.gnu.org/hgweb/octave/rev/70ea511edbc4

This is a change to the script file only, so should be easy to test.  Could you please get the latest version of the script file:

http://hg.savannah.gnu.org/hgweb/octave/file/519343308ab1/scripts/strings/strjoin.m

(go to the web location and click on the left column menu item that indicates "raw") and let us know if that solves the problem?

Dan Sebald <sebald>
Wed 19 Jun 2013 01:45:25 PM UTC, original submission:  

strjoin (from the strings package; reference) ignores trailing spaces in the first parameter, prefixstr:


> strjoin(' loves-> ','marie','amy','beth')
Expected result: marie loves-> amy loves-> beth
Actual result: marie loves->amy loves->beth

> strjoin(', ',{'Octave','Scilab','Lush','Yorick'})
Expected result: Octave, Scilab, Lush, Yorick
Actual result: Octave,Scilab,Lush,Yorick


Packages: octave 3.6.2-5+deb7u1 and octave-strings 1.1.0-1 amd64 from the Debian Wheezy repository.

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 bpabbott (Posted a comment)
  • -email is unavailable- added by sebald (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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-06-24 bpabbott Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code