All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hexdump: use 'll' format modifier instead of the non-standard 'q'.
@ 2014-10-29  8:07 Natanael Copa
  2014-10-29  9:04 ` [PATCH v2] " Natanael Copa
  0 siblings, 1 reply; 3+ messages in thread
From: Natanael Copa @ 2014-10-29  8:07 UTC (permalink / raw)
  To: util-linux; +Cc: Natanael Copa

The printf(3) man page says about 'q':
("quad". 4.4BSD and Linux libc5 only. Don't use.) This is a synonym for ll.

This fixes hexdump with musl libc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 text-utils/hexdump-parse.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/text-utils/hexdump-parse.c b/text-utils/hexdump-parse.c
index 8d14c5b..98e1972 100644
--- a/text-utils/hexdump-parse.c
+++ b/text-utils/hexdump-parse.c
@@ -226,7 +226,7 @@ void rewrite_rules(struct hexdump_fs *fs, struct hexdump *hex)
 	struct hexdump_fu *fu;
 	struct list_head *p, *q;
 	char *p1, *p2, *fmtp;
-	char savech, cs[3];
+	char savech, cs[4];
 	int nconv, prec = 0;
 
 	list_for_each (p, &fs->fulist) {
@@ -301,9 +301,10 @@ void rewrite_rules(struct hexdump_fs *fs, struct hexdump *hex)
 				goto isint;
 			} else if (first_letter(cs, "ouxX")) {
 				pr->flags = F_UINT;
-isint:				cs[2] = '\0';
-				cs[1] = cs[0];
-				cs[0] = 'q';
+isint:				cs[3] = '\0';
+				cs[2] = cs[0];
+				cs[1] = 'l'
+				cs[0] = 'l';
 				switch(fu->bcnt) {
 					case 0:
 						pr->bcnt = 4;
@@ -355,9 +356,10 @@ isint:				cs[2] = '\0';
 						pr->flags = F_ADDRESS;
 						++p2;
 						if (first_letter(p1 + 2, "dox")) {
-							cs[0] = 'q';
-							cs[1] = p1[2];
-							cs[2] = '\0';
+							cs[0] = 'l';
+							cs[1] = 'l';
+							cs[2] = p1[2];
+							cs[3] = '\0';
 						} else {
 							p1[3] = '\0';
 							badconv(p1);
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2] hexdump: use 'll' format modifier instead of the non-standard 'q'.
  2014-10-29  8:07 [PATCH] hexdump: use 'll' format modifier instead of the non-standard 'q' Natanael Copa
@ 2014-10-29  9:04 ` Natanael Copa
  2014-10-31  9:57   ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Natanael Copa @ 2014-10-29  9:04 UTC (permalink / raw)
  To: util-linux; +Cc: Natanael Copa

The printf(3) man page says about 'q':
("quad". 4.4BSD and Linux libc5 only. Don't use.) This is a synonym for ll.

This fixes hexdump with musl libc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---

Changes v1 -> v2:

> @@ -301,9 +301,10 @@ void rewrite_rules(struct hexdump_fs *fs, struct hexdump *hex)
>                               goto isint;
>                       } else if (first_letter(cs, "ouxX")) {
>                               pr->flags = F_UINT;
> -isint:                               cs[2] = '\0';
> -                             cs[1] = cs[0];
> -                             cs[0] = 'q';
> +isint:                               cs[3] = '\0';
> +                             cs[2] = cs[0];
> +                             cs[1] = 'l'
add missing ; above                       ^^^


I missed the ; when rebasing the patch. sorry.

This patch have been used in Alpine Linux since May 2014:
http://git.alpinelinux.org/cgit/aports/commit/main/util-linux?id=3c201cf3c1b78959444efa8cc2c49ecff7a6727c


 text-utils/hexdump-parse.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/text-utils/hexdump-parse.c b/text-utils/hexdump-parse.c
index 8d14c5b..9eb016d 100644
--- a/text-utils/hexdump-parse.c
+++ b/text-utils/hexdump-parse.c
@@ -226,7 +226,7 @@ void rewrite_rules(struct hexdump_fs *fs, struct hexdump *hex)
 	struct hexdump_fu *fu;
 	struct list_head *p, *q;
 	char *p1, *p2, *fmtp;
-	char savech, cs[3];
+	char savech, cs[4];
 	int nconv, prec = 0;
 
 	list_for_each (p, &fs->fulist) {
@@ -301,9 +301,10 @@ void rewrite_rules(struct hexdump_fs *fs, struct hexdump *hex)
 				goto isint;
 			} else if (first_letter(cs, "ouxX")) {
 				pr->flags = F_UINT;
-isint:				cs[2] = '\0';
-				cs[1] = cs[0];
-				cs[0] = 'q';
+isint:				cs[3] = '\0';
+				cs[2] = cs[0];
+				cs[1] = 'l';
+				cs[0] = 'l';
 				switch(fu->bcnt) {
 					case 0:
 						pr->bcnt = 4;
@@ -355,9 +356,10 @@ isint:				cs[2] = '\0';
 						pr->flags = F_ADDRESS;
 						++p2;
 						if (first_letter(p1 + 2, "dox")) {
-							cs[0] = 'q';
-							cs[1] = p1[2];
-							cs[2] = '\0';
+							cs[0] = 'l';
+							cs[1] = 'l';
+							cs[2] = p1[2];
+							cs[3] = '\0';
 						} else {
 							p1[3] = '\0';
 							badconv(p1);
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hexdump: use 'll' format modifier instead of the non-standard 'q'.
  2014-10-29  9:04 ` [PATCH v2] " Natanael Copa
@ 2014-10-31  9:57   ` Karel Zak
  0 siblings, 0 replies; 3+ messages in thread
From: Karel Zak @ 2014-10-31  9:57 UTC (permalink / raw)
  To: Natanael Copa; +Cc: util-linux

On Wed, Oct 29, 2014 at 09:04:27AM +0000, Natanael Copa wrote:
>  text-utils/hexdump-parse.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-31  9:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29  8:07 [PATCH] hexdump: use 'll' format modifier instead of the non-standard 'q' Natanael Copa
2014-10-29  9:04 ` [PATCH v2] " Natanael Copa
2014-10-31  9:57   ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.