bugGNU Gengetopt - Bugs: bug #35998, argoptional unexpected behavior

 
 

bug #35998: argoptional unexpected behavior

Submitter:  None
Submitted:  Sun 25 Mar 2012 04:59:41 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
   

Sun 25 Mar 2012 04:59:41 PM UTC, original submission:  

The getopt code in cmdline.c, generated with the argoptional flag, as in


# sample.ggo
option   "x-opt"   x "x option"   argoptional
option   "test"    t "t option"   optional argoptional


with gengetopt --input=sample.ggo --file-name=cmdline is not following the getopt-gnu specifications [1]. The generated code is


448       static struct option long_options[] = {
449         { "help", 0, NULL, 'h' },
450         { "version",  0, NULL, 'V' },
451         { "x-opt",  0, NULL, 'x' },
452         { "test", 0, NULL, 't' },
453         { 0,  0, 0, 0 }
454       };
455
456       c = getopt_long (argc, argv, "hVx:t:", long_options, &option_index);


but it should be


448       static struct option long_options[] = {
449         { "help", 0, NULL, 'h' },
450         { "version",  0, NULL, 'V' },
451         { "x-opt",  2, NULL, 'x' },
452         { "test", 2, NULL, 't' },
453         { 0,  0, 0, 0 }
454       };
455
456       c = getopt_long (argc, argv, "hVx::t::", long_options, &option_index);


(optional_argument==2 and two colons).

[1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html

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-269c.
Corresponding source code