|
3 | 3 | *
|
4 | 4 | * Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.65 2005/07/14 06:49:58 momjian Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.66 2005/07/14 07:32:01 momjian Exp $ |
7 | 7 | */
|
8 | 8 | #include "postgres_fe.h"
|
9 | 9 | #include "common.h"
|
@@ -37,7 +37,7 @@ pg_local_malloc(size_t size)
|
37 | 37 | tmp = malloc(size);
|
38 | 38 | if (!tmp)
|
39 | 39 | {
|
40 |
| - psql_error("out of memory\n"); |
| 40 | + fprintf(stderr, _("out of memory\n")); |
41 | 41 | exit(EXIT_FAILURE);
|
42 | 42 | }
|
43 | 43 | return tmp;
|
@@ -999,7 +999,8 @@ static void
|
999 | 999 | print_latex_text(const char *title, const char *const *headers,
|
1000 | 1000 | const char *const *cells, const char *const *footers,
|
1001 | 1001 | const char *opt_align, bool opt_tuples_only,
|
1002 |
| - unsigned short int opt_border, FILE *fout) |
| 1002 | + char *opt_numericsep, unsigned short int opt_border, |
| 1003 | + FILE *fout) |
1003 | 1004 | {
|
1004 | 1005 | unsigned int col_count = 0;
|
1005 | 1006 | unsigned int i;
|
@@ -1059,7 +1060,18 @@ print_latex_text(const char *title, const char *const *headers,
|
1059 | 1060 | /* print cells */
|
1060 | 1061 | for (i = 0, ptr = cells; *ptr; i++, ptr++)
|
1061 | 1062 | {
|
1062 |
| - latex_escaped_print(*ptr, fout); |
| 1063 | + if (strlen(*ptr) != 0 && |
| 1064 | + opt_numericsep != NULL && strlen(opt_numericsep) > 0) |
| 1065 | + { |
| 1066 | + char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1); |
| 1067 | + |
| 1068 | + strcpy(my_cell, *ptr); |
| 1069 | + format_numericsep(my_cell, opt_numericsep); |
| 1070 | + latex_escaped_print(my_cell, fout); |
| 1071 | + free(my_cell); |
| 1072 | + } |
| 1073 | + else |
| 1074 | + latex_escaped_print(*ptr, fout); |
1063 | 1075 |
|
1064 | 1076 | if ((i + 1) % col_count == 0)
|
1065 | 1077 | fputs(" \\\\\n", fout);
|
@@ -1091,7 +1103,8 @@ static void
|
1091 | 1103 | print_latex_vertical(const char *title, const char *const *headers,
|
1092 | 1104 | const char *const *cells, const char *const *footers,
|
1093 | 1105 | const char *opt_align, bool opt_tuples_only,
|
1094 |
| - unsigned short int opt_border, FILE *fout) |
| 1106 | + char *opt_numericsep, unsigned short int opt_border, |
| 1107 | + FILE *fout) |
1095 | 1108 | {
|
1096 | 1109 | unsigned int col_count = 0;
|
1097 | 1110 | unsigned int i;
|
@@ -1161,7 +1174,18 @@ print_latex_vertical(const char *title, const char *const *headers,
|
1161 | 1174 | if (footers && !opt_tuples_only)
|
1162 | 1175 | for (ptr = footers; *ptr; ptr++)
|
1163 | 1176 | {
|
1164 |
| - latex_escaped_print(*ptr, fout); |
| 1177 | + if (strlen(*ptr) != 0 && |
| 1178 | + opt_numericsep != NULL && strlen(opt_numericsep) > 0) |
| 1179 | + { |
| 1180 | + char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1); |
| 1181 | + |
| 1182 | + strcpy(my_cell, *ptr); |
| 1183 | + format_numericsep(my_cell, opt_numericsep); |
| 1184 | + latex_escaped_print(my_cell, fout); |
| 1185 | + free(my_cell); |
| 1186 | + } |
| 1187 | + else |
| 1188 | + latex_escaped_print(*ptr, fout); |
1165 | 1189 | fputs(" \\\\\n", fout);
|
1166 | 1190 | }
|
1167 | 1191 |
|
@@ -1197,7 +1221,8 @@ static void
|
1197 | 1221 | print_troff_ms_text(const char *title, const char *const *headers,
|
1198 | 1222 | const char *const *cells, const char *const *footers,
|
1199 | 1223 | const char *opt_align, bool opt_tuples_only,
|
1200 |
| - unsigned short int opt_border, FILE *fout) |
| 1224 | + char *opt_numericsep, unsigned short int opt_border, |
| 1225 | + FILE *fout) |
1201 | 1226 | {
|
1202 | 1227 | unsigned int col_count = 0;
|
1203 | 1228 | unsigned int i;
|
@@ -1245,14 +1270,23 @@ print_troff_ms_text(const char *title, const char *const *headers,
|
1245 | 1270 | }
|
1246 | 1271 |
|
1247 | 1272 | if (!opt_tuples_only)
|
1248 |
| - { |
1249 | 1273 | fputs("\n_\n", fout);
|
1250 |
| - } |
1251 | 1274 |
|
1252 | 1275 | /* print cells */
|
1253 | 1276 | for (i = 0, ptr = cells; *ptr; i++, ptr++)
|
1254 | 1277 | {
|
1255 |
| - troff_ms_escaped_print(*ptr, fout); |
| 1278 | + if (strlen(*ptr) != 0 && |
| 1279 | + opt_numericsep != NULL && strlen(opt_numericsep) > 0) |
| 1280 | + { |
| 1281 | + char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1); |
| 1282 | + |
| 1283 | + strcpy(my_cell, *ptr); |
| 1284 | + format_numericsep(my_cell, opt_numericsep); |
| 1285 | + troff_ms_escaped_print(my_cell, fout); |
| 1286 | + free(my_cell); |
| 1287 | + } |
| 1288 | + else |
| 1289 | + troff_ms_escaped_print(*ptr, fout); |
1256 | 1290 |
|
1257 | 1291 | if ((i + 1) % col_count == 0)
|
1258 | 1292 | fputc('\n', fout);
|
@@ -1281,7 +1315,8 @@ static void
|
1281 | 1315 | print_troff_ms_vertical(const char *title, const char *const *headers,
|
1282 | 1316 | const char *const *cells, const char *const *footers,
|
1283 | 1317 | const char *opt_align, bool opt_tuples_only,
|
1284 |
| - unsigned short int opt_border, FILE *fout) |
| 1318 | + char *opt_numericsep, unsigned short int opt_border, |
| 1319 | + FILE *fout) |
1285 | 1320 | {
|
1286 | 1321 | unsigned int col_count = 0;
|
1287 | 1322 | unsigned int i;
|
@@ -1324,7 +1359,6 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
|
1324 | 1359 | {
|
1325 | 1360 | if (!opt_tuples_only)
|
1326 | 1361 | {
|
1327 |
| - |
1328 | 1362 | if (current_format != 1)
|
1329 | 1363 | {
|
1330 | 1364 | if (opt_border == 2 && i > 0)
|
@@ -1356,7 +1390,19 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
|
1356 | 1390 |
|
1357 | 1391 | troff_ms_escaped_print(headers[i % col_count], fout);
|
1358 | 1392 | fputc('\t', fout);
|
1359 |
| - troff_ms_escaped_print(*ptr, fout); |
| 1393 | + if (strlen(*ptr) != 0 && |
| 1394 | + opt_numericsep != NULL && strlen(opt_numericsep) > 0) |
| 1395 | + { |
| 1396 | + char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1); |
| 1397 | + |
| 1398 | + strcpy(my_cell, *ptr); |
| 1399 | + format_numericsep(my_cell, opt_numericsep); |
| 1400 | + troff_ms_escaped_print(my_cell, fout); |
| 1401 | + free(my_cell); |
| 1402 | + } |
| 1403 | + else |
| 1404 | + troff_ms_escaped_print(*ptr, fout); |
| 1405 | + |
1360 | 1406 | fputc('\n', fout);
|
1361 | 1407 | }
|
1362 | 1408 |
|
@@ -1529,19 +1575,21 @@ printTable(const char *title,
|
1529 | 1575 | case PRINT_LATEX:
|
1530 | 1576 | if (use_expanded)
|
1531 | 1577 | print_latex_vertical(title, headers, cells, footers, align,
|
1532 |
| - opt->tuples_only, border, output); |
| 1578 | + opt->tuples_only, opt->numericSep, |
| 1579 | + border, output); |
1533 | 1580 | else
|
1534 | 1581 | print_latex_text(title, headers, cells, footers, align,
|
1535 |
| - opt->tuples_only, border, output); |
| 1582 | + opt->tuples_only, opt->numericSep, |
| 1583 | + border, output); |
1536 | 1584 | break;
|
1537 | 1585 | case PRINT_TROFF_MS:
|
1538 | 1586 | if (use_expanded)
|
1539 |
| - print_troff_ms_vertical(title, headers, cells, footers, |
1540 |
| - align, opt->tuples_only, |
| 1587 | + print_troff_ms_vertical(title, headers, cells, footers, align, |
| 1588 | + opt->tuples_only, opt->numericSep, |
1541 | 1589 | border, output);
|
1542 | 1590 | else
|
1543 |
| - print_troff_ms_text(title, headers, cells, footers, |
1544 |
| - align, opt->tuples_only, |
| 1591 | + print_troff_ms_text(title, headers, cells, footers, align, |
| 1592 | + opt->tuples_only, opt->numericSep, |
1545 | 1593 | border, output);
|
1546 | 1594 | break;
|
1547 | 1595 | default:
|
|
0 commit comments