static void read_all_cnf (kpathsea kpse) { string *cnf_files; string *cnf; const_string cnf_path = kpathsea_init_format (kpse, kpse_cnf_format); kpse->cnf_hash = hash_create (CNF_HASH_SIZE); cnf_files = kpathsea_all_path_search (kpse, cnf_path, CNF_NAME); if (cnf_files && *cnf_files) { for (cnf = cnf_files; *cnf; cnf++) { string line; FILE *cnf_file = xfopen (*cnf, FOPEN_R_MODE); if (kpse->record_input) kpse->record_input (*cnf); while ((line = read_line (cnf_file)) != NULL) { unsigned len = strlen (line); /* Strip trailing spaces. */ while (len > 0 && ISSPACE(line[len-1])) { line[len - 1] = 0; --len; } /* Concatenate consecutive lines that end with \. */ while (len > 0 && line[len - 1] == '\\') { string next_line = read_line (cnf_file); line[len - 1] = 0; if (!next_line) { WARNING1 ("%s: Last line ends with \\", *cnf); } else { string new_line; new_line = concat (line, next_line); free (line); line = new_line; len = strlen (line); } } do_line (kpse, line); free (line); } xfclose (cnf_file, *cnf); free (*cnf); } free (cnf_files); } else { string warn = getenv ("KPATHSEA_WARNING"); if (!(warn && STREQ (warn, "0"))) { WARNING1 ("kpathsea: configuration file texmf.cnf not found in these directories: %s", cnf_path); } } }
static void map_file_parse (kpathsea kpse, const_string map_filename) { char *orig_l; unsigned map_lineno = 0; FILE *f = xfopen (map_filename, FOPEN_R_MODE); if (kpse->record_input) kpse->record_input (map_filename); while ((orig_l = read_line (f)) != NULL) { string filename; string l = orig_l; /* save for free() */ string comment_loc = strrchr (l, '%'); if (!comment_loc) { comment_loc = strstr (l, "@c"); } /* Ignore anything after a % or @c. */ if (comment_loc) *comment_loc = 0; map_lineno++; /* Skip leading whitespace so we can use strlen below. Can't use strtok since this routine is recursive. */ while (*l && ISSPACE (*l)) l++; /* If we don't have any filename, that's ok, the line is blank. */ filename = token (l); if (filename) { string alias = token (l + strlen (filename)); if (STREQ (filename, "include")) { if (alias == NULL) { WARNING2 ("%s:%u: Filename argument for include directive missing", map_filename, map_lineno); } else { string include_fname = kpathsea_path_search (kpse, kpse->map_path, alias, false); if (include_fname) { map_file_parse (kpse, include_fname); if (include_fname != alias) free (include_fname); } else { WARNING3 ("%s:%u: Can't find fontname include file `%s'", map_filename, map_lineno, alias); } free (alias); free (filename); } /* But if we have a filename and no alias, something's wrong. */ } else if (alias == NULL) { WARNING3 ("%s:%u: Fontname alias missing for filename `%s'", map_filename, map_lineno, filename); free (filename); } else { /* We've got everything. Insert the new entry. They were already dynamically allocated by token(), so don't bother with xstrdup. */ hash_insert_normalized (&(kpse->map), alias, filename); } } free (orig_l); } xfclose (f, map_filename); }