@ -178,7 +178,7 @@ static char bin_path[MAXPGPATH];
static char backend_exec [ MAXPGPATH ] ;
static void * pg_malloc ( size_t size ) ;
static char * x strdup( const char * s ) ;
static char * pg_ strdup( const char * s ) ;
static char * * replace_token ( char * * lines ,
const char * token , const char * replacement ) ;
@ -304,7 +304,7 @@ pg_malloc(size_t size)
}
static char *
x strdup( const char * s )
pg_ strdup( const char * s )
{
char * result ;
@ -453,7 +453,7 @@ readfile(const char *path)
rewind ( infile ) ;
nlines = 0 ;
while ( fgets ( buffer , maxlength + 1 , infile ) ! = NULL )
result [ nlines + + ] = x strdup( buffer ) ;
result [ nlines + + ] = pg_ strdup( buffer ) ;
fclose ( infile ) ;
free ( buffer ) ;
@ -796,7 +796,7 @@ get_id(void)
}
# endif
return x strdup( pw - > pw_name ) ;
return pg_ strdup( pw - > pw_name ) ;
}
static char *
@ -805,7 +805,7 @@ encodingid_to_string(int enc)
char result [ 20 ] ;
sprintf ( result , " %d " , enc ) ;
return x strdup( result ) ;
return pg_ strdup( result ) ;
}
/*
@ -888,10 +888,10 @@ find_matching_ts_config(const char *lc_type)
* underscore . Just for paranoia , we also stop at ' . ' or ' @ ' .
*/
if ( lc_type = = NULL )
langname = x strdup( " " ) ;
langname = pg_ strdup( " " ) ;
else
{
ptr = langname = x strdup( lc_type ) ;
ptr = langname = pg_ strdup( lc_type ) ;
while ( * ptr & & * ptr ! = ' _ ' & & * ptr ! = ' . ' & & * ptr ! = ' @ ' )
ptr + + ;
* ptr = ' \0 ' ;
@ -1410,10 +1410,10 @@ bootstrap_template1(void)
* there doesn ' t seem to be any compelling reason to do that .
*/
snprintf ( cmd , sizeof ( cmd ) , " LC_COLLATE=%s " , lc_collate ) ;
putenv ( x strdup( cmd ) ) ;
putenv ( pg_ strdup( cmd ) ) ;
snprintf ( cmd , sizeof ( cmd ) , " LC_CTYPE=%s " , lc_ctype ) ;
putenv ( x strdup( cmd ) ) ;
putenv ( pg_ strdup( cmd ) ) ;
unsetenv ( " LC_ALL " ) ;
@ -1531,7 +1531,7 @@ get_set_pwd(void)
while ( i > 0 & & ( pwdbuf [ i - 1 ] = = ' \r ' | | pwdbuf [ i - 1 ] = = ' \n ' ) )
pwdbuf [ - - i ] = ' \0 ' ;
pwd1 = x strdup( pwdbuf ) ;
pwd1 = pg_ strdup( pwdbuf ) ;
}
printf ( _ ( " setting password ... " ) ) ;
@ -2065,7 +2065,7 @@ set_info_version(void)
minor = 0 ,
micro = 0 ;
char * endptr ;
char * vstr = x strdup( PG_VERSION ) ;
char * vstr = pg_ strdup( PG_VERSION ) ;
char * ptr ;
ptr = vstr + ( strlen ( vstr ) - 1 ) ;
@ -2433,7 +2433,7 @@ locale_date_order(const char *locale)
save = setlocale ( LC_TIME , NULL ) ;
if ( ! save )
return result ;
save = x strdup( save ) ;
save = pg_ strdup( save ) ;
setlocale ( LC_TIME , locale ) ;
@ -2493,14 +2493,14 @@ check_locale_name(int category, const char *locale, char **canonname)
return false ; /* won't happen, we hope */
/* save may be pointing at a modifiable scratch variable, so copy it. */
save = x strdup( save ) ;
save = pg_ strdup( save ) ;
/* set the locale with setlocale, to see if it accepts it. */
res = setlocale ( category , locale ) ;
/* save canonical name if requested. */
if ( res & & canonname )
* canonname = x strdup( res ) ;
* canonname = pg_ strdup( res ) ;
/* restore old value. */
if ( ! setlocale ( category , save ) )
@ -2588,34 +2588,34 @@ setlocales(void)
if ( check_locale_name ( LC_CTYPE , lc_ctype , & canonname ) )
lc_ctype = canonname ;
else
lc_ctype = x strdup( setlocale ( LC_CTYPE , NULL ) ) ;
lc_ctype = pg_ strdup( setlocale ( LC_CTYPE , NULL ) ) ;
if ( check_locale_name ( LC_COLLATE , lc_collate , & canonname ) )
lc_collate = canonname ;
else
lc_collate = x strdup( setlocale ( LC_COLLATE , NULL ) ) ;
lc_collate = pg_ strdup( setlocale ( LC_COLLATE , NULL ) ) ;
if ( check_locale_name ( LC_NUMERIC , lc_numeric , & canonname ) )
lc_numeric = canonname ;
else
lc_numeric = x strdup( setlocale ( LC_NUMERIC , NULL ) ) ;
lc_numeric = pg_ strdup( setlocale ( LC_NUMERIC , NULL ) ) ;
if ( check_locale_name ( LC_TIME , lc_time , & canonname ) )
lc_time = canonname ;
else
lc_time = x strdup( setlocale ( LC_TIME , NULL ) ) ;
lc_time = pg_ strdup( setlocale ( LC_TIME , NULL ) ) ;
if ( check_locale_name ( LC_MONETARY , lc_monetary , & canonname ) )
lc_monetary = canonname ;
else
lc_monetary = x strdup( setlocale ( LC_MONETARY , NULL ) ) ;
lc_monetary = pg_ strdup( setlocale ( LC_MONETARY , NULL ) ) ;
# if defined(LC_MESSAGES) && !defined(WIN32)
if ( check_locale_name ( LC_MESSAGES , lc_messages , & canonname ) )
lc_messages = canonname ;
else
lc_messages = x strdup( setlocale ( LC_MESSAGES , NULL ) ) ;
lc_messages = pg_ strdup( setlocale ( LC_MESSAGES , NULL ) ) ;
# else
/* when LC_MESSAGES is not available, use the LC_CTYPE setting */
if ( check_locale_name ( LC_CTYPE , lc_messages , & canonname ) )
lc_messages = canonname ;
else
lc_messages = x strdup( setlocale ( LC_CTYPE , NULL ) ) ;
lc_messages = pg_ strdup( setlocale ( LC_CTYPE , NULL ) ) ;
# endif
}
@ -2910,7 +2910,7 @@ main(int argc, char *argv[])
switch ( c )
{
case ' A ' :
authmethodlocal = authmethodhost = x strdup( optarg ) ;
authmethodlocal = authmethodhost = pg_ strdup( optarg ) ;
/*
* When ident is specified , use peer for local connections .
@ -2923,22 +2923,22 @@ main(int argc, char *argv[])
authmethodhost = " ident " ;
break ;
case 10 :
authmethodlocal = x strdup( optarg ) ;
authmethodlocal = pg_ strdup( optarg ) ;
break ;
case 11 :
authmethodhost = x strdup( optarg ) ;
authmethodhost = pg_ strdup( optarg ) ;
break ;
case ' D ' :
pg_data = x strdup( optarg ) ;
pg_data = pg_ strdup( optarg ) ;
break ;
case ' E ' :
encoding = x strdup( optarg ) ;
encoding = pg_ strdup( optarg ) ;
break ;
case ' W ' :
pwprompt = true ;
break ;
case ' U ' :
username = x strdup( optarg ) ;
username = pg_ strdup( optarg ) ;
break ;
case ' d ' :
debug = true ;
@ -2952,43 +2952,43 @@ main(int argc, char *argv[])
do_sync = false ;
break ;
case ' L ' :
share_path = x strdup( optarg ) ;
share_path = pg_ strdup( optarg ) ;
break ;
case 1 :
locale = x strdup( optarg ) ;
locale = pg_ strdup( optarg ) ;
break ;
case 2 :
lc_collate = x strdup( optarg ) ;
lc_collate = pg_ strdup( optarg ) ;
break ;
case 3 :
lc_ctype = x strdup( optarg ) ;
lc_ctype = pg_ strdup( optarg ) ;
break ;
case 4 :
lc_monetary = x strdup( optarg ) ;
lc_monetary = pg_ strdup( optarg ) ;
break ;
case 5 :
lc_numeric = x strdup( optarg ) ;
lc_numeric = pg_ strdup( optarg ) ;
break ;
case 6 :
lc_time = x strdup( optarg ) ;
lc_time = pg_ strdup( optarg ) ;
break ;
case 7 :
lc_messages = x strdup( optarg ) ;
lc_messages = pg_ strdup( optarg ) ;
break ;
case 8 :
locale = " C " ;
break ;
case 9 :
pwfilename = x strdup( optarg ) ;
pwfilename = pg_ strdup( optarg ) ;
break ;
case ' s ' :
show_setting = true ;
break ;
case ' T ' :
default_text_search_config = x strdup( optarg ) ;
default_text_search_config = pg_ strdup( optarg ) ;
break ;
case ' X ' :
xlog_dir = x strdup( optarg ) ;
xlog_dir = pg_ strdup( optarg ) ;
break ;
default :
/* getopt_long already emitted a complaint */
@ -3005,7 +3005,7 @@ main(int argc, char *argv[])
*/
if ( optind < argc & & strlen ( pg_data ) = = 0 )
{
pg_data = x strdup( argv [ optind ] ) ;
pg_data = pg_ strdup( argv [ optind ] ) ;
optind + + ;
}
@ -3038,7 +3038,7 @@ main(int argc, char *argv[])
if ( pgdenv & & strlen ( pgdenv ) )
{
/* PGDATA found */
pg_data = x strdup( pgdenv ) ;
pg_data = pg_ strdup( pgdenv ) ;
}
else
{
@ -3069,7 +3069,7 @@ main(int argc, char *argv[])
ZeroMemory ( & pi , sizeof ( pi ) ) ;
cmdline = x strdup( GetCommandLine ( ) ) ;
cmdline = pg_ strdup( GetCommandLine ( ) ) ;
putenv ( " PG_RESTRICT_EXEC=1 " ) ;