static int show_path(lua_State * L) { int op = luaL_checkoption(L, -1, "tex", filetypenames); unsigned user_format = filetypes[op]; TEST_PROGRAM_NAME_SET; if (!kpse_format_info[user_format].type) /* needed if arg was numeric */ kpse_init_format(user_format); lua_pushstring(L, kpse_format_info[user_format].path); return 1; }
static void read_all_maps P1H(void) { string *filenames; map_path = kpse_init_format (kpse_fontmap_format); filenames = kpse_all_path_search (map_path, MAP_NAME); map = hash_create (MAP_HASH_SIZE); while (*filenames) { map_file_parse (*filenames); filenames++; } }
static void read_all_cnf P1H(void) { string *cnf_files; const_string cnf_path = kpse_init_format (kpse_cnf_format); cnf_hash = hash_create (CNF_HASH_SIZE); for (cnf_files = kpse_all_path_search (cnf_path, CNF_NAME); cnf_files && *cnf_files; cnf_files++) { string line; string cnf_filename = *cnf_files; FILE *cnf_file = xfopen (cnf_filename, FOPEN_R_MODE); 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_filename); } else { string new_line; new_line = concat (line, next_line); free (line); line = new_line; len = strlen (line); } } do_line (line); free (line); } xfclose (cnf_file, cnf_filename); } }
static string try_format P3C(const_string, fontname, unsigned, dpi, kpse_file_format_type, format) { static const_string bitmap_specs[] = { UNIX_BITMAP_SPEC, DPI_BITMAP_SPEC, NULL }; const_string *spec; boolean must_exist; string ret = NULL; const_string path = kpse_format_info[format].path; const_string *sfx; if (!path) path = kpse_init_format (format); /* Set the suffix on the name we'll be searching for. */ sfx = kpse_format_info[format].suffix; if (sfx && *sfx) xputenv ("KPATHSEA_FORMAT", *sfx); /* OK, the limits on this for loop are a little hokey, but it saves having to repeat the body. We want to do it once with `must_exist' false to avoid looking on the disk for cmr10.600pk if dpi600/cmr10.pk is in ls-R. (The time spent in the extra variable expansions and db searches is negligible.) */ for (must_exist = false; !ret && must_exist <= true; must_exist++) { for (spec = bitmap_specs; !ret && *spec; spec++) { string name = kpse_var_expand (*spec); ret = kpse_path_search (path, name, must_exist); if (name != ret) free (name); } } return ret; }
string kpse_make_tex P2C(kpse_file_format_type, format, const_string, base) { kpse_format_info_type spec; /* some compilers lack struct initialization */ string ret = NULL; spec = kpse_format_info[format]; if (!spec.type) { /* Not initialized yet? */ kpse_init_format (format); spec = kpse_format_info[format]; } if (spec.program && spec.program_enabled_p) { /* See the documentation for the envvars we're dealing with here. */ /* Number of arguments is spec.argc + 1, plus the trailing NULL. */ string *args = XTALLOC (spec.argc + 2, string); /* Helpers */ int argnum; int i; /* FIXME * Check whether the name we were given is likely to be a problem. * Right now we err on the side of strictness: * - may not start with a hyphen (fixable in the scripts). * - allowed are: alphanumeric, underscore, hyphen, period * ? also allowed DIRSEP, as we can be fed that when creating pk fonts * No doubt some possibilities were overlooked. */ if (base[0] == '-' /* || IS_DIR_SEP(base[0]) */) { fprintf(stderr, "kpathsea: Illegal fontname `%s': starts with '%c'\n", base, base[0]); return NULL; } for (i = 0; base[i]; i++) { if (!ISALNUM(base[i]) && base[i] != '+' && base[i] != '-' && base[i] != '_' && base[i] != '.' && !IS_DIR_SEP(base[i])) { fprintf(stderr, "kpathsea: Illegal fontname `%s': contains '%c'\n", base, base[i]); return NULL; } } if (format == kpse_gf_format || format == kpse_pk_format || format == kpse_any_glyph_format) set_maketex_mag (); /* Here's an awful kludge: if the mode is `/', mktexpk recognizes it as a special case. `kpse_prog_init' sets it to this in the first place when no mode is otherwise specified; this is so when the user defines a resolution, they don't also have to specify a mode; instead, mktexpk's guesses will take over. They use / for the value because then when it is expanded as part of the PKFONTS et al. path values, we'll wind up searching all the pk directories. We put $MAKETEX_MODE in the path values in the first place so that sites with two different devices with the same resolution can find the right fonts; but such sites are uncommon, so they shouldn't make things harder for everyone else. */ for (argnum = 0; argnum < spec.argc; argnum++) { args[argnum] = kpse_var_expand (spec.argv[argnum]); } args[argnum++] = xstrdup(base); args[argnum] = NULL; ret = maketex (format, args); for (argnum = 0; args[argnum] != NULL; argnum++) free (args[argnum]); free (args); } return ret; }