Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iMpq7-0006kO-U3 for mharc-grub-devel@gnu.org; Tue, 22 Oct 2019 04:48:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48842) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMpq5-0006iz-0J for grub-devel@gnu.org; Tue, 22 Oct 2019 04:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMpq3-0004rD-WA for grub-devel@gnu.org; Tue, 22 Oct 2019 04:48:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36294) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iMpq3-0004r2-ON for grub-devel@gnu.org; Tue, 22 Oct 2019 04:48:23 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.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 D886F368B1 for ; Tue, 22 Oct 2019 08:48:22 +0000 (UTC) Received: by mail-wr1-f72.google.com with SMTP id r8so1540002wrx.8 for ; Tue, 22 Oct 2019 01:48:22 -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=mI/CGeGj3TR7Atf+28gcoqTUp87QGlK9G5qRfTJdBEI=; b=ZaUXg46MHtcfXf609L+p/RpoHmeyscrB9c8uv8ivse2BWSxYm11c1Z0Dg1Md54m7Qk JmsFzzqgk0cyu6R8HUr0QhDpJN8KjjigDfGWU+5J05kXakm8ydVI6jSrX4DlTCzlRwNS bTvQ8JIcMa5K6scDSrNynsfmHGmfzJGgHUO+u1lzvfnwwtPfLRTifSIStn3Nz2F1tedP iJljTStbdnUXx/RUYhO4ggJLKYDw5/xSNEkMY/h+LEI4sf8b5v9/WrgvFvuNd+YZ98u8 yU/vfdRWLJg6BFJ1hAeY91EziD3kP0bo41w16nSX2BD5CZp6ww/dSyMn1yMcyhQagaEL EgnQ== X-Gm-Message-State: APjAAAWNaQn1TF0H5iTDQkTkjGAhEFCpR0sLGpNRT7ANEk6ctIc3Kyun cZDX521W5UZYztpOToowvpvsJNb1qTRHdUFX/WYGSFqZm2Kv3prGZZuusVvrU0SsAhzRF+OLQt0 MQeCmpRd3iIE= X-Received: by 2002:a5d:63ca:: with SMTP id c10mr2526343wrw.79.1571734101096; Tue, 22 Oct 2019 01:48:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWly2rhOoeWj8QRIMgGKXm3y6QcukXPd4ywo/uN8izyvaSaDgHRCR+41LzlqWrKPkaXtoc9Q== X-Received: by 2002:a5d:63ca:: with SMTP id c10mr2526323wrw.79.1571734100827; Tue, 22 Oct 2019 01:48:20 -0700 (PDT) Received: from minerva.redhat.com ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id u1sm28276092wru.90.2019.10.22.01.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:48:19 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Vladimir Serbinenko , Daniel Kiper , Paulo Flabiano Smorigo , Javier Martinez Canillas Subject: [PATCH v3 1/5] Add %X option to printf functions Date: Tue, 22 Oct 2019 10:48:10 +0200 Message-Id: <20191022084814.8071-2-javierm@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191022084814.8071-1-javierm@redhat.com> References: <20191022084814.8071-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: Tue, 22 Oct 2019 08:48:26 -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 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