Re: "format" function documentation fix

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: "format" function documentation fix
Дата
Msg-id CAEZATCWKDeMCs-=n65ZyHS2jTLc_b=0gn7HPKEAkoOGn+O5T_w@mail.gmail.com
обсуждение исходный текст
Ответ на "format" function documentation fix  (rudolf <stu3.1@eq.cz>)
Список pgsql-docs
On 17 September 2013 10:00, rudolf <stu3.1@eq.cz> wrote:
> (Please CC me the reply, since I'm not subscribed to the list.)
>
> Dean Rasheed wrote:
>>
>> On 14 September 2013 09:29, rudolf <stu3.1@eq.cz> wrote:
>>>
>>> The last example from
>>>
>>> http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT
>>> - "examples using width fields and the - flag" seems to be incorrect, see
>>> the attached patch.
>>
>>
>> No, the example is correct. Referring to the documentation above that:
>>
>>      If the width argument is negative, the result is left aligned (as
>> if the - flag had been specified) ...
>>
>> This applies even if the "-" flag is also specified. So the last
>> example is meant to illustrate that 2 minuses don't make a plus here.
>
>
> That's very unusual, IMO. This behavior follows some SQL standard or is it
> an invention of PostgreSQL?
>

It's not part of the SQL standard, but it is based on C printf() and
friends from the Single UNIX Specification, see for example
http://pubs.opengroup.org/onlinepubs/7908799/xsh/fprintf.html

My reading of that is that "-" is to be treated as a flag, not as a
minus sign, so specifying it multiple times has the same effect as
specifying it once. On my linux box, the following both produce
left-justified output:

  printf("'%-10s'\n", "foo");
  printf("'%--10s'\n", "foo");

Regards,
Dean


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

Предыдущее
От: Dean Rasheed
Дата:
Сообщение: Re: "format" function documentation fix
Следующее
От: rudolf
Дата:
Сообщение: Re: "format" function documentation fix