[comp.lang.c] Bug in demo.c of argproc.shar

dan@srs.UUCP (Dan Kegel) (04/06/88)

The package 'argproc' recently posted to comp.sources.misc contains a bug
in the demo program 'demo.c'.  On line 62 where it reads
    argproc(argc, argv, "=bc {=help} =s%s -x%d {-pi%lf} %s",
it should really read
    arg_string[0] = '\0';	/* clear so we can see if user gave it */
    argproc(argc, argv, "=bc {=help} =s%s -x%d {-pi%lf} %s",

The documentation also fails to explicitly say that
    o the variable associated with scanf-style parameters (%s, %d...) is only
      altered if the user typed the corresponding value.  Thus, in demo.c, 
      the string arg_string should be cleared before calling argproc().
    o the boolean variable associated with =switch is always altered; it
      is set TRUE if the switch is given, FALSE if it is not.

I'll be over in the back eating humble pie if you need me.

- A. Nonymous
-- 
  Dan Kegel   "... earn it anew if thou wouldst possess it."  - Goethe: Faust
  srs!dan@cs.rochester.edu  rochester!srs!dan dan%srs.uucp@harvard.harvard.edu