Skip to content

setlocale( LC_ALL, "") changes the locale for the entire application #770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dinghram opened this issue Nov 7, 2018 · 40 comments
Closed

Comments

@dinghram
Copy link

dinghram commented Nov 7, 2018

In tidylib.c:
TY_(tidySetLanguage)( setlocale( LC_ALL, "") );

The purpose of this line, as far as I can tell, is not to change the application locale, but only to query it. However, that is not what happens. Rather, it changes the behavior of the entire application to the point where my customers in Europe could not enter floating point values as they were parsed incorrectly after this call that I did not expect to find in a 3rd party library.

From the documentation, if you want to query the locale without changing it:

If locale is a null pointer, setlocale queries the current C locale without modifying it.

@geoffmcl
Copy link
Contributor

@dinghram yes, libtidy does indeed use setlocale(LC_ALL, ""), essentially to query, and set the library language... sorry if this seems to cause you a problem...

Unfortunately, the setlocale(LC_ALL, NULL) you suggest does not yield the actual language in use, it returns C, so is not helpful in this regard...

Is there another way to get/query the system default language, compatible to WIN32 and UNIX?

But this code can be avoided by apps using libtidy, by one of 2 ways -

Either successfully using the tidySetLanguage API, called from their own app before the call to tidyCreate()... this action will set TY_(tidyGetLanguageSetByUser)() == yes...

Or compiling a libtidy without localization support, using like cmake ../.. -DSUPPORT_LOCALIZATIONS:BOOL=OFF [other options]... this will completely remove that code from libtidy... and remove all the language headers leaving only language_en.h as the single message file...

Maybe we need to improve the documentation in this regard? Suggestions appreciated... thanks...

Does this help?

@ler762
Copy link
Contributor

ler762 commented Nov 14, 2018

@dinghram that setlocale call seems to be required. Take a look at
https://www.gnu.org/software/libc/manual/html_node/Setting-the-Locale.html
ISO C says that all programs start by default in the standard ‘C’ locale. To use the locales specified by the environment, you must call setlocale. Call it as follows:
setlocale (LC_ALL, "");
to select a locale based on the user choice of the appropriate environment variables.

Would it be possible to get the output from locale and examples of the input your customers said were parsed incorrectly?

@brlin-tw
Copy link
Contributor

brlin-tw commented Nov 29, 2018

I believe the setlocale call is proper, we should fix whatever problems that the user's locale cause after adopting it instead of keep it C or C.UTF-8

@langemeijer
Copy link

It is unacceptable for any library function to have changing the locale as side-effect.
At least change the locale back to what is was!

@brlin-tw
Copy link
Contributor

brlin-tw commented Dec 3, 2018

At least change the locale back to what is was!

Good point, this should be as easy as a setlocale(LC_ALL, "C") call.

@langemeijer
Copy link

No it isn't! I think you are missing the point on how setlocale() works in the context of an application. setlocale() keeps state for this process. In my case a php thread is setlocale()'d to the locale set for a logged-in user on a website. The user gets correctly formatted dates and such because of this.

Possibly you should not change the locale if it is set to a non-'C' value. Autodetecting the locale according to the environment variables should only be done if no locale is set.

@langemeijer
Copy link

langemeijer commented Dec 3, 2018

Also, you should use LC_MESSAGES for this, not LC_ALL.

I really think you should not be doing any initialization. If library code finds an uninitialized locale situation that's just bad luck and the code should fallback to a decent default language. That is wat "C" is for.

setlocale() documentation http://man7.org/linux/man-pages/man3/setlocale.3.html says:

On startup of the main program, the portable "C" locale is selected
as default. A program may be made portable to all locales by
calling: setlocale(LC_ALL, "");

Emphasis on program is mine.

@brlin-tw
Copy link
Contributor

brlin-tw commented Dec 3, 2018

Also, you should use LC_MESSAGES for this, not LC_ALL.

LC_MESSAGES isn't portable(it isn't in the Standard C, POSIX maybe)

@brlin-tw
Copy link
Contributor

brlin-tw commented Dec 3, 2018

What about:

/* Backup the previous locale */
char *previous_locale = setlocale(LC_ALL, NULL);

/* Inherit the locale from the environment and use it to set Tidy's language */
TY_(tidySetLanguage)( setlocale( LC_ALL, "" ) );

