You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Philip Martin <ph...@codematters.co.uk> on 2004/08/08 21:49:10 UTC

Re: svn commit: r10521 - trunk/subversion/libsvn_subr

brane@tigris.org writes:

> Author: brane
> Date: Sat Aug  7 03:20:16 2004
> New Revision: 10521
>
> --- trunk/subversion/libsvn_subr/validate.c	(original)
> +++ trunk/subversion/libsvn_subr/validate.c	Sat Aug  7 03:20:16 2004
> @@ -70,7 +70,7 @@
>    /* See comment in svn_mime_type_validate() above. */
>    const apr_size_t len = strcspn (mime_type, "; ");
>    return ((strncmp (mime_type, "text/", 5) != 0)
> -          && (strncmp (mime_type, "image/x-xbitmap", len) != 0)
> -          && (strncmp (mime_type, "image/x-xpixmap", len) != 0)
> +          && (len != 15 || strncmp (mime_type, "image/x-xbitmap", len) != 0)
> +          && (len != 15 || strncmp (mime_type, "image/x-xpixmap", len) != 0)

That 15 looks prone to error, particularly if/when more types get
added.  How about something like

#define LEN_STRNCMP(s) (len != sizeof(s) - 1 \
                        || strncmp (mime_type, s, sizeof(s) - 1) != 0)

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r10521 - trunk/subversion/libsvn_subr

Posted by Ben Reser <be...@reser.org>.
On Sun, Aug 08, 2004 at 10:49:10PM +0100, Philip Martin wrote:
> brane@tigris.org writes:
> 
> > Author: brane
> > Date: Sat Aug  7 03:20:16 2004
> > New Revision: 10521
> >
> > --- trunk/subversion/libsvn_subr/validate.c	(original)
> > +++ trunk/subversion/libsvn_subr/validate.c	Sat Aug  7 03:20:16 2004
> > @@ -70,7 +70,7 @@
> >    /* See comment in svn_mime_type_validate() above. */
> >    const apr_size_t len = strcspn (mime_type, "; ");
> >    return ((strncmp (mime_type, "text/", 5) != 0)
> > -          && (strncmp (mime_type, "image/x-xbitmap", len) != 0)
> > -          && (strncmp (mime_type, "image/x-xpixmap", len) != 0)
> > +          && (len != 15 || strncmp (mime_type, "image/x-xbitmap", len) != 0)
> > +          && (len != 15 || strncmp (mime_type, "image/x-xpixmap", len) != 0)
> 
> That 15 looks prone to error, particularly if/when more types get
> added.

Let's leave well enough alone.  We decided not to add anymore types here
and to make this user configurable...

-- 
Ben Reser <be...@reser.org>
http://ben.reser.org

"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r10521 - trunk/subversion/libsvn_subr

Posted by Greg Hudson <gh...@MIT.EDU>.
On Sun, 2004-08-08 at 17:49, Philip Martin wrote:
> That 15 looks prone to error, particularly if/when more types get
> added.  How about something like
> 
> #define LEN_STRNCMP(s) (len != sizeof(s) - 1 \
>                         || strncmp (mime_type, s, sizeof(s) - 1) != 0)

My experience is that overuse of the C preprocessor is infuriating when
you have to debug any of the relevant code.  If we're going to introduce
extra engineering here, I'd prefer that it take the form of some tables,
rather than preprocessor macros.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org