From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: scdbackup@gmx.net
Subject: Re: About the CLI of both grub-mkrescue versions
Date: Fri, 10 Oct 2014 22:19:04 +0400 [thread overview]
Message-ID: <20141010221904.4a602eff@opensuse.site> (raw)
In-Reply-To: <1495546211684188288@scdbackup.webframe.org>
В Wed, 01 Oct 2014 09:25:12 +0200
"Thomas Schmitt" <scdbackup@gmx.net> пишет:
> Hi,
>
> to substantiate my proposal of renaming young grub-mkrescue.c to
> grub-mkiso.c and to add a built-in emulation of grub-mkrescue(.in),
> here the necessary code which i tested standalone with valgrind.
Well, below is much more simple patch which is reusing argp
infrastructure. The only problem - it needs small patch for gnulib
otherwise --help does not work. IMHO this is a bug in gnulib. If you
convince them to fix it ...
I do not say that I particular like it, but looks better than
reimplement parser from scratch.
---
grub-core/gnulib/argp-parse.c | 7 +++++--
util/grub-mkrescue.c | 37 ++++++++++++++++++++++++++++---------
2 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/grub-core/gnulib/argp-parse.c b/grub-core/gnulib/argp-parse.c
index 67ea32c..8fb50e1 100644
--- a/grub-core/gnulib/argp-parse.c
+++ b/grub-core/gnulib/argp-parse.c
@@ -89,13 +89,16 @@ static const struct argp_option argp_default_options[] =
static error_t
argp_default_parser (int key, char *arg, struct argp_state *state)
{
+ struct argp_state help_state = *state;
+
+ help_state.flags &= ~ARGP_NO_ERRS;
switch (key)
{
case '?':
- __argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP);
+ __argp_state_help (&help_state, state->out_stream, ARGP_HELP_STD_HELP);
break;
case OPT_USAGE:
- __argp_state_help (state, state->out_stream,
+ __argp_state_help (&help_state, state->out_stream,
ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
break;
diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
index e719839..8decb4e 100644
--- a/util/grub-mkrescue.c
+++ b/util/grub-mkrescue.c
@@ -70,6 +70,19 @@ xorriso_push (const char *val)
}
static void
+xorriso_push_tail (const char *val)
+{
+ if (xorriso_tail_arg_alloc <= xorriso_tail_argc)
+ {
+ xorriso_tail_arg_alloc = 2 * (4 + xorriso_tail_argc);
+ xorriso_tail_argv = xrealloc (xorriso_tail_argv,
+ sizeof (xorriso_tail_argv[0])
+ * xorriso_tail_arg_alloc);
+ }
+ xorriso_tail_argv[xorriso_tail_argc++] = xstrdup (val);
+}
+
+static void
xorriso_link (const char *from, const char *to)
{
char *tof = grub_util_path_concat (2, iso9660_dir, to);
@@ -156,6 +169,12 @@ enum {
static error_t
argp_parser (int key, char *arg, struct argp_state *state)
{
+ if (state->quoted && !(int *)state->input)
+ {
+ *(int *)state->input = 1;
+ xorriso_push_tail ("--");
+ }
+
if (grub_install_parse (key, arg))
return 0;
switch (key)
@@ -216,14 +235,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
return 0;
case ARGP_KEY_ARG:
- if (xorriso_tail_arg_alloc <= xorriso_tail_argc)
- {
- xorriso_tail_arg_alloc = 2 * (4 + xorriso_tail_argc);
- xorriso_tail_argv = xrealloc (xorriso_tail_argv,
- sizeof (xorriso_tail_argv[0])
- * xorriso_tail_arg_alloc);
- }
- xorriso_tail_argv[xorriso_tail_argc++] = xstrdup (arg);
+ xorriso_push_tail (arg);
return 0;
default:
return ARGP_ERR_UNKNOWN;
@@ -380,6 +392,8 @@ main (int argc, char *argv[])
char *romdir;
char *sysarea_img = NULL;
const char *pkgdatadir;
+ int quote_seen = 0;
+ int unknown;
grub_util_host_init (&argc, &argv);
grub_util_disable_fd_syncs ();
@@ -391,7 +405,12 @@ main (int argc, char *argv[])
xorriso = xstrdup ("xorriso");
label_font = grub_util_path_concat (2, pkgdatadir, "unicode.pf2");
- argp_parse (&argp, argc, argv, 0, 0, 0);
+ while (argc > 0 && argp_parse (&argp, argc, argv, ARGP_NO_ERRS, &unknown, "e_seen))
+ {
+ xorriso_push_tail (argv[unknown]);
+ argv += unknown;
+ argc -= unknown;
+ }
if (!output_image)
grub_util_error ("%s", _("output file must be specified"));
--
tg: (77063f4..) u/grub-mkrescue-options (depends on: master)
next prev parent reply other threads:[~2014-10-10 18:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-23 8:12 About the CLI of both grub-mkrescue versions Thomas Schmitt
2014-09-28 16:17 ` Andrei Borzenkov
2014-09-28 16:52 ` Thomas Schmitt
2014-09-28 18:28 ` Thomas Schmitt
2014-09-29 5:04 ` Andrei Borzenkov
2014-09-29 7:07 ` Thomas Schmitt
2014-10-01 7:25 ` Thomas Schmitt
2014-10-10 18:19 ` Andrei Borzenkov [this message]
2014-10-10 20:29 ` Thomas Schmitt
2014-11-28 19:41 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-11-29 5:38 ` Andrei Borzenkov
2014-11-29 10:55 ` Thomas Schmitt
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=20141010221904.4a602eff@opensuse.site \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
--cc=scdbackup@gmx.net \
/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 NNTP newsgroup(s).