@@ -74,37 +74,38 @@ static int32 json_level = 0;
7474
7575static const char * lc_env_locale ;
7676typedef enum {
77- LOCALE_OUTPUT ,
78- LOCALE_ENV
77+ LOCALE_C , // Used for formatting output to unify the dot-based floating point representation
78+ LOCALE_ENV // Default environment locale
7979} output_numeric_locale ;
8080
8181#ifdef HAVE_USELOCALE
82- static locale_t env_locale , out_locale ;
82+ static locale_t env_locale , c_locale ;
8383#endif
8484void memorize_environment_locale () {
8585 lc_env_locale = (const char * )getenv ("LC_NUMERIC" );
8686 lc_env_locale = lc_env_locale != NULL ? lc_env_locale : "C" ;
8787#ifdef HAVE_USELOCALE
8888 env_locale = newlocale (LC_NUMERIC_MASK , lc_env_locale , (locale_t )0 );
89- out_locale = newlocale (LC_NUMERIC_MASK , "C" , (locale_t )0 );
89+ c_locale = newlocale (LC_NUMERIC_MASK , "C" , (locale_t )0 );
90+ #else
91+ #ifdef HAVE__CONFIGTHREADLOCALE
92+ _configthreadlocale (_ENABLE_PER_THREAD_LOCALE );
93+ #endif
9094#endif
9195}
9296
9397void free_environment_locale () {
9498#ifdef HAVE_USELOCALE
9599 freelocale (env_locale );
96- freelocale (out_locale );
100+ freelocale (c_locale );
97101#endif
98102}
99103
100104static void set_output_numeric_locale (output_numeric_locale loc ) {
101105#ifdef HAVE_USELOCALE
102- uselocale (loc == LOCALE_OUTPUT ? out_locale : env_locale );
106+ uselocale (loc == LOCALE_C ? c_locale : env_locale );
103107#else
104- #ifdef HAVE__CONFIGTHREADLOCALE
105- _configthreadlocale (_ENABLE_PER_THREAD_LOCALE );
106- #endif
107- setlocale (LC_NUMERIC , loc == LOCALE_OUTPUT ? lc_env_locale : "C" );
108+ setlocale (LC_NUMERIC , loc == LOCALE_C ? "C" : lc_env_locale );
108109#endif
109110}
110111
@@ -125,7 +126,7 @@ do_show(CatalogState *catalogState, InstanceState *instanceState,
125126 requested_backup_id != INVALID_BACKUP_ID )
126127 elog (ERROR , "You cannot specify --archive and (-i, --backup-id) options together" );
127128
128- set_output_numeric_locale (LOCALE_ENV );
129+ set_output_numeric_locale (LOCALE_C );
129130 /*
130131 * if instance is not specified,
131132 * show information about all instances in this backup catalog
@@ -148,7 +149,7 @@ do_show(CatalogState *catalogState, InstanceState *instanceState,
148149 show_instance (instanceState , INVALID_BACKUP_ID , true);
149150 }
150151 show_instance_end ();
151- set_output_numeric_locale (LOCALE_OUTPUT );
152+ set_output_numeric_locale (LOCALE_ENV );
152153
153154 return 0 ;
154155 }
@@ -167,7 +168,7 @@ do_show(CatalogState *catalogState, InstanceState *instanceState,
167168 show_instance (instanceState , requested_backup_id , false);
168169
169170 show_instance_end ();
170- set_output_numeric_locale (LOCALE_OUTPUT );
171+ set_output_numeric_locale (LOCALE_ENV );
171172
172173 return 0 ;
173174 }
@@ -181,7 +182,7 @@ do_show(CatalogState *catalogState, InstanceState *instanceState,
181182 else
182183 show_backup (instanceState , requested_backup_id );
183184
184- set_output_numeric_locale (LOCALE_OUTPUT );
185+ set_output_numeric_locale (LOCALE_ENV );
185186 return 0 ;
186187 }
187188}
0 commit comments