From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iGWJf-0000hc-NQ for mharc-grub-devel@gnu.org; Fri, 04 Oct 2019 18:44:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48815) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGWJd-0000fa-0K for grub-devel@gnu.org; Fri, 04 Oct 2019 18:44:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGWJb-0004kQ-UR for grub-devel@gnu.org; Fri, 04 Oct 2019 18:44:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iGWJb-0004k2-Ms for grub-devel@gnu.org; Fri, 04 Oct 2019 18:44:47 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDDA47BDA5 for ; Fri, 4 Oct 2019 22:44:46 +0000 (UTC) Received: by mail-wr1-f71.google.com with SMTP id w10so3373695wrl.5 for ; Fri, 04 Oct 2019 15:44:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v24pI65m7rpM/8vx53fgVX6rtKcp/q+DuRDe0/8KnPY=; b=UJMtBos0VNpxhNERRziKPCXfPRM5J2OzLzw0h0pL+kTwIY2HqIG47zuWZ1xkuGwNJd KD0ID6RQWzq3xvJjD4eiD2MaUCG8KFsi33dzuva1za+qkWsN8fV/qikZrVBQ4lAs9DBz 4+vLTUWHm03mzvy+BsDetcIcrLnNbXjNBCgsBbmuWJcYyzatetJZWDYHNbzAJ54P9dOY m/RRIee7l3QP7JmAqI0A6Xlsi68h0h90ZXcWo/Rxaj7VMllc5vLowOhejyUv5vUQ0MT6 uD+sfngtexvQ1F6YhnBJpKUYsqM4BokbgfBBmB0BUUeZxaf6P1lWS1sv+hUDmIKu+k93 dl4Q== X-Gm-Message-State: APjAAAVw22T3Vrhm84SebPvzmnGbpxDe7iBG74u3vyVaF/vVTXGye0Jc rbmwhDtEbZBQXAvsljQkbpTAFfqXeXyvTkGMUJqk8PjWQijqmF9G1bJJZ6tbMgxqGTU59FrQBf2 myJSIh8DYbTo= X-Received: by 2002:adf:f3c9:: with SMTP id g9mr13733023wrp.19.1570229084883; Fri, 04 Oct 2019 15:44:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxT3deuROeIKwx63H37M5DPmeePssLIeWWyjbnLA3/Wg/Rpze1T4A4FPTZTx/mo0xLz93jKYQ== X-Received: by 2002:adf:f3c9:: with SMTP id g9mr13733012wrp.19.1570229084655; Fri, 04 Oct 2019 15:44:44 -0700 (PDT) Received: from minerva.home ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id a204sm13033256wmh.21.2019.10.04.15.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2019 15:44:44 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Vladimir Serbinenko , Daniel Kiper , Paulo Flabiano Smorigo , Javier Martinez Canillas Subject: [PATCH 2/3] Add %X option to printf functions Date: Sat, 5 Oct 2019 00:44:26 +0200 Message-Id: <20191004224427.22480-3-javierm@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191004224427.22480-1-javierm@redhat.com> References: <20191004224427.22480-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Oct 2019 22:44:50 -0000 From: Paulo Flabiano Smorigo The printf(3) function has support for the %X format specifier, to output an unsigned hexadecimal integer in uppercase. This can be achived in GRUB using the %x format specifier in grub_printf(= ) and calling grub_toupper(), but it is more convenient if there is support for %X in grub_printf(). Signed-off-by: Paulo Flabiano Smorigo Signed-off-by: Javier Martinez Canillas --- grub-core/kern/misc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 3b633d51f4c..76e7fb22872 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -588,7 +588,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub= _uint64_t *r) static inline char * grub_lltoa (char *str, int c, unsigned long long n) { - unsigned base =3D (c =3D=3D 'x') ? 16 : 10; + unsigned base =3D ((c =3D=3D 'x') || (c =3D=3D 'X')) ? 16 : 10; char *p; =20 if ((long long) n < 0 && c =3D=3D 'd') @@ -603,7 +603,7 @@ grub_lltoa (char *str, int c, unsigned long long n) do { unsigned d =3D (unsigned) (n & 0xf); - *p++ =3D (d > 9) ? d + 'a' - 10 : d + '0'; + *p++ =3D (d > 9) ? d + ((c =3D=3D 'x') ? 'a' : 'A') - 10 : d + '0'; } while (n >>=3D 4); else @@ -676,6 +676,7 @@ parse_printf_args (const char *fmt0, struct printf_ar= gs *args, { case 'p': case 'x': + case 'X': case 'u': case 'd': case 'c': @@ -762,6 +763,7 @@ parse_printf_args (const char *fmt0, struct printf_ar= gs *args, switch (c) { case 'x': + case 'X': case 'u': args->ptr[curn].type =3D UNSIGNED_INT + longfmt; break; @@ -900,6 +902,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, = const char *fmt0, c =3D 'x'; /* Fall through. */ case 'x': + case 'X': case 'u': case 'd': { --=20 2.21.0