summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Ramsay <lack@gentoo.org>2008-01-24 20:08:11 +0000
committerJim Ramsay <lack@gentoo.org>2008-01-24 20:08:11 +0000
commit96095764f8ebee623a4238a6e13a99015f2f5119 (patch)
tree98dbcbcf1d29f8a643cff98304b50473362e613a /rox-base
parentSigning Manifest. (diff)
downloadgentoo-2-96095764f8ebee623a4238a6e13a99015f2f5119.tar.gz
gentoo-2-96095764f8ebee623a4238a6e13a99015f2f5119.tar.bz2
gentoo-2-96095764f8ebee623a4238a6e13a99015f2f5119.zip
Added patch to fix detection of text/plain files.
(Portage version: 2.1.4_rc14)
Diffstat (limited to 'rox-base')
-rw-r--r--rox-base/rox/ChangeLog9
-rw-r--r--rox-base/rox/files/digest-rox-2.7.1-r1 (renamed from rox-base/rox/files/digest-rox-2.7.1)0
-rw-r--r--rox-base/rox/files/rox-2.7-text_plain.patch150
-rw-r--r--rox-base/rox/rox-2.7-r2.ebuild3
-rw-r--r--rox-base/rox/rox-2.7.1-r1.ebuild (renamed from rox-base/rox/rox-2.7.1.ebuild)3
-rw-r--r--rox-base/rox/rox-2.7.ebuild3
6 files changed, 164 insertions, 4 deletions
diff --git a/rox-base/rox/ChangeLog b/rox-base/rox/ChangeLog
index bbd33135f68b..a774ffebb7e6 100644
--- a/rox-base/rox/ChangeLog
+++ b/rox-base/rox/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for rox-base/rox
# Copyright 2002-2008 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/ChangeLog,v 1.54 2008/01/23 14:45:26 lack Exp $
+# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/ChangeLog,v 1.55 2008/01/24 20:08:10 lack Exp $
+
+*rox-2.7.1-r1 (24 Jan 2008)
+
+ 24 Jan 2008; Jim Ramsay <lack@gentoo.org> +files/rox-2.7-text_plain.patch,
+ rox-2.7.ebuild, rox-2.7-r2.ebuild, -rox-2.7.1.ebuild,
+ +rox-2.7.1-r1.ebuild:
+ Added patch to fix detection of text/plain files.
*rox-2.7.1 (23 Jan 2008)
diff --git a/rox-base/rox/files/digest-rox-2.7.1 b/rox-base/rox/files/digest-rox-2.7.1-r1
index 5d69c6176534..5d69c6176534 100644
--- a/rox-base/rox/files/digest-rox-2.7.1
+++ b/rox-base/rox/files/digest-rox-2.7.1-r1
diff --git a/rox-base/rox/files/rox-2.7-text_plain.patch b/rox-base/rox/files/rox-2.7-text_plain.patch
new file mode 100644
index 000000000000..37630e76175c
--- /dev/null
+++ b/rox-base/rox/files/rox-2.7-text_plain.patch
@@ -0,0 +1,150 @@
+commit ed0adb6e4e873eca15b4765035d3c89888c74a72
+Author: Stephen Watson <stephen@kerofin.demon.co.uk>
+Date: Mon Jan 21 23:33:13 2008 +0000
+
+ MIME magic lookup now returns text/plain for certain unknown file types.
+ Restored the code, lost in the update to the newer XDG MIME code, which checks
+ unknown files to see if they are text.
+
+ Modifications to the XDG code are tagged with ROX: comments.
+
+diff --git a/ROX-Filer/src/xdgmime.c b/ROX-Filer/src/xdgmime.c
+index 133282d..51d38d6 100644
+--- a/ROX-Filer/src/xdgmime.c
++++ b/ROX-Filer/src/xdgmime.c
+@@ -65,6 +65,7 @@ XdgMimeCache **_xdg_mime_caches = NULL;
+ static int n_caches = 0;
+
+ const char xdg_mime_type_unknown[] = "application/octet-stream";
++const char xdg_mime_type_unknown_text[] = "text/plain"; /* ROX: */
+
+
+ enum
+diff --git a/ROX-Filer/src/xdgmime.h b/ROX-Filer/src/xdgmime.h
+index 82b5585..52d1524 100644
+--- a/ROX-Filer/src/xdgmime.h
++++ b/ROX-Filer/src/xdgmime.h
+@@ -74,7 +74,11 @@ typedef void (*XdgMimeDestroy) (void *user_data);
+ #endif
+
+ extern const char xdg_mime_type_unknown[];
+-#define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
++#define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
++
++/* ROX: */
++extern const char xdg_mime_type_unknown_text[];
++#define XDG_MIME_TYPE_UNKNOWN_TEXT xdg_mime_type_unknown_text
+
+ const char *xdg_mime_get_mime_type_for_data (const void *data,
+ size_t len);
+diff --git a/ROX-Filer/src/xdgmimemagic.c b/ROX-Filer/src/xdgmimemagic.c
+index 892688b..d1d04b6 100644
+--- a/ROX-Filer/src/xdgmimemagic.c
++++ b/ROX-Filer/src/xdgmimemagic.c
+@@ -39,6 +39,9 @@
+ #include <errno.h>
+ #include <limits.h>
+
++/* ROX: */
++#include <glib.h>
++
+ #ifndef FALSE
+ #define FALSE (0)
+ #endif
+@@ -654,6 +657,83 @@ _xdg_mime_magic_get_buffer_extents (XdgMimeMagic *mime_magic)
+ return mime_magic->max_extent;
+ }
+
++static gboolean _rox_buffer_looks_like_text (const void *data,
++ const size_t len)
++{
++ gchar *end;
++
++ if (g_utf8_validate (data, len, (const gchar**)&end))
++ {
++ /* g_utf8_validate allows control characters */
++ int i;
++ for (i = 0; i < len; i++)
++ {
++ unsigned char c = ((const guchar *) data)[i];
++ if (c < 32 && c != '\r' && c != '\n' && c != '\t')
++ return FALSE;
++ }
++ return TRUE;
++
++ } else {
++ /* Check whether the string was truncated in the middle of
++ * a valid UTF8 char, or if we really have an invalid
++ * UTF8 string
++ */
++ gint remaining_bytes = len;
++
++ remaining_bytes -= (end-((gchar*)data));
++
++ if (g_utf8_get_char_validated(end, remaining_bytes) == -2)
++ return TRUE;
++#if defined(HAVE_WCTYPE_H) && defined (HAVE_MBRTOWC)
++ else {
++ size_t wlen;
++ wchar_t wc;
++ gchar *src, *end;
++ mbstate_t state;
++
++ src = data;
++ end = data+len;
++
++ memset (&state, 0, sizeof (state));
++ while (src < end) {
++ /* Don't allow embedded zeros in textfiles */
++ if (*src == 0)
++ return FALSE;
++
++ wlen = mbrtowc(&wc, src, end - src, &state);
++
++ if (wlen == (size_t)(-1)) {
++ /* Illegal mb sequence */
++ return FALSE;
++ }
++
++ if (wlen == (size_t)(-2)) {
++ /* No complete mb char before end
++ * Probably a cut off char which is ok */
++ return TRUE;
++ }
++
++ if (wlen == 0) {
++ /* Don't allow embedded zeros in textfiles */
++ return FALSE;
++ }
++
++ if (!iswspace (wc) && !iswprint(wc)) {
++ /* Not a printable or whitspace
++ * Probably not a text file */
++ return FALSE;
++ }
++
++ src += wlen;
++ }
++ return TRUE;
++ }
++#endif /* defined(HAVE_WCTYPE_H) && defined (HAVE_MBRTOWC) */
++ }
++ return FALSE;
++}
++
+ const char *
+ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
+ const void *data,
+@@ -708,6 +788,12 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
+ }
+ }
+
++ if (mime_type == NULL)
++ {
++ if(_rox_buffer_looks_like_text(data, len))
++ mime_type = XDG_MIME_TYPE_UNKNOWN_TEXT;
++ }
++
+ return mime_type;
+ }
+
diff --git a/rox-base/rox/rox-2.7-r2.ebuild b/rox-base/rox/rox-2.7-r2.ebuild
index be597c97edd5..d4e877500f6e 100644
--- a/rox-base/rox/rox-2.7-r2.ebuild
+++ b/rox-base/rox/rox-2.7-r2.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/rox-2.7-r2.ebuild,v 1.4 2008/01/02 12:44:42 lack Exp $
+# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/rox-2.7-r2.ebuild,v 1.5 2008/01/24 20:08:10 lack Exp $
EAPI=1
inherit eutils multilib
@@ -42,6 +42,7 @@ src_unpack() {
unpack ${A}
cd "${S}"
epatch "${FILESDIR}"/${P}-nostrip.patch
+ epatch "${FILESDIR}"/${P}-text_plain.patch
}
src_compile() {
diff --git a/rox-base/rox/rox-2.7.1.ebuild b/rox-base/rox/rox-2.7.1-r1.ebuild
index 0905c634e926..0aa8e2416366 100644
--- a/rox-base/rox/rox-2.7.1.ebuild
+++ b/rox-base/rox/rox-2.7.1-r1.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/rox-2.7.1.ebuild,v 1.1 2008/01/23 14:45:26 lack Exp $
+# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/rox-2.7.1-r1.ebuild,v 1.1 2008/01/24 20:08:10 lack Exp $
EAPI=1
inherit eutils multilib
@@ -42,6 +42,7 @@ src_unpack() {
unpack ${A}
cd "${S}"
epatch "${FILESDIR}"/${PN}-2.7-nostrip.patch
+ epatch "${FILESDIR}"/${PN}-2.7-text_plain.patch
}
src_compile() {
diff --git a/rox-base/rox/rox-2.7.ebuild b/rox-base/rox/rox-2.7.ebuild
index c38a90f85f49..15cf6daf3fad 100644
--- a/rox-base/rox/rox-2.7.ebuild
+++ b/rox-base/rox/rox-2.7.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/rox-2.7.ebuild,v 1.2 2008/01/02 12:44:42 lack Exp $
+# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/rox-2.7.ebuild,v 1.3 2008/01/24 20:08:10 lack Exp $
inherit eutils multilib
@@ -36,6 +36,7 @@ src_unpack() {
unpack ${A}
cd "${S}"
epatch "${FILESDIR}"/${P}-nostrip.patch
+ epatch "${FILESDIR}"/${P}-text_plain.patch
}
src_compile() {