[FarGroup/FarManager] master: Allow decimal size suffixes in filters and search (6eaedc32f)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Mar 23, 2026, 7:30:55 PM (4 days ago) Mar 23
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/6eaedc32f72d263bdd5b537111432096a36aa900

>---------------------------------------------------------------

commit 6eaedc32f72d263bdd5b537111432096a36aa900
Author: Alex Alabuzhev <alab...@gmail.com>
Date: Mon Mar 23 23:23:23 2026 +0000

Allow decimal size suffixes in filters and search


>---------------------------------------------------------------

6eaedc32f72d263bdd5b537111432096a36aa900
far/FarCze.hlf.m4 | 6 ++++
far/FarEng.hlf.m4 | 6 ++++
far/FarGer.hlf.m4 | 6 ++++
far/FarHun.hlf.m4 | 6 ++++
far/FarPol.hlf.m4 | 6 ++++
far/FarRus.hlf.m4 | 6 ++++
far/FarSky.hlf.m4 | 6 ++++
far/FarUkr.hlf.m4 | 6 ++++
far/changelog | 5 +++
far/strmix.cpp | 91 ++++++++++++++++++++++++++++++++++++-------------------
far/vbuild.m4 | 2 +-
11 files changed, 113 insertions(+), 33 deletions(-)

