From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23802 invoked by alias); 15 Nov 2017 21:35:29 -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 23778 invoked by uid 89); 15 Nov 2017 21:35:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Available, CONTROL, territory, ICON X-HELO: smtp-out-no.shaw.ca Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Nov 2017 21:35:27 +0000 Received: from [192.168.1.100] ([24.64.240.204]) by shaw.ca with SMTP id F5LAe5IUyRDG7F5LBel6WV; Wed, 15 Nov 2017 14:35:25 -0700 X-Authority-Analysis: v=2.2 cv=b+PC2pOx c=1 sm=1 tr=0 a=MVEHjbUiAHxQW0jfcDq5EA==:117 a=MVEHjbUiAHxQW0jfcDq5EA==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=LIImWlOHEBONvEmeHlMA:9 a=Je4kIA-Kjk-uavMN:21 a=gxuqntsiyerVrfTm:21 a=pILNOxqGKmIA:10 a=PyBlM00BvKScqurQRiIA:9 a=vbYxYvQ2M15dBcaU:21 a=2ZbCTc4g6zGB5qw1:21 a=QEXdDO2ut3YA:10 a=CdiWusdWvyIA:10 From: Brian Inglis Subject: [PATCH] make setup mirror list more like web page not just urls Reply-To: Brian.Inglis@SystematicSw.ab.ca To: cygwin-apps@cygwin.com Message-ID: <09c0dc5b-f975-42a9-a204-b02edef6a3ad@SystematicSw.ab.ca> Date: Wed, 15 Nov 2017 21:35:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------10B9775ADB56D74A5BFC9052" X-CMAE-Envelope: MS4wfIy5HmTo94Zragz+woXgbGXYdTbsai17Ai3TpvbaDdH5DhHUX4q1oRchjW9ArmRU8Pb1r6Y6CFhJk1Fjb3TJd5e+qwiVE/Ae6BRfP8LvpHeH+4bOAcGH G1SIyu21VGhOiCDmKYNAki+w8IUFNz35l0cgFXiS22Ty57DauFukDmhL+0gTAL09LmLxnRmd4c4E0A== X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg00061.txt.bz2 This is a multi-part message in MIME format. --------------10B9775ADB56D74A5BFC9052 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-length: 2233 Hi folks, [reposted without text attachment to see if patch gets thru] Working on a FAST_CWD FAQ, looking at the Setup mirror site page and the web page, I wondered if we could usefully add the mirrors.lst region and territory (called area and location in the code) to the Setup display, to avoid users having to refer to the web page to find out where mirrors are based geographically. The first change was to prefix the displayed_url member in site.cc site_list_type::init "constructor" with "area - location - ". The sort key was the mirror url host name with the domain components in reverse order to sort non-country TLDs together before CC TLDs. The code tested for TLD length == 3 to distinguish between CC and non-CC TLDs, as this code is over 10 years old and there were only the original com, edu, gov, mil, net, org non-CC domains, before other gTLDs were added. That test was changed to handle all gTLDs with length >= 3, to prefix area and location to the sort key member, reverse the domain components in the servername field instead of the url host, and suffix the url protocol prefix to keep the key unique where sites offer both ftp and http mirrors, rather than the whole url in the original. For checking, a short script used awk to do the same when fed with mirrors.lst, produce lines with the displayed url and sort key separated by a tab, and sort by the key to produce the displayed urls in the same order as the code should. The output of the script [was] in the first text attachment to show the displayed urls in the sorted order. When this was displayed in setup, some of the urls were cut off by the list box border, estimated about 3 ems too narrow. The width of the list box and related controls in res.rc was increased by about 30 pixels, and the position of the Add button moved over the same amount, to give an acceptable display. The required patch is attached for discussion: some may not like the display of the default mirror from /etc/setup/setup.rc last_mirror, which appears in the list as " - - url", as the other mirrors.lst fields are not currently saved under last_mirror, and more work may be needed to improve this. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada --------------10B9775ADB56D74A5BFC9052 Content-Type: text/plain; charset=UTF-8; name="0001-setup-site.cc-site_list_type-init-display-and-order.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-setup-site.cc-site_list_type-init-display-and-order.pat"; filename*1="ch" Content-length: 3509 diff --git a/res.rc b/res.rc index 80d1bf1..fa90a65 100644 --- a/res.rc +++ b/res.rc @@ -135,10 +135,10 @@ CAPTION "Cygwin Setup - Choose Download Site(s)" FONT 8, "MS Shell Dlg" BEGIN ICON IDI_CYGWIN,IDC_HEADICON,SETUP_HEADICON_X,0,21,20 - LISTBOX IDC_URL_LIST,66,45,185,110,LBS_NOINTEGRALHEIGHT | + LISTBOX IDC_URL_LIST,66,45,216,110,LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_HSCROLL | WS_GROUP | WS_TABSTOP - LTEXT "Available Download Sites:",IDC_STATIC,66,34,183,8,NOT + LTEXT "Available Download Sites:",IDC_STATIC,66,34,216,8,NOT WS_GROUP CONTROL "",IDC_HEADSEPARATOR,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, SETUP_STANDARD_DIALOG_W,1 @@ -146,10 +146,10 @@ BEGIN IDC_STATIC,21,9,239,16,NOT WS_GROUP LTEXT "Choose A Download Site",IDC_STATIC_HEADER_TITLE,7,0,258, 8,NOT WS_GROUP - EDITTEXT IDC_EDIT_USER_URL,65,160,185,14,ES_AUTOHSCROLL | + EDITTEXT IDC_EDIT_USER_URL,65,160,216,14,ES_AUTOHSCROLL | WS_GROUP LTEXT "User URL:",IDC_SITE_USERURL,15,162,45,8,NOT WS_GROUP - PUSHBUTTON "Add",IDC_BUTTON_ADD_URL,255,160,50,14 + PUSHBUTTON "Add",IDC_BUTTON_ADD_URL,288,160,50,14 END IDD_NET DIALOG DISCARDABLE 0, 0, SETUP_STANDARD_DIALOG_DIMS diff --git a/setup.exe.manifest b/setup.exe.manifest old mode 100755 new mode 100644 diff --git a/setup64.exe.manifest b/setup64.exe.manifest old mode 100755 new mode 100644 diff --git a/site.cc b/site.cc index c33da36..b8b988e 100644 --- a/site.cc +++ b/site.cc @@ -154,30 +154,30 @@ site_list_type::init (const string &_url, const string &_servername, if (url.at(url.length()-1) != '/') url.append("/"); - /* displayed_url is protocol and site name part of url */ + /* displayed_url is area, location, protocol part of url, and servername */ string::size_type path_offset = url.find ("/", url.find ("//") + 2); - displayed_url = url.substr(0, path_offset); - - /* the sorting key is hostname components in reverse order (to sort by country code) - plus the url (to ensure uniqueness) */ - key = string(); - string::size_type last_idx = displayed_url.length () - 1; - string::size_type idx = url.find_last_of("./", last_idx); - if (last_idx - idx == 3) + displayed_url = area + " - " + location + " - " + url.substr (0, path_offset); + + /* the sorting key is area, location, servername components in reverse order + * (to sort by country code) plus the protocol (to ensure uniqueness) */ + key = area + " " + location + " "; + string::size_type last_idx = servername.length (); + string::size_type idx = servername.find_last_of (".", last_idx); + + if (last_idx - idx >= 3) { - /* Sort non-country TLDs (.com, .net, ...) together. */ + /* Sort gTLDs (.com, .net, .info, ...) together. */ key += " "; } + do { - key += url.substr(idx + 1, last_idx - idx); - key += " "; + key += servername.substr (idx + 1, last_idx - idx) + " "; last_idx = idx - 1; - idx = url.find_last_of("./", last_idx); - if (idx == string::npos) - idx = 0; - } while (idx > 0); - key += url; + idx = servername.find_last_of (".", last_idx); + } while (idx != string::npos && idx > 0); + + key += url.substr (0, url.find (':')); } site_list_type::site_list_type (const string &_url, --------------10B9775ADB56D74A5BFC9052--