pspp-dev
[Top][All Lists]
Advanced

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

Re: [patch #5704] Data New/Open/Save


From: Ben Pfaff
Subject: Re: [patch #5704] Data New/Open/Save
Date: Tue, 23 Jan 2007 16:22:14 -0800
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

John Darrington <address@hidden> writes:

> I was thinking that an alternative approach would be to implement a
> special conversion specification within the
> create_syntax_string_source function.  Then we could simply write
> something like:
>
>  create_syntax_string_source ("EXPORT OUTFILE=%q.", de->file_name);
>
> This way, there's no need for the caller to worry about buffers or
> dealloction at all.

Yes, that's a good idea.

However, I'd propose a slightly different syntax:
        create_syntax_string_source ("EXPORT OUTFILE=%sq.",
                                     de->file_name);
If you make the full specification %sq, then you can still get
GCC to check that a "char *" argument is present by telling it
that it's a printf-like function.  There'd need to be a suffix
character for unquoted strings too, e.g. %su, but all in all the
slight inconvenience of using 2-character conversions is vastly
outweighed (in my opinion) by having compile-time checking.

> I remember coming across a sprintf like function  which allows you to
> specify custom conversions, but I can't remember where I found it.

There's a variety of them, and glibc even includes one of its
own, but they're not hard to write yourself, especially if you
don't need the full generality of printf (and I doubt we do).
-- 
Ben Pfaff 
address@hidden
http://benpfaff.org




reply via email to

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