FreeBSD/usr.bin/locale/locale.c
/*
 * Output information about all available charmaps
 *
 * XXX this function is doing a task in hackish way, i.e. by scaning
 *     list of locales, spliting their codeset part and building list of
 *     them.
 */
Output information about all available charmaps
XXX this function is doing a task in hackish way, i.e. by scaning
list of locales, spliting their codeset part and building list of
them.
Output information about all available charmaps XXX this function is doing a task in hackish way i . e . by scaning list of locales spliting their codeset part and building list of them .
void
list_charmaps(void)
{
	size_t i;
	char *s, *cs;
	StringList *charmaps;
	charmaps = sl_init();
	if (charmaps == NULL)
		err(1, "could not allocate memory");
	init_locales_list();
	for (i = 0; i < locales->sl_cur; i++) {
		s = locales->sl_str[i];
		if ((cs = strchr(s, '.')) != NULL) {
			cs++;
			if (sl_find(charmaps, cs) == NULL)
				sl_add(charmaps, cs);
		}
	}
	if (sl_find(charmaps, "US-ASCII") == NULL)
		sl_add(charmaps, "US-ASCII");
	qsort(charmaps->sl_str, charmaps->sl_cur, sizeof(char *), scmp);
	for (i = 0; i < charmaps->sl_cur; i++) {
		printf("%s\n", charmaps->sl_str[i]);
	}
}
void list_charmaps ( void ) { size_t i ; char * s , * cs ; StringList * charmaps ; charmaps = sl_init ( ) ; if ( charmaps == NULL ) err ( 1 , " " ) ; init_locales_list ( ) ; for ( i = 0 ; i < locales -> sl_cur ; i ++ ) { s = locales -> sl_str [ i ] ; if ( ( cs = strchr ( s , ' ' ) ) != NULL ) { cs ++ ; if ( sl_find ( charmaps , cs ) == NULL ) sl_add ( charmaps , cs ) ; } } if ( sl_find ( charmaps , " " ) == NULL ) sl_add ( charmaps , " " ) ; qsort ( charmaps -> sl_str , charmaps -> sl_cur , sizeof ( char * ) , scmp ) ; for ( i = 0 ; i < charmaps -> sl_cur ; i ++ ) { printf ( " \n " , charmaps -> sl_str [ i ] ) ; } }
Output information about all available charmaps
 XXX this function is doing a task in hackish way, i.e.
Output information about all available charmaps XXX this function is doing a task in hackish way i . e .
/* initialize StringList */ /* fetch locales list */ /* split codesets and build their list */ /* add US-ASCII, if not yet added */ /* sort the list */ /* print results */