Paul Eggert <[EMAIL PROTECTED]> writes:

> If 'size' is of type size_t, then where I was suggesting this:
>
>      unsigned long int s = size;
>      printf (_("The size is %lu.\n"), size);
>
> the gettext manual suggests something like this instead:
>
>      char buf[INT_BUFSIZE_BOUND (size_t)];
>      sprintf (buf, "%" PRIuSIZE, size);
>      printf (_("The size is %s.\n"), buf1);
>
> where we define PRIuSIZE in system.h.  But this is even more awkward.

I have an idea, but I don't know whether it's reasonable.  How
about a function that does a makes a copy of a format string, in
the process doing a textual search-and-replace of %zu, etc. by
the local system's appropriate size modifier?  Then the above
would become something like:

        printf (fix_sizes (_("The size is %zu.\n")), size);

We'd want to write an Autoconf test for whether `z' and friends
are supported so that fix_sizes could be stubbed out if it was
unneeded, e.g.

        #ifdef HAS_C99_PRINTF
        #define fix_sizes(FORMAT) (FORMAT)
        #endif

Presumably fix_sizes() would be written something like quote() to
avoid the need to explicitly free a dynamically allocated string.
-- 
Ben Pfaff 
email: [EMAIL PROTECTED]
web: http://benpfaff.org



_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to