Author: stsp
Date: Sat Jun 4 13:04:51 2011
New Revision: 1131389
URL: http://svn.apache.org/viewvc?rev=1131389&view=rev
Log:
Work around older libmagic versions that don't define MAGIC_MIME_TYPE.
This should fix the centos buildbot.
* subversion/libsvn_subr/magic.c:
(svn_magic__init): If MAGIC_MIME_TYPE isn't supported use MAGIC_MIME instead.
(svn_magic__detect_binary_mimetype): Strip charset information from the
string returned by libmagic if MAGIC_MIME was used.
Modified:
subversion/trunk/subversion/libsvn_subr/magic.c
Modified: subversion/trunk/subversion/libsvn_subr/magic.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/magic.c?rev=1131389&r1=1131388&r2=1131389&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/magic.c (original)
+++ subversion/trunk/subversion/libsvn_subr/magic.c Sat Jun 4 13:04:51 2011
@@ -70,7 +70,14 @@ svn_magic__init(svn_magic__cookie_t **ma
mc = apr_palloc(result_pool, sizeof(*mc));
/* Initialise libmagic. */
+#ifndef MAGIC_MIME_TYPE
+ /* Some old versions of libmagic don't support MAGIC_MIME_TYPE.
+ * We can use MAGIC_MIME instead. It returns more than we need
+ * but we can work around that (see below). */
+ mc->magic = magic_open(MAGIC_MIME | MAGIC_ERROR);
+#else
mc->magic = magic_open(MAGIC_MIME_TYPE | MAGIC_ERROR);
+#endif
if (mc->magic)
{
/* This loads the default magic database.
@@ -115,6 +122,14 @@ svn_magic__detect_binary_mimetype(const
magic_mimetype = NULL;
else
{
+#ifndef MAGIC_MIME_TYPE
+ char *p;
+
+ /* Strip off trailing stuff like " charset=ascii". */
+ p = strchr(magic_mimetype, ' ');
+ if (p)
+ *p = '\0';
+#endif
/* The string is allocated from memory managed by libmagic so
* we must copy it to the result pool. */
magic_mimetype = apr_pstrdup(result_pool, magic_mimetype);