sprintf truncates at 29 characters in some cases

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

sprintf truncates at 29 characters in some cases

Miodrag Milenković
This post has NOT been accepted by the mailing list yet.
I'm just learning csound and I seem to have encountered a bug when trying to run the example 03B01_Variable_types.csd from the FLOSS manual. When I try to sprintf a string containing a non-string as its first argument in the format, the resulting string gets truncated to 29 characters for some reason. Here's some code that demonstrates this:

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
  instr 1
SVard1   sprintf   "012345678901234567890123456789 %d", 1
SVarf1   sprintf   "012345678901234567890123456789 %f", 0.1
SVare1   sprintf   "012345678901234567890123456789 %e", 3.14159
SVard2   sprintf   "01234567890123456789 %d", 1
SVarf2   sprintf   "01234567890123456789 %f", 0.1
SVare2   sprintf   "01234567890123456789 %e", 3.14159
SVars1    sprintf   "012345678901234567890123456789 %s", "foobar"
SVars2    sprintf   "012345678901234567890123456789 %s %d", "foobar", 1
SVars3    sprintf   "012345678901234567890123456789 %d %s", 1, "foobar"
          printf_i  "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", 1, SVard1, SVarf1, SVare1, SVard2, SVarf2, SVare2, SVars1, SVars2, SVars3
  endin
</CsInstruments>
<CsScore>
i 1 0 1
</CsScore>
</CsoundSynthesizer>

and here's the output:

01234567890123456789012345678
01234567890123456789012345678
01234567890123456789012345678
01234567890123456789 1
01234567890123456789 0.100000
01234567890123456789 3.141590
012345678901234567890123456789 foobar
012345678901234567890123456789 foobar 1
01234567890123456789012345678

Any ideas what could be going wrong? I'm running this on Mac OS 10.12.4 and the version string is "Csound version 6.08 (double samples) Nov 23 2016"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sprintf truncates at 29 characters in some cases

Miodrag Milenković
This post has NOT been accepted by the mailing list yet.
Loading...