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: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned 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 File(s):
   
   
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 click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

No Changes Have Been Made to This Item

Back to the top


Powered by Savane 3.1-cleanup1