static char *share_path = NULL;
/* values to be obtained from arguments */
-static char *pg_data = "";
-static char *encoding = "";
-static char *locale = "";
-static char *lc_collate = "";
-static char *lc_ctype = "";
-static char *lc_monetary = "";
-static char *lc_numeric = "";
-static char *lc_time = "";
-static char *lc_messages = "";
-static const char *default_text_search_config = "";
-static char *username = "";
+static char *pg_data = NULL;
+static char *encoding = NULL;
+static char *locale = NULL;
+static char *lc_collate = NULL;
+static char *lc_ctype = NULL;
+static char *lc_monetary = NULL;
+static char *lc_numeric = NULL;
+static char *lc_time = NULL;
+static char *lc_messages = NULL;
+static const char *default_text_search_config = NULL;
+static char *username = NULL;
static bool pwprompt = false;
static char *pwfilename = NULL;
static char *superuser_password = NULL;
-static const char *authmethodhost = "";
-static const char *authmethodlocal = "";
+static const char *authmethodhost = NULL;
+static const char *authmethodlocal = NULL;
static bool debug = false;
static bool noclean = false;
static bool do_sync = true;
static bool sync_only = false;
static bool show_setting = false;
static bool data_checksums = false;
-static char *xlog_dir = "";
+static char *xlog_dir = NULL;
/* internal vars */
{
PG_CMD_DECL;
char **line;
- char *talkargs = "";
char **bki_lines;
char headerline[MAXPGPATH];
char buf[64];
printf(_("running bootstrap script ... "));
fflush(stdout);
- if (debug)
- talkargs = "-d 5";
-
bki_lines = readfile(bki_file);
/* Check that bki file appears to be of the right version */
"\"%s\" --boot -x1 %s %s %s",
backend_exec,
data_checksums ? "-k" : "",
- boot_options, talkargs);
+ boot_options,
+ debug ? "-d 5" : "");
+
PG_CMD_OPEN;
/* save may be pointing at a modifiable scratch variable, so copy it. */
save = pg_strdup(save);
+ /* for setlocale() call */
+ if (!locale)
+ locale = "";
+
/* set the locale with setlocale, to see if it accepts it. */
res = setlocale(category, locale);
/* set empty lc_* values to locale config if set */
- if (strlen(locale) > 0)
+ if (locale)
{
- if (strlen(lc_ctype) == 0)
+ if (!lc_ctype)
lc_ctype = locale;
- if (strlen(lc_collate) == 0)
+ if (!lc_collate)
lc_collate = locale;
- if (strlen(lc_numeric) == 0)
+ if (!lc_numeric)
lc_numeric = locale;
- if (strlen(lc_time) == 0)
+ if (!lc_time)
lc_time = locale;
- if (strlen(lc_monetary) == 0)
+ if (!lc_monetary)
lc_monetary = locale;
- if (strlen(lc_messages) == 0)
+ if (!lc_messages)
lc_messages = locale;
}
static void
check_authmethod_unspecified(const char **authmethod)
{
- if (*authmethod == NULL || strlen(*authmethod) == 0)
+ if (*authmethod == NULL)
{
authwarning = _("\nWARNING: enabling \"trust\" authentication for local connections\n"
"You can change this by editing pg_hba.conf or using the option -A, or\n"
char *pgdata_get_env,
*pgdata_set_env;
- if (strlen(pg_data) == 0)
+ if (!pg_data)
{
pgdata_get_env = getenv("PGDATA");
if (pgdata_get_env && strlen(pgdata_get_env))
lc_time);
}
- if (strlen(encoding) == 0)
+ if (!encoding)
{
int ctype_enc;
void
setup_text_search(void)
{
- if (strlen(default_text_search_config) == 0)
+ if (!default_text_search_config)
{
default_text_search_config = find_matching_ts_config(lc_ctype);
- if (default_text_search_config == NULL)
+ if (!default_text_search_config)
{
printf(_("%s: could not find suitable text search configuration for locale \"%s\"\n"),
progname, lc_ctype);
/* form name of the place for the subdirectory or symlink */
subdirloc = psprintf("%s/pg_wal", pg_data);
- if (strcmp(xlog_dir, "") != 0)
+ if (xlog_dir)
{
int ret;
* Non-option argument specifies data directory as long as it wasn't
* already specified with -D / --pgdata
*/
- if (optind < argc && strlen(pg_data) == 0)
+ if (optind < argc && !pg_data)
{
pg_data = pg_strdup(argv[optind]);
optind++;
setup_bin_paths(argv[0]);
effective_user = get_id();
- if (strlen(username) == 0)
+ if (!username)
username = effective_user;
if (strncmp(username, "pg_", 3) == 0)