From 78a4e462d5538490e8f24cf9d9b083bb043c9cab Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 2 Dec 2013 11:12:19 -0600 Subject: [PATCH] libCom: Recognize hex literals in epicsStrtod() Allows Windows and VxWorks to accept hex integers as a double. --- documentation/RELEASE_NOTES.html | 8 ++++++++ src/libCom/misc/epicsStdlib.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index cdbca97cf..0b5b01f4e 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,14 @@ +

Hex literal support in epicStrtod()

+ +

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.

+

Added support for 64-bit Cygwin and MinGW targets

Both windows-x64-mingw and cygwin-x86_64 build targets are now provided.

diff --git a/src/libCom/misc/epicsStdlib.c b/src/libCom/misc/epicsStdlib.c index 494fc60be..f1c89aaa3 100644 --- a/src/libCom/misc/epicsStdlib.c +++ b/src/libCom/misc/epicsStdlib.c @@ -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);