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

 
 

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

Submitter:  None
Submitted:  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
* Mandatory Fields

Add a New Comment Rich Markup
   

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

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

No changes have been made to this item

Back to the top

Powered by Savane 3.13-da57.
Corresponding source code