Skip to content

Commit

Permalink
refactor(deps): Internallize strtod (using the ryu2 code)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Nov 9, 2024
1 parent 95089cb commit 61e63e1
Show file tree
Hide file tree
Showing 4 changed files with 683 additions and 18 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ if(UA_ENABLE_JSON_ENCODING)
${PROJECT_SOURCE_DIR}/src/ua_types_encoding_json.h)
list(APPEND lib_sources ${PROJECT_SOURCE_DIR}/deps/cj5.c
${PROJECT_SOURCE_DIR}/deps/parse_num.c
${PROJECT_SOURCE_DIR}/deps/strtod.c
${PROJECT_SOURCE_DIR}/src/ua_types_encoding_json.c
${PROJECT_SOURCE_DIR}/src/pubsub/ua_pubsub_networkmessage_json.c)
endif()
Expand Down
1 change: 1 addition & 0 deletions deps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ The following third party libraries may be included -- depending on the activate
| ziptree | MPL 2.0 | Reusable zip tree implementation |
| mqtt-c | MIT | a portable MQTT client in C |
| dtoa | BSL (Boost) | Printing of float numbers |
| strtod | BSL (Boost) | Parsing of float numbers |
| mp_printf | MIT | Our version of github:mpaland/printf |
18 changes: 0 additions & 18 deletions deps/parse_num.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@

#include "parse_num.h"

#include <string.h>
#include <stdlib.h>
#include <errno.h>

size_t
parseUInt64(const char *str, size_t size, uint64_t *result) {
size_t i = 0;
Expand Down Expand Up @@ -95,17 +91,3 @@ parseInt64(const char *str, size_t size, int64_t *result) {
}
return len + i;
}

size_t parseDouble(const char *str, size_t size, double *result) {
char buf[2000];
if(size >= 2000)
return 0;
memcpy(buf, str, size);
buf[size] = 0;
errno = 0;
char *endptr;
*result = strtod(str, &endptr);
if(errno != 0 && errno != ERANGE)
return 0;
return (uintptr_t)endptr - (uintptr_t)str;
}
Loading

0 comments on commit 61e63e1

Please sign in to comment.