From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1S3vuc-00006x-C3 for mharc-grub-devel@gnu.org; Sat, 03 Mar 2012 15:50:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3vuZ-00006U-9d for grub-devel@gnu.org; Sat, 03 Mar 2012 15:50:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S3vuX-0002Dw-E3 for grub-devel@gnu.org; Sat, 03 Mar 2012 15:50:38 -0500 Received: from wp191.webpack.hosteurope.de ([80.237.132.198]:50606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3vuX-0002Dn-1l for grub-devel@gnu.org; Sat, 03 Mar 2012 15:50:37 -0500 Received: from p54ba694b.dip.t-dialin.net ([84.186.105.75] helo=neptun.omega.ssw.de); authenticated by wp191.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) id 1S3vuV-0002KB-3A; Sat, 03 Mar 2012 21:50:35 +0100 Received: from localhost (localhost [127.0.0.1]) by neptun.omega.ssw.de (Postfix) with ESMTP id 50082E180A8 for ; Sat, 3 Mar 2012 21:50:34 +0100 (CET) X-Virus-Scanned: amavisd-new at omega.ssw.de Received: from neptun.omega.ssw.de ([127.0.0.1]) by localhost (neptun.omega.ssw.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pav1qRycdLe9 for ; Sat, 3 Mar 2012 21:50:23 +0100 (CET) Received: from [192.168.3.102] (ANVOIT-2.fritz.box [192.168.2.21]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by neptun.omega.ssw.de (Postfix) with ESMTP id BF640E180A7 for ; Sat, 3 Mar 2012 21:50:23 +0100 (CET) Message-ID: <4F528409.2010901@anvo-it.de> Date: Sat, 03 Mar 2012 21:50:17 +0100 From: Andreas Vogel User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: [PATCH] Using enum symbols as indices into menuentry options Content-Type: multipart/mixed; boundary="------------060407020409080309090504" X-bounce-key: webpack.hosteurope.de; andreas.vogel@anvo-it.de; 1330807836; b925b16f; X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.237.132.198 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2012 20:50:40 -0000 This is a multi-part message in MIME format. --------------060407020409080309090504 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Here is another tiny patch which uses a enum to reference the options array when dealing with command line options for a menuentry. This method is already used by some other modules. I have some more patches which are adding more options for the menuentry command so finally readabilty will be improved using these symbols. Any comments? Andreas --------------060407020409080309090504 Content-Type: text/plain; name="02-menuentry_options_enum.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="02-menuentry_options_enum.patch" ------------------------------------------------------------ revno: 4099 committer: Andreas Vogel branch nick: 02-menuentry_options_enum timestamp: Thu 2012-03-01 22:40:25 +0100 message: * grub-core/commands/menuentry.c: use enum symbols for indexing the options array in order to improve readability diff: === modified file 'grub-core/commands/menuentry.c' --- grub-core/commands/menuentry.c 2012-03-01 21:38:32 +0000 +++ grub-core/commands/menuentry.c 2012-03-01 21:40:25 +0000 @@ -25,6 +25,14 @@ #include #include +enum options + { + O_CLASS = 0, + O_USERS, + O_HOTKEY, + O_SOURCE, + }; + static const struct grub_arg_option options[] = { {"class", 1, GRUB_ARG_OPTION_REPEATABLE, @@ -324,18 +332,18 @@ if (! argc) return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing arguments"); - if (ctxt->state[3].set && ctxt->script) + if (ctxt->state[O_SOURCE].set && ctxt->script) return grub_error (GRUB_ERR_BAD_ARGUMENT, "multiple menuentry definitions"); - if (! ctxt->state[3].set && ! ctxt->script) + if (! ctxt->state[O_SOURCE].set && ! ctxt->script) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition"); if (! ctxt->script) return grub_normal_add_menu_entry (argc, (const char **) args, - (ctxt->state[0].set ? ctxt->state[0].args - : NULL), ctxt->state[1].arg, - ctxt->state[2].arg, 0, - ctxt->state[3].arg, + (ctxt->state[O_CLASS].set ? ctxt->state[O_CLASS].args + : NULL), ctxt->state[O_USERS].arg, + ctxt->state[O_HOTKEY].arg, 0, + ctxt->state[O_SOURCE].arg, ctxt->extcmd->cmd->name[0] == 's'); src = args[argc - 1]; @@ -350,8 +358,8 @@ return grub_errno; r = grub_normal_add_menu_entry (argc - 1, (const char **) args, - ctxt->state[0].args, ctxt->state[1].arg, - ctxt->state[2].arg, prefix, src + 1, + ctxt->state[O_CLASS].args, ctxt->state[O_USERS].arg, + ctxt->state[O_HOTKEY].arg, prefix, src + 1, ctxt->extcmd->cmd->name[0] == 's'); src[len - 1] = ch; --------------060407020409080309090504--