diff options
author | 2021-06-29 10:09:10 +0200 | |
---|---|---|
committer | 2021-06-29 10:29:33 +0200 | |
commit | 68e24256a0449b2a27e44879f95171780f21526b (patch) | |
tree | 9ca16e8c59f84a003b228d75bc685c9507bdf1e6 /sys-apps/file/files | |
parent | dev-go/gopls: Initial import (diff) | |
download | gentoo-68e24256a0449b2a27e44879f95171780f21526b.tar.gz gentoo-68e24256a0449b2a27e44879f95171780f21526b.tar.bz2 gentoo-68e24256a0449b2a27e44879f95171780f21526b.zip |
sys-apps/file: Fix character count heuristic
This restores behaviour of file-5.39, i.e. correctly identifies small
text files as text/plain rather than application/octet-stream again.
Patch taken from upstream and (trivially) backported to 5.40.
Closes: https://bugs.gentoo.org/799188
Bug: https://bugs.astron.com/view.php?id=261
Package-Manager: Portage-3.0.20, Repoman-3.0.3
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
Diffstat (limited to 'sys-apps/file/files')
-rw-r--r-- | sys-apps/file/files/file-5.40-revert-char-count.patch | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/sys-apps/file/files/file-5.40-revert-char-count.patch b/sys-apps/file/files/file-5.40-revert-char-count.patch new file mode 100644 index 000000000000..9d6f5be60fac --- /dev/null +++ b/sys-apps/file/files/file-5.40-revert-char-count.patch @@ -0,0 +1,49 @@ +From c07e242e766242a44ff720c149b1bdd4924ec247 Mon Sep 17 00:00:00 2001 +From: Christos Zoulas <christos@zoulas.com> +Date: Tue, 27 Apr 2021 19:37:14 +0000 +Subject: [PATCH] Revert the fix for PR/180. It lead to PR/261. Using character + count heuristics ends up with confusing behavior, the following should not be + producing different results: echo -n xx | ./file - echo -n xy | + ./file - + +--- +[patch backported to 5.40 release -- ulm] + + src/encoding.c | 15 ++------------- + 1 file changed, 2 insertions(+), 13 deletions(-) + +diff --git a/src/encoding.c b/src/encoding.c +index 31d4d125..3647a481 100644 +--- a/src/encoding.c ++++ b/src/encoding.c +@@ -265,9 +265,7 @@ private int \ + looks_ ## NAME(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, \ + size_t *ulen) \ + { \ +- size_t i, u; \ +- unsigned char dist[256]; \ +- memset(dist, 0, sizeof(dist)); \ ++ size_t i; \ + \ + *ulen = 0; \ + \ +@@ -278,16 +276,7 @@ looks_ ## NAME(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, \ + return 0; \ + \ + ubuf[(*ulen)++] = buf[i]; \ +- dist[buf[i]]++; \ + } \ +- u = 0; \ +- for (i = 0; i < __arraycount(dist); i++) { \ +- if (dist[i]) \ +- u++; \ +- } \ +- if (u < 3) \ +- return 0; \ +-\ + return 1; \ + } + +-- +2.32.0 + |