FreeBSD/usr.bin/catman/catman.c
/*
 * Processes one argument, which may be a colon-separated list of
 * directories.
 */
Processes one argument, which may be a colon-separated list of
directories.
Processes one argument which may be a colon - separated list of directories .
static void
process_argument(const char *arg)
{
	char *dir;
	char *mandir;
	char *section;
	char *parg;
	parg = strdup(arg);
	if (parg == NULL)
		err(1, "out of memory");
	while ((dir = strsep(&parg, ":")) != NULL) {
		switch (directory_type(dir)) {
		case TOP_LEVEL_DIR:
			if (locale != NULL) {
				asprintf(&mandir, "%s/%s", dir, locale);
				process_mandir(mandir, NULL);
				free(mandir);
				if (lang_locale != NULL) {
					asprintf(&mandir, "%s/%s", dir,
					    lang_locale);
					process_mandir(mandir, NULL);
					free(mandir);
				}
			} else {
				process_mandir(dir, NULL);
			}
			break;
		case MAN_SECTION_DIR: {
			mandir = strdup(dirname(dir));
			section = strdup(basename(dir));
			process_mandir(mandir, section);
			free(mandir);
			free(section);
			break;
			}
		default:
			warnx("%s: directory name not in proper man form", dir);
			exit_code = 1;
		}
	}
	free(parg);
}
static void process_argument ( const char * arg ) { char * dir ; char * mandir ; char * section ; char * parg ; parg = strdup ( arg ) ; if ( parg == NULL ) err ( 1 , " " ) ; while ( ( dir = strsep ( & parg , " " ) ) != NULL ) { switch ( directory_type ( dir ) ) { case TOP_LEVEL_DIR : if ( locale != NULL ) { asprintf ( & mandir , " " , dir , locale ) ; process_mandir ( mandir , NULL ) ; free ( mandir ) ; if ( lang_locale != NULL ) { asprintf ( & mandir , " " , dir , lang_locale ) ; process_mandir ( mandir , NULL ) ; free ( mandir ) ; } } else { process_mandir ( dir , NULL ) ; } break ; case MAN_SECTION_DIR : { mandir = strdup ( dirname ( dir ) ) ; section = strdup ( basename ( dir ) ) ; process_mandir ( mandir , section ) ; free ( mandir ) ; free ( section ) ; break ; } default : warnx ( " " , dir ) ; exit_code = 1 ; } } free ( parg ) ; }
Processes one argument, which may be a colon-separated list of
 directories.
Processes one argument which may be a colon - separated list of directories .