[tex-k] Locale-related bug in MakeIndex (was: makeindex breaks up index group on a capitalized entry)

Hartmut Henkel hartmut_henkel at gmx.de
Tue Nov 2 00:18:53 CET 2004

On Mon, 1 Nov 2004 geolsoft at mail.ru wrote:

> +    prev_locale = setlocale(LC_CTYPE, "");
> +#endif

if this is meant to implement some stack, shouldn't it then be

  prev_locale = setlocale(LC_CTYPE, NULL);
  setlocale(LC_CTYPE, "");

since with "" instead of the NULL it will already change the locale, so
the prev_locale does not contain the previous value. E. g.

#include <stdlib.h>
#include <stdio.h>
#include <locale.h>

int main()
    char *prev_locale, *show_locale;

    show_locale = setlocale(LC_CTYPE, NULL);
    printf("1 show_locale = %s\n", show_locale);

    prev_locale = setlocale(LC_CTYPE, "");
    printf("2 prev_locale = %s\n", prev_locale);

    show_locale = setlocale(LC_CTYPE, NULL);
    printf("3 show_locale = %s\n", show_locale);

    setlocale(LC_CTYPE, prev_locale);

    show_locale = setlocale(LC_CTYPE, NULL);
    printf("4 show_locale = %s\n", show_locale);

    return 0;


1 show_locale = C
2 prev_locale = de_DE.ISO-8859-1
3 show_locale = de_DE.ISO-8859-1
4 show_locale = de_DE.ISO-8859-1

No C locale back at the end. And it's similar in sortid.c.

Regards, Hartmut

More information about the tex-k mailing list