xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 90323e90269b90fea821132e169313b437664b0c

Extend range of numbers Ctrl-A/Ctrl-X deals with
From [-2**31; 2**31) to [-2**63; 2**63). Both are approximate, can go
up and down depending on implementation.

Thanks to CaptainFantastic.
Author: xaizek
Author date (UTC): 2025-05-01 21:44
Committer name: xaizek
Committer date (UTC): 2025-05-02 07:58
Parent(s): 32674117a8f1efc6b355cfaacc739a7fb043868d
Signing key: 99DC5E4DB05F6BE2
Tree: 74836ee9a6bfe139480d83460cb451865b91914c
File Lines added Lines deleted
BUGS 2 0
ChangeLog 3 0
src/fops_rename.c 3 3
tests/misc/rename.c 13 0
File BUGS changed (mode: 100644) (index d9d3da793..dfe07fc4c)
22 22 'syscalls' is on, this is some subtle issue, because the code looks fine. 'syscalls' is on, this is some subtle issue, because the code looks fine.
23 23 * Commands starting with a dash don't work in fish shell and maybe some other * Commands starting with a dash don't work in fish shell and maybe some other
24 24 non-POSIX shells which have `-c` option accept a value. non-POSIX shells which have `-c` option accept a value.
25 * Incrementing/decrementing file names doesn't work as expected for numbers
26 outside [-2**63; -2**63) range.
File ChangeLog changed (mode: 100644) (index 852dae55e..58ef90c2f)
16 16 Updated .desktop-file to add localizations and be more up-to-date with Updated .desktop-file to add localizations and be more up-to-date with
17 17 modern recommendations. Patch by Matěj Cepl (a.k.a. mcepl). modern recommendations. Patch by Matěj Cepl (a.k.a. mcepl).
18 18
19 Extended range of numbers Ctrl-A/Ctrl-X can deal with from [-2**31; 2**31)
20 to [-2**63; 2**63). Thanks to CaptainFantastic.
21
19 22 Fixed 'trashdir' with "%r" on BSD-like systems (those with getmntinfo() Fixed 'trashdir' with "%r" on BSD-like systems (those with getmntinfo()
20 23 instead of getmntent() API). The regression was apparently introduced in instead of getmntent() API). The regression was apparently introduced in
21 24 v0.9.1-beta. Thanks to sublimal. v0.9.1-beta. Thanks to sublimal.
File src/fops_rename.c changed (mode: 100644) (index 2ff68ab51..4c08e82e2)
... ... incdec_name(const char fname[], int k)
600 600 static char result[NAME_MAX + 1]; static char result[NAME_MAX + 1];
601 601 char format[16]; char format[16];
602 602 char *b, *e; char *b, *e;
603 int i, n;
603 int n;
604 604
605 605 b = strpbrk(fname, "0123456789"); b = strpbrk(fname, "0123456789");
606 606 if(b == NULL) if(b == NULL)
 
... ... incdec_name(const char fname[], int k)
620 620 --b; --b;
621 621 } }
622 622
623 i = strtol(b, &e, 10);
623 long long i = strtoll(b, &e, 10);
624 624
625 625 if(i + k < 0) if(i + k < 0)
626 626 { {
 
... ... incdec_name(const char fname[], int k)
628 628 } }
629 629
630 630 copy_str(result, b - fname + 1, fname); copy_str(result, b - fname + 1, fname);
631 snprintf(format, sizeof(format), "%%0%dd%%s", n + count_digits(i));
631 snprintf(format, sizeof(format), "%%0%dlld%%s", n + count_digits(i));
632 632 snprintf(result + (b - fname), sizeof(result) - (b - fname), format, i + k, snprintf(result + (b - fname), sizeof(result) - (b - fname), format, i + k,
633 633 e); e);
634 634
File tests/misc/rename.c changed (mode: 100644) (index e4d5260b7..109c89492)
... ... TEST(incdec_leaves_zeros)
190 190 assert_string_equal("a01.", incdec_name("a00.", 1)); assert_string_equal("a01.", incdec_name("a00.", 1));
191 191 } }
192 192
193 TEST(incdec_handles_large_numbers)
194 {
195 /* 2**31-1 / 2**31 / 2**31+1 */
196 assert_string_equal("2147483648", incdec_name("2147483647", 1));
197 assert_string_equal("2147483649", incdec_name("2147483648", 1));
198 assert_string_equal("2147483650", incdec_name("2147483649", 1));
199
200 /* 2**32-1 / 2**32 / 2**32+1 */
201 assert_string_equal("4294967296", incdec_name("4294967295", 1));
202 assert_string_equal("4294967297", incdec_name("4294967296", 1));
203 assert_string_equal("4294967298", incdec_name("4294967297", 1));
204 }
205
193 206 TEST(single_file_rename) TEST(single_file_rename)
194 207 { {
195 208 char *error = NULL; char *error = NULL;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master