summaryrefslogtreecommitdiff
path: root/src/backend/tsearch
diff options
context:
space:
mode:
authorTom Lane2010-05-09 02:16:00 +0000
committerTom Lane2010-05-09 02:16:00 +0000
commited437e2b27c48219a78f3504b0d05c17c2082d02 (patch)
tree04b0bbedba8b34ef187a5df895cb1cff9a877728 /src/backend/tsearch
parent54cd4f04576833abc394e131288bf3dd7dcf4806 (diff)
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.
Diffstat (limited to 'src/backend/tsearch')
-rw-r--r--src/backend/tsearch/wparser_def.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c
index d2e47ceaf5e..cda28103c24 100644
--- a/src/backend/tsearch/wparser_def.c
+++ b/src/backend/tsearch/wparser_def.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.31 2010/05/08 16:39:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.32 2010/05/09 02:15:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -323,10 +323,9 @@ TParserInit(char *str, int len)
#ifdef WPARSER_TRACE
/*
- * Use of %.*s here is not portable when the string contains multibyte
- * characters: some machines interpret the length in characters, others
- * in bytes. Since it's only a debugging aid, we haven't bothered to
- * fix this.
+ * Use of %.*s here is a bit risky since it can misbehave if the data
+ * is not in what libc thinks is the prevailing encoding. However,
+ * since this is just a debugging aid, we choose to live with that.
*/
fprintf(stderr, "parsing \"%.*s\"\n", len, str);
#endif