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

Commit2e27b0e

Browse files
committed
Fix utterly-bogus code for computing row heights. Per crashes on
spoonbill, though one wonders why it didn't misbehave everywhere.In passing remove some unnecessary modulo calculations.
1 parent1a604b4 commit2e27b0e

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

‎src/bin/psql/print.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.103 2008/05/16 18:35:38 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.104 2008/05/17 17:52:14 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -522,7 +522,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
522522
introws=cell_count /col_count;
523523

524524
for (i=0;i<col_count;i++)
525-
width_average[i %col_count] /=rows;
525+
width_average[i] /=rows;
526526
}
527527

528528
/* adjust the total display width based on border style */
@@ -645,30 +645,36 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
645645
if (!is_pager)
646646
{
647647
/* scan all cells, find maximum width, compute cell_count */
648-
for (i=0,ptr=cont->cells;*ptr;ptr++,i++,cell_count++)
648+
for (i=0,ptr=cont->cells;*ptr;ptr++,cell_count++)
649649
{
650650
intwidth,
651651
nl_lines,
652652
bytes_required;
653653

654654
pg_wcssize((unsignedchar*)*ptr,strlen(*ptr),encoding,
655655
&width,&nl_lines,&bytes_required);
656-
if (opt_numeric_locale&&cont->align[i %col_count]=='r')
656+
if (opt_numeric_locale&&cont->align[i]=='r')
657657
width+=additional_numeric_locale_len(*ptr);
658658

659659
/*
660660
*A row can have both wrapping and newlines that cause
661661
*it to display across multiple lines. We check
662662
*for both cases below.
663663
*/
664-
if (width>0&&width_wrap[i]&&
665-
(width-1) /width_wrap[i]+nl_lines>extra_row_output_lines)
666-
extra_row_output_lines= (width-1) /width_wrap[i]+nl_lines;
664+
if (width>0&&width_wrap[i])
665+
{
666+
unsignedintextra_lines;
667+
668+
extra_lines= (width-1) /width_wrap[i]+nl_lines;
669+
if (extra_lines>extra_row_output_lines)
670+
extra_row_output_lines=extra_lines;
671+
}
667672

668-
/*If lastcolumn, add tallest column height */
669-
if (i %col_count==col_count-1)
673+
/*i is the currentcolumn number: increment with wrap */
674+
if (++i >=col_count)
670675
{
671-
/* Add height of tallest row */
676+
i=0;
677+
/* At last column of each row, add tallest column height */
672678
extra_output_lines+=extra_row_output_lines;
673679
extra_row_output_lines=0;
674680
}
@@ -780,7 +786,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
780786
col_lineptrs[j],max_nl_lines[j]);
781787
curr_nl_line[j]=0;
782788

783-
if (opt_numeric_locale&&cont->aligns[j %col_count]=='r')
789+
if (opt_numeric_locale&&cont->aligns[j]=='r')
784790
{
785791
char*my_cell;
786792

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp