]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
textutils: use fgetwc() instead of getwc()
authorThomas Weißschuh <thomas@t-8ch.de>
Sat, 13 Apr 2024 08:21:21 +0000 (10:21 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 13 Apr 2024 08:34:53 +0000 (10:34 +0200)
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 <thomas@t-8ch.de>
text-utils/colcrt.c
text-utils/colrm.c
text-utils/ul.c

index a6da499763e8c8e200e027203e9a931acd695029..44d2c8a8c8c1994ed149379e0e80f69a57e68c0f 100644 (file)
@@ -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;
index 122564339f4f242bdf5e91f64f14a71b1728f93f..d893137164f0f6b14ab0e8f3184b763f47419ed1 100644 (file)
@@ -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') {
index 85fa86fe48b563aeecb95d3e58c4a26b30983fe9..1df4642eb38bd64524c603d7804c88d911afdc9c 100644 (file)
@@ -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);
                        }