Mon 20 Oct 2014 02:28:35 PM UTC, original submission:
It's impossible to have a default string contain the characters \ (backslash) and n next to each other without it turning into a new line.
Trying to escape the new line's backslash with "\\n" incorrectly outputs "\\n". While "\n" turns into a newline which I don't believe is intended behavior.
Example input:
package "slop"
version "v3.1.6"
usage "slop [options]"
option "format" f "Set the output format string. Format specifiers are %x, %y, %w, %h, %i, %g, and %c."
string
default="X=%x\\nY=%y\\nW=%w\\nH=%h\\nG=%g\\nID=%i\\nCancel=%c\\n"
optional
Expected output:
const char *gengetopt_args_info_help[] = {
...
" -f, --format=STRING Set the output format string. Format specifiers\n are %x, %y, %w, %h, %i, %g, and %c.\n (default=`X=%x\\nY=%y\\nW=%w\\nH=%h\\nG=%g\\nID=%i\\nCancel=%c\\n')",
...
};
static
void clear_args (struct gengetopt_args_info *args_info)
{
...
args_info->format_arg = gengetopt_strdup ("X=%x\nY=%y\nW=%w\nH=%h\nG=%g\nID=%i\nCancel=%c\n");
...
}
int cmdline_parser_internal (...) {
...
&(local_args_info.format_given), optarg, 0, "X=%x\nY=%y\nW=%w\nH=%h\nG=%g\nID=%i\nCancel=%c\n", ARG_STRING,
check_ambiguity, override, 0, 0,
"format", 'f',
additional_error))
...
}
Actual output:
const char *gengetopt_args_info_help[] = {
...
" -f, --format=STRING Set the output format string. Format specifiers\n are %x, %y, %w, %h, %i, %g, and %c.\n (default=`X=%x\\nY=%y\\nW=%w\\nH=%h\\nG=%g\\nID=%i\\nCancel=%c\\n')",
...
};
static
void clear_args (struct gengetopt_args_info *args_info)
{
...
args_info->format_arg = gengetopt_strdup ("X=%x\\nY=%y\\nW=%w\\nH=%h\\nG=%g\\nID=%i\\nCancel=%c\\n");
...
}
int cmdline_parser_internal (...) {
...
&(local_args_info.format_given), optarg, 0, "X=%x\\nY=%y\\nW=%w\\nH=%h\\nG=%g\\nID=%i\\nCancel=%c\\n", ARG_STRING,
check_ambiguity, override, 0, 0,
"format", 'f',
additional_error))
...
}
|