]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
write: remove PUTC macro
authorSami Kerola <kerolasa@iki.fi>
Sat, 14 May 2016 15:40:45 +0000 (16:40 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 3 Jul 2016 22:34:55 +0000 (23:34 +0100)
Function like macros make following the execution flow unnecessarily
difficult, and deserves to be removed.

Requested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
term-utils/write.c

index 696a7a7953daa2a1a8a1b5d9685fba7c168aa008..40be5c2de4db53d77c0dc286f800c5cd82f3989e 100644 (file)
@@ -220,18 +220,13 @@ static void signal_handler(int signo)
  */
 static void write_line(char *s)
 {
-       char c;
-
-#define        PUTC(c) if (fputc_careful(c, stdout, '^') == EOF) \
-    err(EXIT_FAILURE, _("carefulputc failed"));
        while (*s) {
-               c = *s++;
-               if (c == '\n')
-                       PUTC('\r');
-               PUTC(c);
+               const int c = *s++;
+
+               if ((c == '\n' && fputc_careful('\r', stdout, '^') == EOF)
+                   || fputc_careful(c, stdout, '^') == EOF)
+                       err(EXIT_FAILURE, _("carefulputc failed"));
        }
-       return;
-#undef PUTC
 }
 
 /*