diff options
author | PJ v M <pjvm742@disroot.org> | 2022-03-18 18:40:57 +0000 |
---|---|---|
committer | PJ v M <pjvm742@disroot.org> | 2022-03-18 18:56:08 +0000 |
commit | 4ecd49359505dd088a1b65551f52630d001fd806 (patch) | |
tree | 54b1d9b2ddb50f1a0a0053163a28351cfefa9f10 | |
parent | 3323033e70b87434e125b66974a80b364da353c5 (diff) |
unspecial: don't assume comma, update description
Fix the unspecial() procedure in file.c :
For writing a ?sv file, don't assume the delimiter is a comma
when multiple delimiters are allowed.
This leads to quoting when we shouldn't and not quoting when
we should.
Also updated the procedure's documentation with the current
functionality.
-rw-r--r-- | src/file.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1797,21 +1797,22 @@ void export_latex(char * fname, int r0, int c0, int rn, int cn, int verbose) { /** - * \brief unspecial() + * \brief escape special characters and output cell to file * - * \details Unspecial (backquotes - > ") things that are special - * chars in a table + * \details For the export formats delimiter-separated value + * and LaTex. Escapes the special characters in one cell value + * and appends the cell to the file. * * \param[in] f file pointer - * \param[in] srt string pointer + * \param[in] str string pointer * \param[in] delim * * \return none */ void unspecial(FILE * f, char * str, int delim) { int backquote = 0; + if (strchr(str, delim) != NULL) backquote = 1; - if (str_in_str(str, ",") != -1) backquote = 1; if (backquote) putc('\"', f); if (*str == '\\') str++; // delete wheeling string operator, OK? while (*str) { |