Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6bb7b46

Browse files
committed
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.
1 parentde9be56 commit6bb7b46

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

‎src/bin/psql/mbprint.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.23 2006/10/04 00:30:06 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.24 2006/12/27 19:45:36 tgl Exp $
77
*/
88

99
#include"postgres_fe.h"
@@ -196,7 +196,7 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
196196
break;
197197
w=PQdsplen((char*)pwcs,encoding);
198198

199-
if (chlen==1)/*ASCII char */
199+
if (chlen==1)/*single-byte char */
200200
{
201201
if (*pwcs=='\n')/* Newline */
202202
{
@@ -211,25 +211,23 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
211211
linewidth+=2;
212212
format_size+=2;
213213
}
214-
elseif (w <=0)/* Other control char */
214+
elseif (w<0)/* Other control char */
215215
{
216216
linewidth+=4;
217217
format_size+=4;
218218
}
219-
else
220-
/* Output itself */
219+
else/* Output it as-is */
221220
{
222-
linewidth++;
221+
linewidth+=w;
223222
format_size+=1;
224223
}
225224
}
226-
elseif (w <=0)/* Non-ascii control char */
225+
elseif (w<0)/* Non-ascii control char */
227226
{
228227
linewidth+=6;/* \u0000 */
229228
format_size+=6;
230229
}
231-
else
232-
/* All other chars */
230+
else/* All other chars */
233231
{
234232
linewidth+=w;
235233
format_size+=chlen;
@@ -267,11 +265,11 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
267265
break;
268266
w=PQdsplen((char*)pwcs,encoding);
269267

270-
if (chlen==1)/* singlebyte char char */
268+
if (chlen==1)/* single-byte char */
271269
{
272270
if (*pwcs=='\n')/* Newline */
273271
{
274-
*ptr++=0;/* NULL char */
272+
*ptr++='\0';
275273
lines->width=linewidth;
276274
linewidth=0;
277275
lines++;
@@ -287,20 +285,19 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
287285
linewidth+=2;
288286
ptr+=2;
289287
}
290-
elseif (w <=0)/* Other control char */
288+
elseif (w<0)/* Other control char */
291289
{
292290
sprintf((char*)ptr,"\\x%02X",*pwcs);
293291
linewidth+=4;
294292
ptr+=4;
295293
}
296-
else
297-
/* Output itself */
294+
else/* Output it as-is */
298295
{
299-
linewidth++;
296+
linewidth+=w;
300297
*ptr++=*pwcs;
301298
}
302299
}
303-
elseif (w <=0)/* Non-ascii control char */
300+
elseif (w<0)/* Non-ascii control char */
304301
{
305302
if (encoding==PG_UTF8)
306303
sprintf((char*)ptr,"\\u%04X",utf2ucs(pwcs));
@@ -316,8 +313,7 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
316313
ptr+=6;
317314
linewidth+=6;
318315
}
319-
else
320-
/* All other chars */
316+
else/* All other chars */
321317
{
322318
inti;
323319

@@ -327,13 +323,12 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
327323
}
328324
len-=chlen;
329325
}
330-
*ptr++=0;
326+
*ptr++='\0';
331327
lines->width=linewidth;
332328
lines++;
333329
count--;
334330
if (count>0)
335331
lines->ptr=NULL;
336-
return;
337332
}
338333

339334
unsignedchar*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp