Re: proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used
Date: 2012-12-29 19:00:45
Message-ID: 20121229190045.GW16126@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Pavel,

* Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
> 2012/12/29 Stephen Frost <sfrost(at)snowman(dot)net>:
> > This is correct, if we're matching glibc (and SUS, I believe), isn't it?
> > You're not allowed to mix '%2$s' type parameters and '%s' in a single
> > format.
>
> I am not sure, please recheck

According to the man pages on my Ubuntu system, under 'Format of the
format string':

-------------------
If the style using '$' is used, it must be used throughout for
all conversions taking an argument and all width and precision
arguments, but it may be mixed with "%%" formats which do not consume
an argument.
-------------------

> pavel ~ $ cat test.c
> #include <stdio.h>
>
> void main()
> {
>
> printf("%s %2$s %s\n", "AHOJ", "Svete");
> }
>
> pavel ~ $ gcc test.c # no warning here

You didn't turn any on...

sfrost(at)tamriel:/home/sfrost> gcc -o qq -Wall test.c
test.c: In function ‘main’:
test.c:5:3: warning: $ operand number used after format without operand number [-Wformat]

Thanks,

Stephen

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2012-12-29 19:08:32 Re: pg_dump transaction's read-only mode
Previous Message Gavin Flower 2012-12-29 18:59:04 Re: inconsistent time zone formats in log