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

Patch submission + Help request

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2001-01-24 17:04:29 CET

Howdy, all.

Attached is my first attempt at a code patch EVER. In theory, it is a
fix for the behavior that Bill Tutt was allegedly seeing in Windows
where path names were looking like c:\foo\bar\/baz.

Here's the deal-io, though. I'm having a non-trivial amount of
problems building under Windows (mostly APR's fault), so I need to
focus some attention on that little hell before moving on in the code
base.

If you are a regular Windows-bound Subversion compiler/user and have
seen the behavior mentioned above, please apply this patch and let me
know if it fixes the problem. And if you have any hints in getting
APR to build pleasantly...I'm listening.

Meanwhile, I'll be in the trenches with MS Visual C++ 6.0.

* config.hw (SVN_PATH_LOCAL_SEPARATOR): Added #define for local
    path separators (used in Windows).
* configure.in (SVN_PATH_LOCAL_SEPARATOR): Added #define for local
    path separators (presumed to be used only in Unix with ./configure).
* svn_path.h (SVN_PATH_URL_SEPARATOR, SVN_PATH_REPOS_SEPARATOR): We
    round out our path separator #defines by #include-ing config.h,
    adding a #define for url path separators.
* path.c (get_separator_from_style): Added a new internal function for
    determining the path separator character from a given path style.
    Several other functions in this file changed to make use of this
    (instead of just always using the repos separator type).

Index: config.hw
===================================================================
RCS file: /cvs/subversion/config.hw,v
retrieving revision 1.2
diff -c -r1.2 config.hw
*** config.hw 2000/12/21 23:09:31 1.2
--- config.hw 2001/01/24 15:16:44
***************
*** 45,50 ****
--- 45,54 ----
  # define SVN_CLIENT_PATCH "X:/path/to/patch.exe"
  #endif
  
+ /* Path separator for local filesystem */
+ #ifndef SVN_PATH_LOCAL_SEPARATOR
+ # define SVN_PATH_LOCAL_SEPARATOR '\\'
+ #endif
  
  #endif /* CONFIG_HW */
  
Index: configure.in
===================================================================
RCS file: /cvs/subversion/configure.in,v
retrieving revision 1.45
diff -c -r1.45 configure.in
*** configure.in 2001/01/10 00:08:00 1.45
--- configure.in 2001/01/24 15:16:44
***************
*** 175,180 ****
--- 175,183 ----
  AC_DEFINE_UNQUOTED(SVN_CLIENT_PATCH, "$SVN_CLIENT_PATCH",
          [Define to be the full path to your patch program])
  
+ dnl Since this is used only on Unix-y systems, define the path separator as '/'
+ AC_DEFINE_UNQUOTED(SVN_PATH_LOCAL_SEPARATOR, '/',
+ [Defined to be the path separator used on your local filesystem])
  
  dnl Pass some config data ----------------------------
  
Index: subversion/include/svn_path.h
===================================================================
RCS file: /cvs/subversion/subversion/include/svn_path.h,v
retrieving revision 1.25
diff -c -r1.25 svn_path.h
*** subversion/include/svn_path.h 2000/12/26 18:37:46 1.25
--- subversion/include/svn_path.h 2001/01/24 15:16:45
***************
*** 23,30 ****
  
  #include <apr_pools.h>
  #include "svn_string.h"
  
-
  
  /*** Notes:
   *
--- 23,30 ----
  
  #include <apr_pools.h>
  #include "svn_string.h"
+ #include "config.h"
  
  
  /*** Notes:
   *
***************
*** 32,46 ****
   * path is a file or directory, because we always canonicalize() it.
   *
   * todo: this library really needs a test suite!
   *
   ***/
  
  enum svn_path_style {
    svn_path_local_style = 1, /* parse path using local (client) conventions */
    svn_path_repos_style, /* parse path using repository conventions */
    svn_path_url_style /* parse path using URL conventions */
  };
-
  
  /* Add a COMPONENT (a null-terminated C-string) to PATH.
  
--- 32,64 ----
   * path is a file or directory, because we always canonicalize() it.
   *
   * todo: this library really needs a test suite!
+ *
+ * todo: Though we have a notion of different types of separators for
+ * the local path style, there currently is no logic in place to
+ * account for cases where the separator for one system is a valid
+ * non-separator character for others. For example, a backslash (\)
+ * character is a legal member of a Unix filename, but is the
+ * separator character for Windows platforms (the *file* foo\bar.c on
+ * Unix machine runs the risk of being interpreted by a Windows box as
+ * file bar.c in a directory foo).
   *
   ***/
  
+ /* kff todo: hey, it looks like APR may handle some parts of path
+ portability for us, and we just get to use `/' everywhere. Check
+ up on this. */
+
+ /* Path separator defines. */
+ /* SVN_PATH_LOCAL_SEPARATOR (the local filesystem path separator)
+ _should_ have been defined external this file by the build stuffs */
+ #define SVN_PATH_REPOS_SEPARATOR '/' /* repository separators */
+ #define SVN_PATH_URL_SEPARATOR '/' /* url separators */
+
  enum svn_path_style {
    svn_path_local_style = 1, /* parse path using local (client) conventions */
    svn_path_repos_style, /* parse path using repository conventions */
    svn_path_url_style /* parse path using URL conventions */
  };
  
  /* Add a COMPONENT (a null-terminated C-string) to PATH.
  
Index: subversion/libsvn_subr/path.c
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_subr/path.c,v
retrieving revision 1.28
diff -c -r1.28 path.c
*** subversion/libsvn_subr/path.c 2000/12/05 23:54:14 1.28
--- subversion/libsvn_subr/path.c 2001/01/24 15:16:45
***************
*** 21,35 ****
  
  
  
! /* kff todo: hey, it looks like APR may handle some parts of path
! portability for us, and we just get to use `/' everywhere. Check
! up on this. */
! #define SVN_PATH__REPOS_SEPARATOR '/'
  
  void
  svn_path_canonicalize (svn_string_t *path, enum svn_path_style style)
  {
! /* kff todo: `style' ignored presently. */
  
    /* At some point this could eliminiate redundant components.
       For now, it just makes sure there is no trailing slash. */
--- 21,54 ----
  
  
  
! static char
! get_separator_from_style (enum svn_path_style style)
! {
! switch (style)
! {
! case svn_path_local_style:
! /* local style - path separators used by local filesystem */
! return (SVN_PATH_LOCAL_SEPARATOR);
!
! case svn_path_url_style:
! /* url style - path separators used in urls */
! return (SVN_PATH_URL_SEPARATOR);
!
! default:
! case svn_path_repos_style:
! /* repos style - separators used in repository paths */
! return (SVN_PATH_REPOS_SEPARATOR);
! }
! /* default case = repos style (we should never hit this...) */
! return (SVN_PATH_REPOS_SEPARATOR);
! }
!
  
+
  void
  svn_path_canonicalize (svn_string_t *path, enum svn_path_style style)
  {
! char dirsep = get_separator_from_style (style);
  
    /* At some point this could eliminiate redundant components.
       For now, it just makes sure there is no trailing slash. */
***************
*** 38,44 ****
       libsvn_string. */
  
    while ((path->len > 0)
! && (path->data[(path->len - 1)] == SVN_PATH__REPOS_SEPARATOR))
      {
        path->data[(path->len - 1)] = '\0';
        path->len--;
--- 57,63 ----
       libsvn_string. */
  
    while ((path->len > 0)
! && (path->data[(path->len - 1)] == dirsep))
      {
        path->data[(path->len - 1)] = '\0';
        path->len--;
***************
*** 52,60 ****
                          size_t len,
                          enum svn_path_style style)
  {
! /* kff todo: `style' ignored presently. */
!
! char dirsep = SVN_PATH__REPOS_SEPARATOR;
  
    if (! svn_string_isempty (path))
      svn_string_appendbytes (path, &dirsep, sizeof (dirsep));
--- 71,77 ----
                          size_t len,
                          enum svn_path_style style)
  {
! char dirsep = get_separator_from_style (style);
  
    if (! svn_string_isempty (path))
      svn_string_appendbytes (path, &dirsep, sizeof (dirsep));
***************
*** 85,95 ****
  void
  svn_path_remove_component (svn_string_t *path, enum svn_path_style style)
  {
! /* kff todo: `style' ignored presently. */
  
    svn_path_canonicalize (path, style);
  
! if (! svn_string_chop_back_to_char (path, SVN_PATH__REPOS_SEPARATOR))
      svn_string_setempty (path);
  }
  
--- 102,112 ----
  void
  svn_path_remove_component (svn_string_t *path, enum svn_path_style style)
  {
! char dirsep = get_separator_from_style (style);
  
    svn_path_canonicalize (path, style);
  
! if (! svn_string_chop_back_to_char (path, dirsep))
      svn_string_setempty (path);
  }
  
***************
*** 99,108 ****
                           enum svn_path_style style,
                           apr_pool_t *pool)
  {
! /* kff todo: `style' ignored presently. */
  
    apr_size_t i
! = svn_string_find_char_backward (path, SVN_PATH__REPOS_SEPARATOR);
  
    if (i < path->len)
      {
--- 116,125 ----
                           enum svn_path_style style,
                           apr_pool_t *pool)
  {
! char dirsep = get_separator_from_style (style);
  
    apr_size_t i
! = svn_string_find_char_backward (path, dirsep);
  
    if (i < path->len)
      {
***************
*** 146,156 ****
  int
  svn_path_is_empty (const svn_string_t *path, enum svn_path_style style)
  {
! /* kff todo: `style' ignored presently. */
  
    char buf[3];
    buf[0] = '.';
! buf[0] = SVN_PATH__REPOS_SEPARATOR;
    buf[0] = '\0';
  
    return ((path == NULL)
--- 163,173 ----
  int
  svn_path_is_empty (const svn_string_t *path, enum svn_path_style style)
  {
! char dirsep = get_separator_from_style (style);
  
    char buf[3];
    buf[0] = '.';
! buf[0] = dirsep;
    buf[0] = '\0';
  
    return ((path == NULL)
***************
*** 166,171 ****
--- 183,189 ----
  {
    size_t min_len = ((path1->len) < (path2->len)) ? path1->len : path2->len;
    size_t i;
+ char dirsep = get_separator_from_style (style);
    
    /* Skip past common prefix. */
    for (i = 0; (i < min_len) && (path1->data[i] == path2->data[i]); i++)
***************
*** 173,181 ****
  
    if ((path1->len == path2->len) && (i >= min_len))
      return 0; /* the paths are the same */
! else if (path1->data[i] == SVN_PATH__REPOS_SEPARATOR)
      return 1; /* path1 child of path2, parent always comes before child */
! else if (path2->data[i] == SVN_PATH__REPOS_SEPARATOR)
      return -1; /* path2 child of path1, parent always comes before child */
    else
      return strncmp (path1->data + i, path2->data + i, (min_len - i));
--- 191,199 ----
  
    if ((path1->len == path2->len) && (i >= min_len))
      return 0; /* the paths are the same */
! else if (path1->data[i] == dirsep)
      return 1; /* path1 child of path2, parent always comes before child */
! else if (path2->data[i] == dirsep)
      return -1; /* path2 child of path1, parent always comes before child */
    else
      return strncmp (path1->data + i, path2->data + i, (min_len - i));
Received on Sat Oct 21 14:36:19 2006

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.