pgsql: Work around a subtle portability problem in use of printf %s

Поиск
Список
Период
Сортировка
От tgl@postgresql.org (Tom Lane)
Тема pgsql: Work around a subtle portability problem in use of printf %s
Дата
Msg-id 20100508164052.BDD9B7541D2@cvs.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Log Message:
-----------
Work around a subtle portability problem in use of printf %s format.
Depending on which spec you read, field widths and precisions in %s may be
counted either in bytes or characters.  Our code was assuming bytes, which
is wrong at least for glibc's implementation, and in any case libc might
have a different idea of the prevailing encoding than we do.  Hence, for
portable results we must avoid using anything more complex than just "%s"
unless the string to be printed is known to be all-ASCII.

This patch fixes the cases I could find, including the psql formatting
failure reported by Hernan Gonzalez.  In HEAD only, I also added comments
to some places where it appears safe to continue using "%.*s".

Tags:
----
REL7_4_STABLE

Modified Files:
--------------
    pgsql/src/backend/parser:
        scansup.c (r1.24.4.1 -> r1.24.4.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/scansup.c?r1=1.24.4.1&r2=1.24.4.2)
    pgsql/src/interfaces/libpq:
        fe-misc.c (r1.103.2.1 -> r1.103.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-misc.c?r1=1.103.2.1&r2=1.103.2.2)

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

Предыдущее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Work around a subtle portability problem in use of printf %s
Следующее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Adjust comments about avoiding use of printf's %.*s.