Bug 41071
Summary: | glib should handle positional parameters(%n$) | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Nakai <ynakai> | ||||||
Component: | glib | Assignee: | Owen Taylor <otaylor> | ||||||
Status: | CLOSED WONTFIX | QA Contact: | Aaron Brown <abrown> | ||||||
Severity: | medium | Docs Contact: | |||||||
Priority: | low | ||||||||
Version: | 7.1 | CC: | bhuang, ssato, tagoh, ynakai | ||||||
Target Milestone: | --- | ||||||||
Target Release: | --- | ||||||||
Hardware: | All | ||||||||
OS: | Linux | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2003-01-14 00:46:48 UTC | Type: | --- | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Attachments: |
|
Description
Nakai
2001-05-17 07:07:44 UTC
This bug also occurs on the gnumeric in the Korean environment(LANG=ko_KR.eucKR). (Summary fix: not glibc but glib) This is _extremely_ hard to do. Basically, to do it portably, you either have to: - Ship a complete printf() implementation with GLib to be used on systems where stdio doesn't support positional parameters. Since handling things like float formatting is highly non-trivial, I'd be quite reluctant to do this. - Know how to portably rewrite valists when passing them to vsprintf(). At some point in the future, we may just require a C library with support for positional parameters. However, since positional parameters are NOT part of ISO C99, though they are part of SUSv2, and we do care about portability to non-Unix systems now, I don't imagine we'll be doing this any time soon. For now it should be just be treated as a limitation in GLib. :-( g_printf_string_upper_bound() just returns the total length. If glib doesn't support this, I want another idea of replacement. Many developer will use this. It's easy to make it work on Red Hat, on Linux, on modern Unix. However, then .po files that work on Linux, will suddenly not work and most likely segfault on other operating systems. Since the translations we make should always be sent upstream to the original package maintainers, and since most of the packages we ship that use GLib are not Linux specific, I don't see that adding positional parameters to g_strdup_sprintf(), has significant value. Created attachment 19371 [details]
a code to crash.
Attached is a code to crash with glib. I think it is very silly that it crashes in a function that just returns the length. Created attachment 19372 [details]
And this is a simple patch for glib.
Agreed, it would be better to skip the entire format specifier after warning. (Note that the patch above doesn't seem to handle things like %1$5s) I've filed this as: http://bugzilla.gnome.org/show_bug.cgi?id=55106 Is this fixed for Hampton? GLib-1.2 behaves as you did before ... you can't use positional parameters. GLib-2.0 has some changes so that (on sufficiently modern Unix-like systems) you can use whatever capabilities the native printf has. Not going to do anything on glib-1.2 at this point. In Glib-2.2, Glib will always provide positional parameter support; if the C library doesn't support it, it includes a copy of the 'trio' library. |