lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Scheme function ly:string->duration


From: Joe Neeman
Subject: Re: [PATCH] Scheme function ly:string->duration
Date: Sun, 18 May 2008 09:27:07 +1000

On Sat, 2008-05-17 at 13:31 +0100, Neil Puttock wrote:
> Thanks for your comments, Joe.
> 
> I'm struggling a bit with sscanf () though. I tried your suggestion of
> 
> if (sscanf (s.c_str (), "%d") != s.size ()) ...
> 
> but it fails with a segfault; when compiling, I get two warnings: that
> there's not enough arguments to sscanf (), and about type conversion
> (shouldn't s.size () be cast as int for this comparison?)
> 
> It works OK (ignoring the cast) if I change it to
> 
> if (sscanf (s.c_str (), "%d", &len) != s.size ()) ...
> 
> but I'm a bit confused here: doesn't sscanf () return the number of
> variables which have successfully been assigned values? If so, how can
> the test work?

Sorry, I was under the mistaken impression that sscanf returned the
number of characters that were converted. But given that there's a
scheme function that already does this (should have read the whole
conversation first...) I agree with Nicolas that it's better just to
make that public (or stick a public string->duration function in the
same file as parse-simple-duration).

Joe





reply via email to

[Prev in Thread] Current Thread [Next in Thread]