Tue 17 Feb 2015 11:35:09 PM UTC, comment #10:
Works for me. Marking as fixed and closing report.
|
Tue 17 Feb 2015 06:31:28 AM UTC, comment #9:
I checked in some changes that I think fix the problems reported here and improve compatibility in a few other cases. I added a few tests, but more are probably needed.
http://hg.savannah.gnu.org/hgweb/octave/rev/3c3b9fce7d2b
http://hg.savannah.gnu.org/hgweb/octave/rev/928ecc95f395
http://hg.savannah.gnu.org/hgweb/octave/rev/17a7e9f26e50
|
Mon 16 Feb 2015 05:39:36 PM UTC, comment #8:
Uh, nevermind that patch. It doesn't really do the right thing. I'll try to come up with a better solution. Apparently '%s' and '%c' conversions are supposed to do string conversions for any numeric value that is in the range of valid characters. For Matlab, that seems to be any integer value between 0 and intmax ('uint16') regardless of the storage type (int, double, whatever)
|
Mon 16 Feb 2015 05:34:12 AM UTC, comment #7:
Please try the attached patch.
(file #33098)
|
Wed 18 Jun 2014 12:55:04 PM UTC, comment #6:
I haven't looked through the relevant section in enough detail yet to wager any clarifications or guesses. But note that this bug is not limited to %c. It applies to all integer and floating point conversion formats when given a string argument, so all of the following should apparently be fixed: %c, %d, %i, %o, %u, %x, %X, %f, %e, %E, %g, and %G. All are working in 3.8 and not working on default. I've retitled to make sure that is not lost.
|
Wed 18 Jun 2014 11:44:00 AM UTC, comment #5:
You're absolutely right.
I'm trying to find a fix for this but am still rather confused by the code.
Should the 'c' option handled separately here:
http://hg.savannah.gnu.org/hgweb/octave/rev/491b0adfec95#l1.292
so as not to perform any int or double conversion?
|
Tue 17 Jun 2014 06:12:04 PM UTC, comment #4:
The following example in matlab shows that "%s" and "%c" are different:
The string 'abcd' is an array of characters. In Mike's test, all the characters are treated one after the other using the same format specifier. This behavior is true for all format specifiers except %s which is meant to handle multiple characters at the same time [1].
[1] http://www.mathworks.fr/fr/help/matlab/ref/sscanf.html
|
Tue 17 Jun 2014 05:24:26 PM UTC, comment #3:
The error is indeed a consequence of this change:
http://hg.savannah.gnu.org/hgweb/octave/rev/491b0adfec95#l1.295
Given MATLAB behaviour, it seems that %c should be handled as if it was %s. Would you agree?
|
Wed 30 Apr 2014 07:24:10 AM UTC, comment #2:
On a pretty old Matlab version (r2008b):
|
Wed 30 Apr 2014 02:01:04 AM UTC, comment #1:
Confirmed. I have not bisected but this is likely due to this change (mentioned in NEWS on the default branch btw):
http://hg.savannah.gnu.org/hgweb/octave/rev/491b0adfec95
And obviously you meant printf or sprintf in your example, right? So does Matlab do the following:
? What about the following?
|
Tue 29 Apr 2014 02:45:15 PM UTC, original submission:
I've just recompiled a fresh version of the dev branch and I now get errors each time a %s type is used in a format specification:
|