FreeBSD/usr.bin/locale/locale.c
/*
 * Show current locale status, depending on environment variables
 */
Show current locale status, depending on environment variables
Show current locale status depending on environment variables
void
showlocale(void)
{
	size_t	i;
	const char *lang, *vval, *eval;
	setlocale(LC_ALL, "");
	lang = getenv("LANG");
	if (lang == NULL) {
		lang = "";
	}
	printf("LANG=%s\n", lang);
	for (i = 0; i < NLCINFO; i++) {
		vval = setlocale(lcinfo[i].id, NULL);
		eval = getenv(lcinfo[i].name);
		if (eval != NULL && !strcmp(eval, vval)
				&& strcmp(lang, vval)) {
			printf("%s=%s\n", lcinfo[i].name, vval);
		} else {
			printf("%s=\"%s\"\n", lcinfo[i].name, vval);
		}
	}
	vval = getenv("LC_ALL");
	if (vval == NULL) {
		vval = "";
	}
	printf("LC_ALL=%s\n", vval);
}
void showlocale ( void ) { size_t i ; const char * lang , * vval , * eval ; setlocale ( LC_ALL , " " ) ; lang = getenv ( " " ) ; if ( lang == NULL ) { lang = " " ; } printf ( " \n " , lang ) ; for ( i = 0 ; i < NLCINFO ; i ++ ) { vval = setlocale ( lcinfo [ i ] . id , NULL ) ; eval = getenv ( lcinfo [ i ] . name ) ; if ( eval != NULL && ! strcmp ( eval , vval ) && strcmp ( lang , vval ) ) { printf ( " \n " , lcinfo [ i ] . name , vval ) ; } else { printf ( " \" \" \n " , lcinfo [ i ] . name , vval ) ; } } vval = getenv ( " " ) ; if ( vval == NULL ) { vval = " " ; } printf ( " \n " , vval ) ; }
Show current locale status, depending on environment variables
Show current locale status depending on environment variables
/* XXX: if LANG is null, then set it to "C" to get implied values? */ /*
			 * Appropriate environment variable set, its value
			 * is valid and not overridden by LC_ALL
			 *
			 * XXX: possible side effect: if both LANG and
			 * overridden environment variable are set into same
			 * value, then it'll be assumed as 'implied'
			 */