From 2bf63fcba72c4f4bc54a4caf53d7923c1f9f174f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 10 Sep 2022 15:13:28 -0500 Subject: Modernize integer handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s now safe to assume C99 sprintf %jd, etc. * am/system.m4 (PU_SYSTEM): Do not require gl_INTTOSTR. * gnulib.modules, paxlib.modules: Remove inttostr. Add strtoimax, strtoumax. * lib/system.h (UINTMAX_STRSIZE_BOUND): Remove. * paxlib/error.c (chown_error_details, read_error_details) (read_warn_details, read_fatal_details, seek_error_details) (seek_warn_details, write_error_details): * paxlib/rtape.c (rmt_read, rmt_write, rmt_lseek, rmt_ioctl): * rmt/rmt.c (rmt_reply): * tests/genfile.c (verify_file, print_stat): Use C99 printf formats instead of doing it by hand. * paxlib/paxlib.h, rmt/rmt.c, tests/genfile.c: Do not include inttostr.h. * paxlib/paxlib.h (STRINGIFY_BIGINT): Remove. * tests/argcv.c (xtonum): Use strtol for signed int, not strtoul. * tests/genfile.c (checkpoint, verify_file, parse_opt) (exec_checkpoint, process_checkpoint, exec_command): Prefer uintmax_t to size_t for counters unrelated to object size. (PRINT_INT): New macro. (print_stat): Prefer uintmax_t to unsigned for modes. --- rmt/rmt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'rmt') diff --git a/rmt/rmt.c b/rmt/rmt.c index 658a243..34caf97 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -111,8 +110,7 @@ rmt_write (const char *fmt, ...) static void rmt_reply (uintmax_t code) { - char buf[UINTMAX_STRSIZE_BOUND]; - rmt_write ("A%s\n", umaxtostr (code, buf)); + rmt_write ("A%ju\n", code); } static void @@ -247,7 +245,7 @@ decode_open_flag (const char *mstr, int *pmode) while (mstr) { int v; - + mstr = skip_ws (mstr); if (*mstr == 0) break; @@ -260,7 +258,7 @@ decode_open_flag (const char *mstr, int *pmode) } mode |= v; - + if (*p && c_isblank (*p)) p = skip_ws (p); if (*p == 0) @@ -310,7 +308,7 @@ decode_open_flag (const char *mstr, int *pmode) In addition, a compined form is also allowed, i.e. a decimal mode followed by its symbolic representation. In this case the symbolic representation is given preference. - + Reply ----- A0\n on success, E0\n\n on error. -- cgit v1.2.1