summaryrefslogtreecommitdiff
path: root/Build/source/texk/upmendex/kp.c
diff options
context:
space:
mode:
authorTakuji Tanaka <KXD02663@nifty.ne.jp>2016-02-09 11:02:48 +0000
committerTakuji Tanaka <KXD02663@nifty.ne.jp>2016-02-09 11:02:48 +0000
commitadec059e95b8e5728d8fb2d8420c5e928812c282 (patch)
tree28d38c44042fea2befbccbdd71063c801518d298 /Build/source/texk/upmendex/kp.c
parentb0bdd8cd0fed764f189d773b0b0f69d25415a8f5 (diff)
texk/upmendex: upmendex 0.50
git-svn-id: svn://tug.org/texlive/trunk@39638 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/upmendex/kp.c')
-rw-r--r--Build/source/texk/upmendex/kp.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/Build/source/texk/upmendex/kp.c b/Build/source/texk/upmendex/kp.c
new file mode 100644
index 00000000000..c43453f7857
--- /dev/null
+++ b/Build/source/texk/upmendex/kp.c
@@ -0,0 +1,48 @@
+/* Written by K.Asayayam Sep. 1995 */
+
+#include "mendex.h"
+#include <kpathsea/expand.h>
+#include <kpathsea/pathsearch.h>
+
+#include "kp.h"
+
+/* KP_get_path(char *var, char *def_val)
+ ARGUMENTS:
+ char *var: name of variable.
+ char *def_val: default value.
+ */
+static const char *KP_get_path(const char *var, const char *def_val)
+{
+ char avar[50];
+ const char *p;
+ strcpy(avar, "${");
+ strcat(avar, var);
+ strcat(avar, "}");
+ p = kpse_path_expand(avar);
+ return (p && *p) ? p : def_val;
+}
+
+/*
+ */
+void KP_entry_filetype(KpathseaSupportInfo *info)
+{
+ info->path = KP_get_path(info->var_name,info->path);
+}
+
+/* KP_find_file(KpathseaSupportInfo *info, char *name)
+ ARGUMENTS:
+ KpathseaSupportInfo *info: Informations about the type of files.
+ char *name: Name of file.
+ */
+const char *KP_find_file(KpathseaSupportInfo *info, const char *name)
+{
+ char *ret;
+ ret = kpse_path_search(info->path,name,1);
+ if (!ret && info->suffix && !find_suffix(name)) {
+ char *suff_name;
+ suff_name = concat3(name,".",info->suffix);
+ ret = kpse_path_search(info->path,suff_name,1);
+ free(suff_name);
+ }
+ return ret ? ret : name;
+}