summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/liblcdf/strtonum.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/liblcdf/strtonum.c')
-rw-r--r--Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/liblcdf/strtonum.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/liblcdf/strtonum.c b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/liblcdf/strtonum.c
new file mode 100644
index 00000000000..36898c5a7ad
--- /dev/null
+++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/liblcdf/strtonum.c
@@ -0,0 +1,31 @@
+/* -*- related-file-name: "../include/lcdf/strtonum.h" -*- */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <lcdf/strtonum.h>
+#include <stdlib.h>
+#if HAVE_BROKEN_STRTOD
+# define strtod good_strtod
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A faster strtod which only calls the real strtod if the string has a
+ fractional part. */
+
+double
+strtonumber(const char *f, char **endf)
+{
+ long v = strtol((char *)f, endf, 10);
+
+ /* handle any possible decimal part */
+ if (**endf == '.' || **endf == 'E' || **endf == 'e')
+ return strtod((char *)f, endf);
+ else
+ return v;
+}
+
+#ifdef __cplusplus
+}
+#endif