diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2015-06-22 07:32:51 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2015-06-22 07:32:51 +0000 |
commit | 1e154e99250227dea61d1ddab8d687d5be2a3620 (patch) | |
tree | 899b3cdeefdcce4805b7efca779ba5d285d676b1 /Build/source/texk/kpathsea/win32/mkpaths.c | |
parent | a4f909a88620667e86955c1876be8e5b07bfd6ca (diff) |
texk/kpathsea: Update mktex* programs for w32
git-svn-id: svn://tug.org/texlive/trunk@37637 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea/win32/mkpaths.c')
-rw-r--r-- | Build/source/texk/kpathsea/win32/mkpaths.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/Build/source/texk/kpathsea/win32/mkpaths.c b/Build/source/texk/kpathsea/win32/mkpaths.c new file mode 100644 index 00000000000..5de8c65658f --- /dev/null +++ b/Build/source/texk/kpathsea/win32/mkpaths.c @@ -0,0 +1,95 @@ +/* mkpaths.c + + Copyright 2015 Akira Kakuto. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <kpathsea/kpathsea.h> +#include "mktex.h" + +char ** +mkpaths (int *numptr) +{ + char **pathbuff; + char *texmfdbs; + char *p, *pa, *pc; + int i; + + if (!(p = kpse_var_value ("TEXMFDBS"))) { + fprintf (stderr, "No definition of TEXMFDBS.\n"); + return NULL; + } + + texmfdbs = kpse_brace_expand (p); + free (p); + if (!texmfdbs) { + fprintf (stderr, "I cannot expand braces in TEXMFDBS.\n"); + return NULL; + } + + p = texmfdbs; + i = 0; + + while(*p) { + if(*p == '!' && *(p+1) == '!') + p += 2; + if(*p == ';') + while(*p == ';') + p++; + if(*p && *p != '!') { + while(*p != ';' && *p) + p++; + i++; + while(*p == ';') + p++; + } + } + + if (!i) { + free (texmfdbs); + fprintf (stderr, "No database paths in TEXMFDBS.\n"); + return NULL; + } + + *numptr = i; + pathbuff = xmalloc(i * sizeof(char *)); + + p = texmfdbs; + i = 0; + + while (*p) { + if (*p == '!' && *(p + 1) == '!') + p += 2; + if (*p == ';') { + while (*p == ';') + p++; + } + if(*p && *p != '!') { + pa = p; + while(*p != ';' && *p) + p++; + pc = p; + pathbuff[i] = xmalloc(pc - pa + 1); + strncpy(pathbuff[i], pa, pc - pa); + pathbuff[i][pc - pa] = 0; + i++; + while(*p == ';') + p++; + } + } + + free(texmfdbs); + return pathbuff; +} |