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

Re: parsing paths

From: Karl Fogel <kfogel_at_galois.collab.net>
Date: 2001-02-15 18:45:39 CET

Jim Blandy <jimb@zwingli.cygnus.com> writes:
> I'm not saying the libsvn_subr function should be changed to behave
> this way. But I know people will tell me I'm duplicating code, so I'm
> just explaining the behavior I require. If libsvn_subr wants to
> provide it, groovy for me. I don't feel that I know its clientele
> well enough to make changes there myself.

As far as I know, the other users of svn_path_* also depend on N
consecutive slashes being equivalent to a single slash, and also
ignore trailing slashes. Ben, you've more experience with those
callers lately though, please correct the above if necessary.

If it's all true, we can change the path library to do what you need,
Jim, and you can get rid of the duplicated code.

Below is Jim's comment from svn_fs.h:

/* Here are the rules for directory entry names, and directory paths:

   A directory entry name is a Unicode string encoded in UTF-8, and
   may not contain the null character (U+0000). The name should be in
   Unicode canonical decomposition and ordering. No directory entry
   may be named '.', '..', or the empty string. Given a directory
   entry name which fails to meet these requirements, a filesystem
   function returns an SVN_ERR_FS_PATH_SYNTAX error.

   A directory path is a sequence of one or more directory entry
   names, separated by slash characters (U+002f). Sequences of two or
   more consecutive slash characters are treated as if they were a
   single slash. If a path ends with a slash, it refers to the same
   node it would without the slash, but that node must be a directory,
   or else the function returns an SVN_ERR_FS_NOT_DIRECTORY error.

   Paths may not start with a slash. All directory paths in
   Subversion are relative; all functions that expect a path as an
   argument also expect a directory the path should be interpreted
   relative to. If a function receives a path that begins with a
   slash, it will return an SVN_ERR_FS_PATH_SYNTAX error. */

-K

Jim Blandy <jimb@zwingli.cygnus.com> writes:
> I've just committed some path-traversal code to libsvn_fs/tree.c which
> includes a function next_entry_name for parsing paths.
>
> I know there are existing functions for dealing with paths in
> libsvn_subr, but they don't work the way I want. In particular:
>
> - They leave it to the caller to interpret series of two or more
> consecutive slashes. The filesystem interface defines how they must
> be interpreted (see svn_fs.h, "Directory entry names and directory
> paths"), requiring that they be handled as in POSIX: multiple
> slashes are equivalent to one slash.
>
> - They don't provide any convenient way to handle trailing slashes.
> The filesystem also defines what this means, consistent with the
> usage in the GNU fileutils (and, I think, POSIX). next_entry_name
> does something that is easy to deal with.
>
> I'm not saying the libsvn_subr function should be changed to behave
> this way. But I know people will tell me I'm duplicating code, so I'm
> just explaining the behavior I require. If libsvn_subr wants to
> provide it, groovy for me. I don't feel that I know its clientele
> well enough to make changes there myself.
Received on Sat Oct 21 14:36:22 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.