diff --git a/far/FarCze.hlf.m4 b/far/FarCze.hlf.m4
index fb90b0b51..3f7b142b1 100644
--- a/far/FarCze.hlf.m4
+++ b/far/FarCze.hlf.m4
@@ -1824,6 +1824,9 @@ is ignored even if the searched for sequence exists there.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
#Column types# - Allows to specify search results output format.
Column types are encoded with one or more characters delimited with commas.
The following column types are supported:
@@ -1995,6 +1998,9 @@ masks. If mask analysis is off, file name is ignored.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
Filter conditions are met if file size analysis is on, and it is inside the given range.
If nothing is specified (empty line) for one or both range boundaries then file size for that
boundary is not limited.
diff --git a/far/FarEng.hlf.m4 b/far/FarEng.hlf.m4
index 1c516ecdf..f09359b3a 100644
--- a/far/FarEng.hlf.m4
+++ b/far/FarEng.hlf.m4
@@ -1796,6 +1796,9 @@ is ignored even if the searched for sequence exists there.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
#Column types# - Allows to specify search results output format.
Column types are encoded with one or more characters delimited with commas.
The following column types are supported:
@@ -1968,6 +1971,9 @@ masks. If mask analysis is off, file name is ignored.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
Filter conditions are met if file size analysis is on, and it is inside the given range.
If nothing is specified (empty line) for one or both range boundaries then file size for that
boundary is not limited.
diff --git a/far/FarGer.hlf.m4 b/far/FarGer.hlf.m4
index 963e1934a..512266977 100644
--- a/far/FarGer.hlf.m4
+++ b/far/FarGer.hlf.m4
@@ -1852,6 +1852,9 @@ is ignored even if the searched for sequence exists there.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
#Column types# - Allows to specify search results output format.
Column types are encoded with one or more characters delimited with commas.
The following column types are supported:
@@ -2027,6 +2030,9 @@ masks. If mask analysis is off, file name is ignored.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
Filter conditions are met if file size analysis is on, and it is inside the given range.
If nothing is specified (empty line) for one or both range boundaries then file size for that
boundary is not limited.
diff --git a/far/FarHun.hlf.m4 b/far/FarHun.hlf.m4
index 7f0d47e13..cb0d9800e 100644
--- a/far/FarHun.hlf.m4
+++ b/far/FarHun.hlf.m4
@@ -1852,6 +1852,9 @@ tartományon túli része a szöveget, oda nem terjed ki a keresés.
- #P# - petabájt;
- #E# - exabájt.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
#Column types# - Allows to specify search results output format.
Column types are encoded with one or more characters delimited with commas.
The following column types are supported:
@@ -2023,6 +2026,9 @@ maszkok elemzése ki van kapcsolva, a fájl nevét a Far nem veszi figyelembe.
- #P# - petabájt;
- #E# - exabájt.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
A szűrőfeltételek akkor teljesülnek, ha a
fájlméretelemzés be van kapcsolva és a fájl mérete a tartományon belül esik.
Ahol valamelyik értéket nem korlátozzuk (üresen hagyott sorral), ott a fájl
diff --git a/far/FarPol.hlf.m4 b/far/FarPol.hlf.m4
index e609d744d..d7ea23d31 100644
--- a/far/FarPol.hlf.m4
+++ b/far/FarPol.hlf.m4
@@ -1793,6 +1793,9 @@ znajdować.
- #P# dla petabajtów;
- #E# dla eksabajtów.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
#Typy kolumn# - pozwala na sformatowanie wyników wyszukiwania.
Typy kolumn są kodowane jednym lub więcej znakami rozdzielanymi przecinkami.
Obsługiwane są następujące typy kolumn:
@@ -1966,6 +1969,9 @@ podane warunki. Jeżeli analiza jest wyłączona, nazwa pliku jest ignorowana.
- #P# dla petabajtów;
- #E# dla eksabajtów.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
Warunki filtru zostaną spełnione, jeżeli analiza wielkości pliku jest włączona i znajduje się
w podanym zakresie. Jeżeli nic nie podano (pusta linia) w jednej lub obu granicach zakresu
to rozmiar pliku dla tej granicy nie jest ograniczony.
diff --git a/far/FarRus.hlf.m4 b/far/FarRus.hlf.m4
index 7f8a4bf63..eff3cc932 100644
--- a/far/FarRus.hlf.m4
+++ b/far/FarRus.hlf.m4
@@ -1842,6 +1842,9 @@ $ #Дополнительные параметры поиска#
- #P# для петабайтов;
- #E# для эксабайтов.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
#Типы колонок# - позволяет задавать формат вывода результатов поиска.
Типы колонок кодируются с помощью одной или нескольких букв, разделённых запятыми.
Допускаются следующие типы колонок:
@@ -2011,6 +2014,9 @@ $ #Фильтр#
- #P# для петабайтов;
- #E# для эксабайтов.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
Файл попадает в условия фильтра, если включён анализ размера файла и он входит в введённый
диапазон. Если в качестве одной или обеих границ диапазона ничего не введено (пустая строка), тогда
размер по этому условию не ограничивается.
diff --git a/far/FarSky.hlf.m4 b/far/FarSky.hlf.m4
index 6cdef9f2d..75eb6ab53 100644
--- a/far/FarSky.hlf.m4
+++ b/far/FarSky.hlf.m4
@@ -1792,6 +1792,9 @@ is ignored even if the searched for sequence exists there.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
#Column types# - Allows to specify search results output format.
Column types are encoded with one or more characters delimited with commas.
The following column types are supported:
@@ -1963,6 +1966,9 @@ masks. If mask analysis is off, file name is ignored.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
Filter conditions are met if file size analysis is on, and it is inside the given range.
If nothing is specified (empty line) for one or both range boundaries then file size for that
boundary is not limited.
diff --git a/far/FarUkr.hlf.m4 b/far/FarUkr.hlf.m4
index 3bd26c169..d1052dbea 100644
--- a/far/FarUkr.hlf.m4
+++ b/far/FarUkr.hlf.m4
@@ -1835,6 +1835,9 @@ is ignored even if the searched for sequence exists there.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
#Column types# - Allows to specify search results output format.
Column types are encoded with one or more characters delimited with commas.
The following column types are supported:
@@ -2007,6 +2010,9 @@ masks. If mask analysis is off, file name is ignored.
- #P# for petabytes;
- #E# for exabytes.

+ These units are binary rather than decimal, e.g. 1K is 1024 bytes, not 1000.
+ To specify decimal units, use lowercase letters, e.g. 1k.
+
Filter conditions are met if file size analysis is on, and it is inside the given range.
If nothing is specified (empty line) for one or both range boundaries then file size for that
boundary is not limited.
diff --git a/far/changelog b/far/changelog
index acfe48d6d..e7a7f1005 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,3 +1,8 @@
+--------------------------------------------------------------------------------
+drkns 2026-03-23 23:23:23+00:00 - build 6666
+
+1. Allow decimal size suffixes in filters and search.
+
--------------------------------------------------------------------------------
drkns 2026-03-23 22:34:47+00:00 - build 6665

diff --git a/far/strmix.cpp b/far/strmix.cpp
index 1a5405f00..7f269f57b 100644
--- a/far/strmix.cpp
+++ b/far/strmix.cpp
@@ -979,16 +979,29 @@ unsigned long long ConvertFileSizeString(string_view const FileSizeStr)

const auto n = from_string<unsigned long long>(FileSizeStr);

