From: Thomas Weißschuh Date: Sat, 13 Apr 2024 08:21:21 +0000 (+0200) Subject: textutils: use fgetwc() instead of getwc() X-Git-Tag: v2.42-start~403^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef4fd528cb6dcddb867df903355d8289e12a7206;p=thirdparty%2Futil-linux.git textutils: use fgetwc() instead of getwc() getwc() has the same semantics as fgetwc() but may be a function or macro. According to the manpage "there is no reason ever to use it". Signed-off-by: Thomas Weißschuh --- diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c index a6da49976..44d2c8a8c 100644 --- a/text-utils/colcrt.c +++ b/text-utils/colcrt.c @@ -164,7 +164,7 @@ static void colcrt(struct colcrt_control *ctl) errno = 0; old_pos = ftell(ctl->f); - while (getwc(ctl->f) != L'\n') { + while (fgetwc(ctl->f) != L'\n') { long new_pos; if (ferror(ctl->f) || feof(ctl->f)) @@ -179,10 +179,10 @@ static void colcrt(struct colcrt_control *ctl) col = -1; continue; } - c = getwc(ctl->f); + c = fgetwc(ctl->f); switch (c) { case 033: /* ESC */ - c = getwc(ctl->f); + c = fgetwc(ctl->f); if (c == L'8') { col = rubchars(ctl, col, 1); continue; diff --git a/text-utils/colrm.c b/text-utils/colrm.c index 122564339..d89313716 100644 --- a/text-utils/colrm.c +++ b/text-utils/colrm.c @@ -81,7 +81,7 @@ static int process_input(unsigned long first, unsigned long last) int padding; for (;;) { - c = getwc(stdin); + c = fgetwc(stdin); if (c == WEOF) return 0; if (c == '\t') @@ -112,7 +112,7 @@ static int process_input(unsigned long first, unsigned long last) /* Loop getting rid of characters */ while (!last || ct < last) { - c = getwc(stdin); + c = fgetwc(stdin); if (c == WEOF) return 0; if (c == '\n') { @@ -135,7 +135,7 @@ static int process_input(unsigned long first, unsigned long last) /* Output last of the line */ for (;;) { - c = getwc(stdin); + c = fgetwc(stdin); if (c == WEOF) break; if (c == '\n') { diff --git a/text-utils/ul.c b/text-utils/ul.c index 85fa86fe4..1df4642eb 100644 --- a/text-utils/ul.c +++ b/text-utils/ul.c @@ -439,7 +439,7 @@ static int handle_escape(struct ul_ctl *ctl, struct term_caps const *const tcs, { wint_t c; - switch (c = getwc(f)) { + switch (c = fgetwc(f)) { case HREV: if (0 < ctl->half_position) { ctl->mode &= ~SUBSCRIPT; @@ -479,7 +479,7 @@ static void filter(struct ul_ctl *ctl, struct term_caps const *const tcs, FILE * wint_t c; int i, width; - while ((c = getwc(f)) != WEOF) { + while ((c = fgetwc(f)) != WEOF) { switch (c) { case '\b': set_column(ctl, ctl->column && 0 < ctl->column ? ctl->column - 1 : 0); @@ -498,7 +498,7 @@ static void filter(struct ul_ctl *ctl, struct term_caps const *const tcs, FILE * continue; case ESC: if (handle_escape(ctl, tcs, f)) { - c = getwc(f); + c = fgetwc(f); errx(EXIT_FAILURE, _("unknown escape sequence in input: %o, %o"), ESC, c); }