summaryrefslogtreecommitdiffstats
path: root/contrib/file/src/funcs.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2016-05-08 18:09:30 +0000
committerdelphij <delphij@FreeBSD.org>2016-05-08 18:09:30 +0000
commit474ac0fbf4af918a4825854649bafccc48949fc1 (patch)
tree71e3f513282a26fd8dae12a0f0258b39eff11078 /contrib/file/src/funcs.c
parent1e1c6951b00289b8de42bb7d821861b25d4fc604 (diff)
downloadFreeBSD-src-474ac0fbf4af918a4825854649bafccc48949fc1.zip
FreeBSD-src-474ac0fbf4af918a4825854649bafccc48949fc1.tar.gz
Revert r298920 until we have addressed all known regressions on head/ after
settle. file is now downgraded to 5.25. PR: bin/209211 Requested by: Tomoaki AOKI Relnotes: yes
Diffstat (limited to 'contrib/file/src/funcs.c')
-rw-r--r--contrib/file/src/funcs.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/contrib/file/src/funcs.c b/contrib/file/src/funcs.c
index df8dbae..97d4a0a 100644
--- a/contrib/file/src/funcs.c
+++ b/contrib/file/src/funcs.c
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.89 2016/03/21 15:56:53 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.84 2015/09/10 13:32:19 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -178,6 +178,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__u
const void *buf, size_t nb)
{
int m = 0, rv = 0, looks_text = 0;
+ int mime = ms->flags & MAGIC_MIME;
const unsigned char *ubuf = CAST(const unsigned char *, buf);
unichar *u8buf = NULL;
size_t ulen;
@@ -251,8 +252,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__u
/* try soft magic tests */
if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)
- m = file_softmagic(ms, ubuf, nb, NULL, NULL, BINTEST,
- looks_text);
+ m = file_softmagic(ms, ubuf, nb, 0, NULL, BINTEST, looks_text);
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr, "[try softmagic %d]\n", m);
if (m) {
@@ -293,19 +293,9 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__u
simple:
/* give up */
m = 1;
- if (ms->flags & MAGIC_MIME) {
- if ((ms->flags & MAGIC_MIME_TYPE) &&
- file_printf(ms, "%s", type) == -1)
- rv = -1;
- } else if (ms->flags & MAGIC_APPLE) {
- if (file_printf(ms, "UNKNUNKN") == -1)
- rv = -1;
- } else if (ms->flags & MAGIC_EXTENSION) {
- if (file_printf(ms, "???") == -1)
- rv = -1;
- } else {
- if (file_printf(ms, "%s", def) == -1)
- rv = -1;
+ if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
+ file_printf(ms, "%s", mime ? type : def) == -1) {
+ rv = -1;
}
done:
if ((ms->flags & MAGIC_MIME_ENCODING) != 0) {
@@ -495,8 +485,6 @@ file_regcomp(file_regex_t *rx, const char *pat, int flags)
assert(rx->c_lc_ctype != NULL);
rx->old_lc_ctype = uselocale(rx->c_lc_ctype);
assert(rx->old_lc_ctype != NULL);
-#else
- rx->old_lc_ctype = setlocale(LC_CTYPE, "C");
#endif
rx->pat = pat;
@@ -519,8 +507,6 @@ file_regfree(file_regex_t *rx)
#ifdef USE_C_LOCALE
(void)uselocale(rx->old_lc_ctype);
freelocale(rx->c_lc_ctype);
-#else
- (void)setlocale(LC_CTYPE, rx->old_lc_ctype);
#endif
}
OpenPOWER on IntegriCloud