/* Restore the previous locale */
setlocale(LC_ALL, previous_locale);

Does that make sense and solve the OP's problem?

RETURN VALUE
A successful call to setlocale() returns an opaque string that corresponds to the locale
set. This string may be allocated in static storage. The string returned is such that a
subsequent call with that string and its associated category will restore that part of the
process's locale
. The return value is NULL if the request cannot be honored.

@geoffmcl
Copy link
Contributor

geoffmcl commented Dec 3, 2018

I certainly agree with @langemeijer -

It is unacceptable for any library function to have changing the locale as side-effect. At least change the locale back to what is was!

@Lin-Buo-Ren maybe the above save and restore patch could be added to PR #785 ...

libTidy only wants a way to auto-detect the users preferred language for LC_MESSAGES output... not in any way effect numeric or date output of the system...

It certainly does not want the change anything... just detect...

In unix, at least, the env vars LC_MESSAGES, or LANGUAGE, may means libTidy does not need, use setlocale( LC_ALL, "" ), so seems the way to go, with or without the patch to save and restore...

Look forward to further feedback on this, and related #783 ... looking positive... thanks...

@russianfool
Copy link

@Lin-Buo-Ren: The "check, then change back" is not great in a library either. For multi-threaded users this all falls apart, since there's no guarantee that you'll cache or restore the locale appropriately (T2 caches T1's modified state, and "restores" that modified state when T2 is done; if T1 has finished first, global locale has been reset).

Although maybe Tidy isn't really meant for multi-threaded use; the only spots that I've found so far that break this are the setlocale (which is fine with SUPPORT_LOCALIZATIONS off, or by pre-initializing the language), and the tag_defs set-reset usage (although here due to concurrent table use; easy enough to thread-local the thing).

@langemeijer
Copy link

@geoffmcl wrote

Unfortunately, the setlocale(LC_ALL, NULL) you suggest does not yield the actual language in use, it returns C, so is not helpful in this regard...

If the application sets a locale, which is should if it is deemed appropriate, that locale is returned. In my opinion 'C' should fallback to 'en_EN'.
(pseudo-code)

locale = setlocale(LC_ALL, NULL);

if (locale == 'C') {
   TY_(tidySetLanguage)( 'en_EN' );
} else {
   TY_(tidySetLanguage)( locale );
}

As an alternative, (still not very elegant, because I think setlocale( LC_ALL, "" ) should not be in a library) I would suggest the following approach: (pseudo-code)

previous_locale = setlocale(LC_ALL, NULL);

if (previous_locale == 'C') {
   /* Inherit the locale from the environment and use it to set Tidy's language */
   TY_(tidySetLanguage)( setlocale( LC_ALL, "" ) );
   /* Restore the previous locale */
   setlocale(LC_ALL, previous_locale);
}

@geoffmcl
Copy link
Contributor

geoffmcl commented Dec 7, 2018

@ler762, @Lin-Buo-Ren, @russianfool, @langemeijer, all, thank you for the helpful comments...

I too have tried lots of things... see setlocale in tidy-test and test-locale for some of these efforts...

While #783 is more about i18n console tidy support through environment variable, they certainly share the same libTidy code... and may have a common solution...

Since this is like libTidy's gettext function, I was looking at - 2.3.2 Locale Environment Variables, quoted, in part -

A locale is composed of several locale categories, see Aspects. When a program looks up locale dependent values, 
it does this according to the following environment variables, in priority order:

LANGUAGE
LC_ALL
LC_xxx, according to selected locale category: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, ...
LANG

Given that a libTidy user already has the choices of (a) excluding SUPPORT_LOCALIZATIONS in the build, or (b) by pre-setting the tidySetLanguage, before creating a document...

The following suggested pseudo-code seems to add to that, in that the user's app can further ensure LANGUAGE, ..., LANG, are set in the environment before calling tidyCreate... thus no setlocale( LC_ALL, "" ) is needed...

#if SUPPORT_LOCALIZATIONS
    if ( TY_(tidyGetLanguageSetByUser)() == no ) {
        /*\
         *  Is. #770 #783 - this should be 'last' choice, if at all?
         *  TY_(tidySetLanguage)( setlocale( LC_ALL, "") );
         *  That is take every other opportunity to set the 'language'
        \*/
        if( ! TY_(tidySetLanguage)( getenv( "LANGUAGE" ) ) ) {
            if( ! TY_(tidySetLanguage)( getenv( "LC_MESSAGES" ) ) ) {
                if( ! TY_(tidySetLanguage)( getenv( "LANG" ) ) ) {
                    char *current = setlocal( LC_ALL, NULL );
                    if( ! TY_(tidySetLanguage)( current ) ) {
#ifndef NO_LIBTIDY_SETLOCALE    /* optional, maybe overkill, ... */
                        /* no choice but to briefly disturb things */
                        TY_(tidySetLanguage)( setlocale( LC_ALL, "" ) );
                        current = setlocal( LC_ALL, current );
#endif /* NO_LIBTIDY_SETLOCALE */
                    }
                }
            }
        }
    }
#endif /* SUPPORT_LOCALIZATIONS */

This does not address any threading issue, but if neccessary the tidyCreate() could be run in a critical section... or something...

I am not sure the new suggested compile flag, like NO_LIBTIDY_SETLOCALE, is necessary, or would ever have a use case... so not keen on this...

Also this does not yet address any tidy doc changes... nor maybe any potential cross-platform issues...

To repeat, just looking for a non-invasive way to setup the libTidy gettext language to use...

Further feedback very welcome to reach the best solution... thanks...

@balthisar
Copy link
Member

This used to be in the console application. A change early this year moved it to the library. I would suggest moving it back to the console application.

@ler762
Copy link
Contributor

ler762 commented Dec 9, 2018

I agree with the others about library functions shouldn't change the locale. The calling program should be responsible for setting the locale - as well as calling tidySetLanguage.

Take another look at #770 (comment)

In my case a php thread is setlocale()'d to the locale set for a logged-in user on a website. The user gets correctly formatted dates and such because of this.

Unless the calling program has per-thread environment variables and the calling program sets all the LC_xxx, LANG, whatevers correctly, setlocale( LC_ALL, "") is going to do the wrong thing occasionally.

So this bit in src/tidylib.c goes:

#if SUPPORT_LOCALIZATIONS
    if ( TY_(tidyGetLanguageSetByUser)() == no )
    {
        TY_(tidySetLanguage)( setlocale( LC_ALL, "") );
    }
#endif

as well as the

#if SUPPORT_LOCALIZATIONS
#  include "locale.h"
#endif

and add something like

#if SUPPORT_LOCALIZATIONS
    setlocale(LC_ALL, "");
    TY_(tidySetLanguage)( setlocale( LC_MESSAGES, "") );
#endif

to console/tidy.c before the call to tidyCreate()

and update the tidylib docs + examples to show the calling program setting the locale & tidy language.

@geoffmcl
Copy link
Contributor

No time tonight, but it seems we are mostly agreed... and now there is #780 as further proof... thanks...

I will try to work on this with my ideas, discoveries... in the coming days...

Feel PR #785 is little step in the right direction... but needs more...

And then there is doc changes to match...

Look forward to more patch/code suggestions... thanks...

@cmb69
Copy link
Contributor

cmb69 commented Dec 11, 2018

This used to be in the console application. A change early this year moved it to the library. I would suggest moving it back to the console application.

I second that. In my opinion, reverting 57f623e is the most reasonable way forward. Clients of libtidy could still call tidySetLanguage() if they desire.

@geoffmcl
Copy link
Contributor

While it seems all fully agreed that a library should not do setlocale( LC_ALL, "" ), without a proper reset, are we also abandoning the library auto-detecting of the language? Why?

Yes, libTidy language selection can be made the sole responsibility of the program using libTidy... an additional API burden...

In our case the console app tidy.c could have this added, re-added... but there is potentially many other libTidy users...

But it seems the following non-invasive library pseudo-code would keep auto-detection -

#if SUPPORT_LOCALIZATIONS
    if ( TY_(tidyGetLanguageSetByUser)() == no ) {
        /*\
         *  Using app has 'not' selected a language
         *  Is. #770 #783 #780 - this should be 'last' choice, if at all?
         *  TY_(tidySetLanguage)( setlocale( LC_ALL, "") );
         *  That is take every other opportunity to set the 'language'
        \*/
        if( ! TY_(tidySetLanguage)( getenv( "LANGUAGE" ) ) ) {
            if( ! TY_(tidySetLanguage)( getenv( "LC_MESSAGES" ) ) ) {
                if( ! TY_(tidySetLanguage)( getenv( "LANG" ) ) ) {
                    char *current = setlocal( LC_ALL, NULL );
                    if( ! TY_(tidySetLanguage)( current ) ) {
#ifdef _WIN32    /* perhaps there is some other way for windows... */
                        /* no choice but to briefly disturb things */
                        char *previous =  0;
                        if (current)
                            previous = strdup(current);
                        TY_(tidySetLanguage)( setlocale( LC_ALL, "" ) );
                        if (prevous) {
                            current = setlocal( LC_ALL, previous );
                            free(previous);
                        }
#endif /* _WIN32 */
                    }
                }
            }
        }
    }
#endif /* SUPPORT_LOCALIZATIONS */

Note this is guarded by if ( TY_(tidyGetLanguageSetByUser)() == no )... has the user done tidySetLanguage?

Still doing research on the Windows _WIN32, code... note, have found that the current pointer can become invalid, hence the copy... but would certainly appreciate feedback on this... it seems there are other problems in the Windows language selection... see TY_(tidyNormalizedLocaleName)... etc...

Anyway, just a suggestion for discussion... Look forward to further feedback... thanks...

@cmb69
Copy link
Contributor

cmb69 commented Dec 14, 2018

While it seems all fully agreed that a library should not do setlocale( LC_ALL, "" ), without a proper reset, are we also abandoning the library auto-detecting of the language? Why?

Well, to keep things simple. setlocale() affects the process, so in a multi-threaded environment there might be issues. For instance, thread A might just have read the locale, then thread B might change the locale, and finally thread A might reset to the old locale. Making sure that this won't happen is certainly possible, but might not be that simple, and I don't think that auto-detecting the language is really important for the library.

Anyhow, would checking the environment variables be really necessary? Both the POSIX and the MSDN docs say that passing NULL to the locale parameter of setlocale() will query the current locale setting without modifying it.

@geoffmcl
Copy link
Contributor

@cmb69 thank you for your feedback...

Agree to keep things simple ;=))

