/* Quote names as for a C language string (ls --quoting-style=c).
Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is
- in effect.
+ in effect. Split into consecutive strings if
+ QA_SPLIT_TRIGRAPHS.
quotearg_buffer:
- "\"simple\"", "\"\\0 \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\""
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
quotearg:
- "\"simple\"", "\"\\0 \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\""
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
quotearg_colon:
- "\"simple\"", "\"\\0 \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a\\:b\""
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
*/
c_quoting_style,
characters if no quoted characters are encountered.
quotearg_buffer:
- "simple", "\"\\0 \\t\\n'\\\"\\033?\"\"?/\\\\\"", "a:b"
+ "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
quotearg:
- "simple", "\"\\0 \\t\\n'\\\"\\033?\"\"?/\\\\\"", "a:b"
+ "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
quotearg_colon:
- "simple", "\"\\0 \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\""
+ "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
*/
c_maybe_quoting_style,
/* Like c_quoting_style except always omit the surrounding
- double-quote characters and don't worry about trigraphs (ls
- --quoting-style=escape).
+ double-quote characters (ls --quoting-style=escape).
quotearg_buffer:
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
locale_quoting_style,
/* Like c_quoting_style except use quotation marks appropriate for
- the locale and don't worry about trigraphs (ls
- --quoting-style=clocale).
+ the locale (ls --quoting-style=clocale).
LC_MESSAGES=C
quotearg_buffer:
/* Omit the surrounding quote characters if no escaped characters
are encountered. */
- QA_ELIDE_OUTER_QUOTES = 0x02
+ QA_ELIDE_OUTER_QUOTES = 0x02,
+
+ /* In the c_quoting_style and c_maybe_quoting_style, split ANSI
+ trigraph sequences into concatenated strings (for example,
+ "?""?/" rather than "??/", which could be confused with
+ "\\"). */
+ QA_SPLIT_TRIGRAPHS = 0x04
};
/* For now, --quoting-style=literal is the default, but this may change. */
/* c_quoting_style */
{ { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"",
- "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\"" },
+ "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"" },
{ "\"\"", "\"\\0001\\0\"", 9, "\"simple\"",
- "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\"" },
+ "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"" },
{ "\"\"", "\"\\0001\\0\"", 9, "\"simple\"",
- "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a\\:b\"" } },
+ "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a\\:b\"" } },
/* c_maybe_quoting_style */
- { { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"",
+ { { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"",
"a:b" },
- { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"",
+ { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"",
"a:b" },
- { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"",
+ { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"",
"\"a:b\"" } },
/* escape_quoting_style */
"\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a\\:b\"" } }
};
+static struct result_groups flag_results[] = {
+ /* literal_quoting_style and QA_ELIDE_NULL_BYTES */
+ { { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b" },
+ { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b" },
+ { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b" } },
+
+ /* c_quoting_style and QA_ELIDE_OUTER_QUOTES */
+ { { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"",
+ "a:b" },
+ { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"",
+ "a:b" },
+ { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"",
+ "\"a:b\"" } },
+
+ /* c_quoting_style and QA_SPLIT_TRIGRAPHS */
+ { { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"",
+ "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\"" },
+ { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"",
+ "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\"" },
+ { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"",
+ "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a\\:b\"" } }
+};
+
#if ENABLE_NLS
static struct result_groups locale_results[] = {
/* locale_quoting_style */
compare_strings (use_quotearg_colon, &results_g[i].group3);
}
+ set_quoting_style (NULL, literal_quoting_style);
+ ASSERT (set_quoting_flags (NULL, QA_ELIDE_NULL_BYTES) == 0);
+ compare_strings (use_quotearg_buffer, &flag_results[0].group1);
+ compare_strings (use_quotearg, &flag_results[0].group2);
+ compare_strings (use_quotearg_colon, &flag_results[0].group3);
+
+ set_quoting_style (NULL, c_quoting_style);
+ ASSERT (set_quoting_flags (NULL, QA_ELIDE_OUTER_QUOTES)
+ == QA_ELIDE_NULL_BYTES);
+ compare_strings (use_quotearg_buffer, &flag_results[1].group1);
+ compare_strings (use_quotearg, &flag_results[1].group2);
+ compare_strings (use_quotearg_colon, &flag_results[1].group3);
+
+ ASSERT (set_quoting_flags (NULL, QA_SPLIT_TRIGRAPHS)
+ == QA_ELIDE_OUTER_QUOTES);
+ compare_strings (use_quotearg_buffer, &flag_results[2].group1);
+ compare_strings (use_quotearg, &flag_results[2].group2);
+ compare_strings (use_quotearg_colon, &flag_results[2].group3);
+
+ ASSERT (set_quoting_flags (NULL, 0) == QA_SPLIT_TRIGRAPHS);
+
#if ENABLE_NLS
/* Rather than change locales, and require a .gmo file with
translations for "`" and "'" that match our expectations, we