pgsql: Adjust comments about avoiding use of printf's %.*s. - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: Adjust comments about avoiding use of printf's %.*s.
Date
Msg-id 20100509021600.6BCBB7541D2@cvs.postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
Adjust comments about avoiding use of printf's %.*s.
My initial impression that glibc was measuring the precision in characters
(which is what the Linux man page says it does) was incorrect.  It does take
the precision to be in bytes, but it also tries to truncate the string at a
character boundary.  The bottom line remains the same: it will mess up
if the string is not in the encoding it expects, so we need to avoid %.*s
anytime there's a significant risk of that.  Previous code changes are still
good, but adjust the comments to reflect this knowledge.  Per research by
Hernan Gonzalez.

Modified Files:
--------------
    pgsql/src/backend/parser:
        scansup.c (r1.40 -> r1.41)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/scansup.c?r1=1.40&r2=1.41)
    pgsql/src/backend/tsearch:
        wparser_def.c (r1.31 -> r1.32)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/tsearch/wparser_def.c?r1=1.31&r2=1.32)
    pgsql/src/backend/utils/adt:
        datetime.c (r1.211 -> r1.212)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/datetime.c?r1=1.211&r2=1.212)
    pgsql/src/bin/psql:
        print.c (r1.125 -> r1.126)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/print.c?r1=1.125&r2=1.126)
    pgsql/src/interfaces/ecpg/pgtypeslib:
        dt_common.c (r1.52 -> r1.53)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c?r1=1.52&r2=1.53)
    pgsql/src/interfaces/libpq:
        fe-misc.c (r1.142 -> r1.143)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-misc.c?r1=1.142&r2=1.143)

pgsql-committers by date:

Previous
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Work around a subtle portability problem in use of printf %s
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Fix typo: PGTYPES_NUM_OVERFLOW should be PGTYPES_NUM_UNDERFLOW.