@@ -1222,15 +1222,16 @@ print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
1222
1222
1223
1223
1224
1224
static void
1225
- print_aligned_vertical_line (const printTextFormat * format ,
1226
- const unsigned short opt_border ,
1225
+ print_aligned_vertical_line (const printTableOpt * topt ,
1227
1226
unsigned long record ,
1228
1227
unsigned int hwidth ,
1229
1228
unsigned int dwidth ,
1229
+ int output_columns ,
1230
1230
printTextRule pos ,
1231
1231
FILE * fout )
1232
1232
{
1233
- const printTextLineFormat * lformat = & format -> lrule [pos ];
1233
+ const printTextLineFormat * lformat = & get_line_style (topt )-> lrule [pos ];
1234
+ const unsigned short opt_border = topt -> border ;
1234
1235
unsigned int i ;
1235
1236
int reclen = 0 ;
1236
1237
@@ -1259,21 +1260,62 @@ print_aligned_vertical_line(const printTextFormat *format,
1259
1260
if (reclen -- <= 0 )
1260
1261
fputs (lformat -> hrule , fout );
1261
1262
if (reclen -- <= 0 )
1262
- fputs (lformat -> midvrule , fout );
1263
- if (reclen -- <= 0 )
1263
+ {
1264
+ if (topt -> expanded_header_width_type == PRINT_XHEADER_COLUMN )
1265
+ {
1266
+ fputs (lformat -> rightvrule , fout );
1267
+ }
1268
+ else
1269
+ {
1270
+ fputs (lformat -> midvrule , fout );
1271
+ }
1272
+ }
1273
+ if (reclen -- <= 0
1274
+ && topt -> expanded_header_width_type != PRINT_XHEADER_COLUMN )
1264
1275
fputs (lformat -> hrule , fout );
1265
1276
}
1266
1277
else
1267
1278
{
1268
1279
if (reclen -- <= 0 )
1269
1280
fputc (' ' , fout );
1270
1281
}
1271
- if (reclen < 0 )
1272
- reclen = 0 ;
1273
- for (i = reclen ; i < dwidth ; i ++ )
1274
- fputs (opt_border > 0 ? lformat -> hrule : " " , fout );
1275
- if (opt_border == 2 )
1276
- fprintf (fout , "%s%s" , lformat -> hrule , lformat -> rightvrule );
1282
+
1283
+ if (topt -> expanded_header_width_type != PRINT_XHEADER_COLUMN )
1284
+ {
1285
+ if (topt -> expanded_header_width_type == PRINT_XHEADER_PAGE
1286
+ || topt -> expanded_header_width_type == PRINT_XHEADER_EXACT_WIDTH )
1287
+ {
1288
+ if (topt -> expanded_header_width_type == PRINT_XHEADER_EXACT_WIDTH )
1289
+ {
1290
+ output_columns = topt -> expanded_header_exact_width ;
1291
+ }
1292
+ if (output_columns > 0 )
1293
+ {
1294
+ if (opt_border == 0 )
1295
+ dwidth = Min (dwidth , Max (0 , (int ) (output_columns - hwidth )));
1296
+ if (opt_border == 1 )
1297
+ dwidth = Min (dwidth , Max (0 , (int ) (output_columns - hwidth - 3 )));
1298
+ /*
1299
+ * Handling the xheader width for border=2 doesn't make
1300
+ * much sense because this format has an additional
1301
+ * right border, but keep this for consistency.
1302
+ */
1303
+ if (opt_border == 2 )
1304
+ dwidth = Min (dwidth , Max (0 , (int ) (output_columns - hwidth - 7 )));
1305
+ }
1306
+ }
1307
+
1308
+ if (reclen < 0 )
1309
+ reclen = 0 ;
1310
+ if (dwidth < reclen )
1311
+ dwidth = reclen ;
1312
+
1313
+ for (i = reclen ; i < dwidth ; i ++ )
1314
+ fputs (opt_border > 0 ? lformat -> hrule : " " , fout );
1315
+ if (opt_border == 2 )
1316
+ fprintf (fout , "%s%s" , lformat -> hrule , lformat -> rightvrule );
1317
+ }
1318
+
1277
1319
fputc ('\n' , fout );
1278
1320
}
1279
1321
@@ -1570,11 +1612,12 @@ print_aligned_vertical(const printTableContent *cont,
1570
1612
lhwidth ++ ; /* for newline indicators */
1571
1613
1572
1614
if (!opt_tuples_only )
1573
- print_aligned_vertical_line (format , opt_border , record ++ ,
1574
- lhwidth , dwidth , pos , fout );
1615
+ print_aligned_vertical_line (cont -> opt , record ++ ,
1616
+ lhwidth , dwidth , output_columns ,
1617
+ pos , fout );
1575
1618
else if (i != 0 || !cont -> opt -> start_table || opt_border == 2 )
1576
- print_aligned_vertical_line (format , opt_border , 0 , lhwidth ,
1577
- dwidth , pos , fout );
1619
+ print_aligned_vertical_line (cont -> opt , 0 , lhwidth ,
1620
+ dwidth , output_columns , pos , fout );
1578
1621
}
1579
1622
1580
1623
/* Format the header */
@@ -1760,8 +1803,8 @@ print_aligned_vertical(const printTableContent *cont,
1760
1803
if (cont -> opt -> stop_table )
1761
1804
{
1762
1805
if (opt_border == 2 && !cancel_pressed )
1763
- print_aligned_vertical_line (format , opt_border , 0 , hwidth , dwidth ,
1764
- PRINT_RULE_BOTTOM , fout );
1806
+ print_aligned_vertical_line (cont -> opt , 0 , hwidth , dwidth ,
1807
+ output_columns , PRINT_RULE_BOTTOM , fout );
1765
1808
1766
1809
/* print footers */
1767
1810
if (!opt_tuples_only && cont -> footers != NULL && !cancel_pressed )
0 commit comments