commit 96d38c410c7242de02a20243892e9d7fc8038f9f
parent bd958637f3f30c59c36a2462cad857fb1e8baebb
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Wed, 6 Jan 2021 16:36:44 -0800
Swap ranges with a bigger low end in frange()
I can't see it being an issue to not report such errors and it
shortens the function.
Also improve error message and don't print errno when there is an
unbalenced range.
Diffstat:
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/command.c b/command.c
@@ -212,7 +212,7 @@ frange(int argc, char **argv, int ino, char **item)
if (warg(3, -1, argc, argv))
return FAIL;
if (argc % 2 != 1) {
- warn(errno, "%s: Invalid ranges", *argv);
+ warn(0, "%s: Unbalenced range.", *argv);
return FAIL;
}
@@ -223,11 +223,9 @@ frange(int argc, char **argv, int ino, char **item)
return FAIL;
}
if (range[0] > range[1]) {
- warn(errno, "%s: %d greater than %d",
- *argv, range[0], range[1]);
- return FAIL;
- }
- if (ino < range[0] || ino > range[1])
+ if (ino < range[1] || ino > range[0])
+ return NEXT;
+ } else if (ino < range[0] || ino > range[1])
return NEXT;
}