libCom: Recognize hex literals in epicsStrtod()
Allows Windows and VxWorks to accept hex integers as a double.
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user