From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10235 invoked by alias); 21 Apr 2014 11:16:38 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 10196 invoked by uid 89); 21 Apr 2014 11:16:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: smtpout17.bt.lon5.cpcloud.co.uk Received: from smtpout17.bt.lon5.cpcloud.co.uk (HELO smtpout17.bt.lon5.cpcloud.co.uk) (65.20.0.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Apr 2014 11:16:36 +0000 X-CTCH-RefID: str=0001.0A090208.5354FE13.00F0,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-Junkmail-Premium-Raw: score=7/97,refid=2.7.2:2014.3.18.91815:17:7.944,ip=,rules=__HAS_FROM, __TO_MALFORMED_2, __TO_NO_NAME, __HAS_MSGID, __SANE_MSGID, __HAS_X_MAILER, __IN_REP_TO, __ANY_URI, __URI_NO_WWW, __CP_URI_IN_BODY, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, BODY_SIZE_7000_LESS X-CTCH-Spam: Unknown Received: from localhost.localdomain (86.164.67.104) by smtpout17.bt.lon5.cpcloud.co.uk (8.6.100.99.10223) (authenticated as jonturney@btinternet.com) id 5318507B025AA860; Mon, 21 Apr 2014 12:16:36 +0100 From: Jon TURNEY To: cygwin-apps@cygwin.com Cc: Jon TURNEY Subject: [PATCH setup 3/3] Add the last element of URL path to site chooser, if interesting. Date: Mon, 21 Apr 2014 11:16:00 -0000 Message-Id: <1398078987-5116-4-git-send-email-jon.turney@dronecode.org.uk> In-Reply-To: <1398078987-5116-1-git-send-email-jon.turney@dronecode.org.uk> References: <1398078987-5116-1-git-send-email-jon.turney@dronecode.org.uk> X-SW-Source: 2014-04/txt/msg00055.txt.bz2 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 * 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 --- 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 + ")"); + } + } } site_list_type::site_list_type (const string &_url, -- 1.8.5.5