From nobody Fri Oct 13 17:24:34 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S6YKH1wHDz4wWmB; Fri, 13 Oct 2023 17:24:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S6YKH16hzz4HHt; Fri, 13 Oct 2023 17:24:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697217875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L96dLAbjP7QYdabDkTn1aci4FjB2HOTgWxseiejHrss=; b=H/PVXbrn+2Fd8qH4KZkPDaCF6eIjfiJiGTseq7xFR1TKD6vZnZ/NvtPieV+gDAKMVw70Hu dbUqEz3WGAXJz/JJtMKHvCohYdBOF3an02q42BWzaNf00tuzhF5DAsVRTrh88IjUryYFGF PqvMis1zbZcQiHLN/MJGhidQpkfl+3pk6piMsqohRNH8IjZDwTPmJY0XwM3TFcFQKMxpyR Iw/3FmYxbvg3tiyh+uZSzcXewfbiWfDdpnknEeuNthHgHfsnN/yPh6Cl+hxvjDO39qJnxE uvtSW1DEkMEHv9buvqvcJRFy4LIGOEvcN041VgO/9jr4TaslYE0EtmXNgNfncg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697217875; a=rsa-sha256; cv=none; b=AoXhrE7HsCrHaiwg8i/wEal1Rc11PJBlDW4cmZPCsgijA3BIv4XSD3Jk/nltnieEpKyqOP mb4hovlnrMT6yRdIFpjp7g/bbBbF+amA0m8lSE4OUYIrRR50YEQQ9cevyq2fWaOKm8dyhH Wzcbr1B7ngcFmF8biTPu+9QFw50Qxp753pwj5g5gk4Jg5M44cZbjw5QNkzSA3I8EayAPiO XH4qNuUYbck0dE/Mgj/8qp6VBhpkakTXJyoWm6fd0q6m4XYe+kHNpl6lmKxMjH77Ps9c3j M8CYLHToOaE75XMv++XbN73q35ilW4exg4/irU8XP3x3A4IjLTmvlBLyh7Fxuw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697217875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L96dLAbjP7QYdabDkTn1aci4FjB2HOTgWxseiejHrss=; b=AV8AzhDQfkipuCMC+ZORi4PThZ2oXdVZZdyemRJG218iKCiOCFrOdPDVGyJYqfPAQp6wof tO6IyICsZ7Tnx00AOa2nkInzC0Q7ArRI6qXbkWxeC884iLw/FNez8P5SPyK18zezHFUe3H zAQdJWwjWoISVoMOtzXayBHgHQ0LA8lD3yeCQgey3MFWBvFLVTlIzZdqlfTLim4K/DNyxp H+kwAX/kml3gDujA4CatfdXs1keK309Miz+oEqtL4N9/8u+rgohIDvJNrYPkhMrhYvAsxB i48EjjCIl85e3B+wm2UPib0qaCF8ZLfB+F6DHnxqUzGKiKFUTBM5Iq3TlXbw/w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S6YKH08BHzwV7; Fri, 13 Oct 2023 17:24:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39DHOYZZ081729; Fri, 13 Oct 2023 17:24:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39DHOYGC081726; Fri, 13 Oct 2023 17:24:34 GMT (envelope-from git) Date: Fri, 13 Oct 2023 17:24:34 GMT Message-Id: <202310131724.39DHOYGC081726@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 914ab28c598c - main - tzsetup: add support for countries in two continents List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 914ab28c598c108bcfa5c040cc3056a8e6fc3811 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=914ab28c598c108bcfa5c040cc3056a8e6fc3811 commit 914ab28c598c108bcfa5c040cc3056a8e6fc3811 Author: Pierre Pronchery AuthorDate: 2023-07-27 16:07:22 +0000 Commit: Ed Maste CommitDate: 2023-10-13 17:23:59 +0000 tzsetup: add support for countries in two continents This supports countries located across multiple continents, as per the zone1970.tab file. This only affects Cyprus and Türkiye at the moment. PR: 236874 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41306 --- usr.sbin/tzsetup/tzsetup.c | 67 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c index 5dfe840528b5..4279f888a33f 100644 --- a/usr.sbin/tzsetup/tzsetup.c +++ b/usr.sbin/tzsetup/tzsetup.c @@ -276,6 +276,7 @@ struct country { char *tlc; int nzones; struct continent *override; /* continent override */ + struct continent *alternate; /* extra continent */ TAILQ_HEAD(, zone) zones; dialogMenuItem *submenu; }; @@ -374,6 +375,18 @@ find_country(int lineno, const char *tlc) return (cp); } +static void +add_cont_to_country(struct country *cp, struct continent *cont) +{ + struct zone *zp; + + TAILQ_FOREACH(zp, &cp->zones, link) { + if (zp->continent == cont) + return; + } + cp->alternate = cont; +} + static void add_zone_to_country(int lineno, struct country *cp, const char *descr, const char *file, struct continent *cont) @@ -441,13 +454,13 @@ read_zones(void) struct country *cp; size_t len; char *line, *country_list, *tlc, *file, *descr; + char *p, *q; int lineno; - bool pass1; + int pass = 1; fp = fopen(path_zonetab, "r"); if (!fp) err(1, "%s", path_zonetab); - pass1 = true; again: lineno = 0; @@ -457,7 +470,9 @@ again: errx(1, "%s:%d: invalid format", path_zonetab, lineno); line[len - 1] = '\0'; - if (pass1) { + switch (pass) + { + case 1: /* * First pass: collect overrides, only looking for * single continent ones for the moment. @@ -481,7 +496,8 @@ again: cp = find_country(lineno, tlc); cp->override = cont; } - } else { + break; + case 2: /* Second pass: parse actual data */ if (line[0] == '#') continue; @@ -498,11 +514,34 @@ again: add_zone_to_country(lineno, cp, descr, file, cont); } + break; + case 3: + /* Third pass: collect multi-continent overrides */ + if (strncmp(line, "#@", strlen("#@")) != 0) + continue; + line += 2; + country_list = strsep(&line, "\t"); + /* Skip single-continent overrides */ + if (strchr(line, ',') == NULL) + continue; + while (line != NULL) { + cont = find_continent(lineno, line); + p = q = strdup(country_list); + if (p == NULL) + errx(1, "malloc failed"); + while (q != NULL) { + tlc = strsep(&q, ","); + cp = find_country(lineno, tlc); + add_cont_to_country(cp, cont); + } + free(p); + strsep(&line, ","); + } + break; } } - if (pass1) { - pass1 = false; + if (pass++ < 3) { errno = 0; rewind(fp); if (errno != 0) @@ -555,6 +594,12 @@ make_menus(void) if (zp2 == zp) zp->continent->nitems++; } + + for (i = 0; i < NCONTINENTS; i++) { + if (cp->alternate == continent_names[i].continent) { + continent_names[i].continent->nitems++; + } + } } /* @@ -611,6 +656,16 @@ make_menus(void) dmi->fire = set_zone_menu; dmi->data = cp; } + + if (cp->alternate != NULL) { + cont = cp->alternate; + dmi = &cont->menu[cont->nitems]; + memset(dmi, 0, sizeof(*dmi)); + asprintf(&dmi->prompt, "%d", ++cont->nitems); + dmi->title = cp->name; + dmi->fire = set_zone_menu; + dmi->data = cp; + } } }