aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-12-27 19:45:36 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-12-27 19:45:36 +0000
commit6bb7b467c0572e4baafca5eb491aab2739e44378 (patch)
tree83660af84c7913b8b4660f4cc5236f04dd73e85c /src
parentde9be563d49baf175522e7917962aa29e88b0af6 (diff)
downloadpostgresql-6bb7b467c0572e4baafca5eb491aab2739e44378.tar.gz
postgresql-6bb7b467c0572e4baafca5eb491aab2739e44378.zip
Print combining characters (those reported as having zero width by
PQdsplen()) normally, instead of replacing them by \uXXXX sequences. Assume that they in fact occupy zero screen space for formatting purposes. Per gripe from Michael Fuhr and ensuing discussion.
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/mbprint.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c
index 8a25955b5c4..491b2181a7f 100644
--- a/src/bin/psql/mbprint.c
+++ b/src/bin/psql/mbprint.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.23 2006/10/04 00:30:06 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.24 2006/12/27 19:45:36 tgl Exp $
*/
#include "postgres_fe.h"
@@ -196,7 +196,7 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
break;
w = PQdsplen((char *) pwcs, encoding);
- if (chlen == 1) /* ASCII char */
+ if (chlen == 1) /* single-byte char */
{
if (*pwcs == '\n') /* Newline */
{
@@ -211,25 +211,23 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
linewidth += 2;
format_size += 2;
}
- else if (w <= 0) /* Other control char */
+ else if (w < 0) /* Other control char */
{
linewidth += 4;
format_size += 4;
}
- else
- /* Output itself */
+ else /* Output it as-is */
{
- linewidth++;
+ linewidth += w;
format_size += 1;
}
}
- else if (w <= 0) /* Non-ascii control char */
+ else if (w < 0) /* Non-ascii control char */
{
linewidth += 6; /* \u0000 */
format_size += 6;
}
- else
- /* All other chars */
+ else /* All other chars */
{
linewidth += w;
format_size += chlen;
@@ -267,11 +265,11 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
break;
w = PQdsplen((char *) pwcs, encoding);
- if (chlen == 1) /* single byte char char */
+ if (chlen == 1) /* single-byte char */
{
if (*pwcs == '\n') /* Newline */
{
- *ptr++ = 0; /* NULL char */
+ *ptr++ = '\0';
lines->width = linewidth;
linewidth = 0;
lines++;
@@ -287,20 +285,19 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
linewidth += 2;
ptr += 2;
}
- else if (w <= 0) /* Other control char */
+ else if (w < 0) /* Other control char */
{
sprintf((char *) ptr, "\\x%02X", *pwcs);
linewidth += 4;
ptr += 4;
}
- else
- /* Output itself */
+ else /* Output it as-is */
{
- linewidth++;
+ linewidth += w;
*ptr++ = *pwcs;
}
}
- else if (w <= 0) /* Non-ascii control char */
+ else if (w < 0) /* Non-ascii control char */
{
if (encoding == PG_UTF8)
sprintf((char *) ptr, "\\u%04X", utf2ucs(pwcs));
@@ -316,8 +313,7 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
ptr += 6;
linewidth += 6;
}
- else
- /* All other chars */
+ else /* All other chars */
{
int i;
@@ -327,13 +323,12 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
}
len -= chlen;
}
- *ptr++ = 0;
+ *ptr++ = '\0';
lines->width = linewidth;
lines++;
count--;
if (count > 0)
lines->ptr = NULL;
- return;
}
unsigned char *