diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c index 32d5444831..4672d8b2a4 100644 --- a/contrib/oid2name/oid2name.c +++ b/contrib/oid2name/oid2name.c @@ -422,7 +422,7 @@ sql_exec(PGconn *conn, const char *todo, bool quiet) fprintf(stdout, "%*s", length[j] + 2, PQfname(res, j)); l += length[j] + 2; } - fprintf(stdout, "\n"); + fputc('\n', stdout); pad = (char *) pg_malloc(l + 1); memset(pad, '-', l); pad[l] = '\0'; @@ -435,7 +435,7 @@ sql_exec(PGconn *conn, const char *todo, bool quiet) { for (j = 0; j < nfields; j++) fprintf(stdout, "%*s", length[j] + 2, PQgetvalue(res, i, j)); - fprintf(stdout, "\n"); + fputc('\n', stdout); } /* cleanup */ diff --git a/contrib/pg_trgm/trgm_regexp.c b/contrib/pg_trgm/trgm_regexp.c index 58d32ba946..ed1ab65940 100644 --- a/contrib/pg_trgm/trgm_regexp.c +++ b/contrib/pg_trgm/trgm_regexp.c @@ -2201,7 +2201,7 @@ printSourceNFA(regex_t *regex, TrgmColorInfo *colors, int ncolors) /* dot -Tpng -o /tmp/source.png < /tmp/source.gv */ FILE *fp = fopen("/tmp/source.gv", "w"); - fprintf(fp, "%s", buf.data); + fputs(buf.data, fp); fclose(fp); } @@ -2263,7 +2263,7 @@ printTrgmNFA(TrgmNFA *trgmNFA) /* dot -Tpng -o /tmp/transformed.png < /tmp/transformed.gv */ FILE *fp = fopen("/tmp/transformed.gv", "w"); - fprintf(fp, "%s", buf.data); + fputs(buf.data, fp); fclose(fp); } @@ -2354,7 +2354,7 @@ printTrgmPackedGraph(TrgmPackedGraph *packedGraph, TRGM *trigrams) /* dot -Tpng -o /tmp/packed.png < /tmp/packed.gv */ FILE *fp = fopen("/tmp/packed.gv", "w"); - fprintf(fp, "%s", buf.data); + fputs(buf.data, fp); fclose(fp); } diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c index 264b879bd3..e51ce8df57 100644 --- a/contrib/vacuumlo/vacuumlo.c +++ b/contrib/vacuumlo/vacuumlo.c @@ -133,7 +133,7 @@ vacuumlo(const char *database, const struct _param *param) { fprintf(stdout, "Connected to database \"%s\"\n", database); if (param->dry_run) - fprintf(stdout, "Test run: no large objects will be removed!\n"); + fputs("Test run: no large objects will be removed!\n", stdout); } res = PQexec(conn, ALWAYS_SECURE_SEARCH_PATH_SQL); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 7a710e6490..343555e095 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -8641,7 +8641,7 @@ do_pg_backup_stop(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) * Transfer remaining lines including label and start timeline to * history file. */ - fprintf(fp, "%s", remaining); + fputs(remaining, fp); fprintf(fp, "STOP TIME: %s\n", strfbuf); fprintf(fp, "STOP TIMELINE: %u\n", stoptli); if (fflush(fp) || ferror(fp) || FreeFile(fp)) diff --git a/src/backend/optimizer/geqo/geqo_misc.c b/src/backend/optimizer/geqo/geqo_misc.c index 890ac363e9..0d024f227f 100644 --- a/src/backend/optimizer/geqo/geqo_misc.c +++ b/src/backend/optimizer/geqo/geqo_misc.c @@ -114,17 +114,17 @@ print_edge_table(FILE *fp, Edge *edge_table, int num_gene) int i, j; - fprintf(fp, "\nEDGE TABLE\n"); + fputs("\nEDGE TABLE\n", fp); for (i = 1; i <= num_gene; i++) { fprintf(fp, "%d :", i); for (j = 0; j < edge_table[i].unused_edges; j++) fprintf(fp, " %d", edge_table[i].edge_list[j]); - fprintf(fp, "\n"); + fputc('\n', fp); } - fprintf(fp, "\n"); + fputc('\n', fp); fflush(fp); } diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index e75611fdd5..36808438c8 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -5601,10 +5601,10 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname) return false; } - fprintf(fp, "%s", fullprogname); + fputs(fullprogname, fp); for (i = 1; i < argc; i++) fprintf(fp, " \"%s\"", argv[i]); - fputs("\n", fp); + fputc('\n', fp); if (fclose(fp)) { diff --git a/src/backend/regex/regc_color.c b/src/backend/regex/regc_color.c index 30bda0e5ad..affeb099ee 100644 --- a/src/backend/regex/regc_color.c +++ b/src/backend/regex/regc_color.c @@ -1134,7 +1134,7 @@ dumpcolors(struct colormap *cm, for (c = CHR_MIN; c <= MAX_SIMPLE_CHR; c++) if (GETCOLOR(cm, c) == co) dumpchr(c, f); - fprintf(f, "\n"); + fputc('\n', f); } } /* dump the high colormap if it contains anything interesting */ @@ -1144,12 +1144,12 @@ dumpcolors(struct colormap *cm, c; const color *rowptr; - fprintf(f, "other:\t"); + fputs("other:\t", f); for (c = 0; c < cm->hiarraycols; c++) { fprintf(f, "\t%ld", (long) cm->hicolormap[c]); } - fprintf(f, "\n"); + fputc('\n', f); for (r = 0; r < cm->numcmranges; r++) { dumpchr(cm->cmranges[r].cmin, f); @@ -1161,7 +1161,7 @@ dumpcolors(struct colormap *cm, { fprintf(f, "\t%ld", (long) rowptr[c]); } - fprintf(f, "\n"); + fputc('\n', f); } } } diff --git a/src/backend/regex/regc_nfa.c b/src/backend/regex/regc_nfa.c index 60fb0bec5d..27ea726768 100644 --- a/src/backend/regex/regc_nfa.c +++ b/src/backend/regex/regc_nfa.c @@ -3667,7 +3667,7 @@ dumpnfa(struct nfa *nfa, else fprintf(f, ", maxmatchall %d", nfa->maxmatchall); } - fprintf(f, "\n"); + fputc('\n', f); for (s = nfa->states; s != NULL; s = s->next) { dumpstate(s, f); @@ -3730,7 +3730,7 @@ dumparcs(struct state *s, dumparc(a, s, f); if (pos == 5) { - fprintf(f, "\n"); + fputc('\n', f); pos = 1; } else @@ -3738,7 +3738,7 @@ dumparcs(struct state *s, a = a->outchainRev; } while (a != NULL); if (pos != 1) - fprintf(f, "\n"); + fputc('\n', f); } /* @@ -3751,7 +3751,7 @@ dumparc(struct arc *a, { struct arc *aa; - fprintf(f, "\t"); + fputc('\t', ); switch (a->type) { case PLAIN: @@ -3836,7 +3836,7 @@ dumpcnfa(struct cnfa *cnfa, else fprintf(f, ", maxmatchall %d", cnfa->maxmatchall); } - fprintf(f, "\n"); + fputc('\n', f); for (st = 0; st < cnfa->nstates; st++) dumpcstate(st, cnfa, f); fflush(f); @@ -3868,14 +3868,14 @@ dumpcstate(int st, fprintf(f, "\t:%ld:->%d", (long) (ca->co - cnfa->ncolors), ca->to); if (pos == 5) { - fprintf(f, "\n"); + fputc('\n', f); pos = 1; } else pos++; } if (ca == cnfa->states[st] || pos != 1) - fprintf(f, "\n"); + fputc('\n', f); fflush(f); } diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index 473738040b..ca7b9252b9 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -2517,7 +2517,7 @@ dump(regex_t *re, fprintf(f, "\nla%d (%s):\n", i, latype); dumpcnfa(&lasub->cnfa, f); } - fprintf(f, "\n"); + fputc('\n', f); dumpst(g->tree, f, 0); } @@ -2530,7 +2530,7 @@ dumpst(struct subre *t, int nfapresent) /* is the original NFA still around? */ { if (t == NULL) - fprintf(f, "null tree\n"); + fputs("null tree\n", f); else stdump(t, f, nfapresent); fflush(f); @@ -2586,10 +2586,10 @@ stdump(struct subre *t, fprintf(f, " S:%s", stid(t->sibling, idbuf, sizeof(idbuf))); if (!NULLCNFA(t->cnfa)) { - fprintf(f, "\n"); + fputc('\n', f); dumpcnfa(&t->cnfa, f); } - fprintf(f, "\n"); + fputc('\n', f); for (t2 = t->child; t2 != NULL; t2 = t2->sibling) stdump(t2, f, nfapresent); } diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c index 4e473ec27e..357eb11cab 100644 --- a/src/backend/storage/lmgr/s_lock.c +++ b/src/backend/storage/lmgr/s_lock.c @@ -139,7 +139,7 @@ perform_spin_delay(SpinDelayStatus *status) pg_usleep(status->cur_delay); #if defined(S_LOCK_TEST) - fprintf(stdout, "*"); + fputc('*', stdout); fflush(stdout); #endif diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 55bf998511..effcddc422 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -11010,7 +11010,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) if (gconf->source == PGC_S_DEFAULT) return; - fprintf(fp, "%s", gconf->name); + fputs(gconf->name, fp); fputc(0, fp); switch (gconf->vartype) @@ -11020,9 +11020,9 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) struct config_bool *conf = (struct config_bool *) gconf; if (*conf->variable) - fprintf(fp, "true"); + fputs("true", fp); else - fprintf(fp, "false"); + fputs("false", fp); } break; @@ -11046,7 +11046,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) { struct config_string *conf = (struct config_string *) gconf; - fprintf(fp, "%s", *conf->variable); + fputs(*conf->variable, fp); } break; @@ -11054,8 +11054,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) { struct config_enum *conf = (struct config_enum *) gconf; - fprintf(fp, "%s", - config_enum_lookup_by_value(conf, *conf->variable)); + fputs(config_enum_lookup_by_value(conf, *conf->variable), fp); } break; } @@ -11063,7 +11062,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) fputc(0, fp); if (gconf->sourcefile) - fprintf(fp, "%s", gconf->sourcefile); + fputs(gconf->sourcefile, fp); fputc(0, fp); fwrite(&gconf->sourceline, 1, sizeof(gconf->sourceline), fp); diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index 115a64cfe4..649f6a589f 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -680,7 +680,7 @@ MemoryContextStatsInternal(MemoryContext context, int level, int i; for (i = 0; i <= level; i++) - fprintf(stderr, " "); + fputs(" ", stderr); fprintf(stderr, "%d more child contexts containing %zu total in %zu blocks; %zu free (%zu chunks); %zu used\n", ichild - max_children, @@ -782,7 +782,7 @@ MemoryContextStatsPrint(MemoryContext context, void *passthru, if (print_to_stderr) { for (i = 0; i < level; i++) - fprintf(stderr, " "); + fputs(" ", stderr); fprintf(stderr, "%s: %s%s\n", name, stats_string, truncated_ident); } else diff --git a/src/bin/pg_amcheck/pg_amcheck.c b/src/bin/pg_amcheck/pg_amcheck.c index fea35e4b14..330d296fa4 100644 --- a/src/bin/pg_amcheck/pg_amcheck.c +++ b/src/bin/pg_amcheck/pg_amcheck.c @@ -726,7 +726,7 @@ main(int argc, char *argv[]) if (opts.verbose) { if (opts.show_progress && progress_since_last_stderr) - fprintf(stderr, "\n"); + fputc('\n', stderr); pg_log_info("checking heap table \"%s.%s.%s\"", rel->datinfo->datname, rel->nspname, rel->relname); progress_since_last_stderr = false; @@ -741,7 +741,7 @@ main(int argc, char *argv[]) if (opts.verbose) { if (opts.show_progress && progress_since_last_stderr) - fprintf(stderr, "\n"); + fputc('\n', stderr); pg_log_info("checking btree index \"%s.%s.%s\"", rel->datinfo->datname, rel->nspname, rel->relname); @@ -1095,7 +1095,7 @@ verify_btree_slot_handler(PGresult *res, PGconn *conn, void *context) * event loop, so it doesn't matter. */ if (opts.show_progress && progress_since_last_stderr) - fprintf(stderr, "\n"); + fputc('\n', stderr); pg_log_warning("btree index \"%s.%s.%s\": btree checking function returned unexpected number of rows: %d", rel->datinfo->datname, rel->nspname, rel->relname, ntups); if (opts.verbose) diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 9ce30d43a4..888dfa7fc0 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -1904,11 +1904,11 @@ BaseBackup(char *compression_algorithm, char *compression_detail, if (showprogress && !verbose) { - fprintf(stderr, "waiting for checkpoint"); + fputs("waiting for checkpoint", stderr); if (isatty(fileno(stderr))) - fprintf(stderr, "\r"); + fputc('\r', stderr); else - fprintf(stderr, "\n"); + fputc('\n', stderr); } if (use_new_option_syntax && buf.len > 0) diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 69ae027bd3..9481e68c5e 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -535,7 +535,7 @@ main(int argc, char *argv[]) if (quote_all_identifiers) executeCommand(conn, "SET quote_all_identifiers = true"); - fprintf(OPF, "--\n-- PostgreSQL database cluster dump\n--\n\n"); + fputs("--\n-- PostgreSQL database cluster dump\n--\n\n", OPF); if (verbose) dumpTimestamp("Started on"); @@ -547,15 +547,15 @@ main(int argc, char *argv[]) */ /* Restore will need to write to the target cluster */ - fprintf(OPF, "SET default_transaction_read_only = off;\n\n"); + fputs("SET default_transaction_read_only = off;\n\n", OPF); /* Replicate encoding and std_strings in output */ fprintf(OPF, "SET client_encoding = '%s';\n", pg_encoding_to_char(encoding)); fprintf(OPF, "SET standard_conforming_strings = %s;\n", std_strings); if (strcmp(std_strings, "off") == 0) - fprintf(OPF, "SET escape_string_warning = off;\n"); - fprintf(OPF, "\n"); + fputs("SET escape_string_warning = off;\n", OPF); + fputc('\n', OPF); if (!data_only) { @@ -606,7 +606,7 @@ main(int argc, char *argv[]) if (verbose) dumpTimestamp("Completed on"); - fprintf(OPF, "--\n-- PostgreSQL database cluster dump complete\n--\n\n"); + fputs("--\n-- PostgreSQL database cluster dump complete\n--\n\n", OPF); if (filename) { @@ -716,7 +716,7 @@ dropRoles(PGconn *conn) i_rolname = PQfnumber(res, "rolname"); if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Drop roles\n--\n\n"); + fputs("--\n-- Drop roles\n--\n\n", OPF); for (i = 0; i < PQntuples(res); i++) { @@ -732,7 +732,7 @@ dropRoles(PGconn *conn) PQclear(res); destroyPQExpBuffer(buf); - fprintf(OPF, "\n\n"); + fputs("\n\n", OPF); } /* @@ -811,7 +811,7 @@ dumpRoles(PGconn *conn) i_is_current_user = PQfnumber(res, "is_current_user"); if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Roles\n--\n\n"); + fputs("--\n-- Roles\n--\n\n", OPF); for (i = 0; i < PQntuples(res); i++) { @@ -915,7 +915,7 @@ dumpRoles(PGconn *conn) "ROLE", rolename, buf); - fprintf(OPF, "%s", buf->data); + fputs(buf->data, OPF); } /* @@ -924,14 +924,14 @@ dumpRoles(PGconn *conn) * names of other roles. */ if (PQntuples(res) > 0) - fprintf(OPF, "\n--\n-- User Configurations\n--\n"); + fputs("\n--\n-- User Configurations\n--\n", OPF); for (i = 0; i < PQntuples(res); i++) dumpUserConfig(conn, PQgetvalue(res, i, i_rolname)); PQclear(res); - fprintf(OPF, "\n\n"); + fputs("\n\n", OPF); destroyPQExpBuffer(buf); } @@ -989,7 +989,7 @@ dumpRoleMembership(PGconn *conn) i_inherit_option = PQfnumber(res, "inherit_option"); if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Role memberships\n--\n\n"); + fputs("--\n-- Role memberships\n--\n\n", OPF); /* * We can't dump these GRANT commands in arbitary order, because a role @@ -1111,7 +1111,7 @@ dumpRoleMembership(PGconn *conn) fprintf(OPF, " WITH %s", optbuf->data); if (dump_grantors) fprintf(OPF, " GRANTED BY %s", fmtId(grantor)); - fprintf(OPF, ";\n"); + fputs(";\n", OPF); } } @@ -1123,7 +1123,7 @@ dumpRoleMembership(PGconn *conn) PQclear(res); destroyPQExpBuffer(buf); - fprintf(OPF, "\n\n"); + fputs("\n\n", OPF); } @@ -1151,7 +1151,7 @@ dumpRoleGUCPrivs(PGconn *conn) "ORDER BY 1"); if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Role privileges on configuration parameters\n--\n\n"); + fputs("--\n-- Role privileges on configuration parameters\n--\n\n", OPF); for (i = 0; i < PQntuples(res); i++) { @@ -1175,14 +1175,14 @@ dumpRoleGUCPrivs(PGconn *conn) exit_nicely(1); } - fprintf(OPF, "%s", buf->data); + fputs(buf->data, OPF); free(fparname); destroyPQExpBuffer(buf); } PQclear(res); - fprintf(OPF, "\n\n"); + fputs("\n\n", OPF); } @@ -1205,7 +1205,7 @@ dropTablespaces(PGconn *conn) "ORDER BY 1"); if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Drop tablespaces\n--\n\n"); + fputs("--\n-- Drop tablespaces\n--\n\n", OPF); for (i = 0; i < PQntuples(res); i++) { @@ -1218,7 +1218,7 @@ dropTablespaces(PGconn *conn) PQclear(res); - fprintf(OPF, "\n\n"); + fputs("\n\n", OPF); } /* @@ -1245,7 +1245,7 @@ dumpTablespaces(PGconn *conn) "ORDER BY 1"); if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Tablespaces\n--\n\n"); + fputs("--\n-- Tablespaces\n--\n\n", OPF); for (i = 0; i < PQntuples(res); i++) { @@ -1305,14 +1305,14 @@ dumpTablespaces(PGconn *conn) "TABLESPACE", spcname, buf); - fprintf(OPF, "%s", buf->data); + fputs(buf->data, OPF); free(fspcname); destroyPQExpBuffer(buf); } PQclear(res); - fprintf(OPF, "\n\n"); + fputs("\n\n", OPF); } @@ -1336,7 +1336,7 @@ dropDBs(PGconn *conn) "ORDER BY datname"); if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Drop databases (except postgres and template1)\n--\n\n"); + fputs("--\n-- Drop databases (except postgres and template1)\n--\n\n", OPF); for (i = 0; i < PQntuples(res); i++) { @@ -1359,7 +1359,7 @@ dropDBs(PGconn *conn) PQclear(res); - fprintf(OPF, "\n\n"); + fputs("\n\n", OPF); } @@ -1390,7 +1390,7 @@ dumpUserConfig(PGconn *conn, const char *username) makeAlterConfigCommand(conn, PQgetvalue(res, i, 0), "ROLE", username, NULL, NULL, buf); - fprintf(OPF, "%s", buf->data); + fputs(buf->data, OPF); } PQclear(res); @@ -1479,7 +1479,7 @@ dumpDatabases(PGconn *conn) "ORDER BY (datname <> 'template1'), datname"); if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Databases\n--\n\n"); + fputs("--\n-- Databases\n--\n\n", OPF); for (i = 0; i < PQntuples(res); i++) { diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index f4969bcdad..b3c90cf121 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -582,7 +582,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) #ifndef WIN32 /* add shebang header */ - fprintf(script, "#!/bin/sh\n\n"); + fputs("#!/bin/sh\n\n", script); #endif /* delete old cluster's default tablespace */ @@ -601,7 +601,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) /* delete per-database directories */ int dbnum; - fprintf(script, "\n"); + fputc('\n', script); for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++) fprintf(script, RMDIR_CMD " %c%s%c%u%c\n", PATH_QUOTE, diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c index 60f4b5443e..470fc4855b 100644 --- a/src/bin/pg_upgrade/exec.c +++ b/src/bin/pg_upgrade/exec.c @@ -159,13 +159,13 @@ exec_prog(const char *log_filename, const char *opt_log_file, #ifdef WIN32 /* Are we printing "command:" before its output? */ if (mainThreadId == GetCurrentThreadId()) - fprintf(log, "\n\n"); + fputs("\n\n", log); #endif fprintf(log, "command: %s\n", cmd); #ifdef WIN32 /* Are we printing "command:" after its output? */ if (mainThreadId != GetCurrentThreadId()) - fprintf(log, "\n\n"); + fputs("\n\n", log); #endif /* @@ -213,7 +213,7 @@ exec_prog(const char *log_filename, const char *opt_log_file, */ if ((log = fopen(log_file, "a")) == NULL) pg_fatal("could not write to log file \"%s\": %m", log_file); - fprintf(log, "\n\n"); + fputs("\n\n", log); fclose(log); #endif diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c index 593a843917..486918021b 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -181,7 +181,7 @@ pg_log_v(eLogType type, const char *fmt, va_list ap) /* status messages get two leading spaces, see below */ fprintf(log_opts.internal, " %s\n", message); else if (type == PG_REPORT_NONL) - fprintf(log_opts.internal, "%s", message); + fputs(message, log_opts.internal); else fprintf(log_opts.internal, "%s\n", message); fflush(log_opts.internal); diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 098fb43b3c..338bc31904 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -2532,7 +2532,7 @@ evalStandardFunc(CState *st, st->use_file, st->command + 1); if (varg->type == PGBT_NULL) - fprintf(stderr, "null\n"); + fputs("null\n", stderr); else if (varg->type == PGBT_BOOLEAN) fprintf(stderr, "boolean %s\n", varg->u.bval ? "true" : "false"); else if (varg->type == PGBT_INT) @@ -4633,7 +4633,7 @@ disconnect_all(CState *state, int length) static void initDropTables(PGconn *con) { - fprintf(stderr, "dropping old tables...\n"); + fputs("dropping old tables...\n", stderr); /* * We drop all the tables in one command, so that whether there are @@ -4771,7 +4771,7 @@ initCreateTables(PGconn *con) int i; PQExpBufferData query; - fprintf(stderr, "creating tables...\n"); + fputs("creating tables...\n", stderr); initPQExpBuffer(&query); @@ -4845,7 +4845,7 @@ initGenerateDataClientSide(PGconn *con) /* Stay on the same line if reporting to a terminal */ char eol = isatty(fileno(stderr)) ? '\r' : '\n'; - fprintf(stderr, "generating data (client-side)...\n"); + fputs("generating data (client-side)...\n", stderr); /* * we do all of this in one transaction to enable the backend's @@ -4970,7 +4970,7 @@ initGenerateDataServerSide(PGconn *con) { PQExpBufferData sql; - fprintf(stderr, "generating data (server-side)...\n"); + fputs("generating data (server-side)...\n", stderr); /* * we do all of this in one transaction to enable the backend's @@ -5013,7 +5013,7 @@ initGenerateDataServerSide(PGconn *con) static void initVacuum(PGconn *con) { - fprintf(stderr, "vacuuming...\n"); + fputs("vacuuming...\n", stderr); executeStatement(con, "vacuum analyze pgbench_branches"); executeStatement(con, "vacuum analyze pgbench_tellers"); executeStatement(con, "vacuum analyze pgbench_accounts"); @@ -5034,7 +5034,7 @@ initCreatePKeys(PGconn *con) int i; PQExpBufferData query; - fprintf(stderr, "creating primary keys...\n"); + fputs("creating primary keys...\n", stderr); initPQExpBuffer(&query); for (i = 0; i < lengthof(DDLINDEXes); i++) @@ -5073,7 +5073,7 @@ initCreateFKeys(PGconn *con) }; int i; - fprintf(stderr, "creating foreign keys...\n"); + fputs("creating foreign keys...\n", stderr); for (i = 0; i < lengthof(DDLKEYs); i++) { executeStatement(con, DDLKEYs[i]); @@ -5992,10 +5992,10 @@ listAvailableScripts(void) { int i; - fprintf(stderr, "Available builtin scripts:\n"); + fputs("Available builtin scripts:\n", stderr); for (i = 0; i < lengthof(builtin_script); i++) fprintf(stderr, " %13s: %s\n", builtin_script[i].name, builtin_script[i].desc); - fprintf(stderr, "\n"); + fputc('\n', stderr); } /* return builtin script "name" if unambiguous, fails if not found */ @@ -6181,7 +6181,7 @@ printProgressReport(TState *threads, int64 test_start, pg_time_usec_t now, fprintf(stderr, ", " INT64_FORMAT " retried, " INT64_FORMAT " retries", retried, cur.retries - last->retries); - fprintf(stderr, "\n"); + fputc('\n', stderr); *last = cur; *last_report = now; @@ -7138,17 +7138,17 @@ main(int argc, char **argv) if (!is_no_vacuum) { - fprintf(stderr, "starting vacuum..."); + fputs("starting vacuum...", stderr); tryExecuteStatement(con, "vacuum pgbench_branches"); tryExecuteStatement(con, "vacuum pgbench_tellers"); tryExecuteStatement(con, "truncate pgbench_history"); - fprintf(stderr, "end.\n"); + fputs("end.\n", stderr); if (do_vacuum_accounts) { - fprintf(stderr, "starting vacuum pgbench_accounts..."); + fputs("starting vacuum pgbench_accounts...", stderr); tryExecuteStatement(con, "vacuum analyze pgbench_accounts"); - fprintf(stderr, "end.\n"); + fputs("end.\n", stderr); } } PQfinish(con); diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index a141146e70..75fe181c15 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1243,7 +1243,7 @@ exec_command_echo(PsqlScanState scan_state, bool active_branch, const char *cmd) free(value); } if (!no_newline) - fputs("\n", fout); + fputc('\n', fout); } else ignore_slash_options(scan_state); @@ -5212,7 +5212,7 @@ do_watch(PQExpBuffer query_buf, double sleep) * using a pager, because pagers are expected to restore the screen to * a sane state on exit. */ - fprintf(stdout, "\n"); + fputc('\n', stdout); fflush(stdout); } diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index e611e3266d..d7222c8489 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -309,12 +309,12 @@ CheckConnection(void) exit(EXIT_BADCONN); } - fprintf(stderr, _("The connection to the server was lost. Attempting reset: ")); + fputs(_("The connection to the server was lost. Attempting reset: "), stderr); PQreset(pset.db); OK = ConnectionUp(); if (!OK) { - fprintf(stderr, _("Failed.\n")); + fputs(_("Failed.\n"), stderr); /* * Transition to having no connection; but stash away the failed @@ -331,7 +331,7 @@ CheckConnection(void) } else { - fprintf(stderr, _("Succeeded.\n")); + fputs(_("Succeeded.\n"), stderr); /* * Re-sync, just in case anything changed. Keep this in sync with @@ -1404,8 +1404,7 @@ DescribeQuery(const char *query, double *elapsed_msec) termPQExpBuffer(&buf); } else - fprintf(pset.queryFout, - _("The command has no result, or the result has no columns.\n")); + fputs(_("The command has no result, or the result has no columns.\n"), pset.queryFout); } SetResultVariables(result, OK); diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index f8ce1a0706..d00e6197d9 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -617,14 +617,13 @@ helpSQL(const char *topic, unsigned short int pager) for (i = 0; i < nrows; i++) { - fprintf(output, " "); + fputs(" ", output); for (j = 0; j < ncolumns - 1; j++) fprintf(output, "%-*s", QL_MAX_CMD_LEN + 1, VALUE_OR_NULL(QL_HELP[i + j * nrows].cmd)); if (i + j * nrows < QL_HELP_COUNT) - fprintf(output, "%s", - VALUE_OR_NULL(QL_HELP[i + j * nrows].cmd)); + fputs(VALUE_OR_NULL(QL_HELP[i + j * nrows].cmd), output); fputc('\n', output); } diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c index 64338d538e..9ba573dc08 100644 --- a/src/bin/psql/large_obj.c +++ b/src/bin/psql/large_obj.c @@ -32,7 +32,7 @@ print_lo_result(const char *fmt,...) if (pset.popt.topt.format == PRINT_HTML) fputs("
\n", pset.queryFout); else - fputs("\n", pset.queryFout); + fputc('\n', pset.queryFout); } if (pset.logfile) @@ -40,7 +40,7 @@ print_lo_result(const char *fmt,...) va_start(ap, fmt); vfprintf(pset.logfile, fmt, ap); va_end(ap); - fputs("\n", pset.logfile); + fputc('\n', pset.logfile); } } diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c index 991930a1ae..d635e71c54 100644 --- a/src/bin/scripts/createuser.c +++ b/src/bin/scripts/createuser.c @@ -233,7 +233,7 @@ main(int argc, char *argv[]) pw2 = simple_prompt("Enter it again: ", false); if (strcmp(newpassword, pw2) != 0) { - fprintf(stderr, _("Passwords didn't match.\n")); + fputs(_("Passwords didn't match.\n"), stderr); exit(1); } free(pw2); diff --git a/src/common/fe_memutils.c b/src/common/fe_memutils.c index b1e6c65576..3e169b823e 100644 --- a/src/common/fe_memutils.c +++ b/src/common/fe_memutils.c @@ -32,7 +32,7 @@ pg_malloc_internal(size_t size, int flags) { if ((flags & MCXT_ALLOC_NO_OOM) == 0) { - fprintf(stderr, _("out of memory\n")); + fputs(_("out of memory\n"), stderr); exit(EXIT_FAILURE); } return NULL; @@ -72,7 +72,7 @@ pg_realloc(void *ptr, size_t size) tmp = realloc(ptr, size); if (!tmp) { - fprintf(stderr, _("out of memory\n")); + fputs(_("out of memory\n"), stderr); exit(EXIT_FAILURE); } return tmp; @@ -88,14 +88,13 @@ pg_strdup(const char *in) if (!in) { - fprintf(stderr, - _("cannot duplicate null pointer (internal error)\n")); + fputs(_("cannot duplicate null pointer (internal error)\n"), stderr); exit(EXIT_FAILURE); } tmp = strdup(in); if (!tmp) { - fprintf(stderr, _("out of memory\n")); + fputs(_("out of memory\n"), stderr); exit(EXIT_FAILURE); } return tmp; @@ -149,8 +148,7 @@ pnstrdup(const char *in, Size size) if (!in) { - fprintf(stderr, - _("cannot duplicate null pointer (internal error)\n")); + fputs(_("cannot duplicate null pointer (internal error)\n"), stderr); exit(EXIT_FAILURE); } @@ -158,7 +156,7 @@ pnstrdup(const char *in, Size size) tmp = malloc(len + 1); if (tmp == NULL) { - fprintf(stderr, _("out of memory\n")); + fputs(_("out of memory\n"), stderr); exit(EXIT_FAILURE); } diff --git a/src/common/logging.c b/src/common/logging.c index 64604c5209..896c89f487 100644 --- a/src/common/logging.c +++ b/src/common/logging.c @@ -258,9 +258,9 @@ pg_log_generic_v(enum pg_log_level level, enum pg_log_part part, if (lineno > 0) fprintf(stderr, UINT64_FORMAT ":", lineno); } - fprintf(stderr, " "); + fputc(' ', stderr); if (sgr_locus) - fprintf(stderr, ANSI_ESCAPE_RESET); + fputs(ANSI_ESCAPE_RESET, stderr); } if (!(log_flags & PG_LOG_FLAG_TERSE)) @@ -275,14 +275,14 @@ pg_log_generic_v(enum pg_log_level level, enum pg_log_part part, fprintf(stderr, ANSI_ESCAPE_FMT, sgr_error); fprintf(stderr, _("error: ")); if (sgr_error) - fprintf(stderr, ANSI_ESCAPE_RESET); + fputs(ANSI_ESCAPE_RESET, stderr); break; case PG_LOG_WARNING: if (sgr_warning) fprintf(stderr, ANSI_ESCAPE_FMT, sgr_warning); - fprintf(stderr, _("warning: ")); + fputs(_("warning: "), stderr); if (sgr_warning) - fprintf(stderr, ANSI_ESCAPE_RESET); + fputs(ANSI_ESCAPE_RESET, stderr); break; default: break; @@ -291,16 +291,16 @@ pg_log_generic_v(enum pg_log_level level, enum pg_log_part part, case PG_LOG_DETAIL: if (sgr_note) fprintf(stderr, ANSI_ESCAPE_FMT, sgr_note); - fprintf(stderr, _("detail: ")); + fputs(_("detail: "), stderr); if (sgr_note) - fprintf(stderr, ANSI_ESCAPE_RESET); + fputs(ANSI_ESCAPE_RESET, stderr); break; case PG_LOG_HINT: if (sgr_note) fprintf(stderr, ANSI_ESCAPE_FMT, sgr_note); - fprintf(stderr, _("hint: ")); + fputs(_("hint: "), stderr); if (sgr_note) - fprintf(stderr, ANSI_ESCAPE_RESET); + fputs(ANSI_ESCAPE_RESET, stderr); break; } } diff --git a/src/common/psprintf.c b/src/common/psprintf.c index a5a5cb121c..79eb41c1e5 100644 --- a/src/common/psprintf.c +++ b/src/common/psprintf.c @@ -142,7 +142,7 @@ pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("out of memory"))); #else - fprintf(stderr, _("out of memory\n")); + fputs(_("out of memory\n"), stderr); exit(EXIT_FAILURE); #endif } diff --git a/src/common/sprompt.c b/src/common/sprompt.c index 8b836846e3..ebab6c44fd 100644 --- a/src/common/sprompt.c +++ b/src/common/sprompt.c @@ -156,18 +156,18 @@ simple_prompt_extended(const char *prompt, bool echo, /* restore previous echo behavior, then echo \n */ #if defined(HAVE_TERMIOS_H) tcsetattr(fileno(termin), TCSAFLUSH, &t_orig); - fputs("\n", termout); + fputc('\n', termout); fflush(termout); #elif defined(WIN32) SetConsoleMode(t, t_orig); - fputs("\n", termout); + fputc('\n', termout); fflush(termout); #endif } else if (prompt_ctx && prompt_ctx->canceled) { /* also echo \n if prompt was canceled */ - fputs("\n", termout); + fputc('\n', termout); fflush(termout); } diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c index 55288f8876..87d23887b0 100644 --- a/src/fe_utils/print.c +++ b/src/fe_utils/print.c @@ -1640,7 +1640,7 @@ print_aligned_vertical(const printTableContent *cont, { /* Left border */ if (opt_border == 2) - fprintf(fout, "%s", dformat->leftvrule); + fputs(dformat->leftvrule, fout); /* Header (never wrapped so just need to deal with newlines) */ if (!hcomplete) @@ -1685,7 +1685,7 @@ print_aligned_vertical(const printTableContent *cont, /* This was the last line of the header */ if ((opt_border > 0) || (hmultiline && (format != &pg_asciiformat_old))) - fputs(" ", fout); + fputc(' ', fout); hcomplete = 1; } } @@ -1775,7 +1775,7 @@ print_aligned_vertical(const printTableContent *cont, { if (swidth > 0) fprintf(fout, "%*s", swidth, " "); - fputs(" ", fout); + fputc(' ', fout); } dcomplete = 1; } @@ -1784,7 +1784,7 @@ print_aligned_vertical(const printTableContent *cont, if (opt_border == 2) fputs(dformat->rightvrule, fout); - fputs("\n", fout); + fputc('\n', fout); } else { @@ -1793,7 +1793,7 @@ print_aligned_vertical(const printTableContent *cont, * data due to newlines in the header) */ if (opt_border < 2) - fputs("\n", fout); + fputc('\n', fout); else fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule); } @@ -1977,7 +1977,7 @@ html_escaped_print(const char *in, FILE *fout) if (leading_space) fputs(" ", fout); else - fputs(" ", fout); + fputc(' ', fout); break; default: fputc(*p, fout); @@ -2195,14 +2195,14 @@ print_asciidoc_text(const printTableContent *cont, FILE *fout) if (cont->opt->start_table) { /* print table in new paragraph - enforce preliminary new line */ - fputs("\n", fout); + fputc('\n', fout); /* print title */ if (!opt_tuples_only && cont->title) { - fputs(".", fout); + fputc('.', fout); fputs(cont->title, fout); - fputs("\n", fout); + fputc('\n', fout); } /* print table [] header definition */ @@ -2210,10 +2210,10 @@ print_asciidoc_text(const printTableContent *cont, FILE *fout) for (i = 0; i < cont->ncolumns; i++) { if (i != 0) - fputs(",", fout); - fprintf(fout, "%s", cont->aligns[(i) % cont->ncolumns] == 'r' ? ">l" : "