You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Uwe Zeisberger <ze...@informatik.uni-freiburg.de> on 2004/12/23 16:56:47 UTC

[PATCH] skip_uri_schema without strlen

Hello,

browsing subversion/libsvn_subr/path.c I found skip_uri_schema using
strlen and a comment that this is inefficient.

Moreover in my opinion the function is broken.  If path == "file://" it
returns NULL instead of path + 7 because j only loops to < len - 3.  Is
should loop to <= len - 3. 

Here is a patch which makes skip_uri_schema behave like `<= len - 3' and
which doesn't use strlen.  In my eyes it is simpler, too.

It passes `make check'.

{{{
* subversion/libsvn_subr/path.c
  (skip_uri_schema): Rewrite.  Now it doesn't use strlen anymore.
  The old version was broken if path ends with "://"

* subversion/tests/libsvn_subr/path-test.c
  (test_is_url): add to test cases and calculate the length of the list
  to test instead of hard coding it.
}}}

-- 
Uwe Zeisberger

http://www.google.com/search?q=the+speed+of+light+in+m%2Fs

Re: [PATCH] skip_uri_schema without strlen

Posted by Michael W Thelen <mi...@pietdepsi.com>.
Uwe Zeisberger wrote:
> {{{
> * subversion/libsvn_subr/path.c
>   (skip_uri_schema): Rewrite.  Now it doesn't use strlen anymore.
>   The old version was broken if path ends with "://"
>
> * subversion/tests/libsvn_subr/path-test.c
>   (test_is_url): add two test cases and calculate the length of the list
>   of tests instead of hard coding it to 5.
> }}}

Thanks for the patch, I've filed it as issue #2211:
http://subversion.tigris.org/issues/show_bug.cgi?id=2211

--
Michael W Thelen
It is a mistake to think you can solve any major problems just with
potatoes.       -- Douglas Adams

Re: [PATCH] skip_uri_schema without strlen

Posted by Uwe Zeisberger <ze...@informatik.uni-freiburg.de>.
Hello

Max Bowsher wrote:
> It seems you forgot to attach the patch!
Sigh. Ok, once again ...

{{{
* subversion/libsvn_subr/path.c
  (skip_uri_schema): Rewrite.  Now it doesn't use strlen anymore.
  The old version was broken if path ends with "://"

* subversion/tests/libsvn_subr/path-test.c
  (test_is_url): add two test cases and calculate the length of the list
  of tests instead of hard coding it to 5.
}}}

Thanks Max

Uwe

-- 
Uwe Zeisberger

http://www.google.com/search?q=2004+in+roman+numerals

Re: [PATCH] skip_uri_schema without strlen

Posted by Max Bowsher <ma...@ukf.net>.
Uwe Zeisberger wrote:
> Hello,
> 
> Peter N. Lundblad wrote:
>> Thanks. Could you resend the corrected patch instead? It is easier to
>> review/apply that way:-)
> ok, here it comes.  This time the patch is not retyped by hand and it
> passes `make check'.
> 
> {{{
> * subversion/libsvn_subr/path.c
>   (skip_uri_schema): Rewrite.  Now it doesn't use strlen anymore.
>   The old version was broken if path ends with "://"
> 
> * subversion/tests/libsvn_subr/path-test.c
>   (test_is_url): add two test cases and calculate the length of the list
>   of tests instead of hard coding it to 5.
> }}}
> 
> Regards
> Uwe

It seems you forgot to attach the patch!

Max.


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

[PATCH] skip_uri_schema without strlen

Posted by Uwe Zeisberger <ze...@informatik.uni-freiburg.de>.
Hello,

Peter N. Lundblad wrote:
> Thanks. Could you resend the corrected patch instead? It is easier to
> review/apply that way:-)
ok, here it comes.  This time the patch is not retyped by hand and it
passes `make check'.

{{{
* subversion/libsvn_subr/path.c
  (skip_uri_schema): Rewrite.  Now it doesn't use strlen anymore.
  The old version was broken if path ends with "://"

* subversion/tests/libsvn_subr/path-test.c
  (test_is_url): add two test cases and calculate the length of the list
  of tests instead of hard coding it to 5.
}}}

Regards
Uwe


-- 
Uwe Zeisberger

http://www.google.com/search?q=half+a+cup+in+teaspoons

Re: [PATCH] skip_uri_schema without strlen

Posted by "Peter N. Lundblad" <pe...@famlundblad.se>.
On Thu, 23 Dec 2004, Uwe Zeisberger wrote:

> Oops, I made (at least) two typos:
>
Thanks. Could you resend the corrected patch instead? It is easier to
review/apply that way:-)

Regards,
//Peter

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

Re: [PATCH] skip_uri_schema without strlen

Posted by Uwe Zeisberger <ze...@informatik.uni-freiburg.de>.
Oops, I made (at least) two typos:
 
Uwe Zeisberger wrote:
> {{{
> * subversion/libsvn_subr/path.c
>   (skip_uri_schema): Rewrite.  Now it doesn't use strlen anymore.
>   The old version was broken if path ends with "://"
> 
> * subversion/tests/libsvn_subr/path-test.c
>   (test_is_url): add to test cases and calculate the length of the list
this should be two ----^, ...

> -          && (path[j + 2] == '/'))
> -        return path + j + 3;
> -      
> -      return NULL;
> +      if (path[j] == ':')
> +        {
> +          if (path[j + 1] == '/' && path[j + 2] == '/')
> +            return path = j = 3;
... and the previous line should read

+            return path + j + 3;

> +          else
> +            return NULL;
> +        }
>      }

Uwe

-- 
Uwe Zeisberger

fib where fib = 0 : 1 : zipWith (+) fib (tail fib)