|
Re: [patch #5704] Data New/Open/Save: msg#00061statistics.pspp.devel
John Darrington <john@xxxxxxxxxxxxxxx> 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 blp@xxxxxxxxxxxxxxx http://benpfaff.org |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [patch #5704] Data New/Open/Save: 00061, John Darrington |
|---|---|
| Next by Date: | Re: [patch #5704] Data New/Open/Save: 00061, John Darrington |
| Previous by Thread: | Re: [patch #5704] Data New/Open/Savei: 00061, John Darrington |
| Next by Thread: | Re: [patch #5704] Data New/Open/Save: 00061, John Darrington |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |