You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/03/27 18:19:58 UTC

svn commit: r1461725 - /subversion/trunk/subversion/libsvn_fs_fs/tree.c

Author: stsp
Date: Wed Mar 27 17:19:57 2013
New Revision: 1461725

URL: http://svn.apache.org/r1461725
Log:
* subversion/libsvn_fs_fs/tree.c
  (escape_newline): Replace a hand-rolled loop with strchr() call.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/tree.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/tree.c?rev=1461725&r1=1461724&r2=1461725&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/tree.c Wed Mar 27 17:19:57 2013
@@ -2230,15 +2230,12 @@ escape_newline(const char *path, apr_poo
 static svn_error_t *
 check_newline(const char *path, apr_pool_t *pool)
 {
-  const char *c;
+  char *c = strchr(path, '\n');
 
-  for (c = path; *c; c++)
-    {
-      if (*c == '\n')
-        return svn_error_createf(SVN_ERR_FS_PATH_SYNTAX, NULL,
-           _("Invalid control character '0x%02x' in path '%s'"),
-           (unsigned char)*c, escape_newline(path, pool));
-    }
+  if (c)
+    return svn_error_createf(SVN_ERR_FS_PATH_SYNTAX, NULL,
+       _("Invalid control character '0x%02x' in path '%s'"),
+       (unsigned char)*c, escape_newline(path, pool));
 
   return SVN_NO_ERROR;
 }



Re: svn commit: r1461725 - /subversion/trunk/subversion/libsvn_fs_fs/tree.c

Posted by Daniel Shahaf <da...@elego.de>.
stsp@apache.org wrote on Wed, Mar 27, 2013 at 17:19:58 -0000:
> Author: stsp
> Date: Wed Mar 27 17:19:57 2013
> New Revision: 1461725
> 
> URL: http://svn.apache.org/r1461725
> Log:
> * subversion/libsvn_fs_fs/tree.c
>   (escape_newline): Replace a hand-rolled loop with strchr() call.
> 
> Modified:
>     subversion/trunk/subversion/libsvn_fs_fs/tree.c
> 
> Modified: subversion/trunk/subversion/libsvn_fs_fs/tree.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/tree.c?rev=1461725&r1=1461724&r2=1461725&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_fs_fs/tree.c (original)
> +++ subversion/trunk/subversion/libsvn_fs_fs/tree.c Wed Mar 27 17:19:57 2013
> @@ -2230,15 +2230,12 @@ escape_newline(const char *path, apr_poo
>  static svn_error_t *
>  check_newline(const char *path, apr_pool_t *pool)
>  {
> -  const char *c;
>  
> +  if (c)
> +    return svn_error_createf(SVN_ERR_FS_PATH_SYNTAX, NULL,
> +       _("Invalid control character '0x%02x' in path '%s'"),
> +       (unsigned char)*c, escape_newline(path, pool));
>  

Any reason not to push this escape_newline() call down to
svn_error_createf() itself?  i.e., apply escape_newline to every
stringy variadic argument (but not to the printf template).

>    return SVN_NO_ERROR;
>  }
> 
> 

Re: svn commit: r1461725 - /subversion/trunk/subversion/libsvn_fs_fs/tree.c

Posted by Daniel Shahaf <da...@elego.de>.
stsp@apache.org wrote on Wed, Mar 27, 2013 at 17:19:58 -0000:
> Author: stsp
> Date: Wed Mar 27 17:19:57 2013
> New Revision: 1461725
> 
> URL: http://svn.apache.org/r1461725
> Log:
> * subversion/libsvn_fs_fs/tree.c
>   (escape_newline): Replace a hand-rolled loop with strchr() call.
> 
> Modified:
>     subversion/trunk/subversion/libsvn_fs_fs/tree.c
> 
> Modified: subversion/trunk/subversion/libsvn_fs_fs/tree.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/tree.c?rev=1461725&r1=1461724&r2=1461725&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_fs_fs/tree.c (original)
> +++ subversion/trunk/subversion/libsvn_fs_fs/tree.c Wed Mar 27 17:19:57 2013
> @@ -2230,15 +2230,12 @@ escape_newline(const char *path, apr_poo
>  static svn_error_t *
>  check_newline(const char *path, apr_pool_t *pool)
>  {
> -  const char *c;
>  
> +  if (c)
> +    return svn_error_createf(SVN_ERR_FS_PATH_SYNTAX, NULL,
> +       _("Invalid control character '0x%02x' in path '%s'"),
> +       (unsigned char)*c, escape_newline(path, pool));
>  

Any reason not to push this escape_newline() call down to
svn_error_createf() itself?  i.e., apply escape_newline to every
stringy variadic argument (but not to the printf template).

>    return SVN_NO_ERROR;
>  }
> 
>