From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-apps@cygwin.com
Subject: Re: setup
Date: Thu, 02 Jul 2015 09:10:00 -0000 [thread overview]
Message-ID: <20150702091018.GA21212@calimero.vinschen.de> (raw)
In-Reply-To: <87vbe3ehrb.fsf@Rainer.invalid>
[-- Attachment #1: Type: text/plain, Size: 6180 bytes --]
Hi Achim,
On Jul 1 22:37, Achim Gratz wrote:
> Corinna Vinschen writes:
> > Ok, for once. But please make sure that you split the commit into
> > functional chunks next time it's so large. And send it to this list, so
> > code snippets can be referenced in the review.
>
> I've split it up into three parts that at least compile cleanly.
Thanks!
> +extern IniList found_ini_list, setup_ext_list;
> +const std::string setup_exts[] = { "xz", "bz2", "ini" };
See (*) below.
> @@ -97,6 +99,8 @@ static BoolOption PackageManagerOption (false, 'M', "package-manager", "Semi-att
> static BoolOption NoAdminOption (false, 'B', "no-admin", "Do not check for and enforce running as Administrator");
> static BoolOption WaitOption (false, 'W', "wait", "When elevating, wait for elevated child process");
> static BoolOption HelpOption (false, 'h', "help", "print help");
> +static StringOption SetupBaseNameOpt ("setup", 'i', "ini-basename", "Use a different basename instead of setup", false);
The word setup needs quoting of some sort I think. An example wouldn't
hurt either. What about
"Use a different ini file basename instead of \"setup\", e.g. \"foo\".ini"
?
> + (theFile->nFileSizeLow || theFile->nFileSizeHigh))
> + {
> + if (!casecompare (SetupBaseName + ".xz", theFile->cFileName))
> + found_xz = true;
> + if (!casecompare (SetupBaseName + ".bz2", theFile->cFileName))
> + found_bz2 = true;
> + if (!casecompare (SetupBaseName + ".ini", theFile->cFileName))
> + found_ini = true;
> + }
(*) This puzzles me a bit. You're keeping arrays and lists in terms of
the file suffix (setup_ext, setup_ext_list), but you don't use the
information here and elsewhere. The setup_exts array already contains
the suffixes and constitutes an order. If you extend the array of
strings to a struct, you could just run a loop over it in places like
the above and generalize the suffix handling. For instance...
struct ini_suffix_t
{
char *suffix;
bool needs_decompressing;
[...]
}
ini_suffix_t ini_suffixes[] = {
{ "xz", true },
{ "bz2", true },
{ "ini", false },
{ NULL, false } };
bool found_ini[]; // <- just as example
for (i = 0; ini_suffixes[i].suffix; ++i)
if (!casecompare (SetupBaseName + "." + ini_suffixes[i].suffix, ...)
found_ini[i] = true;
This would work OOTB, without C++11x initializer lists, and you could
drop setup_ext_list entirely.
This would also simplify things if there's a new compression we want to
support.
> + if (found_xz)
> + found_ini_list.push_back(basePath + "/" + aDir->cFileName + "/" + SetupBaseName + ".xz");
> + else if (found_bz2)
> + found_ini_list.push_back(basePath + "/" + aDir->cFileName + "/" + SetupBaseName + ".bz2");
> + else if (found_ini)
> + found_ini_list.push_back(basePath + "/" + aDir->cFileName + "/" + SetupBaseName + ".ini");
Same kind of loop here.
for (i = 0; ini_suffixes[i].suffix; ++i)
if (found_ini[i])
found_ini_list.push_back (... + ini_suffixes[i].suffix);
Ideally found_ini_list keeps a pointer into ini_suffixes as well so
you don't have to extract the suffix again at (**).
> Subject: [PATCH 3/5] Refactor setup search and implement XZ compressed setup
> files
>
> * ini.cc: Construct setup_ext_list from array until we can use
> C++11 aggregate initializers.
> (decompress_ini): Refactored for use from do_local_ini and
> do_remote_ini. Change outdated comment about setup.ini
> uncompressed size.
> (check_ini_sig): Factor out signature check.
> (fetch_remote_ini): Refactored for use from do_remote_ini.
> (do_local_ini): Iterate over search results in found_ini_list.
> Use ini_decompress and check_ini_sig.
^^^^^^^^^^^^^^
missing name change
> + // Unless the NoVerifyOption is set, check the signature for the
> + // current setup and record the result. On a failed signature check
> + // the streams are invalidated so even if we tried to read in the
> + // setup anyway there's be nothing to parse.
I'd prefer /* */ for multiline comments, but that's used pretty
inconsistently anyway, so, never mind.
> + IniDBBuilderPackage aBuilder(myFeedback);
> + io_stream *ini_file, *ini_sig_file;
> + // iterate over all setup files found in do_from_local_dir
> + for (IniList::const_iterator n = found_ini_list.begin();
> + n != found_ini_list.end(); ++n)
> + {
> + bool sig_fail = false;
> + std::string current_ini_ext, current_ini_name, current_ini_sig_name;
> +
> + current_ini_name = *n;
> + current_ini_sig_name = current_ini_name + ".sig";
> + current_ini_ext = current_ini_name.substr(current_ini_name.rfind(".") + 1);
(**) See above.
> + ini_sig_file = io_stream::open("file://" + current_ini_sig_name, "rb", 0);
> + ini_file = io_stream::open("file://" + current_ini_name, "rb", 0);
> + ini_file = check_ini_sig (ini_file, ini_sig_file, sig_fail,
> + "localdir", current_ini_sig_name.c_str(), owner);
The existing code is inconsistently formatted, but for new code it would
be nice if we could try to be more consistent. Always prepend a space
to a left parenthesis, please.
> + // did we find a compressed setup?
> + if (ini_file &&
> + !(casecompare (current_ini_ext, "xz") &&
> + casecompare (current_ini_ext, "bz2")))
> + ini_file = decompress_ini(ini_file);
(*) And this could simply use the information from ini_suffixes if
"current_ini_ext" wouldn't be the actual extension, but rather a pointer
into ini_suffixes. Kind of like
if (ini_file && current_ini_ext->needs_decompressing)
ini_file = decompress_ini (ini_file);
Sorry if that's a lot. It just occured to me while reading your code.
I'm not adamant about the structural change I outlined above, but to
me it seems better to do it that way. What do you think?
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-07-02 9:10 UTC|newest]
Thread overview: 125+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 19:37 setup Achim Gratz
2015-05-31 10:24 ` setup Corinna Vinschen
2015-06-01 18:11 ` setup Achim Gratz
2015-06-01 18:34 ` setup Corinna Vinschen
2015-06-01 19:49 ` setup Achim Gratz
2015-06-01 21:06 ` setup Corinna Vinschen
2015-06-02 5:17 ` setup Achim Gratz
2015-06-02 8:29 ` setup Corinna Vinschen
2015-06-02 16:24 ` setup Achim Gratz
2015-06-03 8:19 ` setup Corinna Vinschen
2015-06-03 8:31 ` setup Marco Atzeri
2015-06-03 11:07 ` setup Corinna Vinschen
2015-06-03 12:45 ` setup Eric Blake
2015-06-03 16:51 ` setup Achim Gratz
2015-06-03 17:04 ` setup Yaakov Selkowitz
2015-06-03 17:11 ` setup Achim Gratz
2015-06-08 12:56 ` setup Corinna Vinschen
2015-06-08 13:49 ` setup Corinna Vinschen
2015-06-08 18:34 ` setup Yaakov Selkowitz
2015-06-08 18:47 ` setup Corinna Vinschen
2015-06-08 19:05 ` setup Yaakov Selkowitz
2015-06-08 19:35 ` setup Corinna Vinschen
2015-06-08 18:52 ` setup Achim Gratz
2015-06-06 20:58 ` setup Achim Gratz
2015-06-07 20:21 ` setup Achim Gratz
2015-06-08 13:28 ` setup Corinna Vinschen
2015-06-08 18:07 ` setup Achim Gratz
2015-06-08 19:31 ` setup Corinna Vinschen
2015-06-08 20:54 ` setup Achim Gratz
2015-06-09 9:56 ` setup Corinna Vinschen
2015-06-09 16:54 ` setup Achim Gratz
2015-06-10 8:05 ` setup Corinna Vinschen
2015-06-10 17:47 ` setup Achim Gratz
2015-06-10 18:54 ` setup Corinna Vinschen
2015-06-10 20:50 ` setup Achim Gratz
2015-06-11 10:06 ` setup Corinna Vinschen
2015-06-11 10:11 ` setup Corinna Vinschen
2015-06-11 18:10 ` setup Achim Gratz
2015-06-11 21:03 ` setup Achim Gratz
2015-06-12 10:29 ` setup Corinna Vinschen
2015-06-12 17:05 ` setup Achim Gratz
2015-06-12 17:37 ` setup Corinna Vinschen
2015-06-24 20:00 ` setup Achim Gratz
2015-06-25 8:59 ` setup Corinna Vinschen
2015-06-25 16:40 ` setup Achim Gratz
2015-06-25 20:16 ` setup Achim Gratz
2015-06-26 8:34 ` setup Corinna Vinschen
2015-06-26 18:07 ` setup Achim Gratz
2015-06-26 19:03 ` setup Corinna Vinschen
2015-06-28 13:40 ` setup Achim Gratz
2015-06-29 13:41 ` setup Corinna Vinschen
2015-06-30 4:59 ` setup Achim Gratz
2015-06-30 16:40 ` setup Corinna Vinschen
2015-06-30 17:14 ` setup Achim Gratz
2015-06-30 18:42 ` setup Corinna Vinschen
2015-07-01 20:37 ` setup Achim Gratz
2015-07-02 9:10 ` Corinna Vinschen [this message]
2015-07-02 21:03 ` setup Achim Gratz
2015-07-03 10:14 ` setup Corinna Vinschen
2015-07-11 21:31 ` setup Achim Gratz
2015-07-13 9:44 ` setup Corinna Vinschen
2015-07-14 19:57 ` setup Achim Gratz
-- strict thread matches above, loose matches on Subject: below --
2015-07-28 19:19 setup Achim Gratz
2015-07-29 12:51 ` setup Corinna Vinschen
2015-08-01 15:52 ` setup Achim Gratz
2015-08-03 18:03 ` setup Achim Gratz
2015-08-03 19:07 ` setup Achim Gratz
2015-08-03 20:02 ` setup Achim Gratz
2015-08-03 20:29 ` setup Corinna Vinschen
2015-08-03 20:31 ` setup Achim Gratz
2015-08-03 20:40 ` setup Corinna Vinschen
2015-08-03 20:54 ` setup Achim Gratz
2015-08-03 21:20 ` setup Achim Gratz
2015-08-04 18:35 ` setup Achim Gratz
2015-08-05 8:08 ` setup Corinna Vinschen
2015-08-05 15:42 ` setup Achim Gratz
2015-08-06 10:03 ` setup Corinna Vinschen
2015-08-06 15:58 ` setup Achim Gratz
2015-08-07 19:47 ` setup Corinna Vinschen
2015-08-07 21:05 ` setup Warren Young
2015-08-10 8:44 ` setup Corinna Vinschen
2015-08-10 15:02 ` setup Warren Young
2015-08-11 7:48 ` setup Corinna Vinschen
2015-08-11 19:53 ` setup Warren Young
2015-08-08 5:22 ` setup Achim Gratz
2015-08-10 9:18 ` setup Corinna Vinschen
2015-08-10 16:33 ` setup Achim Gratz
2015-08-10 14:44 ` setup Warren Young
2015-08-10 16:40 ` setup Achim Gratz
2015-08-10 16:45 ` setup Warren Young
2015-08-10 17:00 ` setup Achim Gratz
2015-08-10 17:09 ` setup Warren Young
2015-08-10 18:03 ` setup Achim Gratz
2015-08-10 18:41 ` setup Warren Young
2002-03-04 19:28 setup Robert Collins
2002-03-04 23:38 ` setup Michael A Chase
2002-03-05 8:31 ` setup Brian Keener
2002-02-20 23:10 Setup Robert Collins
2002-02-18 6:12 Setup Robert Collins
2002-02-18 13:06 ` Setup Brian Keener
2002-02-18 17:26 ` Setup Robert Collins
2002-02-18 20:05 ` Setup Christopher Faylor
2002-02-18 20:19 ` Setup Robert Collins
2002-02-18 20:31 ` Setup Brian Keener
2002-02-18 20:34 ` Setup Robert Collins
2002-02-18 20:44 ` Setup Brian Keener
2002-02-18 20:50 ` Setup Robert Collins
2002-02-19 8:53 ` Setup Brian Keener
2002-02-24 3:03 ` Setup Robert Collins
2002-02-18 20:46 ` Setup Christopher Faylor
2002-02-18 20:56 ` Setup Christopher Faylor
2002-02-20 22:45 ` Setup Gary R. Van Sickle
2002-02-20 23:00 ` Setup Christopher Faylor
2002-02-24 3:05 ` Setup Robert Collins
2002-02-24 9:07 ` Setup Christopher Faylor
2002-02-18 20:18 ` Setup Brian Keener
2002-02-18 20:30 ` Setup Robert Collins
2002-02-18 18:48 ` Setup Robert Collins
2002-02-18 19:50 ` Setup Robert Collins
2002-02-22 5:38 ` Setup Brian Keener
2002-02-22 14:46 ` Setup Robert Collins
2002-02-22 19:15 ` Setup Brian Keener
2002-02-22 23:04 ` Setup Christopher Faylor
2002-02-24 2:38 ` Setup Robert Collins
2002-02-27 10:20 ` Setup Brian Keener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150702091018.GA21212@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin-apps@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).