Csound Csound-dev Csound-tekno Search About

[Csnd-dev] sprintf on existing string

Date2023-02-01 00:45
FromHlöðver Sigurðsson
Subject[Csnd-dev] sprintf on existing string
Hey csound-devs,

I'm curious about the history behind limiting the use of the same string as input and output argument with sprintf:

INIT ERROR in instr 1 (opcode pr_str) line 12: sprintf: output argument may not be the same as any of the input args

Maybe this was a bug once upon a time and isn't an issue anymore, in which case, I'd be happy to fix this. It seems other string opcodes are fine with returning the string it's manipulating over. And since I'm playing around with writing a parser with the csound strings, it would be way too heavy on the memory in deeply recursive contexts, if I were to assign to new string in memory, copied each time.

In any case, this isn't an issue for me, since I can achieve what I need from other string operators, but I like the cleanliness of sprintf, in csound and c :)

Best,
Hlöðver

Date2023-02-01 09:52
FromRory Walsh
SubjectRe: [Csnd-dev] sprintf on existing string
I'm happy to see this removed, if it is no longer an issue. 

On Wed, 1 Feb 2023 at 00:46, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
Hey csound-devs,

I'm curious about the history behind limiting the use of the same string as input and output argument with sprintf:

INIT ERROR in instr 1 (opcode pr_str) line 12: sprintf: output argument may not be the same as any of the input args

Maybe this was a bug once upon a time and isn't an issue anymore, in which case, I'd be happy to fix this. It seems other string opcodes are fine with returning the string it's manipulating over. And since I'm playing around with writing a parser with the csound strings, it would be way too heavy on the memory in deeply recursive contexts, if I were to assign to new string in memory, copied each time.

In any case, this isn't an issue for me, since I can achieve what I need from other string operators, but I like the cleanliness of sprintf, in csound and c :)

Best,
Hlöðver

Date2023-02-01 14:01
Fromjoachim heintz
SubjectRe: [Csnd-dev] sprintf on existing string
yes, definitely.  i think this was long again issue; probably in the 
csound 4 parser.


On 01/02/2023 10:52, Rory Walsh wrote:
> I'm happy to see this removed, if it is no longer an issue.
> 
> On Wed, 1 Feb 2023 at 00:46, Hlöðver Sigurðsson  > wrote:
> 
>     Hey csound-devs,
> 
>     I'm curious about the history behind limiting the use of the same
>     string as input and output argument with sprintf:
> 
>         INIT ERROR in instr 1 (opcode pr_str) line 12: sprintf: output
>         argument may not be the same as any of the input args
> 
> 
>     Maybe this was a bug once upon a time and isn't an issue anymore, in
>     which case, I'd be happy to fix this. It seems other string opcodes
>     are fine with returning the string it's manipulating over. And since
>     I'm playing around with writing a parser with the csound strings, it
>     would be way too heavy on the memory in deeply recursive contexts,
>     if I were to assign to new string in memory, copied each time.
> 
>     In any case, this isn't an issue for me, since I can achieve what I
>     need from other string operators, but I like the cleanliness of
>     sprintf, in csound and c :)
> 
>     Best,
>     Hlöðver
> 

Date2023-02-01 14:34
FromEduardo Moguillansky
SubjectRe: [Csnd-dev] sprintf on existing string
Looking at the code it cannot be removed at the moment.

On 01.02.23 15:01, joachim heintz  wrote:
> yes, definitely.  i think this was long again issue; probably in the 
> csound 4 parser.
> 
> 
> On 01/02/2023 10:52, Rory Walsh wrote:
> > I'm happy to see this removed, if it is no longer an issue.
> >
> > On Wed, 1 Feb 2023 at 00:46, Hlöðver Sigurðsson  > > wrote:
> >
> >     Hey csound-devs,
> >
> >     I'm curious about the history behind limiting the use of the same
> >     string as input and output argument with sprintf:
> >
> >         INIT ERROR in instr 1 (opcode pr_str) line 12: sprintf: output
> >         argument may not be the same as any of the input args
> >
> >
> >     Maybe this was a bug once upon a time and isn't an issue anymore, in
> >     which case, I'd be happy to fix this. It seems other string opcodes
> >     are fine with returning the string it's manipulating over. And since
> >     I'm playing around with writing a parser with the csound strings, it
> >     would be way too heavy on the memory in deeply recursive contexts,
> >     if I were to assign to new string in memory, copied each time.
> >
> >     In any case, this isn't an issue for me, since I can achieve what I
> >     need from other string operators, but I like the cleanliness of
> >     sprintf, in csound and c :)
> >
> >     Best,
> >     Hlöðver
> >
>