But as you point out, not all setlocale() affects the process... setlocal(LC_ALL, NULL) only queries...

In all that I can read, in the UNIX environment, the environment variables LANGUAGE, ..., LANG are used to establish, and enable, gettext, which libTidy sort of emulates, so it seems to make a lot of sense to use them to establish a default libTidy language... harmlessly...

In Windows, those environment variables do not normally exist, and setlocal(LC_ALL, NULL) only return C, so is useless. Only setlocale(LC_ALL, "") returns a language string... if there is some concern about threading in this environment, then the set and reset could be in a Critical Section wrapper - no big deal...

StartCriticalSection();
    DoSomethingImportant();
EndCriticalSection();

Or even some other native Windows API, like GetUserDefaultUILanguage(), or maybe others... as mentioned still exploring these...

I don't think that auto-detecting the language is really important for the library

Ok, if ALL fears of affecting the process, and threading are removed, that is all fears and FUD, then WHY NOT?

I personally have several apps using libTidy, and I expect the library to auto-select the language, else forget localization...

And are we to now force an additional burden on the likes of PHP, Perl, Edbrowse, Notepad++, etc, etc... to name a few... to modify their interface with the libTidy... add an additional API call, if they want any language support libTidy has... which I agree at this stage is very minimal... to some for sure it would not matter...

