Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iNGFs-0006FJ-05 for mharc-grub-devel@gnu.org; Wed, 23 Oct 2019 09:00:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41010) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNGFo-0006DF-RJ for grub-devel@gnu.org; Wed, 23 Oct 2019 09:00:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNGFn-0004jX-I7 for grub-devel@gnu.org; Wed, 23 Oct 2019 09:00:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3163) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNGFn-0004io-9y for grub-devel@gnu.org; Wed, 23 Oct 2019 09:00:43 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (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 2850E368E2 for ; Wed, 23 Oct 2019 13:00:42 +0000 (UTC) Received: by mail-wm1-f72.google.com with SMTP id k184so8807068wmk.1 for ; Wed, 23 Oct 2019 06:00:42 -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=z5wRyUHmTc6MlnXlU+EitzvfbWS8pzGhoKUdAmZEHDQ=; b=Za77EUYOGzB9DeDjul/JXUHVI7hgzaDNhtQB4vr0Nj+hhs7OTYL6JUrFQi6sKdi/nT /O9Ktn/jLIp/g9+1p/RlpILOhsGRvpk4fNLNGXuwzkkYjbRODGLq7ybTWJq/yH9Lb0jM C17We8oSsJz8UQWCIbS/EyfRRdA/gD1gg6uIbMfuqff5XFKfpTqWIViEgCu8GZsuK6cL S7Y+wsivTeFaqW+76J1H0pzCC91RWsYMjzq01TfYJO28M11YtUvGSbF5SsrZX6PAUAx9 EYn5S+lR+xjlIIbDfziNBbb3idx7c019cnVwx/x9by8qCcyVvv48sDrgzWq14nj/yLWz IQrg== X-Gm-Message-State: APjAAAX08ghHcY4lvjpXrZR0UKitNNCQ7sXgq5/rs7ZeBgaAs5gcaaP6 2BcK4KOr/3gvG4+TS9+P2dXXJVHtgfz6Lr2kMnRvPRbDYwI2Eoat/9wnyIQ/zOWBDUtohZ/hsiK dRPThByfxJsE= X-Received: by 2002:adf:a547:: with SMTP id j7mr8224559wrb.154.1571835640395; Wed, 23 Oct 2019 06:00:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoFnCgApO62RMGXFKTDwY3gWwztfhL5z5ZJzFppeqyrmO1LNth7pwmIhCvWIuP3h9D7Vm9bg== X-Received: by 2002:adf:a547:: with SMTP id j7mr8224543wrb.154.1571835640143; Wed, 23 Oct 2019 06:00:40 -0700 (PDT) Received: from minerva.redhat.com ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id t123sm27423301wma.40.2019.10.23.06.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 06:00:39 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Vladimir Serbinenko , Daniel Kiper , Paulo Flabiano Smorigo , Javier Martinez Canillas Subject: [PATCH v4 1/5] Add %X option to printf functions Date: Wed, 23 Oct 2019 15:00:29 +0200 Message-Id: <20191023130034.12834-2-javierm@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023130034.12834-1-javierm@redhat.com> References: <20191023130034.12834-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: Wed, 23 Oct 2019 13:00:46 -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 Reviewed-by: Daniel Kiper --- Changes in v4: None Changes in v3: None Changes in v2: - Put patch that adds the %X format specifier first in the series. 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