Temporary local string "oldlocale".

This commit is contained in:
2025-04-19 02:39:13 -04:00
parent 23d178d472
commit b5b137c2df

View File

@ -146,7 +146,7 @@ static int parseOption(char *name, char *value,
*/
void PrefsParser::parse(FILE *fp)
{
char *line, *name, *value, *oldLocale;
char *line, *name, *value;
int st, line_number = 1;
/* Symbol array, sorted alphabetically */
@ -252,7 +252,7 @@ void PrefsParser::parse(FILE *fp)
};
// changing the LC_NUMERIC locale (temporarily) to C
// avoids parsing problems with float numbers
oldLocale = dStrdup(setlocale(LC_NUMERIC, NULL));
std::string oldLocale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
// scan the file line by line
@ -272,6 +272,5 @@ void PrefsParser::parse(FILE *fp)
fclose(fp);
// restore the old numeric locale
setlocale(LC_NUMERIC, oldLocale);
dFree(oldLocale);
setlocale(LC_NUMERIC, oldLocale.c_str());
}