From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from re-prd-fep-049.btinternet.com (mailomta9-re.btinternet.com [213.120.69.102]) by sourceware.org (Postfix) with ESMTPS id 23715385E451 for ; Fri, 8 Mar 2024 18:35:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23715385E451 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 23715385E451 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=213.120.69.102 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709922939; cv=none; b=mkezNQ0T4S6snYII2iET+0SzpazrSt8Z7L85izvjumHYNdPKWjva2njDN2skwmJGWb7STs3632jyJru9zarBpg7NTzzkMgQRgztu8zIdb8xNJqblO9DYAudnvKZh1gz6CvXVAUnzGlSSS5AyGCJrc/AxO0087XzkCTQFjTUa72E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709922939; c=relaxed/simple; bh=7mfQze53/08Ju9OMfW9iNtjecySOngXtLKcmJEd8tFI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=G4m5/LD+L4VzX+X1KCRlak6jrM4zRIkBxiaAN+FdRQ7ESjPolkVbqeiDkzmjbWopc59l8h1aadAOJA7nc/jS7q38snPCPL86dhBBhO28yq11PHm7sF4VcJ6RNjAtKJTdQN8U2BkAmD8rNv4I0KPjVPa8LTimhYmRH0+Nv5MhjCg= 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-049.btinternet.com with ESMTP id <20240308183536.ILBB8012.re-prd-fep-049.btinternet.com@re-prd-rgout-004.btmx-prd.synchronoss.net>; Fri, 8 Mar 2024 18:35:36 +0000 Authentication-Results: btinternet.com; none X-SNCR-Rigid: 6577B87C0AB06653 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: gggruggvucftvghtrhhoucdtuddrgedvledrieehgdduudegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheplfhonhcuvfhurhhnvgihuceojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheqnecuggftrfgrthhtvghrnhepleeitdejhfdtveekheeugeffgeevfedtjeejveefhfeiffefkedtvdetheehieejnecukfhppeekuddrudehfedrleekrddukeehnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehhvghloheplhhotggrlhhhohhsthdrlhhotggrlhguohhmrghinhdpihhnvghtpeekuddrudehfedrleekrddukeehpdhmrghilhhfrhhomhepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdpnhgspghrtghpthhtohepvddprhgtphhtthhopegthihgfihinhdqrghpphhssegthihgfihinhdrtghomhdprhgtphhtthhopehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkpdhrvghvkffrpehhohhsthekuddqudehfedqleekqddukeehrdhrrghnghgvkeduqdduheefrdgsthgtvghnthhrrghlphhluhhsrdgtohhmpdgruhhthhgpuhhsvghrpehjohhnthhurhhnvgihsegsthhinhhtvghrnhgvthdrtghomhdpghgvohfk 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 6577B87C0AB06653; Fri, 8 Mar 2024 18:35:36 +0000 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup 06/16] Simplify invocation of UserSettings::open_settings() Date: Fri, 8 Mar 2024 18:34:25 +0000 Message-ID: <20240308183440.4263-7-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.5 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: Simplify how we check for a setup.rc settings file in the local cache dir (Who knew that setup even did this?): pass the directory down to UserSettings::open_settings() as a parameter, rather than by storing it in an (otherwise unused) member. Also: rename the 'cwd' parameter, because it's actually an arbitrary directory, not the cwd. (Archeology seems to indicate that at one stage we'd save settings in the cwd if we needed to write them before the cygwin root was known, and migrate that file to the cygwin root when it becomes known; then we changed to keeping that file in the cache dir, then we forgot to migrate it, so perhaps all this complexity isn't needed?) --- UserSettings.cc | 12 +++++++----- UserSettings.h | 4 +--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/UserSettings.cc b/UserSettings.cc index c8ddd3d..3ec6798 100644 --- a/UserSettings.cc +++ b/UserSettings.cc @@ -65,14 +65,17 @@ UserSettings::extend_table (ssize_t i) } io_stream * -UserSettings::open_settings (const char *filename, std::string &pathname) +UserSettings::open_settings (const char *filename, std::string &dir, std::string &pathname) { + // first look for a settings file in specified dir pathname = "file://"; - pathname += cwd; - if (!isdirsep (cwd[cwd.size () - 1]) && !isdirsep (filename[0])) + pathname += dir; + if (!isdirsep (dir[dir.size () - 1]) && !isdirsep (filename[0])) pathname += "/"; pathname += filename; io_stream *f = io_stream::open(pathname, "rt", 0); + + // if not found, look in cygwin installation if (!f) { pathname = "cygfile:///etc/setup/"; @@ -92,8 +95,7 @@ UserSettings::UserSettings () void UserSettings::load (std::string local_dir) { - cwd = local_dir; - io_stream *f = open_settings ("setup.rc", filename); + io_stream *f = open_settings ("setup.rc", local_dir, filename); if (!f) return; diff --git a/UserSettings.h b/UserSettings.h index 3de06e1..dc06ab2 100644 --- a/UserSettings.h +++ b/UserSettings.h @@ -27,7 +27,6 @@ private: ssize_t table_len; std::string filename; - std::string cwd; public: static class UserSettings *global; @@ -44,8 +43,7 @@ public: private: void extend_table (ssize_t); - io_stream *open_settings (const char *, std::string&); - + io_stream *open_settings (const char *, std::string &, std::string&); }; #endif // SETUP_USERSETTINGS_H -- 2.43.0