From: | tgl(at)postgresql(dot)org (Tom Lane) |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Work around a subtle portability problem in use of printf %s |
Date: | 2010-05-08 16:40:31 |
Message-ID: | 20100508164031.C283E7541D3@cvs.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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:
----
REL8_2_STABLE
Modified Files:
--------------
pgsql/src/backend/parser:
scansup.c (r1.34 -> r1.34.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/scansup.c?r1=1.34&r2=1.34.2.1)
pgsql/src/backend/utils/error:
elog.c (r1.178.2.8 -> r1.178.2.9)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/error/elog.c?r1=1.178.2.8&r2=1.178.2.9)
pgsql/src/interfaces/libpq:
fe-misc.c (r1.130.2.1 -> r1.130.2.2)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-misc.c?r1=1.130.2.1&r2=1.130.2.2)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-05-08 16:40:39 | pgsql: Work around a subtle portability problem in use of printf %s |
Previous Message | Tom Lane | 2010-05-08 16:40:14 | pgsql: Work around a subtle portability problem in use of printf %s |