That's my thoughts on auto-detection... so, why not?

Look forward to further feedback... thanks...

@ler762
Copy link
Contributor

ler762 commented Dec 15, 2018

are we also abandoning the library auto-detecting of the language?

yes

Why?

Because the caller is the only one who knows how it should be set.

I personally have several apps using libTidy, and I expect the library to auto-select the language, else forget localization...

It's your app, presumably you still have the source code, add this line before calling tidyCreate()
tidySetLanguage( setlocale( LC_ALL, "") );
and you've got what the library is doing now.

Recall

In my case a php thread is setlocale()'d to the locale set for a logged-in user on a website. The user gets correctly formatted dates and such because of this.

Consider what happens in a German locale with this snippet in the library:

#if SUPPORT_LOCALIZATIONS
    if ( TY_(tidyGetLanguageSetByUser)() == no ) {
        /*\
         *  Using app has 'not' selected a language

Tidy doesn't have a German translation, so TY_(tidyGetLanguageSetByUser) will be no. Or do you get a different result after calling tidySetLanguage("de_DE")?

You can't look at environment variables because they're set for the calling php program, not the logged-in user on the website. And you can't call setlocale( LC_ALL, "" ) for the same reason.. The library doesn't know anything about the logged-in user on the website, so there's no way the library can set the locale correctly.

You have to make the calling program responsible for setting the locale & selecting the language.

@langemeijer
Copy link

To add to @ler762: setlocale()'s behaviour to read the environment variables only makes any sense for applications started by a user on the command line. It does not make sense for a daemon (service) running in the background.

@cmb69
Copy link
Contributor

cmb69 commented Dec 18, 2018

You can't look at environment variables because they're set for the calling php program, not the logged-in user on the website. And you can't call setlocale( LC_ALL, "" ) for the same reason.. The library doesn't know anything about the logged-in user on the website, so there's no way the library can set the locale correctly.

Is there currently any way to set the desired locale for Tidy in PHP?

@ler762
Copy link
Contributor

ler762 commented Dec 27, 2018

If the desired locale is one tidy has a translation for - yes, tidySetLanguage(locale)
The problem is that tidy doesn't have all that many translations, so something like

setlocale( ... );
if ( ! tidySetLanguage( ... ) ) tidySetLanguage("en_US");

would probably be enough to keep tidy from calling setlocale(LC_ALL, "") for you.

@cmb69
Copy link
Contributor

cmb69 commented Dec 27, 2018

@ler762 I'm particularly interested whether it is possible to set tidy's locale from PHP (without relying on any setlocale detection libtidy does or may do in the future). If it is not possible, it would make sense to expose a PHP function/method to allow this.

@ler762
Copy link
Contributor

ler762 commented Dec 27, 2018

src/tidylib.c has this bit:

#if SUPPORT_LOCALIZATIONS
    if ( TY_(tidyGetLanguageSetByUser)() == no )
    {
        TY_(tidySetLanguage)( setlocale( LC_ALL, "") );
    }
#endif

As far as I can tell, TY_(tidyGetLanguageSetByUser)() == yes only if tidySetLanguage() has been called with a locale that tidy knows about.

I know zip about PHP, so you're going to have to do your own testing, but it sure looks like the calling program doing

if ( ! tidySetLanguage( ... ) ) tidySetLanguage("en_US");

before calling tidyCreate() would be enough to keep libtidy from messing with the locale.

@geoffmcl
Copy link
Contributor

Thanks to the comments here, though not all!, others, refs and testing, am now convinced setlocale( LC_ALL, "" ) should not presently be in libTidy... phew...

Accordingly propose the following patch to fix this bug -

#if SUPPORT_LOCALIZATIONS
    if ( TY_(tidyGetLanguageSetByUser)() == no ) {
        /*\
         *  Is. #770 #783 #780 and maybe others - 
         *  using 'setlocale(LC_ALL, "")' is a 'bad' choice!
        \*/
    }
