* Return a malloc'ed string for the \pset value. * * Note that for some string parameters, print.c distinguishes between unset * and empty string, but for others it doesn't. This function should produce * output that produces the correct setting when fed back into \pset. */
| 4784 | * output that produces the correct setting when fed back into \pset. |
| 4785 | */ |
| 4786 | static char * |
| 4787 | pset_value_string(const char *param, printQueryOpt *popt) |
| 4788 | { |
| 4789 | Assert(param != NULL); |
| 4790 | |
| 4791 | if (strcmp(param, "border") == 0) |
| 4792 | return psprintf("%d", popt->topt.border); |
| 4793 | else if (strcmp(param, "columns") == 0) |
| 4794 | return psprintf("%d", popt->topt.columns); |
| 4795 | else if (strcmp(param, "csv_fieldsep") == 0) |
| 4796 | return pset_quoted_string(popt->topt.csvFieldSep); |
| 4797 | else if (strcmp(param, "expanded") == 0) |
| 4798 | return pstrdup(popt->topt.expanded == 2 |
| 4799 | ? "auto" |
| 4800 | : pset_bool_string(popt->topt.expanded)); |
| 4801 | else if (strcmp(param, "fieldsep") == 0) |
| 4802 | return pset_quoted_string(popt->topt.fieldSep.separator |
| 4803 | ? popt->topt.fieldSep.separator |
| 4804 | : ""); |
| 4805 | else if (strcmp(param, "fieldsep_zero") == 0) |
| 4806 | return pstrdup(pset_bool_string(popt->topt.fieldSep.separator_zero)); |
| 4807 | else if (strcmp(param, "footer") == 0) |
| 4808 | return pstrdup(pset_bool_string(popt->topt.default_footer)); |
| 4809 | else if (strcmp(param, "format") == 0) |
| 4810 | return psprintf("%s", _align2string(popt->topt.format)); |
| 4811 | else if (strcmp(param, "linestyle") == 0) |
| 4812 | return psprintf("%s", get_line_style(&popt->topt)->name); |
| 4813 | else if (strcmp(param, "null") == 0) |
| 4814 | return pset_quoted_string(popt->nullPrint |
| 4815 | ? popt->nullPrint |
| 4816 | : ""); |
| 4817 | else if (strcmp(param, "numericlocale") == 0) |
| 4818 | return pstrdup(pset_bool_string(popt->topt.numericLocale)); |
| 4819 | else if (strcmp(param, "pager") == 0) |
| 4820 | return psprintf("%d", popt->topt.pager); |
| 4821 | else if (strcmp(param, "pager_min_lines") == 0) |
| 4822 | return psprintf("%d", popt->topt.pager_min_lines); |
| 4823 | else if (strcmp(param, "recordsep") == 0) |
| 4824 | return pset_quoted_string(popt->topt.recordSep.separator |
| 4825 | ? popt->topt.recordSep.separator |
| 4826 | : ""); |
| 4827 | else if (strcmp(param, "recordsep_zero") == 0) |
| 4828 | return pstrdup(pset_bool_string(popt->topt.recordSep.separator_zero)); |
| 4829 | else if (strcmp(param, "tableattr") == 0) |
| 4830 | return popt->topt.tableAttr ? pset_quoted_string(popt->topt.tableAttr) : pstrdup(""); |
| 4831 | else if (strcmp(param, "title") == 0) |
| 4832 | return popt->title ? pset_quoted_string(popt->title) : pstrdup(""); |
| 4833 | else if (strcmp(param, "tuples_only") == 0) |
| 4834 | return pstrdup(pset_bool_string(popt->topt.tuples_only)); |
| 4835 | else if (strcmp(param, "unicode_border_linestyle") == 0) |
| 4836 | return pstrdup(_unicode_linestyle2string(popt->topt.unicode_border_linestyle)); |
| 4837 | else if (strcmp(param, "unicode_column_linestyle") == 0) |
| 4838 | return pstrdup(_unicode_linestyle2string(popt->topt.unicode_column_linestyle)); |
| 4839 | else if (strcmp(param, "unicode_header_linestyle") == 0) |
| 4840 | return pstrdup(_unicode_linestyle2string(popt->topt.unicode_header_linestyle)); |
| 4841 | else |
| 4842 | return pstrdup("ERROR"); |
| 4843 | } |
no test coverage detected