[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 11/30: [grops]: Migrate from `strtol()` to `strtoul()`.
From: |
G. Branden Robinson |
Subject: |
[groff] 11/30: [grops]: Migrate from `strtol()` to `strtoul()`. |
Date: |
Sat, 12 Oct 2024 12:07:52 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 051d6f0946f6f2f021ae0a8e34e4b5ae32dd7f3d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Oct 11 10:55:44 2024 -0500
[grops]: Migrate from `strtol()` to `strtoul()`.
* src/devices/grops/psrm.cpp (read_uint_arg): Thirty years ago (see
"ChangeLog.old"), James Clark converted some code in grolj4(1) from
strtoul(3) to strtol(3), possibly because the function was not
widespread or standardized. Presumably that lesson was applied here
as well. It's standard now, in ISO C99, for which we require compiler
support. Migrate text-to-integer conversion and discard diagnosis of
negative value.
---
ChangeLog | 10 ++++++++++
src/devices/grops/psrm.cpp | 7 +------
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bba7e9212..075b7b895 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-10-11 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/devices/grops/psrm.cpp (read_uint_arg): Thirty years ago
+ {see "ChangeLog.old"}, James Clark converted some code in
+ grolj4(1) from strtoul(3) to strtol(3), possibly because the
+ function was not widespread or standardized. Presumably that
+ lesson was applied here as well. It's standard now, in ISO C99,
+ for which we require compiler support. Migrate text-to-integer
+ conversion and discard diagnosis of negative value.
+
2024-10-11 Deri James <deri@chuzzlewit.myzen.co.uk>
Don't use inbuilt pdf parser on user supplied data.
diff --git a/src/devices/grops/psrm.cpp b/src/devices/grops/psrm.cpp
index 1948a0807..eb260eab6 100644
--- a/src/devices/grops/psrm.cpp
+++ b/src/devices/grops/psrm.cpp
@@ -88,16 +88,11 @@ static int read_uint_arg(const char **pp, unsigned *res)
return 0;
}
const char *start = *pp;
- // XXX use strtoul
- long n = strtol(start, (char **)pp, 10);
+ unsigned long n = strtoul(start, (char **)pp, 10);
if (*pp == start) {
error("not an integer");
return 0;
}
- if (n < 0) {
- error("argument must not be negative");
- return 0;
- }
*res = unsigned(n);
return 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 11/30: [grops]: Migrate from `strtol()` to `strtoul()`.,
G. Branden Robinson <=