From: Ralph Corderoy Date: Mon, 30 Oct 2017 19:55:14 +0000 (+0000) Subject: Replace printf(3) with fputs(3) where possible. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/eed1bea439a5e3c62958fa1e524d527c4a2fb85d?ds=sidebyside Replace printf(3) with fputs(3) where possible. The format string has no format specifiers, and doesn't end with `\n', so fputs() to stdout is sufficient. --- diff --git a/uip/ali.c b/uip/ali.c index a1b642cb..f4e46648 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -177,10 +177,10 @@ print_aka (char *p, bool list, int margin) printf ("\n%*s", margin, ""); else { if (pos >= 68) { - printf (",\n "); + fputs(",\n ", stdout); pos = 2; } else { - printf (", "); + fputs(", ", stdout); pos += 2; } } diff --git a/uip/anno.c b/uip/anno.c index 1c4e0cae..2335ada0 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -274,7 +274,7 @@ make_comp (char **ap) char *cp, buffer[BUFSIZ]; if (*ap == NULL) { - printf ("Enter component name: "); + fputs("Enter component name: ", stdout); fflush (stdout); if (fgets (buffer, sizeof buffer, stdin) == NULL) diff --git a/uip/fmtdump.c b/uip/fmtdump.c index be6b7631..3fa0876a 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -155,7 +155,7 @@ dumpone(struct format *fmt) case FT_LS_COMP: case FT_LV_COMPFLAG: case FT_LV_COMP: - printf(", comp "); + fputs(", comp ", stdout); litputs(fmt->f_comp->c_name); if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); @@ -187,7 +187,7 @@ dumpone(struct format *fmt) case FT_LOCALDATE: case FT_GMTDATE: case FT_PARSEDATE: - printf(", c_name "); + fputs(", c_name ", stdout); litputs(fmt->f_comp->c_name); if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); @@ -211,7 +211,7 @@ dumpone(struct format *fmt) case FT_MYMBOX: case FT_GETMYMBOX: case FT_GETMYADDR: - printf(", c_name "); + fputs(", c_name ", stdout); litputs(fmt->f_comp->c_name); if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); @@ -222,7 +222,7 @@ dumpone(struct format *fmt) case FT_COMPF: printf(", width %d, fill '", fmt->f_width); litputc(fmt->f_fill); - printf("' name "); + fputs("' name ", stdout); litputs(fmt->f_comp->c_name); if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); @@ -245,7 +245,7 @@ dumpone(struct format *fmt) case FT_LITF: printf(", width %d, fill '", fmt->f_width); litputc(fmt->f_fill); - printf("' "); + fputs("' ", stdout); litputs(fmt->f_text); break; @@ -261,7 +261,7 @@ dumpone(struct format *fmt) case FT_IF_S_NULL: case FT_IF_MATCH: case FT_IF_AMATCH: - printf(" continue else goto"); + fputs(" continue else goto", stdout); /* FALLTHRU */ case FT_GOTO: i = findlabel(fmt + fmt->f_skip); @@ -288,17 +288,17 @@ dumpone(struct format *fmt) break; case FT_LS_LIT: - printf(" str "); + fputs(" str ", stdout); litputs(fmt->f_text); break; case FT_LS_GETENV: - printf(" getenv "); + fputs(" getenv ", stdout); litputs(fmt->f_text); break; case FT_LS_DECODECOMP: - printf(", comp "); + fputs(", comp ", stdout); litputs(fmt->f_comp->c_name); break; diff --git a/uip/fmttest.c b/uip/fmttest.c index 9a569ae4..d458bb6b 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -734,7 +734,7 @@ test_trace(void *context, struct format *fmt, int num, char *str, if (str != ctx->str) { if (changed++) putchar(' '); - printf("str="); + fputs("str=", stdout); litputs(str); ctx->str = str; } @@ -743,7 +743,7 @@ test_trace(void *context, struct format *fmt, int num, char *str, putchar('\n'); if (strcmp(outbuf, ctx->outbuf) != 0) { - printf("outbuf="); + fputs("outbuf=", stdout); litputs(outbuf); putchar('\n'); free(ctx->outbuf); @@ -783,7 +783,7 @@ dumpone(struct format *fmt) case FT_LS_COMP: case FT_LV_COMPFLAG: case FT_LV_COMP: - printf(", comp "); + fputs(", comp ", stdout); litputs(fmt->f_comp->c_name); if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); @@ -815,7 +815,7 @@ dumpone(struct format *fmt) case FT_LOCALDATE: case FT_GMTDATE: case FT_PARSEDATE: - printf(", c_name "); + fputs(", c_name ", stdout); litputs(fmt->f_comp->c_name); if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); @@ -839,7 +839,7 @@ dumpone(struct format *fmt) case FT_MYMBOX: case FT_GETMYMBOX: case FT_GETMYADDR: - printf(", c_name "); + fputs(", c_name ", stdout); litputs(fmt->f_comp->c_name); if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); @@ -850,7 +850,7 @@ dumpone(struct format *fmt) case FT_COMPF: printf(", width %d, fill '", fmt->f_width); litputc(fmt->f_fill); - printf("' name "); + fputs("' name ", stdout); litputs(fmt->f_comp->c_name); if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); @@ -873,7 +873,7 @@ dumpone(struct format *fmt) case FT_LITF: printf(", width %d, fill '", fmt->f_width); litputc(fmt->f_fill); - printf("' "); + fputs("' ", stdout); litputs(fmt->f_text); break; @@ -889,7 +889,7 @@ dumpone(struct format *fmt) case FT_IF_S_NULL: case FT_IF_MATCH: case FT_IF_AMATCH: - printf(" continue else goto"); + fputs(" continue else goto", stdout); /* FALLTHRU */ case FT_GOTO: i = findlabel(fmt + fmt->f_skip); @@ -916,17 +916,17 @@ dumpone(struct format *fmt) break; case FT_LS_LIT: - printf(" str "); + fputs(" str ", stdout); litputs(fmt->f_text); break; case FT_LS_GETENV: - printf(" getenv "); + fputs(" getenv ", stdout); litputs(fmt->f_text); break; case FT_LS_DECODECOMP: - printf(", comp "); + fputs(", comp ", stdout); litputs(fmt->f_comp->c_name); break; diff --git a/uip/install-mh.c b/uip/install-mh.c index 0d5b3bb0..3a1fa2a6 100644 --- a/uip/install-mh.c +++ b/uip/install-mh.c @@ -153,7 +153,7 @@ query: pathname = read_line (); if (pathname == NULL) done (1); } else { - printf ("What is the whole path? /"); + fputs("What is the whole path? /", stdout); pathname = read_line (); if (pathname == NULL) done (1); pathname = concat ("/", pathname, NULL); diff --git a/uip/mhlogin.c b/uip/mhlogin.c index e02ef465..da4f639d 100644 --- a/uip/mhlogin.c +++ b/uip/mhlogin.c @@ -98,7 +98,7 @@ do_login(const char *svc, const char *user, const char *browser, int snoop) " to access %s:\n\n%s\n\n", mh_oauth_svc_display_name(ctx), url); } - printf("Enter the authorization code: "); + fputs("Enter the authorization code: ", stdout); fflush(stdout); code = geta(); diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 5c050e3e..1c8ab4e0 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -933,7 +933,7 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) if (digest) fputs(ofilen == 1 ? delim3 : delim4, stdout); else { - printf ("\n-------"); + fputs("\n-------", stdout); if (ofilen == 1) printf (" Forwarded Message%s", PLURALS(ofilec)); else diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 18f02908..a9993d6d 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -1291,7 +1291,7 @@ clobber_check (char *original_file, mhstoreinfo_t info) { break; case NMH_RENAME: { char buf[PATH_MAX]; - printf ("Enter filename or full path of the new file: "); + fputs("Enter filename or full path of the new file: ", stdout); if (fgets (buf, sizeof buf, stdin) == NULL || buf[0] == '\0') { file = NULL; diff --git a/uip/msgchk.c b/uip/msgchk.c index 3e04f8f7..5551e504 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -368,7 +368,7 @@ remotemail (char *host, char *port, char *user, char *proxy, int notifysw, if (nmsgs) { if (notifysw & NT_MAIL) { if (personal) - printf ("You have "); + fputs("You have ", stdout); else printf ("%s has ", user); diff --git a/uip/post.c b/uip/post.c index c6a09175..93531c99 100644 --- a/uip/post.c +++ b/uip/post.c @@ -1370,26 +1370,26 @@ pl (void) int i; struct mailname *mp; - printf ("-------\n\t-- Addresses --\nlocal:\t"); + fputs("-------\n\t-- Addresses --\nlocal:\t", stdout); for (mp = localaddrs.m_next; mp; mp = mp->m_next) printf ("%s%s%s", mp->m_mbox, mp->m_bcc ? "[BCC]" : "", mp->m_next ? ",\n\t" : ""); - printf ("\nnet:\t"); + fputs("\nnet:\t", stdout); for (mp = netaddrs.m_next; mp; mp = mp->m_next) printf ("%s%s@%s%s%s", FENDNULL(mp->m_path), mp->m_mbox, mp->m_host, mp->m_bcc ? "[BCC]" : "", mp->m_next ? ",\n\t" : ""); - printf ("\nuucp:\t"); + fputs("\nuucp:\t", stdout); for (mp = uuaddrs.m_next; mp; mp = mp->m_next) printf ("%s!%s%s%s", mp->m_host, mp->m_mbox, mp->m_bcc ? "[BCC]" : "", mp->m_next ? ",\n\t" : ""); - printf ("\n\t-- Folder Copies --\nfcc:\t"); + fputs("\n\t-- Folder Copies --\nfcc:\t", stdout); for (i = 0; i < fccind; i++) printf ("%s%s", fccfold[i], i + 1 < fccind ? ",\n\t" : ""); putchar('\n'); @@ -1848,7 +1848,7 @@ do_an_address (struct mailname *lp, int talk) return; } if (talk) - printf (": "); + fputs(": ", stdout); fflush (stdout); switch (retval = sm_wadr (mbox, host, diff --git a/uip/slocal.c b/uip/slocal.c index dae9ca95..cfdc0dff 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -1354,7 +1354,7 @@ adorn (char *what, char *fmt, ...) char *s; eindex = errno; /* save the errno */ - printf(", "); + fputs(", ", stdout); va_start(ap, fmt); vprintf(fmt, ap);