#endif
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.114 2008/02/11 01:36:08 rrt Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.115 2008/02/11 22:12:24 rrt Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
mapped = rv;
- if (magic == NULL || nmagic == 0) {
+ if (magic == NULL) {
file_delmagic(magic, mapped, nmagic);
return -1;
}
file_error(ms, errno, "cannot stat `%s'", dbname);
goto error;
}
- if (st.st_size < 16) {
+ if (st.st_size < 8) {
file_error(ms, 0, "file `%s' is too small", dbname);
goto error;
}
VERSIONNO, dbname, version);
goto error;
}
- *nmagicp = (uint32_t)(st.st_size / sizeof(struct magic)) - 1;
+ *nmagicp = (uint32_t)(st.st_size / sizeof(struct magic));
+ if (*nmagicp > 0)
+ nmagicp--;
(*magicp)++;
if (needsbyteswap)
byteswap(*magicp, *nmagicp);