Skip to content
Snippets Groups Projects
Commit 6bb7b467 authored by Tom Lane's avatar Tom Lane
Browse files

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.
parent de9be563
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2006, PostgreSQL Global Development Group * 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" #include "postgres_fe.h"
...@@ -196,7 +196,7 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width, ...@@ -196,7 +196,7 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
break; break;
w = PQdsplen((char *) pwcs, encoding); w = PQdsplen((char *) pwcs, encoding);
if (chlen == 1) /* ASCII char */ if (chlen == 1) /* single-byte char */
{ {
if (*pwcs == '\n') /* Newline */ if (*pwcs == '\n') /* Newline */
{ {
...@@ -211,25 +211,23 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width, ...@@ -211,25 +211,23 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
linewidth += 2; linewidth += 2;
format_size += 2; format_size += 2;
} }
else if (w <= 0) /* Other control char */ else if (w < 0) /* Other control char */
{ {
linewidth += 4; linewidth += 4;
format_size += 4; format_size += 4;
} }
else else /* Output it as-is */
/* Output itself */
{ {
linewidth++; linewidth += w;
format_size += 1; format_size += 1;
} }
} }
else if (w <= 0) /* Non-ascii control char */ else if (w < 0) /* Non-ascii control char */
{ {
linewidth += 6; /* \u0000 */ linewidth += 6; /* \u0000 */
format_size += 6; format_size += 6;
} }
else else /* All other chars */
/* All other chars */
{ {
linewidth += w; linewidth += w;
format_size += chlen; format_size += chlen;
...@@ -267,11 +265,11 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding, ...@@ -267,11 +265,11 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
break; break;
w = PQdsplen((char *) pwcs, encoding); w = PQdsplen((char *) pwcs, encoding);
if (chlen == 1) /* single byte char char */ if (chlen == 1) /* single-byte char */
{ {
if (*pwcs == '\n') /* Newline */ if (*pwcs == '\n') /* Newline */
{ {
*ptr++ = 0; /* NULL char */ *ptr++ = '\0';
lines->width = linewidth; lines->width = linewidth;
linewidth = 0; linewidth = 0;
lines++; lines++;
...@@ -287,20 +285,19 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding, ...@@ -287,20 +285,19 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
linewidth += 2; linewidth += 2;
ptr += 2; ptr += 2;
} }
else if (w <= 0) /* Other control char */ else if (w < 0) /* Other control char */
{ {
sprintf((char *) ptr, "\\x%02X", *pwcs); sprintf((char *) ptr, "\\x%02X", *pwcs);
linewidth += 4; linewidth += 4;
ptr += 4; ptr += 4;
} }
else else /* Output it as-is */
/* Output itself */
{ {
linewidth++; linewidth += w;
*ptr++ = *pwcs; *ptr++ = *pwcs;
} }
} }
else if (w <= 0) /* Non-ascii control char */ else if (w < 0) /* Non-ascii control char */
{ {
if (encoding == PG_UTF8) if (encoding == PG_UTF8)
sprintf((char *) ptr, "\\u%04X", utf2ucs(pwcs)); sprintf((char *) ptr, "\\u%04X", utf2ucs(pwcs));
...@@ -316,8 +313,7 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding, ...@@ -316,8 +313,7 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
ptr += 6; ptr += 6;
linewidth += 6; linewidth += 6;
} }
else else /* All other chars */
/* All other chars */
{ {
int i; int i;
...@@ -327,13 +323,12 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding, ...@@ -327,13 +323,12 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
} }
len -= chlen; len -= chlen;
} }
*ptr++ = 0; *ptr++ = '\0';
lines->width = linewidth; lines->width = linewidth;
lines++; lines++;
count--; count--;
if (count > 0) if (count > 0)
lines->ptr = NULL; lines->ptr = NULL;
return;
} }
unsigned char * unsigned char *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment