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

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: Re: proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used
Дата
Msg-id CAEZATCWYncqOjAuGYz-DCJjpZdjbbCViyvPfG0uTBp-EHM4K_A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Re: proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: Re: proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Re: Re: proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
On 28 January 2013 20:32, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> In general a format specifier looks like:
>
> %[parameter][flags][width][.precision][length]type
>

This highlights another problem with the current implementation ---
the '-' flag and the width field need to be parsed separately. So
'%-3s' should be parsed as a '-' flag followed by a width of 3, not as
a width of -3, which is then interpreted as left-aligned. This might
seem like nitpicking, but actually it is important:

* In the future we might support more flags, and they can be specified
in any order, so the '-' flag won't necessarily come immediately
before the width.

* The width field is optional, even if the '-' flag is specified. So
'%-s' is perfectly legal and should be interpreted as '%s'. The
current implementation treats it as a width of 0, which is wrong.

* The width field might not be a number, it might be something like *
or *3$. Note that the SUS allows a negative width to be passed in as a
function argument using this syntax, in which case it should be
treated as if the '-' flag were specified.

Regards,
Dean



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ashutosh Bapat
Дата:
Сообщение: Re: pg_ctl idempotent option
Следующее
От: Dean Rasheed
Дата:
Сообщение: Re: Re: proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used