Hi, On Sat, May 12, 2007 at 10:18:36PM +0200, Tim Dijkstra wrote: > Hi, > > OK, it turns out that my last patch for adding comments to usage had a > horrible bug. Although (struct option_descr) would yield a (struct option), > as anticipated, the increment of the pointers of these structs ofcourse > wouldn't... > > Anyway the patch below fixes this, although also in a bit hackish way. > usage() expects an \0 in the option.name string, and after that a comment. > Like this: > > "help\0this text" > > grts Tim > > Index: config.c > =================================================================== > RCS file: /cvsroot/suspend/suspend/config.c,v > retrieving revision 1.9 > diff -u -r1.9 config.c > --- config.c 2 May 2007 20:55:43 -0000 1.9 > +++ config.c 12 May 2007 20:10:37 -0000 > @@ -104,23 +104,27 @@ > return error; > } > > -void usage(char *my_name, struct option_descr *options, const char > *short_options) > +/* We're abusing struct option a bit. usage() expects an \0 in the > + * name string, and after that a comment. > + */
> + const char *descr = opt->name + strlen(opt->name) + 1; This is not elegant, this is just obfuscated. Trivial code for options parsing should be obvious and trivial IMO. Right now i have no brilliant idea how to solve this better, but i don't like this implementation. -- Stefan Seyfried "Any ideas, John?" "Well, surrounding them's out." ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Suspend-devel mailing list Suspend-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/suspend-devel