? option_dump.diff Index: c_source.h_skel =================================================================== RCS file: /sources/gengetopt/gengetopt/src/skels/c_source.h_skel,v retrieving revision 1.6 diff -u -d -r1.6 c_source.h_skel --- c_source.h_skel 3 Aug 2007 15:58:23 -0000 1.6 +++ c_source.h_skel 16 Oct 2007 08:56:02 -0000 @@ -184,6 +184,25 @@ clear_given (args_info); } + +int address@hidden@_dump(FILE *outfile, struct @args_info@ *args_info) +{ + int i = 0; + + if (!outfile) + { + /* FIXME: error message (do we really need it? */ + fprintf (stderr, "%s: cannot dump options to stream\n", @package_var_name@); + return EXIT_FAILURE; + } + + @file_save_loop:method@ + + i = EXIT_SUCCESS; + return i; +} + int @address@hidden(const char *filename, struct @args_info@ *args_info) { @@ -198,10 +217,9 @@ return EXIT_FAILURE; } - @file_save_loop:method@ + i = @address@hidden(outfile, @args_info@); fclose (outfile); - i = EXIT_SUCCESS; return i; } @@ -702,9 +720,11 @@ } } else - { /* read up the remaining part up to a delimiter */ - next_token = strcspn (farg, " \t\r\n#\'\""); - str_index += next_token; + { /* read up the remaining part up to end of line or comment sign */ + char *ch = (str_index + (next_token = strcspn (farg, "\r\n#"))); + /* remove trailing whitespaces */ + for ( --ch; (*ch >= '\t' && *ch <= '\r') || *ch == ' '; --ch ) + --next_token; } /* truncate farg at the delimiter and store it for further check */ Index: header.h_skel =================================================================== RCS file: /sources/gengetopt/gengetopt/src/skels/header.h_skel,v retrieving revision 1.4 diff -u -d -r1.4 header.h_skel --- header.h_skel 3 Aug 2007 15:58:25 -0000 1.4 +++ header.h_skel 16 Oct 2007 08:56:02 -0000 @@ -93,6 +93,15 @@ struct @address@hidden *params); /** + * Save the contents of the option struct into an already open FILE stream. + * @@param outfile the stream where to dump options + * @@param args_info the option struct to dump + * @@return 0 if everything went fine, NON 0 if an error took place + */ +int @address@hidden(FILE *outfile, + struct @args_info@ *args_info); + +/** * Save the contents of the option struct into a (text) file. * This file can be read by the config file parser (if generated by gengetopt) * @@param filename the file where to save