From nobody Mon Oct 16 12:30:25 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 4S8GfT6tkCz4xK4d; Mon, 16 Oct 2023 12:30:25 +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 4S8GfT6Pzrz3cBR; Mon, 16 Oct 2023 12:30:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697459425; 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=iw500wBvszzUBAPbV1T+/6pAk1v3vH1CEvVFs8ze22Y=; b=gv4G1TPwWK6h3SrhnYbRPZOzNva+RJi8qIi1ux3np1Nty1IN3mIr+a2XkvmlPWdedGCg06 +ri0Db5kN/vr44gX9bJFY5w36xsTQQ08wi6CBDm49Iu8FIPoQtS96oZWsrZyHOnqg/mMbb TNoBTpZuRU/3Zbw1n0bKinqSJpnfrhBq6FiaGPpF2NksGrGzIqgc7lX+KNpLqEP7/chBKA EsPmmDA3PzSiyndMOSOGr+/HahPKjoJIS2Rhw0N1c2NSHunfWaqLGcR4cBZOsCGdGG31P0 6Xp/jYa45MfzRS6I1CQSPneSD46/ANKpVUjy5Y/gGi1qg/9jvqU1Kkfnfz+3iw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697459425; a=rsa-sha256; cv=none; b=IXfEc4lUWTefHQYKcgOOs5tEE0PcJ2yYBcp6VZwQG7Vno+3wr6CjLEr8wKFfn1o35kJU9V 3Ap+S8X2UgUaLqkXa2COScM2aOJhRTlQZkKy7LoYVcjquD7zqVjmhzh/bFsDFvyD70tr1F /1zHNRMlLMUqBQBue3637oAXVcxWP/janRsZX83RT9x7XhRyWa0nB+5/+1wXw78Aprma8k 2tZW6t2m9XpJdaen6+3wVj2l/G8e3UV/UEFr6gDLMWQlylrDJXjQb7NuBODtgOEiozuzBC ulOIv4mX4VJY15nM1Il5+cqSeaaB/MZjSxVfJJJULdHmwUEYfbYOeGOrEAgixg== 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=1697459425; 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=iw500wBvszzUBAPbV1T+/6pAk1v3vH1CEvVFs8ze22Y=; b=gBi/Z4w/lV3IQSGREU2gLWUiVPNO224urP+y4SJztGQEMrKzieOo+uKCbkBWcdsdcqh2K1 RyaMBfbzPH9olSJ1CQkL5nvq+eI9vhxaXtjht9THMooPkBeBpD5wLzfzvgVh3/ICpGmqOm IHyBqBc0pWTvClH8fTub7QmRHG0M2WmOK4QATd3pIXj3YTdhz2w+czYRXH5e+HKIqgpzu5 S0b+2x+GzAZxxSRjEcb6coJ6K13GyZ1HAGeobdVnWM5Ak7Vx4jpOd8aCK60qaikwLoWUFL C7evC+iWg1sSFDalNvAkz3IcqXZDQpk0HJWPDky8L+MLWYc5lC/MEjNohZnP6A== 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 4S8GfT5WSJzgWV; Mon, 16 Oct 2023 12:30:25 +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 39GCUP9d079318; Mon, 16 Oct 2023 12:30:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39GCUPtT079315; Mon, 16 Oct 2023 12:30:25 GMT (envelope-from git) Date: Mon, 16 Oct 2023 12:30:25 GMT Message-Id: <202310161230.39GCUPtT079315@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 9ef162b2392f - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 9ef162b2392f34a88fb40b560ef700d0aacadfe1 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=9ef162b2392f34a88fb40b560ef700d0aacadfe1 commit 9ef162b2392f34a88fb40b560ef700d0aacadfe1 Author: Pierre Pronchery AuthorDate: 2023-07-27 16:07:22 +0000 Commit: Ed Maste CommitDate: 2023-10-16 12:29:46 +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 (cherry picked from commit 914ab28c598c108bcfa5c040cc3056a8e6fc3811) --- 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; + } } }