@@ -118,29 +118,29 @@ static const char *const auth_methods_local[] = {
118118static char * share_path = NULL ;
119119
120120/* values to be obtained from arguments */
121- static char * pg_data = "" ;
122- static char * encoding = "" ;
123- static char * locale = "" ;
124- static char * lc_collate = "" ;
125- static char * lc_ctype = "" ;
126- static char * lc_monetary = "" ;
127- static char * lc_numeric = "" ;
128- static char * lc_time = "" ;
129- static char * lc_messages = "" ;
130- static const char * default_text_search_config = "" ;
131- static char * username = "" ;
121+ static char * pg_data = NULL ;
122+ static char * encoding = NULL ;
123+ static char * locale = NULL ;
124+ static char * lc_collate = NULL ;
125+ static char * lc_ctype = NULL ;
126+ static char * lc_monetary = NULL ;
127+ static char * lc_numeric = NULL ;
128+ static char * lc_time = NULL ;
129+ static char * lc_messages = NULL ;
130+ static const char * default_text_search_config = NULL ;
131+ static char * username = NULL ;
132132static bool pwprompt = false;
133133static char * pwfilename = NULL ;
134134static char * superuser_password = NULL ;
135- static const char * authmethodhost = "" ;
136- static const char * authmethodlocal = "" ;
135+ static const char * authmethodhost = NULL ;
136+ static const char * authmethodlocal = NULL ;
137137static bool debug = false;
138138static bool noclean = false;
139139static bool do_sync = true;
140140static bool sync_only = false;
141141static bool show_setting = false;
142142static bool data_checksums = false;
143- static char * xlog_dir = "" ;
143+ static char * xlog_dir = NULL ;
144144
145145
146146/* internal vars */
@@ -1285,17 +1285,13 @@ bootstrap_template1(void)
12851285{
12861286 PG_CMD_DECL ;
12871287 char * * line ;
1288- char * talkargs = "" ;
12891288 char * * bki_lines ;
12901289 char headerline [MAXPGPATH ];
12911290 char buf [64 ];
12921291
12931292 printf (_ ("running bootstrap script ... " ));
12941293 fflush (stdout );
12951294
1296- if (debug )
1297- talkargs = "-d 5" ;
1298-
12991295 bki_lines = readfile (bki_file );
13001296
13011297 /* Check that bki file appears to be of the right version */
@@ -1359,7 +1355,9 @@ bootstrap_template1(void)
13591355 "\"%s\" --boot -x1 %s %s %s" ,
13601356 backend_exec ,
13611357 data_checksums ? "-k" : "" ,
1362- boot_options , talkargs );
1358+ boot_options ,
1359+ debug ? "-d 5" : "" );
1360+
13631361
13641362 PG_CMD_OPEN ;
13651363
@@ -2136,6 +2134,10 @@ check_locale_name(int category, const char *locale, char **canonname)
21362134 /* save may be pointing at a modifiable scratch variable, so copy it. */
21372135 save = pg_strdup (save );
21382136
2137+ /* for setlocale() call */
2138+ if (!locale )
2139+ locale = "" ;
2140+
21392141 /* set the locale with setlocale, to see if it accepts it. */
21402142 res = setlocale (category , locale );
21412143
@@ -2223,19 +2225,19 @@ setlocales(void)
22232225
22242226 /* set empty lc_* values to locale config if set */
22252227
2226- if (strlen ( locale ) > 0 )
2228+ if (locale )
22272229 {
2228- if (strlen ( lc_ctype ) == 0 )
2230+ if (! lc_ctype )
22292231 lc_ctype = locale ;
2230- if (strlen ( lc_collate ) == 0 )
2232+ if (! lc_collate )
22312233 lc_collate = locale ;
2232- if (strlen ( lc_numeric ) == 0 )
2234+ if (! lc_numeric )
22332235 lc_numeric = locale ;
2234- if (strlen ( lc_time ) == 0 )
2236+ if (! lc_time )
22352237 lc_time = locale ;
2236- if (strlen ( lc_monetary ) == 0 )
2238+ if (! lc_monetary )
22372239 lc_monetary = locale ;
2238- if (strlen ( lc_messages ) == 0 )
2240+ if (! lc_messages )
22392241 lc_messages = locale ;
22402242 }
22412243
@@ -2310,7 +2312,7 @@ usage(const char *progname)
23102312static void
23112313check_authmethod_unspecified (const char * * authmethod )
23122314{
2313- if (* authmethod == NULL || strlen ( * authmethod ) == 0 )
2315+ if (* authmethod == NULL )
23142316 {
23152317 authwarning = _ ("\nWARNING: enabling \"trust\" authentication for local connections\n"
23162318 "You can change this by editing pg_hba.conf or using the option -A, or\n"
@@ -2367,7 +2369,7 @@ setup_pgdata(void)
23672369 char * pgdata_get_env ,
23682370 * pgdata_set_env ;
23692371
2370- if (strlen ( pg_data ) == 0 )
2372+ if (! pg_data )
23712373 {
23722374 pgdata_get_env = getenv ("PGDATA" );
23732375 if (pgdata_get_env && strlen (pgdata_get_env ))
@@ -2479,7 +2481,7 @@ setup_locale_encoding(void)
24792481 lc_time );
24802482 }
24812483
2482- if (strlen ( encoding ) == 0 )
2484+ if (! encoding )
24832485 {
24842486 int ctype_enc ;
24852487
@@ -2589,10 +2591,10 @@ setup_data_file_paths(void)
25892591void
25902592setup_text_search (void )
25912593{
2592- if (strlen ( default_text_search_config ) == 0 )
2594+ if (! default_text_search_config )
25932595 {
25942596 default_text_search_config = find_matching_ts_config (lc_ctype );
2595- if (default_text_search_config == NULL )
2597+ if (! default_text_search_config )
25962598 {
25972599 printf (_ ("%s: could not find suitable text search configuration for locale \"%s\"\n" ),
25982600 progname , lc_ctype );
@@ -2728,7 +2730,7 @@ create_xlog_or_symlink(void)
27282730 /* form name of the place for the subdirectory or symlink */
27292731 subdirloc = psprintf ("%s/pg_wal" , pg_data );
27302732
2731- if (strcmp ( xlog_dir , "" ) != 0 )
2733+ if (xlog_dir )
27322734 {
27332735 int ret ;
27342736
@@ -3131,7 +3133,7 @@ main(int argc, char *argv[])
31313133 * Non-option argument specifies data directory as long as it wasn't
31323134 * already specified with -D / --pgdata
31333135 */
3134- if (optind < argc && strlen ( pg_data ) == 0 )
3136+ if (optind < argc && ! pg_data )
31353137 {
31363138 pg_data = pg_strdup (argv [optind ]);
31373139 optind ++ ;
@@ -3187,7 +3189,7 @@ main(int argc, char *argv[])
31873189 setup_bin_paths (argv [0 ]);
31883190
31893191 effective_user = get_id ();
3190- if (strlen ( username ) == 0 )
3192+ if (! username )
31913193 username = effective_user ;
31923194
31933195 if (strncmp (username , "pg_" , 3 ) == 0 )
0 commit comments