Subject: Re: new stdlib?
To: Berndt Josef Wulf <wulf@ping.net.au>
From: Roger Brooks <R.S.Brooks@liverpool.ac.uk>
List: netbsd-help
Date: 02/08/2000 13:23:06
On Tue, 8 Feb 2000, Berndt Josef Wulf wrote:

>G'day,
>
>does anyone know the following construct? It was found in anteater
>which segfaults at that point.
>
>[...]
> sprintf( c_datestring, "year %1$02d, day %2$02d, month %3$04d",
>	(int)tmdate.tm_mday, (int)tmdate.tm_mon+1,
>	(int)tmdate.tm_year+1900 );
>  string newdate = c_datestring;
>  return newdate;
>
>I've expanded the format string which is constructed earlier
>in the code. I've never seen the use of a "%1$02d" format string nor have I
>found any references in books and manuals. When changed to 
>"%02d" the program runs fine and displays the correct date format.
>
>Is there a new stdlib with extentions of the current format string? I am 
>using egcs-1.1.1 and standard libraries as shipped with NetBSD-1.4.1.

The "1$" part of the format means the 1st arg.  It's intended to allow
the format string to control the order in which the args are printed.
The main use is in NLS support, where a message with 2 or more args
may need them in a different order to allow for conventional word-order
in the language in use.


Roger

------------------------------------------------------------------------------
Roger Brooks (Systems Programmer),          |  Email: R.S.Brooks@liv.ac.uk
Computing Services Dept,                    |  Tel:   +44 151 794 4441
The University of Liverpool,                |  Fax:   +44 151 794 4442
PO Box 147, Liverpool L69 3BX, UK           | 
------------------------------------------------------------------------------