@@ -74,37 +74,38 @@ static int32 json_level = 0;
74
74
75
75
static const char * lc_env_locale ;
76
76
typedef 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
79
79
} output_numeric_locale ;
80
80
81
81
#ifdef HAVE_USELOCALE
82
- static locale_t env_locale , out_locale ;
82
+ static locale_t env_locale , c_locale ;
83
83
#endif
84
84
void memorize_environment_locale () {
85
85
lc_env_locale = (const char * )getenv ("LC_NUMERIC" );
86
86
lc_env_locale = lc_env_locale != NULL ? lc_env_locale : "C" ;
87
87
#ifdef HAVE_USELOCALE
88
88
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
90
94
#endif
91
95
}
92
96
93
97
void free_environment_locale () {
94
98
#ifdef HAVE_USELOCALE
95
99
freelocale (env_locale );
96
- freelocale (out_locale );
100
+ freelocale (c_locale );
97
101
#endif
98
102
}
99
103
100
104
static void set_output_numeric_locale (output_numeric_locale loc ) {
101
105
#ifdef HAVE_USELOCALE
102
- uselocale (loc == LOCALE_OUTPUT ? out_locale : env_locale );
106
+ uselocale (loc == LOCALE_C ? c_locale : env_locale );
103
107
#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 );
108
109
#endif
109
110
}
110
111
@@ -125,7 +126,7 @@ do_show(CatalogState *catalogState, InstanceState *instanceState,
125
126
requested_backup_id != INVALID_BACKUP_ID )
126
127
elog (ERROR , "You cannot specify --archive and (-i, --backup-id) options together" );
127
128
128
- set_output_numeric_locale (LOCALE_ENV );
129
+ set_output_numeric_locale (LOCALE_C );
129
130
/*
130
131
* if instance is not specified,
131
132
* show information about all instances in this backup catalog
@@ -148,7 +149,7 @@ do_show(CatalogState *catalogState, InstanceState *instanceState,
148
149
show_instance (instanceState , INVALID_BACKUP_ID , true);
149
150
}
150
151
show_instance_end ();
151
- set_output_numeric_locale (LOCALE_OUTPUT );
152
+ set_output_numeric_locale (LOCALE_ENV );
152
153
153
154
return 0 ;
154
155
}
@@ -167,7 +168,7 @@ do_show(CatalogState *catalogState, InstanceState *instanceState,
167
168
show_instance (instanceState , requested_backup_id , false);
168
169
169
170
show_instance_end ();
170
- set_output_numeric_locale (LOCALE_OUTPUT );
171
+ set_output_numeric_locale (LOCALE_ENV );
171
172
172
173
return 0 ;
173
174
}
@@ -181,7 +182,7 @@ do_show(CatalogState *catalogState, InstanceState *instanceState,
181
182
else
182
183
show_backup (instanceState , requested_backup_id );
183
184
184
- set_output_numeric_locale (LOCALE_OUTPUT );
185
+ set_output_numeric_locale (LOCALE_ENV );
185
186
return 0 ;
186
187
}
187
188
}
0 commit comments