aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-12-27 19:45:51 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-12-27 19:45:51 +0000
commit38b72135c91491860f9882be9f5a3d0dacab64c5 (patch)
treeca8bdb925be4e6cf2a46ada839baa5c6a37f691c /src
parent094ccd1ca3603d58b8b5397b4272ec06b46b0b03 (diff)
downloadpostgresql-38b72135c91491860f9882be9f5a3d0dacab64c5.tar.gz
postgresql-38b72135c91491860f9882be9f5a3d0dacab64c5.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..c2dbe4dbbc4 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.23.2.1 2006/12/27 19:45:51 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 *