[vlc-devel] [PATCH 2/3] Fix #8105

Rémi Denis-Courmont remi at remlab.net
Fri Mar 8 13:00:09 CET 2013


On Fri,  8 Mar 2013 02:43:02 +0200, Anatoliy Anischovich
<lin.aaa.lin at gmail.com> wrote:
> Vorbis comment's field names are case insensitive, so convert them to
> uppercase.
> ---
>  modules/demux/vorbis.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/modules/demux/vorbis.h b/modules/demux/vorbis.h
> index 2642c4b..7cabe6e 100644
> --- a/modules/demux/vorbis.h
> +++ b/modules/demux/vorbis.h
> @@ -221,6 +221,17 @@ static inline void vorbis_ParseComment( vlc_meta_t
> **pp_meta,
>               * undocumented tags and replay gain ) */
>              char *p = strchr( psz_comment, '=' );
>              *p++ = '\0';
> +
> +            int i=0;
> +            while (psz[i])

Use C++/C99-style for loops.

> +            {
> +                /* ASCII 0x41 through 0x5A inclusive (A-Z) is to be
> considered
> +                 * equivalent to ASCII 0x61 through 0x7A inclusive
(a-z).
> */

Comments should not paraphrase the code.

> +                if ( psz[i] >= 'a' && psz[i] <= 'z' )
> +                    psz[i] ^= ' ';

Please avoid obfuscated code. In this case, this is much more clear:
    psz[i] -= 'a' - 'A';

> +                ++i;
> +            }
> +
>              vlc_meta_AddExtra( p_meta, psz_comment, p );
>          }
>  #undef IF_EXTRACT

-- 
Rémi Denis-Courmont
Sent from my collocated server



More information about the vlc-devel mailing list