|
28 | 28 |
|
29 | 29 |
|
30 | 30 | static void |
31 | | -print_unaligned_text(const char *title, char **headers, char **cells, char **footers, |
| 31 | +print_unaligned_text(const char *title, const char * const * headers, |
| 32 | + const char * const * cells, const char * const * footers, |
32 | 33 | const char *opt_fieldsep, bool opt_barebones, |
33 | 34 | FILE *fout) |
34 | 35 | { |
35 | 36 | unsigned int col_count = 0; |
36 | 37 | unsigned int i; |
37 | | - char **ptr; |
| 38 | + const char * const * ptr; |
38 | 39 |
|
39 | 40 | if (!opt_fieldsep) |
40 | 41 | opt_fieldsep = ""; |
@@ -80,14 +81,15 @@ print_unaligned_text(const char *title, char **headers, char **cells, char **foo |
80 | 81 |
|
81 | 82 |
|
82 | 83 | static void |
83 | | -print_unaligned_vertical(const char *title, char **headers, char **cells, char **footers, |
| 84 | +print_unaligned_vertical(const char *title, const char * const * headers, |
| 85 | + const char * const * cells, const char * const * footers, |
84 | 86 | const char *opt_fieldsep, bool opt_barebones, |
85 | 87 | FILE *fout) |
86 | 88 | { |
87 | 89 | unsigned int col_count = 0; |
88 | 90 | unsigned int i; |
89 | 91 | unsigned int record = 1; |
90 | | - char **ptr; |
| 92 | + const char * const * ptr; |
91 | 93 |
|
92 | 94 | if (!opt_fieldsep) |
93 | 95 | opt_fieldsep = ""; |
@@ -167,16 +169,17 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths, |
167 | 169 |
|
168 | 170 |
|
169 | 171 | static void |
170 | | -print_aligned_text(const char *title, char **headers, char **cells, char **footers, |
171 | | -const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
| 172 | +print_aligned_text(const char *title, const char * const * headers, |
| 173 | + const char * const * cells, const char * const * footers, |
| 174 | + const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
172 | 175 | FILE *fout) |
173 | 176 | { |
174 | 177 | unsigned int col_count = 0; |
175 | 178 | unsigned int i, |
176 | 179 | tmp; |
177 | 180 | unsigned int *widths, |
178 | 181 | total_w; |
179 | | - char **ptr; |
| 182 | + const char * const * ptr; |
180 | 183 |
|
181 | 184 | /* count columns */ |
182 | 185 | for (ptr = headers; *ptr; ptr++) |
@@ -308,13 +311,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
308 | 311 |
|
309 | 312 |
|
310 | 313 | static void |
311 | | -print_aligned_vertical(const char *title, char **headers, char **cells, char **footers, |
| 314 | +print_aligned_vertical(const char *title, const char * const * headers, |
| 315 | + const char * const * cells, const char * const * footers, |
312 | 316 | bool opt_barebones, unsigned short int opt_border, |
313 | 317 | FILE *fout) |
314 | 318 | { |
315 | 319 | unsigned int col_count = 0; |
316 | 320 | unsigned int record = 1; |
317 | | - char **ptr; |
| 321 | + const char * const *ptr; |
318 | 322 | unsigned int i, |
319 | 323 | tmp, |
320 | 324 | hwidth = 0, |
@@ -471,14 +475,15 @@ html_escaped_print(const char *in, FILE *fout) |
471 | 475 |
|
472 | 476 |
|
473 | 477 | static void |
474 | | -print_html_text(const char *title, char **headers, char **cells, char **footers, |
475 | | -const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
476 | | - char *opt_table_attr, |
| 478 | +print_html_text(const char *title, const char * const * headers, |
| 479 | + const char * const * cells, const char * const * footers, |
| 480 | + const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
| 481 | + const char *opt_table_attr, |
477 | 482 | FILE *fout) |
478 | 483 | { |
479 | 484 | unsigned int col_count = 0; |
480 | 485 | unsigned int i; |
481 | | - char **ptr; |
| 486 | + const char * const *ptr; |
482 | 487 |
|
483 | 488 | fprintf(fout, "<table border=%d", opt_border); |
484 | 489 | if (opt_table_attr) |
@@ -544,15 +549,16 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
544 | 549 |
|
545 | 550 |
|
546 | 551 | static void |
547 | | -print_html_vertical(const char *title, char **headers, char **cells, char **footers, |
548 | | -const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
549 | | - char *opt_table_attr, |
| 552 | +print_html_vertical(const char *title, const char * const * headers, |
| 553 | + const char * const * cells, const char * const * footers, |
| 554 | + const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
| 555 | + const char *opt_table_attr, |
550 | 556 | FILE *fout) |
551 | 557 | { |
552 | 558 | unsigned int col_count = 0; |
553 | 559 | unsigned int i; |
554 | 560 | unsigned int record = 1; |
555 | | - char **ptr; |
| 561 | + const char * const *ptr; |
556 | 562 |
|
557 | 563 | fprintf(fout, "<table border=%d", opt_border); |
558 | 564 | if (opt_table_attr) |
@@ -652,14 +658,15 @@ latex_escaped_print(const char *in, FILE *fout) |
652 | 658 |
|
653 | 659 |
|
654 | 660 | static void |
655 | | -print_latex_text(const char *title, char **headers, char **cells, char **footers, |
656 | | -const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
| 661 | +print_latex_text(const char *title, const char * const * headers, |
| 662 | + const char * const * cells, const char * const * footers, |
| 663 | + const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
657 | 664 | FILE *fout) |
658 | 665 | { |
659 | 666 | unsigned int col_count = 0; |
660 | 667 | unsigned int i; |
661 | 668 | const char *cp; |
662 | | - char **ptr; |
| 669 | + const char * const *ptr; |
663 | 670 |
|
664 | 671 |
|
665 | 672 | /* print title */ |
@@ -747,13 +754,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
747 | 754 |
|
748 | 755 |
|
749 | 756 | static void |
750 | | -print_latex_vertical(const char *title, char **headers, char **cells, char **footers, |
751 | | -const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
| 757 | +print_latex_vertical(const char *title, const char * const * headers, |
| 758 | + const char * const * cells, const char * const * footers, |
| 759 | + const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
752 | 760 | FILE *fout) |
753 | 761 | { |
754 | 762 | unsigned int col_count = 0; |
755 | 763 | unsigned int i; |
756 | | - char **ptr; |
| 764 | + const char * const *ptr; |
757 | 765 | unsigned int record = 1; |
758 | 766 |
|
759 | 767 | (void) opt_align; /* currently unused parameter */ |
@@ -833,11 +841,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border, |
833 | 841 |
|
834 | 842 |
|
835 | 843 | void |
836 | | -printTable(const char *title, char **headers, char **cells, char **footers, |
| 844 | +printTable(const char *title, |
| 845 | + const char * const * headers, |
| 846 | + const char * const * cells, |
| 847 | + const char * const * footers, |
837 | 848 | const char *align, |
838 | 849 | const printTableOpt * opt, FILE *fout) |
839 | 850 | { |
840 | | - char *default_footer[] = {NULL}; |
| 851 | + const char *default_footer[] = {NULL}; |
841 | 852 | unsigned short int border = opt->border; |
842 | 853 | FILE *pager = NULL, |
843 | 854 | *output; |
@@ -868,7 +879,7 @@ printTable(const char *title, char **headers, char **cells, char **footers, |
868 | 879 | unsigned int col_count = 0, |
869 | 880 | row_count = 0, |
870 | 881 | lines; |
871 | | - char **ptr; |
| 882 | + const char * const *ptr; |
872 | 883 | int result; |
873 | 884 | struct winsize screen_size; |
874 | 885 |
|
@@ -952,11 +963,11 @@ printTable(const char *title, char **headers, char **cells, char **footers, |
952 | 963 |
|
953 | 964 |
|
954 | 965 | void |
955 | | -printQuery(PGresult *result, const printQueryOpt * opt, FILE *fout) |
| 966 | +printQuery(const PGresult *result, const printQueryOpt * opt, FILE *fout) |
956 | 967 | { |
957 | 968 | int nfields; |
958 | | - char **headers; |
959 | | - char **cells; |
| 969 | + const char **headers; |
| 970 | + const char **cells; |
960 | 971 | char **footers; |
961 | 972 | char *align; |
962 | 973 | int i; |
@@ -1043,8 +1054,9 @@ printQuery(PGresult *result, const printQueryOpt * opt, FILE *fout) |
1043 | 1054 |
|
1044 | 1055 | /* call table printer */ |
1045 | 1056 |
|
1046 | | - printTable(opt->title, headers, cells, footers ? footers : opt->footers, align, |
1047 | | - &opt->topt, fout); |
| 1057 | + printTable(opt->title, headers, cells, |
| 1058 | + footers ? (const char * const *)footers : (const char * const *)(opt->footers), |
| 1059 | + align, &opt->topt, fout); |
1048 | 1060 |
|
1049 | 1061 | free(headers); |
1050 | 1062 | free(cells); |
|
0 commit comments