Hi Branden, Here's a patch set that includes the patches that Dave reminded, the ceil_prime() one, and the fixes for the problems I noticed in your recent commit.
I've rebased everything on top of git HEAD. Below is a range-diff.
Have a lovely day!
Alex
Alejandro Colomar (9):
[libgroff]: Remove redundant checks.
[libgroff]: Remove dead code
src/: Remove redundant checks after strtol(3).
[grolbp]: Remove bogus (and redundant) check
src/: ceil_prime(): Add function to get the lowest prime not smaller
than n
[indxbib]: Don't else after [[noreturn]]
[indxbib]: Clear errno before calling strtol(3)
[indxbib]: Remove dead code
[indxbib]: Collapse related tests
src/devices/grodvi/dvi.cpp | 4 ++--
src/devices/grolbp/lbp.cpp | 4 ++--
src/devices/grolj4/lj4.cpp | 6 +++---
src/devices/grops/ps.cpp | 4 ++--
src/devices/grops/psrm.cpp | 2 +-
src/include/lib.h | 2 +-
src/libs/libbib/index.cpp | 4 +---
src/libs/libgroff/curtime.cpp | 3 +--
src/libs/libgroff/font.cpp | 2 +-
src/libs/libgroff/prime.cpp | 18 +++++++++++++++++-
src/preproc/eqn/lex.cpp | 2 +-
src/preproc/pic/tex.cpp | 2 +-
src/preproc/refer/command.cpp | 3 +--
src/preproc/refer/ref.cpp | 2 +-
src/preproc/refer/refer.cpp | 6 +++---
src/utils/indxbib/indxbib.cpp | 27 ++++++++-------------------
src/utils/lkbib/lkbib.cpp | 2 +-
src/utils/lookbib/lookbib.cpp | 2 +-
src/utils/tfmtodit/tfmtodit.cpp | 5 +----
19 files changed, 49 insertions(+), 51 deletions(-)
Range-diff against v2:
1: bd017c14b ! 1: 1ade0b95a [libgroff]: Remove redundant checks.
@@ Commit message
ERANGE can only happen if strtol(3) returns either LONG_MIN or
LONG_MAX.
+ Link: <https://savannah.gnu.org/bugs/?65451>
+ Cc: "G. Branden Robinson" <[email protected]>
+ Cc: Dave Kemper <[email protected]>
+ Cc: "James K. Lowden" <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
## src/libs/libgroff/curtime.cpp ##
2: 6cbaf842e ! 2: b00a34743 [libgroff]: Remove dead code
@@ Commit message
strtol(3) can only report ERANGE, if the base is valid (and it is).
+ Link: <https://savannah.gnu.org/bugs/?65451>
+ Cc: "G. Branden Robinson" <[email protected]>
+ Cc: Dave Kemper <[email protected]>
+ Cc: "James K. Lowden" <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
## src/libs/libgroff/curtime.cpp ##
3: bb5c66245 ! 3: b16590405 src/: Remove redundant checks after strtol(3).
@@ Commit message
`str == end` can only happen if strtol(3) returns 0.
+ Link: <https://savannah.gnu.org/bugs/?65451>
+ Cc: "G. Branden Robinson" <[email protected]>
+ Cc: Dave Kemper <[email protected]>
+ Cc: "James K. Lowden" <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
## src/devices/grodvi/dvi.cpp ##
@@ src/preproc/refer/refer.cpp: int main(int argc, char **argv)
## src/utils/indxbib/indxbib.cpp ##
@@ src/utils/indxbib/indxbib.cpp: static void check_integer_arg(char opt,
const char *arg, int min, int *res)
- {
- char *ptr;
- long n = strtol(arg, &ptr, 10);
-- if (n == 0 && ptr == arg)
-+ if (ptr == arg)
- error("argument to -%1 not an integer", opt);
+ if (ERANGE == errno)
+ fatal("argument to -%1 must be between %2 and %3", arg, min,
+ INT_MAX);
+- else if (n == 0 && ptr == arg)
++ else if (ptr == arg)
+ fatal("argument to -%1 not an integer", opt);
else if (n < min)
- error("argument to -%1 must not be less than %2", opt, min);
+ fatal("argument to -%1 must not be less than %2", opt, min);
## src/utils/lkbib/lkbib.cpp ##
@@ src/utils/lkbib/lkbib.cpp: int main(int argc, char **argv)
4: 2f913d604 ! 4: be068e3e4 [grolbp]: Remove bogus (and redundant) check
@@ Commit message
`str == end` can only happen if strtol(3) returns 0.
+ Closes: <https://savannah.gnu.org/bugs/?65451>
+ Cc: "G. Branden Robinson" <[email protected]>
+ Cc: Dave Kemper <[email protected]>
+ Cc: "James K. Lowden" <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
## src/devices/grolbp/lbp.cpp ##
5: 9432f7f87 ! 5: 3157b9dd4 src/: ceil_prime(): Add function to get the
lowest prime not smaller than n
@@ Commit message
While at it, fix the logic, which was incorrect in the open-coded call
sites, since for an input of 1, it produced 3, but the first prime is
2.
+ A recent commit started rejecting 1 earlier, so this bug was now
+ impossible to trigger, but remained there.
Also, since this is a library function, let's behave well for an input
- of 0, and return also the first prime, 2.
+ of 0, which is mathematically fine, and return also the first prime, 2.
+ Link: <https://savannah.gnu.org/bugs/?65452>
+ Link: <https://lists.gnu.org/archive/html/groff/2024-03/msg00065.html>
Cc: "G. Branden Robinson" <[email protected]>
+ Cc: Dave Kemper <[email protected]>
+ Cc: "James K. Lowden" <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
## src/include/lib.h ##
@@ src/utils/indxbib/indxbib.cpp
@@ src/utils/indxbib/indxbib.cpp: int main(int argc, char **argv)
{
int requested_hash_table_size;
- check_integer_arg('h', optarg, 1, &requested_hash_table_size);
+ check_integer_arg('h', optarg, 2, &requested_hash_table_size);
- hash_table_size = requested_hash_table_size;
- if ((hash_table_size > 2) && (hash_table_size % 2) == 0)
- hash_table_size++;
-: --------- > 6: f51a4b177 [indxbib]: Don't else after [[noreturn]]
-: --------- > 7: 0212f9790 [indxbib]: Clear errno before calling strtol(3)
-: --------- > 8: 2bc3edd6a [indxbib]: Remove dead code
-: --------- > 9: 06d68f407 [indxbib]: Collapse related tests
--
2.43.0
signature.asc
Description: PGP signature
