home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume10 / parseargs / fp_argtype.c < prev    next >
C/C++ Source or Header  |  1990-02-16  |  1KB  |  62 lines

  1. #include <useful.h>
  2. #include <parseargs.h>
  3.  
  4. VERSIONID("$Header: fp_args.c,v 2.0 89/12/24 00:56:21 eric Exp $");
  5.  
  6. /*
  7. **  PARSEARGV argument type functions for floating point operands.
  8. **
  9. **    These are broken out to avoid loading the floating precision
  10. **    conversion routines when they aren't actually needed.
  11. **
  12. **    Author:
  13. **        Eric Allman
  14. **        University of California, Berkeley
  15. */
  16.  
  17. /*ARGSUSED*/
  18. BOOL
  19. argDouble(ad, vp, copyf)
  20.     register ARGDESC *ad;
  21.     register char *vp;
  22.     BOOL copyf;
  23. {
  24.     auto char *vpp;
  25.     extern double strtod ARGS((char *, char **));
  26.  
  27.     *(double *) ad->ad_valp = strtod(vp, &vpp);
  28.     if (*vpp != '\0')
  29.     {
  30.         usrerr("invalid floating point argument '%s' for %s",
  31.             vp, ad->ad_prompt);
  32.         return (FALSE);
  33.     }
  34.     else
  35.     {
  36.         return (TRUE);
  37.     }
  38. }
  39.  
  40. /*ARGSUSED*/
  41. BOOL
  42. argFloat(ad, vp, copyf)
  43.     register ARGDESC *ad;
  44.     register char *vp;
  45.     BOOL copyf;
  46. {
  47.     auto char *vpp;
  48.     extern double strtod ARGS((char *, char **));
  49.  
  50.     *(float *) ad->ad_valp = (float) strtod(vp, &vpp);
  51.     if (*vpp != '\0')
  52.     {
  53.         usrerr("invalid floating point argument '%s' for %s",
  54.             vp, ad->ad_prompt);
  55.         return (FALSE);
  56.     }
  57.     else
  58.     {
  59.         return (TRUE);
  60.     }
  61. }
  62.