+ // We are aware that this mess exists:
// https://en.wikipedia.org/wiki/Binary_prefix
// https://en.wikipedia.org/wiki/SI_prefix
- switch (upper(FileSizeStr.back()))
- {
- case L'K': return n << 10; // Ki kibi 1024^1 - ~kilo ~10^3
- case L'M': return n << 20; // Mi mebi 1024^2 - ~mega ~10^6
- case L'G': return n << 30; // Gi gibi 1024^3 - ~giga ~10^9
- case L'T': return n << 40; // Ti tebi 1024^4 - ~tera ~10^12
- case L'P': return n << 50; // Pi pebi 1024^5 - ~peta ~10^15
- case L'E': return n << 60; // Ei exbi 1024^6 - ~exa ~10^18
+
+ // We use uppercase for binary prefixes and lowercase for decimal.
+ // It may be technically incorrect, but at least it's consistent.
+
+ switch (FileSizeStr.back())
+ {
+ case L'K': return n * binary::K; // Ki kibi 1024^1
+ case L'M': return n * binary::M; // Mi mebi 1024^2
+ case L'G': return n * binary::G; // Gi gibi 1024^3
+ case L'T': return n * binary::T; // Ti tebi 1024^4
+ case L'P': return n * binary::P; // Pi pebi 1024^5
+ case L'E': return n * binary::E; // Ei exbi 1024^6
+
+ case L'k': return n * decimal::K; // k kilo 10^3
+ case L'm': return n * decimal::M; // M mega 10^6
+ case L'g': return n * decimal::G; // G giga 10^9
+ case L't': return n * decimal::T; // T tera 10^12
+ case L'p': return n * decimal::P; // P peta 10^15
+ case L'e': return n * decimal::E; // E exa 10^18
+
default: return n;
}
}
@@ -1501,14 +1514,20 @@ TEST_CASE("QuoteSpaceOnly")

TEST_CASE("ConvertFileSizeString")
{
- constexpr auto
- B = 0_bit,
- K = 10_bit,
- M = 20_bit,
- G = 30_bit,
- T = 40_bit,
- P = 50_bit,
- E = 60_bit;
+ constexpr uint64_t
+ Ki = binary::K,
+ Mi = binary::M,
+ Gi = binary::G,
+ Ti = binary::T,
+ Pi = binary::P,
+ Ei = binary::E,
+
+ K = decimal::K,
+ M = decimal::M,
+ G = decimal::G,
+ T = decimal::T,
+ P = decimal::P,
+ E = decimal::E;

static const struct
{
@@ -1517,22 +1536,30 @@ TEST_CASE("ConvertFileSizeString")
}
Tests[]
{
- { {}, 0 },
- { L"Beep"sv, 0 },
- { L"0"sv, 0 * B },
- { L"1"sv, 1 * B },
- { L"32K"sv, 32 * K },
- { L"32k"sv, 32 * K },
- { L"a32K"sv, 0 },
- { L"32K+"sv, 0 },
- { L"640K"sv, 640 * K },
- { L"1M"sv, 1 * M },
- { L"345M"sv, 345 * M },
- { L"2G"sv, 2 * G },
- { L"3T"sv, 3 * T },
- { L"42P"sv, 42 * P },
- { L"0E"sv, 0 * E },
- { L"18E"sv, 18 * E },
+ { {}, 0 },
+ { L"Beep"sv, 0 },
+ { L"a32K"sv, 0 },
+ { L"32K+"sv, 0 },
+ { L"0"sv, 0 },
+ { L"1"sv, 1 },
+ { L"32K"sv, 32 * Ki },
+ { L"32k"sv, 32 * K },
+ { L"640K"sv, 640 * Ki },
+ { L"640k"sv, 640 * K },
+ { L"1M"sv, 1 * Mi },
+ { L"1m"sv, 1 * M },
+ { L"345M"sv, 345 * Mi },
+ { L"345m"sv, 345 * M },
+ { L"2G"sv, 2 * Gi },
+ { L"2g"sv, 2 * G },
+ { L"3T"sv, 3 * Ti },
+ { L"3t"sv, 3 * T },
+ { L"42P"sv, 42 * Pi },
+ { L"42p"sv, 42 * P },
+ { L"1E"sv, 1 * Ei },
+ { L"1e"sv, 1 * E },
+ { L"18E"sv, 18 * Ei },
+ { L"18e"sv, 18 * E },
};

for (const auto& i: Tests)
diff --git a/far/vbuild.m4 b/far/vbuild.m4
index c5bb2ec1d..0d195f490 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6665
+6666


Reply all
Reply to author
Forward
0 new messages