* [PR PATCH] Minor fix for `print_human` to have units also below `1M`
@ 2025-07-06 10:05 ferriff
2025-07-06 13:22 ` leahneukirchen
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: ferriff @ 2025-07-06 10:05 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 392 bytes --]
There is a new pull request by ferriff against master on the mblaze repository
https://github.com/ferriff/mblaze print-human
https://github.com/leahneukirchen/mblaze/pull/271
Minor fix for `print_human` to have units also below `1M`
As above `1M` the unit is specified, a `k` should be added below `1M`.
A patch file from https://github.com/leahneukirchen/mblaze/pull/271.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-print-human-271.patch --]
[-- Type: text/x-diff, Size: 661 bytes --]
From 6ab4b276753e23386d460705551f493905c7b5f2 Mon Sep 17 00:00:00 2001
From: Federico Ferri <federico.ferri@cern.ch>
Date: Sun, 6 Jul 2025 11:54:37 +0200
Subject: [PATCH] fix(print_human): add unit k below 1M
---
mscan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mscan.c b/mscan.c
index fd5e4ec..6971a59 100644
--- a/mscan.c
+++ b/mscan.c
@@ -294,9 +294,9 @@ print_human(intmax_t i, int w)
}
if (d < 1.0)
- return printf("%*.2f", w, d);
+ return printf("%*.2fk", w, d);
else if (!*u)
- return printf("%*.0f", w, d);
+ return printf("%*.0fk", w, d);
else if (d < 10.0)
return printf("%*.1f%s", w-1, d, u);
else
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Minor fix for `print_human` to have units also below `1M`
2025-07-06 10:05 [PR PATCH] Minor fix for `print_human` to have units also below `1M` ferriff
@ 2025-07-06 13:22 ` leahneukirchen
2025-07-06 14:06 ` ferriff
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2025-07-06 13:22 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 176 bytes --]
New comment by leahneukirchen on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/271#issuecomment-3041505691
Comment:
This seems better: https://l2.re/Suzkdm
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Minor fix for `print_human` to have units also below `1M`
2025-07-06 10:05 [PR PATCH] Minor fix for `print_human` to have units also below `1M` ferriff
2025-07-06 13:22 ` leahneukirchen
@ 2025-07-06 14:06 ` ferriff
2025-07-06 14:16 ` ferriff
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ferriff @ 2025-07-06 14:06 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 214 bytes --]
New comment by ferriff on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/271#issuecomment-3041716129
Comment:
Yes, I did not want to touch that part as well. Can you please use a lowercase `k`?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Minor fix for `print_human` to have units also below `1M`
2025-07-06 10:05 [PR PATCH] Minor fix for `print_human` to have units also below `1M` ferriff
2025-07-06 13:22 ` leahneukirchen
2025-07-06 14:06 ` ferriff
@ 2025-07-06 14:16 ` ferriff
2025-07-06 16:28 ` leahneukirchen
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ferriff @ 2025-07-06 14:16 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 243 bytes --]
New comment by ferriff on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/271#issuecomment-3041716129
Comment:
Yes, I did not want to touch that part as well. Can you please use a lowercase `k`?
edit: OK for `K` as well :)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Minor fix for `print_human` to have units also below `1M`
2025-07-06 10:05 [PR PATCH] Minor fix for `print_human` to have units also below `1M` ferriff
` (2 preceding siblings ...)
2025-07-06 14:16 ` ferriff
@ 2025-07-06 16:28 ` leahneukirchen
2025-07-06 16:41 ` ferriff
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2025-07-06 16:28 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 217 bytes --]
New comment by leahneukirchen on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/271#issuecomment-3042178253
Comment:
ls, du and mutt use a capital K, however. (And it also doesn't stand for
1000.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Minor fix for `print_human` to have units also below `1M`
2025-07-06 10:05 [PR PATCH] Minor fix for `print_human` to have units also below `1M` ferriff
` (3 preceding siblings ...)
2025-07-06 16:28 ` leahneukirchen
@ 2025-07-06 16:41 ` ferriff
2025-07-07 9:51 ` [PR PATCH] [Updated] " ferriff
2025-07-07 10:31 ` [PR PATCH] [Closed]: " leahneukirchen
6 siblings, 0 replies; 8+ messages in thread
From: ferriff @ 2025-07-06 16:41 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 154 bytes --]
New comment by ferriff on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/271#issuecomment-3042189029
Comment:
Yes, that's why my edit.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR PATCH] [Updated] Minor fix for `print_human` to have units also below `1M`
2025-07-06 10:05 [PR PATCH] Minor fix for `print_human` to have units also below `1M` ferriff
` (4 preceding siblings ...)
2025-07-06 16:41 ` ferriff
@ 2025-07-07 9:51 ` ferriff
2025-07-07 10:31 ` [PR PATCH] [Closed]: " leahneukirchen
6 siblings, 0 replies; 8+ messages in thread
From: ferriff @ 2025-07-07 9:51 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 397 bytes --]
There is an updated pull request by ferriff against master on the mblaze repository
https://github.com/ferriff/mblaze print-human
https://github.com/leahneukirchen/mblaze/pull/271
Minor fix for `print_human` to have units also below `1M`
As above `1M` the unit is specified, a `k` should be added below `1M`.
A patch file from https://github.com/leahneukirchen/mblaze/pull/271.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-print-human-271.patch --]
[-- Type: text/x-diff, Size: 1541 bytes --]
From 6ab4b276753e23386d460705551f493905c7b5f2 Mon Sep 17 00:00:00 2001
From: Federico Ferri <federico.ferri@cern.ch>
Date: Sun, 6 Jul 2025 11:54:37 +0200
Subject: [PATCH 1/2] fix(print_human): add unit k below 1M
---
mscan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mscan.c b/mscan.c
index fd5e4ec..6971a59 100644
--- a/mscan.c
+++ b/mscan.c
@@ -294,9 +294,9 @@ print_human(intmax_t i, int w)
}
if (d < 1.0)
- return printf("%*.2f", w, d);
+ return printf("%*.2fk", w, d);
else if (!*u)
- return printf("%*.0f", w, d);
+ return printf("%*.0fk", w, d);
else if (d < 10.0)
return printf("%*.1f%s", w-1, d, u);
else
From b4ccb6d2203caff84f925c2bf22bf2320616fea9 Mon Sep 17 00:00:00 2001
From: Federico Ferri <federico.ferri@cern.ch>
Date: Mon, 7 Jul 2025 11:50:56 +0200
Subject: [PATCH 2/2] fix(print_human): change as per github discussion #271
---
mscan.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/mscan.c b/mscan.c
index 6971a59..b5ed01e 100644
--- a/mscan.c
+++ b/mscan.c
@@ -287,17 +287,13 @@ static ssize_t
print_human(intmax_t i, int w)
{
double d = i / 1024.0;
- const char *u = "\0\0M\0G\0T\0P\0E\0Z\0Y\0";
+ const char *u = "K\0M\0G\0T\0P\0E\0Z\0Y\0";
while (d >= 1024) {
u += 2;
d /= 1024.0;
}
- if (d < 1.0)
- return printf("%*.2fk", w, d);
- else if (!*u)
- return printf("%*.0fk", w, d);
- else if (d < 10.0)
+ if (d > 0.0 && d < 10.0)
return printf("%*.1f%s", w-1, d, u);
else
return printf("%*.0f%s", w-1, d, u);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR PATCH] [Closed]: Minor fix for `print_human` to have units also below `1M`
2025-07-06 10:05 [PR PATCH] Minor fix for `print_human` to have units also below `1M` ferriff
` (5 preceding siblings ...)
2025-07-07 9:51 ` [PR PATCH] [Updated] " ferriff
@ 2025-07-07 10:31 ` leahneukirchen
6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2025-07-07 10:31 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 249 bytes --]
There's a closed pull request on the mblaze repository
Minor fix for `print_human` to have units also below `1M`
https://github.com/leahneukirchen/mblaze/pull/271
Description:
As above `1M` the unit is specified, a `k` should be added below `1M`.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-07-07 10:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-06 10:05 [PR PATCH] Minor fix for `print_human` to have units also below `1M` ferriff
2025-07-06 13:22 ` leahneukirchen
2025-07-06 14:06 ` ferriff
2025-07-06 14:16 ` ferriff
2025-07-06 16:28 ` leahneukirchen
2025-07-06 16:41 ` ferriff
2025-07-07 9:51 ` [PR PATCH] [Updated] " ferriff
2025-07-07 10:31 ` [PR PATCH] [Closed]: " leahneukirchen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).