bugGNU Gengetopt - Bugs: bug #43445, Default string options cannot...

 
 

bug #43445: Default string options cannot contain '\n'.

Submitted by:  None
Submitted on:  Mon 20 Oct 2014 02:28:35 PM UTC  
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Open

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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))
...
}

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

 

 

No changes have been made to this item

Back to the top


Powered by Savane 3.3