From: Christos Zoulas Date: Thu, 27 Dec 2007 20:52:35 +0000 (+0000) Subject: - deal with missing strtof X-Git-Tag: FILE5_05~556 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb65a5957f4bc33617350504f63b14bfec079a30;p=file - deal with missing strtof - better version mispatch print --- diff --git a/config.h.in b/config.h.in index a745cf13..281a4e40 100644 --- a/config.h.in +++ b/config.h.in @@ -72,6 +72,9 @@ /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP +/* Define to 1 if you have the `strtof' function. */ +#undef HAVE_STRTOF + /* Define to 1 if you have the `strtoul' function. */ #undef HAVE_STRTOUL diff --git a/configure b/configure index 42225b1c..2e420449 100755 --- a/configure +++ b/configure @@ -23398,7 +23398,8 @@ _ACEOF -for ac_func in mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf + +for ac_func in mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf strtof do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index d5e6ca56..8af5dafc 100644 --- a/configure.in +++ b/configure.in @@ -127,7 +127,7 @@ AC_CHECK_SIZEOF_STDC_HEADERS(int64_t, 0) AC_CHECK_SIZEOF_STDC_HEADERS(uint64_t, 0) dnl Checks for functions -AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf) +AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf strtof) dnl Checks for libraries AC_CHECK_LIB(z,gzopen) diff --git a/src/apprentice.c b/src/apprentice.c index 094e4e64..162acfef 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -31,6 +31,7 @@ #include "file.h" #include "magic.h" +#include "patchlevel.h" #include #ifdef HAVE_UNISTD_H #include @@ -46,7 +47,7 @@ #endif #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.108 2007/12/27 16:35:58 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.109 2007/12/27 20:52:36 christos Exp $") #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -1418,7 +1419,11 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) case FILE_LEFLOAT: if (m->reln != 'x') { char *ep; +#ifdef HAVE_STRTOF m->value.f = strtof(*p, &ep); +#else + m->value.f = (float)strtod(*p, &ep); +#endif *p = ep; } return 0; @@ -1758,8 +1763,9 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, else version = ptr[1]; if (version != VERSIONNO) { - file_error(ms, 0, "version mismatch (%d != %d) in `%s'", - version, VERSIONNO, dbname); + file_error(ms, 0, "File %d.%d supports only %d version magic " + "files. `%s' is version %d", FILE_VERSION_MAJOR, patchlevel, + VERSIONNO, dbname, version); goto error; } *nmagicp = (uint32_t)(st.st_size / sizeof(struct magic)) - 1;