#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.272 2018/06/22 20:39:50 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.273 2018/08/01 09:53:18 christos Exp $")
#endif /* lint */
#include "magic.h"
#include <limits.h>
#endif
-#ifndef SSIZE_MAX
-#define MAXMAGIC_SIZE ((ssize_t)0x7fffffff)
-#else
-#define MAXMAGIC_SIZE SSIZE_MAX
-#endif
#define EATAB {while (isascii((unsigned char) *l) && \
isspace((unsigned char) *l)) ++l;}
return p->type;
}
+private off_t
+maxoff_t(void) {
+ if (sizeof(off_t) == sizeof(int))
+ return CAST(off_t, INT_MAX);
+ if (sizeof(off_t) == sizeof(long))
+ return CAST(off_t, LONG_MAX);
+ return 0x7fffffff;
+}
+
private int
get_standard_integer_type(const char *l, const char **t)
{
file_error(ms, errno, "cannot stat `%s'", dbname);
goto error;
}
- if (st.st_size < 8 || st.st_size > MAXMAGIC_SIZE) {
+ if (st.st_size < 8 || st.st_size > maxoff_t()) {
file_error(ms, 0, "file `%s' is too %s", dbname,
st.st_size < 8 ? "small" : "large");
goto error;