summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/lcdf-typetools-2.99/liblcdf/strtonum.c
blob: 36898c5a7add8590a5872e5e581de06ca46ebf70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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