Bug 41071 - glib should handle positional parameters(%n$)
glib should handle positional parameters(%n$)
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: glib (Show other bugs)
7.1
All Linux
low Severity medium
: ---
: ---
Assigned To: Owen Taylor
Aaron Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-05-17 03:07 EDT by Nakai
Modified: 2007-03-26 23:44 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-01-13 19:46:48 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
a code to crash. (198 bytes, patch)
2001-05-23 04:15 EDT, Nakai
no flags Details | Diff
And this is a simple patch for glib. (431 bytes, patch)
2001-05-23 04:18 EDT, Nakai
no flags Details | Diff

  None (edit)
Description Nakai 2001-05-17 03:07:44 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.72 [muriyari-ja] (X11; U; Linux 2.2.14-5.0 i686)

Description of problem:


How reproducible:
Always

Steps to Reproduce:
1. Run gnumeric in Japanese environment(LANG=ja_JP.eucJP)
2. Insert a columun.


Actual Results:  SIGSEGV

Expected Results:  Insert the column.

Additional info:

ja.po in gnumeric says(write Japanese part in alphabet):

#: src/commands.c:928
#, c-format
msgid "Inserting %d column before %s"
msgstr "%2$s no maeni %1$d retsu wo sounyuu"

but glib doesn't support %2$s type so gnumeric crashes.
glib should support this. See 871 line in glib-1.2.9/gstrfuncs.c
Comment 1 Nakai 2001-05-17 03:08:51 EDT
This bug also occurs on the gnumeric in the Korean
environment(LANG=ko_KR.eucKR).
Comment 2 Nakai 2001-05-17 03:36:51 EDT
(Summary fix: not glibc but glib)
Comment 3 Owen Taylor 2001-05-17 10:08:28 EDT
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. :-(
Comment 4 Nakai 2001-05-18 03:50:23 EDT
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.
Comment 5 Owen Taylor 2001-05-18 08:57:38 EDT
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.
Comment 6 Nakai 2001-05-23 04:15:30 EDT
Created attachment 19371 [details]
a code to crash.
Comment 7 Nakai 2001-05-23 04:18:01 EDT
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.

Comment 8 Nakai 2001-05-23 04:18:54 EDT
Created attachment 19372 [details]
And this is a simple patch for glib.
Comment 9 Owen Taylor 2001-05-23 10:56:29 EDT
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
Comment 10 Nakai 2002-03-27 01:38:11 EST
Is this fixed for Hampton?
Comment 11 Owen Taylor 2002-03-27 11:04:51 EST
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.
Comment 12 Owen Taylor 2003-01-13 19:46:48 EST
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.

Note You need to log in before you can comment on or make changes to this bug.