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

Re: CVS update: subversion/subversion/libsvn_ra_local Makefile.am ra_local.h ra_plugin.c split_url.c

From: Greg Stein <gstein_at_lyra.org>
Date: 2001-02-10 02:27:06 CET

On Sat, Feb 10, 2001 at 12:59:19AM -0000, sussman@tigris.org wrote:
>...
> @@ -283,7 +296,10 @@
> apr_pool_t *pool,
> const svn_ra_plugin_t **plugin)
> {
> - *plugin = ra_local_plugin;
> + svn_ra_plugin_t *p = apr_pcalloc (pool, sizeof (*p));
> + memcpy (p, &ra_local_plugin, sizeof (ra_local_plugin));
> +
> + *plugin = p;

Overkill. Use:

    *plugin = &ra_local_plugin;

> /* are we ever going to care about abi_version? */

Yes.

>... [ split_url ]

This function would be a *lot* simpler, if you:

1) make a dup of the URL
2) strip the leading file:// portion (leaving "/abs/path/foo/bar")
3) loop:
   a) try to open FS with the path. succeed: break
   b) chop the last component off
4) fs_path is what remains, repos_path is &URL[strlen(fs_path) + 7]
   (the +7 is to account for "file://" at the start of the URL)

The whole algorithm only requires one string dup to hold the shrinking path.
stripping the leading "file://" is simply advancing string->data (we should
have a utility function for this, because string->blocksize must shrink).
The chopping just drops in '\0' into the dup'd path. The return is done by
duplicating the input URL, or altering the input ->data and ->blocksize
field values.

And warning: I'm not sure whether a file URL is in "local" or "URL" style
separators. Strictly speaking, our "URL style" is really "http scheme URL
style". If the file URL uses "/" no matter what, then we would (strictly)
need to convert the dup'd path (the fs_path) to local style before beginning
the loop/test.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
Received on Sat Oct 21 14:36:21 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.