#endif /* SUPPORT_LOCALIZATIONS */

Will get to it shortly, probably in conjuction with PR #785... maybe the weekend... hopefully...

@geoffmcl
Copy link
Contributor

geoffmcl commented Jan 8, 2019

@dinghram have eventually removed setlocal(LC_ALL, "") from libTidy... thanks for this issue...

Hope you, and/or others, get the chance to pull, build, and test from version 5.7.18 on, so we can close this... thanks..

@cmb69
Copy link
Contributor

cmb69 commented Jan 8, 2019

I have tested PHP 7.3.1 with tidy 5.7.18, and can confirm that #780 is fixed, and I couldn't detect any regressions. Thanks!

Sorry, for the off-topic discussion which I started above.

@AnrDaemon
Copy link

You can't realistically expect two different runtimes, following two different standards, to have a common unambiguous behavior in every specific situation.

There's no such thing as "default language" other than "C" in POSIX, unless you make it to be. I.e. using variables such as LANG, LC_MESSAGES et cetera.

For Windows, the situation is much better, as that explicitly defined in the runtime and can be queried using appropriate API calls.
A good starting point could be https://blogs.msdn.microsoft.com/shawnste/2011/11/09/user-locale-system-locale-ui-language-language-profile-all-that/

@ler762
Copy link
Contributor

ler762 commented Jan 10, 2019

@AnrDaemon if you're responding to my cygwin msg, take a look at http://www.html-tidy.org/developer/
What would you add to the sample program to show how to set the locale & language?

