[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1131389 - /subversion/trunk/subversion/libsvn_subr/magic.c

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Fri, 24 Jun 2011 21:49:31 +0300

stsp_at_apache.org wrote on Sat, Jun 04, 2011 at 13:04:51 -0000:
> 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';

What is 'magic_mimetype' here? Is it guaranteed to contain a space, or
can it be 'text/plain;charset=ascii' ?

i.e., should the strchr look for a semicolon?

(The libmagic ftp mirror is down, and my man page doesn't mention
MAGIC_MIME, so I'm not easily able to check the docs of some old
libmagic version.)

> +#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);
>
>
Received on 2011-06-24 20:50:28 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.