Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Apropos / Subsearch:
optional field

STRING_TO_DECIMAL(3)       Library Functions Manual       STRING_TO_DECIMAL(3)

       string_to_decimal,  file_to_decimal, func_to_decimal - parse characters
       into decimal record

       #include <&lt;floatingpoint.h>&gt;
       #include <&lt;stdio.h>&gt;

       void string_to_decimal(pc,nmax,fortran_conventions,pd,pform,pechar)
       char **pc;
       int nmax;
       int fortran_conventions;
       decimal_record *pd;
       enum decimal_string_form *pform;
       char **pechar;

       void file_to_decimal(pc,nmax,fortran_conventions,pd,pform,pechar,pf,pnread)
       char **pc;
       int nmax;
       int fortran_conventions;
       decimal_record *pd;
       enum decimal_string_form *pform;
       char **pechar;
       FILE *pf;
       int *pnread;

       void func_to_decimal(pc,nmax,fortran_conventions,pd,pform,pechar,pget,pnread,punget)
       char **pc;
       int nmax;
       int fortran_conventions;
       decimal_record *pd;
       enum decimal_string_form *pform;
       char **pechar;
       int (*pget)();
       int *pnread;
       int (*punget)();

       The char_to_decimal() functions parse a numeric token from at most nmax
       characters  in  a  string **pc or file *pf or function (*pget)() into a
       decimal record *pd, classifying the form of the string  in  *pform  and
       *pechar.   The  accepted syntax is intended to be sufficiently flexible
       to accomodate many languages:

              whitespace value


              whitespace sign value

       where whitespace is any number of  characters  defined  by  isspace  in
       <&lt;ctype.h>&gt;,  sign  is  either  of [+-], and value can be number, nan, or
       inf.  inf can be INF (inf_form)  or  INFINITY  (infinity_form)  without
       regard   to   case.    nan   can  be  NAN  (nan_form)  or  NAN(nstring)
       (nanstring_form) without regard to case; nstring is any string of char-
       acters  not  containing ')' or the null character; nstring is copied to
       pd->&gt;ds and, currently, not used subsequently.  number consists of



              significant efield

       where significant must contain one or more digits and may  contain  one
       point; possible forms are

              digits         (int_form)
              digits.        (intdot_form)
              .digits        (dotfrac_form)
              digits.digits  (intdotfrac_form)

       efield consists of

              echar digits


              echar sign digits

       where echar is one of [Ee], and digits contains one or more digits.

       When   fortran_conventions  is  nonzero,  additional  input  forms  are
       accepted according to various Fortran conventions:
       0    no Fortran conventions
       1    Fortran list-directed input conventions
       2    Fortran formatted input conventions, ignore blanks (BN)
       3    Fortran formatted input conventions, blanks are zeros (BZ)

       When fortran_conventions is nonzero, echar may also be one of [Dd], and
       efield may also have the form

              sign digits.

       When  fortran_conventions>=  2, blanks may appear in the digits strings
       for the integer, fraction, and exponent fields and may  appear  between
       echar  and  the exponent sign and after the infinity and NaN forms.  If
       fortran_conventions== 2, the blanks are ignored.  When  fortran_conven-
       tions==  3, the blanks that appear in digits strings are interpreted as
       zeros, and other blanks are ignored.

       When fortran_conventions is zero, the current  locale's  decimal  point
       character  is  used  as  the decimal point; when fortran_conventions is
       nonzero, the period is used as the decimal point.

       The form of the accepted decimal string is placed in  *peform.   If  an
       efield is recognized, *pechar is set to point to the echar.

       On  input,  *pc points to the beginning of a character string buffer of
       length >= nmax.  On output, *pc points to a character in  that  buffer,
       one  past  the  last  accepted character.  string_to_decimal() gets its
       characters from the buffer; file_to_decimal() gets its characters  from
       *pf  and  records  them in the buffer, and places a null after the last
       character read.  func_to_decimal() gets  its  characters  from  an  int
       function (*pget)().

       The  scan  continues  until  no  more characters could possibly fit the
       acceptable syntax or until nmax characters have been scanned.   If  the
       nmax  limit  is not reached then at least one extra character will usu-
       ally be scanned that is not part of the accepted syntax.  file_to_deci-
       mal()  and  func_to_decimal()  set  *pnread to the number of characters
       read from the file; if greater than nmax, some  characters  were  lost.
       If  no  characters  were  lost, file_to_decimal() and func_to_decimal()
       attempt to push back, with ungetc(3S) or (*punget)(), as many as possi-
       ble  of  the excess characters read, adjusting *pnread accordingly.  If
       all unget calls are successful, then **pc will be a null character.  No
       push back will be attempted if (*punget)() is NULL.

       Typical declarations for *pget() and *punget() are:

                   int xget()
                   { ...  }
                   int (*pget)() = xget;
                   int xunget(c)
                   char c ;
                   { ... }
                   int (*punget)() = xunget;

       If  no  valid  number was detected, pd->&gt;fpclass is set to fp_signaling,
       *pc is unchanged, and *pform is set to invalid_form.

       atof()  and  strtod(3)   use   string_to_decimal().    scanf(3V)   uses

       ctype(3V),    localeconv(3),   scanf(3V),   setlocale(3V),   strtod(3),

                                21 January 1988           STRING_TO_DECIMAL(3)