John Darrington <[EMAIL PROTECTED]> 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
[EMAIL PROTECTED]
http://benpfaff.org
_______________________________________________
pspp-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-dev