-- Copyright (C) 1985, 1986 by Xerox Corporation. All rights reserved.
-- Atof.mesa
-- NFS 18-Dec-85 15:13:56
-- C Library function atof (other procedures of CFormat are implemented in C).
DIRECTORY
Ascii USING [NUL],
CFormat USING [],
CString USING [CString, IncrBPointer, ReadChar],
DoubleReal USING [Double, ReadDouble, PlusZero];
Atof: PROGRAM IMPORTS CString, DoubleReal EXPORTS CFormat =
{
atof: PUBLIC PROCEDURE [nptr: CString.CString] RETURNS [d: DoubleReal.Double] = {
GetChar: PROCEDURE RETURNS [c: CHAR] = {
c ← CString.ReadChar[nptr];
IF c # Ascii.NUL THEN nptr ← CString.IncrBPointer[nptr];
};
d ← DoubleReal.PlusZero; -- in case 1st char. is invalid.
d ← DoubleReal.ReadDouble[GetChar];
};
}.