From 092f8178c00fb9c3b2aaf21c5380a529d503afb8 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 21 Sep 2023 19:09:15 -0700 Subject: [PATCH] maint: use mbszero * bootstrap.conf (gnulib_modules): Add mbszero. * src/df.c (replace_invalid_chars): * src/ls.c (quote_name_buf): * src/pathchk.c (portable_chars_only): * src/printf.c (STRTOX): * src/wc.c (wc): Prefer mbszero to clearing an mbstate_t by hand. --- bootstrap.conf | 1 + src/df.c | 2 +- src/ls.c | 2 +- src/pathchk.c | 2 +- src/printf.c | 2 +- src/wc.c | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index a15bda341..0b1ed95f6 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -165,6 +165,7 @@ gnulib_modules=" mbschr mbslen mbswidth + mbszero mcel-prefer memcasecmp memchr diff --git a/src/df.c b/src/df.c index c5eb82051..1f3665a4a 100644 --- a/src/df.c +++ b/src/df.c @@ -319,7 +319,7 @@ replace_invalid_chars (char *cell) { char *srcend = cell + strlen (cell); char *dst = cell; - mbstate_t mbstate = {0}; + mbstate_t mbstate; mbszero (&mbstate); size_t n; for (char *src = cell; src != srcend; src += n) diff --git a/src/ls.c b/src/ls.c index dfb7718f7..eb74f1678 100644 --- a/src/ls.c +++ b/src/ls.c @@ -4609,7 +4609,7 @@ quote_name_buf (char **inbuf, size_t bufsize, char *name, reach its end, replacing each non-printable multibyte character with a single question mark. */ { - mbstate_t mbstate = {0}; + mbstate_t mbstate; mbszero (&mbstate); do { wchar_t wc; diff --git a/src/pathchk.c b/src/pathchk.c index 74ff1fa09..0e8991405 100644 --- a/src/pathchk.c +++ b/src/pathchk.c @@ -188,7 +188,7 @@ portable_chars_only (char const *file, size_t filelen) if (*invalid) { - mbstate_t mbstate = {0}; + mbstate_t mbstate; mbszero (&mbstate); size_t charlen = mbrlen (invalid, filelen - validlen, &mbstate); error (0, 0, _("non-portable character %s in file name %s"), diff --git a/src/printf.c b/src/printf.c index a6f63cb00..16ea1c17f 100644 --- a/src/printf.c +++ b/src/printf.c @@ -172,7 +172,7 @@ FUNC_NAME (char const *s) \ \ if (MB_CUR_MAX > 1 && *(s + 1)) \ { \ - mbstate_t mbstate = {0}; \ + mbstate_t mbstate; mbszero (&mbstate); \ wchar_t wc; \ size_t slen = strlen (s); \ ssize_t bytes; \ diff --git a/src/wc.c b/src/wc.c index 130be8c32..1753acfc1 100644 --- a/src/wc.c +++ b/src/wc.c @@ -452,7 +452,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) { bool in_word = false; uintmax_t linepos = 0; - mbstate_t state = {0}; + mbstate_t state; mbszero (&state); bool in_shift = false; # if SUPPORT_OLD_MBRTOWC /* Back-up the state before each multibyte character conversion and -- 2.11.4.GIT