33 *
44 * Copyright 2000 by PostgreSQL Global Development Group
55 *
6- * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.28 2002/07/18 04:46:24 momjian Exp $
6+ * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.29 2002/08/27 20:16:48 petere Exp $
77 */
88#include "postgres_fe.h"
99#include "print.h"
@@ -209,13 +209,9 @@ print_aligned_text(const char *title, const char *const * headers,
209209 FILE * fout )
210210{
211211 unsigned int col_count = 0 ;
212-
213- #ifdef MULTIBYTE
214212 unsigned int cell_count = 0 ;
215213 unsigned int * head_w ,
216214 * cell_w ;
217- #endif
218-
219215 unsigned int i ,
220216 tmp ;
221217 unsigned int * widths ,
@@ -233,7 +229,6 @@ print_aligned_text(const char *title, const char *const * headers,
233229 exit (EXIT_FAILURE );
234230 }
235231
236- #ifdef MULTIBYTE
237232 head_w = calloc (col_count , sizeof (* head_w ));
238233 if (!head_w )
239234 {
@@ -256,26 +251,21 @@ print_aligned_text(const char *title, const char *const * headers,
256251 }
257252 else
258253 cell_w = 0 ;
259- #endif
260254
261255
262256 /* calc column widths */
263257 for (i = 0 ; i < col_count ; i ++ )
264258 {
265259 if ((tmp = pg_wcswidth ((unsigned char * ) headers [i ], strlen (headers [i ]))) > widths [i ])
266260 widths [i ] = tmp ;
267- #ifdef MULTIBYTE
268261 head_w [i ] = tmp ;
269- #endif
270262 }
271263
272264 for (i = 0 , ptr = cells ; * ptr ; ptr ++ , i ++ )
273265 {
274266 if ((tmp = pg_wcswidth ((unsigned char * ) * ptr , strlen (* ptr ))) > widths [i % col_count ])
275267 widths [i % col_count ] = tmp ;
276- #ifdef MULTIBYTE
277268 cell_w [i ] = tmp ;
278- #endif
279269 }
280270 if (opt_border == 0 )
281271 total_w = col_count - 1 ;
@@ -313,11 +303,7 @@ print_aligned_text(const char *title, const char *const * headers,
313303 {
314304 int nbspace ;
315305
316- #ifdef MULTIBYTE
317306 nbspace = widths [i ] - head_w [i ];
318- #else
319- nbspace = widths [i ] - strlen (headers [i ]);
320- #endif
321307
322308 /* centered */
323309 fprintf (fout , "%-*s%s%-*s" ,
@@ -356,26 +342,16 @@ print_aligned_text(const char *title, const char *const * headers,
356342 /* content */
357343 if (opt_align [(i ) % col_count ] == 'r' )
358344 {
359- #ifdef MULTIBYTE
360345 fprintf (fout , "%*s%s" ,
361346 widths [i % col_count ] - cell_w [i ], "" , cells [i ]);
362- #else
363- fprintf (fout , "%*s" , widths [i % col_count ], cells [i ]);
364- #endif
365347 }
366348 else
367349 {
368350 if ((i + 1 ) % col_count == 0 && opt_border != 2 )
369351 fputs (cells [i ], fout );
370352 else
371- {
372- #ifdef MULTIBYTE
373353 fprintf (fout , "%-s%*s" , cells [i ],
374354 widths [i % col_count ] - cell_w [i ], "" );
375- #else
376- fprintf (fout , "%-*s" , widths [i % col_count ], cells [i ]);
377- #endif
378- }
379355 }
380356
381357 /* divider */
@@ -406,10 +382,8 @@ print_aligned_text(const char *title, const char *const * headers,
406382 fputc ('\n' , fout );
407383
408384 /* clean up */
409- #ifdef MULTIBYTE
410385 free (cell_w );
411386 free (head_w );
412- #endif
413387 free (widths );
414388}
415389
@@ -429,21 +403,17 @@ print_aligned_vertical(const char *title, const char *const * headers,
429403 hwidth = 0 ,
430404 dwidth = 0 ;
431405 char * divider ;
432-
433- #ifdef MULTIBYTE
434406 unsigned int cell_count = 0 ;
435407 unsigned int * cell_w ,
436408 * head_w ;
437- #endif
438409
439410 if (cells [0 ] == NULL )
440411 {
441412 puts (gettext ("(No rows)\n" ));
442413 return ;
443414 }
444415
445- #ifdef MULTIBYTE
446- /* pre-count headers */
416+ /* count headers and find longest one */
447417 for (ptr = headers ; * ptr ; ptr ++ )
448418 col_count ++ ;
449419 head_w = calloc (col_count , sizeof (* head_w ));
@@ -480,22 +450,6 @@ print_aligned_vertical(const char *title, const char *const * headers,
480450 dwidth = tmp ;
481451 cell_w [i ] = tmp ;
482452 }
483- #else
484- /* count columns and find longest header */
485- for (ptr = headers ; * ptr ; ptr ++ )
486- {
487- col_count ++ ;
488- if ((tmp = strlen (* ptr )) > hwidth )
489- hwidth = tmp ; /* don't wanna call strlen twice */
490- }
491-
492- /* find longest data cell */
493- for (ptr = cells ; * ptr ; ptr ++ )
494- {
495- if ((tmp = strlen (* ptr )) > dwidth )
496- dwidth = tmp ;
497- }
498- #endif
499453
500454 /* print title */
501455 if (!opt_barebones && title )
@@ -569,12 +523,8 @@ print_aligned_vertical(const char *title, const char *const * headers,
569523
570524 if (opt_border == 2 )
571525 fputs ("| " , fout );
572- #if MULTIBYTE
573526 fprintf (fout , "%-s%*s" , headers [i % col_count ],
574527 hwidth - head_w [i % col_count ], "" );
575- #else
576- fprintf (fout , "%-*s" , hwidth , headers [i % col_count ]);
577- #endif
578528
579529 if (opt_border > 0 )
580530 fputs (" | " , fout );
@@ -584,13 +534,7 @@ print_aligned_vertical(const char *title, const char *const * headers,
584534 if (opt_border < 2 )
585535 fprintf (fout , "%s\n" , * ptr );
586536 else
587- {
588- #ifdef MULTIBYTE
589537 fprintf (fout , "%-s%*s |\n" , * ptr , dwidth - cell_w [i ], "" );
590- #else
591- fprintf (fout , "%-*s |\n" , dwidth , * ptr );
592- #endif
593- }
594538 }
595539
596540 if (opt_border == 2 )
@@ -610,10 +554,8 @@ print_aligned_vertical(const char *title, const char *const * headers,
610554 fputc ('\n' , fout );
611555 free (divider );
612556
613- #ifdef MULTIBYTE
614557 free (cell_w );
615558 free (head_w );
616- #endif
617559}
618560
619561
@@ -1167,13 +1109,7 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
11671109 }
11681110
11691111 for (i = 0 ; i < nfields ; i ++ )
1170- {
1171- #ifdef MULTIBYTE
11721112 headers [i ] = mbvalidate (PQfname (result , i ));
1173- #else
1174- headers [i ] = PQfname (result , i );
1175- #endif
1176- }
11771113
11781114 /* set cells */
11791115
@@ -1189,13 +1125,7 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
11891125 if (PQgetisnull (result , i / nfields , i % nfields ))
11901126 cells [i ] = opt -> nullPrint ? opt -> nullPrint : "" ;
11911127 else
1192- {
1193- #ifdef MULTIBYTE
11941128 cells [i ] = mbvalidate (PQgetvalue (result , i / nfields , i % nfields ));
1195- #else
1196- cells [i ] = PQgetvalue (result , i / nfields , i % nfields );
1197- #endif
1198- }
11991129 }
12001130
12011131 /* set footers */
0 commit comments