Hi folks,

when looking at locale(1) former output formatting one could notice that
setlocale(LC_ALL, NULL) look "weird". It encodes the whole current
locale configuration so that it can be reused later.  POSIX doesn't say
much - afaik - about the formatting, and that is a point where we differ
from, for example, the glibc.

So if you know of a program that messes up with the string returned by
the above it is probably wrong.  A grep -sR 'setlocale *(LC_ALL, *NULL)'
over the full ports source tree could prove useful.

Example of setlocale(LC_ALL, NULL) output and toy program:
C/fr_FR.UTF-8/C/C/C/C

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

int
main(void)
{
        char *s;

        setlocale(LC_ALL, "");

        s = strdup(setlocale(LC_ALL, NULL));
        printf("current locales values: %s\n", s);

        setlocale(LC_CTYPE, "fr_FR.ISO8859-1");
        printf("LC_CTYPE modified: %s\n", setlocale(LC_ALL, NULL));

        setlocale(LC_ALL, s);
        printf("locales reset: %s\n", setlocale(LC_ALL, NULL));

        free(s);

        return 0;
}

Reply via email to