libCom: Recognize hex literals in epicsStrtod()

Allows Windows and VxWorks to accept hex integers as a double.
This commit is contained in:
Andrew Johnson
2013-12-02 11:12:19 -06:00
parent bd82554299
commit 78a4e462d5
2 changed files with 14 additions and 0 deletions

View File

@@ -13,6 +13,14 @@
<!-- Insert new items immediately below here ... -->
<h3>Hex literal support in epicStrtod()</h3>
<p>Some OS implementations of the standard C library routine strtod() do not
recognize hexadecimal integers, in particular the libraries provided on Windows
and VxWorks. The internal implementation of epicsStrtod() that these targets use
now recognizes the 0x prefix and will convert hex numbers correctly. Thanks to
Dirk Zimoch for suggesting this change.</p>
<h3>Added support for 64-bit Cygwin and MinGW targets</h3>
<p>Both windows-x64-mingw and cygwin-x86_64 build targets are now provided.</p>

View File

@@ -60,6 +60,12 @@ epicsShareFunc double epicsStrtod(const char *str, char **endp)
cp++;
}
if (epicsStrnCaseCmp("0x", cp, 2) == 0) {
if (negative)
return strtol(str, endp, 16);
else
return strtoul(str, endp, 16);
}
if (!isalpha((int)*cp))
return strtod(str, endp);