Use epicsScanFloat/epicsScanDouble rather than sscanf.

This allows proper handling of Nan/Inf on all architectures.
This commit is contained in:
W. Eric Norum
2004-10-12 17:45:31 +00:00
parent 25c797b212
commit 0dc034962c
18 changed files with 53 additions and 52 deletions

View File

@@ -55,7 +55,7 @@
* FLASE expression element not found
*/
#include <stdlib.h>
#include <epicsStdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@@ -347,7 +347,7 @@ long epicsShareAPI postfix(const char *pin,char *ppostfix,short *perror)
*ppostfix++ = '\0';
ppostfix = pposthold;
if ( sscanf(ppostfix,"%lg",&constant) != 1) {
if ( epicsScanDouble(ppostfix, &constant) != 1) {
*ppostfix = '\0';
} else {
memcpy(ppostfix,(void *)&constant,8);

View File

@@ -37,7 +37,7 @@
*-***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <epicsStdlib.h>
#include <string.h>
#include <limits.h>
@@ -198,7 +198,7 @@ double *pDouble /* O pointer to place to store value */
ptext = envGetConfigParam(pParam, sizeof text, text);
if (ptext != NULL) {
count = sscanf(text, "%lf", pDouble);
count = epicsScanDouble(text, pDouble);
if (count == 1) {
return 0;
}

View File

@@ -16,7 +16,7 @@
#include "epicsStdio.h"
epicsShareFunc int epicsShareAPI epicsStrScanDouble(const char *str, double *dest)
epicsShareFunc int epicsShareAPI epicsScanDouble(const char *str, double *dest)
{
char *endp;
double dtmp;
@@ -28,7 +28,7 @@ epicsShareFunc int epicsShareAPI epicsStrScanDouble(const char *str, double *des
return 1;
}
epicsShareFunc int epicsShareAPI epicsStrScanFloat(const char *str, float *dest)
epicsShareFunc int epicsShareAPI epicsScanFloat(const char *str, float *dest)
{
char *endp;
double dtmp;

View File

@@ -16,8 +16,8 @@
extern "C" {
#endif
epicsShareFunc int epicsShareAPI epicsStrScanDouble(const char *str, double *dest);
epicsShareFunc int epicsShareAPI epicsStrScanFloat(const char *str, float *dest);
epicsShareFunc int epicsShareAPI epicsScanDouble(const char *str, double *dest);
epicsShareFunc int epicsShareAPI epicsScanFloat(const char *str, float *dest);
#include <stdlib.h>
#include <osdStrtod.h>