[darcs-users] darcs patch: change is_file to return false on dround... (and 1 more)

Eric Kow kowey at darcs.net
Fri Sep 12 22:09:17 UTC 2008


Hi David,

The second patch seems to change behaviour.  I will wait for further
comments before pushing :-)

change is_file to return false on droundy at darcs.net:
----------------------------------------------------
> -match_not_file = mkRegex "..+:.+"
> +match_not_file = mkRegex "..+:"

Seems harmless enough

refactor Darcs.URL to eliminate use of Regexes.
-----------------------------------------------
Reordering some lines.  Removing needless regexp use seems like a nice
idea.

> -match_not_file = mkRegex "..+:"
> -is_file fou = isNothing $ matchRegex match_not_file fou
> +is_file :: String -> Bool
> +is_file (_:_:fou) = ':' `notElem` fou
> +is_file _ = True

Indeed, this does appear to be unchanged.

I was wondering for a while why we seem to assume that hostnames are at
least two letters long, but then it struck me that this must be because
we want to recognise Windows drive names (e.g. C:) as being such.  IF
so, this is exactly the kind of thing we ought to haddock.

> -match_url = mkRegex ".+://.+"
> +is_url :: String -> Bool
> +is_url (':':'/':'/':_) = True
> +is_url (_:x) = is_url x
> +is_url "" = False

It looks like there is a small change in this function.

Before, we rejected
  foo://
because it was missing a character at the end.  Now we accept it.

I'm guessing this doesn't really matter, but just in case, I am
going to wait until you comment before pushing into stable.

> -match_ssh_nopath = mkRegex "^[^:]{2,}:$"
> -is_ssh_nopath s = isJust $ matchRegex match_ssh_nopath s
> +is_ssh_nopath :: String -> Bool
> +is_ssh_nopath s = case reverse s of
> +                  ':':x@(_:_:_) -> ':' `notElem` x
> +                  _ -> False

Seems the same to me.

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
Url : http://lists.osuosl.org/pipermail/darcs-users/attachments/20080912/73a02bd0/attachment.pgp 


More information about the darcs-users mailing list