From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from re-prd-fep-041.btinternet.com (mailomta29-re.btinternet.com [213.120.69.122]) by sourceware.org (Postfix) with ESMTPS id 98357385E009 for ; Fri, 8 Mar 2024 18:36:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 98357385E009 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dronecode.org.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 98357385E009 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=213.120.69.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709922963; cv=none; b=f20F6hJIyNyQNzSkZq0lOn5EFKn2SHUMfF61enc56UfrRaNBS1nxlURhkyQI1zhWFw9ORZWbywsUAHWCtGjnVelwEexJ6P2hxJuGH25q2m4LQ9Tv5PwWKQAlnz3+uV+g5NifE7IX8ZFWMru0i5sBSx7ruUmdjzWKXzI4PVcvWCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709922963; c=relaxed/simple; bh=lI0ctfG5FvpP5g8IlnQGNvuqwsG2uUkhK+eIk520ktU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=qtFsqSSV+HLOJaA64wbZ0LeGY92gkMcmSvkNRjyqbwp43WmxD03s0lx2QDgF+zU3WnAJkaTK+DU21SkcjJYccJk+TzER7G/tT2VdwReNIv3AqXSPh033893pWjEqFeom+rKEjAQoJympTYPaGobICBbidKhayoXYV5SmFOlqvtw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from re-prd-rgout-004.btmx-prd.synchronoss.net ([10.2.54.7]) by re-prd-fep-041.btinternet.com with ESMTP id <20240308183559.UJOF21578.re-prd-fep-041.btinternet.com@re-prd-rgout-004.btmx-prd.synchronoss.net>; Fri, 8 Mar 2024 18:35:59 +0000 Authentication-Results: btinternet.com; none X-SNCR-Rigid: 6577B87C0AB06899 X-Originating-IP: [81.153.98.185] X-OWM-Source-IP: 81.153.98.185 X-OWM-Env-Sender: jon.turney@dronecode.org.uk X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvledrieehgdduudegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheplfhonhcuvfhurhhnvgihuceojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheqnecuggftrfgrthhtvghrnhepleeitdejhfdtveekheeugeffgeevfedtjeejveefhfeiffefkedtvdetheehieejnecukfhppeekuddrudehfedrleekrddukeehnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehhvghloheplhhotggrlhhhohhsthdrlhhotggrlhguohhmrghinhdpihhnvghtpeekuddrudehfedrleekrddukeehpdhmrghilhhfrhhomhepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdpnhgspghrtghpthhtohepvddprhgtphhtthhopegthihgfihinhdqrghpphhssegthihgfihinhdrtghomhdprhgtphhtthhopehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkpdhrvghvkffrpehhohhsthekuddqudehfedqleekqddukeehrdhrrghnghgvkeduqdduheefrdgsthgtvghnthhrrghlphhluhhsrdgtohhmpdgruhhthhgpuhhsvghrpehjohhnthhurhhnvgihsegsthhinhhtvghrnhgvthdrtghomhdpghgvohfk rfepifeupdfovfetjfhoshhtpehrvgdqphhrugdqrhhgohhuthdqtddtge X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (81.153.98.185) by re-prd-rgout-004.btmx-prd.synchronoss.net (authenticated as jonturney@btinternet.com) id 6577B87C0AB06899; Fri, 8 Mar 2024 18:35:59 +0000 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup 10/16] Move setup.ini pathame components to ini.cc Date: Fri, 8 Mar 2024 18:34:29 +0000 Message-ID: <20240308183440.4263-11-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308183440.4263-1-jon.turney@dronecode.org.uk> References: <20240308183440.4263-1-jon.turney@dronecode.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Move SetupBaseNameOption to ini.cc Eliminate SetupIniDir, it's just SetupArch + "/" Change SetupArch() and SetupBaseName() into functions, to avoid having to do global initialization at the right time. --- fromcwd.cc | 8 ++++---- ini.cc | 22 +++++++++++++++++----- ini.h | 5 ++--- main.cc | 8 -------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/fromcwd.cc b/fromcwd.cc index c53eede..b1f1021 100644 --- a/fromcwd.cc +++ b/fromcwd.cc @@ -52,7 +52,7 @@ public: ext != setup_ext_list.end (); ext++, fi++) { - if (!casecompare (SetupBaseName + "." + *ext, theFile->cFileName)) + if (!casecompare (SetupBaseName() + "." + *ext, theFile->cFileName)) *fi = true; } } @@ -62,7 +62,7 @@ public: { if (level <= 0) return; - inidir = !casecompare (SetupArch, aDir->cFileName); + inidir = !casecompare (SetupArch(), aDir->cFileName); if (level == 1 && !inidir) return; Find aFinder (basePath + aDir->cFileName); @@ -74,8 +74,8 @@ public: { if (*fi) { - found_ini_list.push_back (basePath + SetupArch + "/" - + SetupBaseName + "." + *ext); + found_ini_list.push_back (basePath + SetupArch() + "/" + + SetupBaseName() + "." + *ext); /* * Terminate the search after the first setup file * found, which shadows any setup files with diff --git a/ini.cc b/ini.cc index 2b2da10..42df6a3 100644 --- a/ini.cc +++ b/ini.cc @@ -44,6 +44,7 @@ #include "io_stream_memory.h" #include "getopt++/BoolOption.h" +#include "getopt++/StringOption.h" #include "IniDBBuilderPackage.h" #include "compress.h" #include "msg.h" @@ -58,10 +59,21 @@ IniList setup_ext_list (setup_exts, setup_exts + (sizeof(setup_exts) / sizeof(*setup_exts))); IniList found_ini_list; +static StringOption SetupBaseNameOption ("setup", 'i', "ini-basename", IDS_HELPTEXT_INI_BASENAME, false); static BoolOption NoVerifyOption (false, 'X', "no-verify", IDS_HELPTEXT_NO_VERIFY); static BoolOption NoVersionCheckOption (false, '\0', "no-version-check", IDS_HELPTEXT_NO_VERSION_CHECK); +std::string SetupArch() +{ + return is_64bit ? "x86_64" : "x86"; +} + +std::string SetupBaseName() +{ + return SetupBaseNameOption; +} + static io_stream* decompress_ini (io_stream *ini_file, std::string ¤t_ini_name) { @@ -170,7 +182,7 @@ do_local_ini (Feedback &myFeedback) if (!ini_file || sig_fail) { // no setup found or signature invalid - note (myFeedback.owner(), IDS_SETUPINI_MISSING, SetupBaseName.c_str (), + note (myFeedback.owner(), IDS_SETUPINI_MISSING, SetupBaseName().c_str (), "localdir"); ini_error = true; } @@ -180,7 +192,7 @@ do_local_ini (Feedback &myFeedback) myFeedback.babble ("Found ini file - " + current_ini_name); myFeedback.iniName (current_ini_name); int ldl = local_dir.length () + 1; - int cap = current_ini_name.rfind ("/" + SetupArch); + int cap = current_ini_name.rfind ("/" + SetupArch()); aBuilder.parse_mirror = rfc1738_unescape (current_ini_name.substr (ldl, cap - ldl)); ini_init (ini_file, &aBuilder, myFeedback); @@ -225,7 +237,7 @@ do_remote_ini (Feedback &myFeedback) ext++) { current_ini_ext = *ext; - current_ini_name = n->url + SetupIniDir + SetupBaseName + "." + current_ini_ext; + current_ini_name = n->url + SetupArch() + "/" + SetupBaseName() + "." + current_ini_ext; current_ini_sig_name = current_ini_name + ".sig"; ini_sig_file = get_url_to_membuf (current_ini_sig_name, myFeedback); ini_file = get_url_to_membuf (current_ini_name, myFeedback); @@ -240,7 +252,7 @@ do_remote_ini (Feedback &myFeedback) if (!ini_file || sig_fail) { // no setup found or signature invalid - note (myFeedback.owner(), IDS_SETUPINI_MISSING, SetupBaseName.c_str (), n->url.c_str ()); + note (myFeedback.owner(), IDS_SETUPINI_MISSING, SetupBaseName().c_str (), n->url.c_str ()); ini_error = true; } else @@ -260,7 +272,7 @@ do_remote_ini (Feedback &myFeedback) /* save known-good setup.ini locally */ const std::string fp = "file://" + local_dir + "/" + rfc1738_escape_part (n->url) + - "/" + SetupIniDir + SetupBaseName + ".ini"; + "/" + SetupArch() + "/" + SetupBaseName() + ".ini"; io_stream::mkpath_p (PATH_TO_FILE, fp, 0); if (io_stream *out = io_stream::open (fp, "wb", 0)) { diff --git a/ini.h b/ini.h index 2ca4f5b..05b31e0 100644 --- a/ini.h +++ b/ini.h @@ -24,9 +24,8 @@ typedef std::vector IniList; extern IniList found_ini_list, setup_ext_list; extern bool is_new_install; -extern std::string SetupArch; -extern std::string SetupIniDir; -extern std::string SetupBaseName; +std::string SetupArch(); +std::string SetupBaseName(); class io_stream; class IniDBBuilder; diff --git a/main.cc b/main.cc index c359ba9..4c391f5 100644 --- a/main.cc +++ b/main.cc @@ -84,7 +84,6 @@ extern char **_argv; #endif bool is_new_install = false; -std::string SetupArch; std::string SetupIniDir; HINSTANCE hinstance; @@ -109,14 +108,11 @@ static BoolOption NoAdminOption (false, 'B', "no-admin", IDS_HELPTEXT_NO_ADMIN); static BoolOption WaitOption (false, 'W', "wait", IDS_HELPTEXT_WAIT); static BoolOption HelpOption (false, 'h', "help", IDS_HELPTEXT_HELP); static BoolOption VersionOption (false, 'V', "version", IDS_HELPTEXT_VERSION); -static StringOption SetupBaseNameOpt ("setup", 'i', "ini-basename", IDS_HELPTEXT_INI_BASENAME, false); BoolOption UnsupportedOption (false, '\0', "allow-unsupported-windows", IDS_HELPTEXT_ALLOW_UNSUPPORTED_WINDOWS); static BoolOption DeprecatedOption (false, 'w', "no-warn-deprecated-windows", IDS_HELPTEXT_NO_WARN_DEPRECATED_WINDOWS); static StringChoiceOption SymlinkTypeOption(symlink_types, '\0', "symlink-type", IDS_HELPTEXT_SYMLINK_TYPE, false, SymlinkTypeMagic); static StringOption GuiLangOption ("", '\0', "lang", IDS_HELPTEXT_LANG); -std::string SetupBaseName; - static void inline set_cout () { @@ -298,10 +294,6 @@ WinMain (HINSTANCE h, bool output_only = help_option || VersionOption; - SetupBaseName = SetupBaseNameOpt; - SetupArch = is_64bit ? "x86_64" : "x86"; - SetupIniDir = SetupArch+"/"; - /* Initialize well known SIDs. We need the admin SID to test if we're supposed to elevate. */ nt_sec.initialiseWellKnownSIDs (); -- 2.43.0