This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
Re: [PATCH setup 3/3] Add the last element of URL path to site chooser, if interesting.
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin-apps at cygwin dot com
- Date: Mon, 21 Apr 2014 10:10:28 -0400
- Subject: Re: [PATCH setup 3/3] Add the last element of URL path to site chooser, if interesting.
- Authentication-results: sourceware.org; auth=none
- References: <1398078987-5116-1-git-send-email-jon dot turney at dronecode dot org dot uk> <1398078987-5116-4-git-send-email-jon dot turney at dronecode dot org dot uk>
- Reply-to: cygwin-apps at cygwin dot com
On Mon, Apr 21, 2014 at 12:16:27PM +0100, Jon TURNEY wrote:
>If I add the site http://mirrors.kernel.org/sources.redhat.com/cygwinports/ to
>setup's mirror list, using the GUI or --site option, I get two indistinguishable
>entries named http://mirrors.kernel.org in the mirror list box.
>
>So, to make the site chooser list entries more distinguishable, add the last
>element of the URL path to the site chooser, if it exists and isn't 'cygwin' (or
>some other alternatives used by current mirrors)
>
>As Corinna pointed out in Nov 2010, there is still a corner case of URLs which
>share protocol, hostname and the last element of the URL path being
>indistinguishable. Additionally, it will need updating for any new mirrors which
>don't use one of the expected strings for the last path element in the URL.
>
>2014-04-19 Jon TURNEY <jon.turney@dronecode.org.uk>
>
> * site.cc (init): If interesting, show the last element
> of URL, as well as the protocol and sitename in the site chooser.
>
>Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
>---
> site.cc | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
>diff --git a/site.cc b/site.cc
>index 48ec0aa..70f6303 100644
>--- a/site.cc
>+++ b/site.cc
>@@ -173,6 +173,27 @@ site_list_type::init (const string &_url, const string &_servername,
> idx = 0;
> } while (idx > 0);
> key += url;
>+
>+ /* add last element of url if it exists, and isn't "cygwin" to displayed_url */
>+ if (path_offset+1 < url.length())
>+ {
>+ string url_path = url.substr(path_offset+1);
>+
>+ /* trim any trailing / */
>+ if (url_path.at(url_path.length()-1) == '/')
>+ url_path.erase(url_path.length()-1);
>+
>+ /* add the last path element, if it exists, and isn't "cygwin"
>+ (or some aliases used by existing sites) */
>+ string::size_type pos = url_path.rfind('/');
>+ string lpe = url_path.substr(pos+1);
>+ if ((pos != string::npos) && (lpe.compare("cygwin") != 0) &&
>+ (lpe.compare("cygwin.com") != 0) && (lpe.compare("cygwin32") != 0) &&
>+ (lpe.compare("gnu-win32") != 0))
>+ {
>+ displayed_url.append(" (" + lpe + ")");
>+ }
>+ }
> }
I'd actually be ok with just displaying the whole URL even if it ends with Cygwin.
Is there a reason not to do that?
cgf