@AnrDaemon
Copy link

AnrDaemon commented Jan 10, 2019

It was a reference to the very attempt at using setlocale and expecting it to produce any usable results.
Why do you want to change locale of a running program from within a library that is not relevant to locale operations to begin with?

@geoffmcl
Copy link
Contributor

@cmb69 thank you for the testing and report on 5.7.18... good news...

@AnrDaemon agree with you, one can not expect two different runtimes, ..., to have a common unambiguous behavior...... that would be code heaven ;=))

Your MSDN link suggests, clearly, you have to understand the distinction between "locale" and "language".

It is my understanding, Tidy, in general, has no interest in what locale it is run in, and does NOT want to SET any particular locale at all... FULL STOP...

Tidy did, for a time, incorrectly used setlocal(LC_ALL, ""), now REMOVED, thinking of it as a benign way to detect the "language"... sorry... IMO, a mistake, now corrected...

@ler762, maybe I do not understand correctly! Why do you want to set the locale? Tidy is not the correct place for a tutorial on setting the locale. Tidy 100% accepts the user's environment - as stated, has no interest...

And the API docs already document how to set the language if you really need to...

Have now also done lots more testing, and while there may be other issues, to be addressed separately, in their own issue, this seems closed... thanks for all the participation...

@ler762
Copy link
Contributor

ler762 commented Jan 10, 2019

Why do you want to change locale of a running program from within a library that is not relevant to locale operations to begin with?

I'd rather not have the library change anything; it still might change the language, so like to update the tidylib example program.
(http://www.html-tidy.org/developer/#developer20000401part_sample_program)

The example program doesn't set the locale or tidy language. Now take a look at https://github.com/htacg/tidy-html5/blob/next/src/tidylib.c#L104

If the calling program doesn't set the language for tidy to use the library will

  1. try to set the language to whatever 'getenv( "LC_MESSAGES" )' returns. In the example, the program hasn't called setlocale(), so getenv("LC_MESSAGES") returns "C", which isn't a valid language for tidy, so we do

  2. try to set the language to whatever 'getenv("LANG")' returns. Which may or may not be the right thing to do.

Now pretend the example program has this bit before calling tidyCreate

  setlocale(LC_ALL, "");  // get out of C locale
  ok = tidySetLanguage(setlocale(LC_MESSAGES, NULL)); // set translation for tidy to use
  if ( ! ok ) tidySetLanguage("en_US.utf8");          // translation doesn't exist, default to English

So now when the program does the TidyDoc tdoc = tidyCreate(); call TY_(tidyGetLanguageSetByUser)() will be yes and the library skips the section of code that tries to guess the correct language setting.

@geoffmcl
Copy link
Contributor

@ler762 seem we cross posted...

Agreed, I'd rather not have the library change anything; - now it does not - issue closed...

If you have another issue please open it as a new issue... thanks...

@ler762
Copy link
Contributor

ler762 commented Jan 10, 2019

Agreed, I'd rather not have the library change anything; - now it does not

Is there a change to src/tidylib.c that hasn't been committed yet? It sure looks like the library code might still change the language:
https://github.com/htacg/tidy-html5/blob/next/src/tidylib.c#L120

@geoffmcl
Copy link
Contributor

@ler762 that's the code... what is the issue?

Do I have to REPEAT? If you have another issue please open it as a new issue... thanks...

@ler762
Copy link
Contributor

ler762 commented Jan 10, 2019

If no missing commit, there's still code in the library to change the language. If you want to leave it in, fine, but you just said

Agreed, I'd rather not have the library change anything; - now it does not

so I guess the issue is you said the library doesn't change anything now & it sure looks like it still might.

@cmb69
Copy link
Contributor

cmb69 commented Jan 10, 2019

As I understand it, libtidy still tries to set its internal language from environment variables, but it doesn't change the general locale anymore. While this still might be arguable, this ticket is about the call to setlocale() which has been removed, so this ticket has rightly been closed, in my opinion.

@wallstreetonline
Copy link

The correct way would have been to use 0 (zero, the round one), as the documentation also says:

If locale is NULL or the empty string "", the locale names will be set from the values of environment variables with the same names as the above categories, or from "LANG".

If locale is "0", the locale setting is not affected, only the current setting is returned.

Good job ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants