summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2009-11-17 16:33:37 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2009-11-17 16:33:37 +0000
commit7c18d8c655e3ec05cb6c9479f08abcc7a98c28ac (patch)
tree0b89e3f31776756ba20beb06712c85d2722a751e /Build/source/texk/kpathsea
parent7b5de8aefd0becbda29815510081eff3022c547a (diff)
texk/kpathsea: update openout_any handling for Win/Mingw/Cygwin
git-svn-id: svn://tug.org/texlive/trunk@16049 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog11
-rw-r--r--Build/source/texk/kpathsea/kpathsea.c129
-rw-r--r--Build/source/texk/kpathsea/progname.c58
-rw-r--r--Build/source/texk/kpathsea/tex-file.c79
-rw-r--r--Build/source/texk/kpathsea/types.h3
5 files changed, 80 insertions, 200 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index 86f0b66a105..bf7eabd007d 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,14 @@
+2009-11-17 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * types.h (kpathsea_instance): For Win/Mingw/Cygwin declare
+ suffixlist, listing the executable file suffixes.
+ * progname.c (kpathsea_set_program_name): Build suffixlist.
+ * tex-file.c (kpathsea_out_name_ok): Use suffixlist.
+ From Akira Kakuto <kakuto@fuk.kindai.ac.jp>.
+
+ * kpathsea.c: Remove obsolete initializer.
+ (kpathsea_finish): Destroy suffixlist (not yet used).
+
2009-11-14 Peter Breitenlohner <peb@mppmu.mpg.de>
* tex-file.c (kpathsea_out_name_ok): Allow writing of .pl files.
diff --git a/Build/source/texk/kpathsea/kpathsea.c b/Build/source/texk/kpathsea/kpathsea.c
index fe5a439e205..86a4d053b63 100644
--- a/Build/source/texk/kpathsea/kpathsea.c
+++ b/Build/source/texk/kpathsea/kpathsea.c
@@ -114,6 +114,14 @@ kpathsea_finish (kpathsea kpse)
string_free (kpse->saved_env[i]);
free (kpse->saved_env);
}
+#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
+ if (kpse->suffixlist != NULL) {
+ char **p;
+ for p = kpse->suffixlist; *p; p++)
+ free (*p);
+ free (kpse->suffixlist);
+ }
+#endif /* WIN32 || __MINGW32__ || __CYGWIN__ */
#endif /* KPATHSEA_CAN_FREE */
#if defined (KPSE_COMPAT_API)
if (kpse==kpse_def)
@@ -125,128 +133,7 @@ kpathsea_finish (kpathsea kpse)
#if defined (KPSE_COMPAT_API)
-/*
- * FIXME: completely remove the initializer.
- */
-
-#if 0
-
-#define NULL_FORMAT_INFO(kpse_file_format_type) { \
- NULL, /* const_string type */ \
- NULL, /* const_string path */ \
- NULL, /* const_string raw_path */ \
- NULL, /* const_string path_source */ \
- NULL, /* const_string override_path */ \
- NULL, /* const_string client_path */ \
- NULL, /* const_string cnf_path */ \
- NULL, /* const_string default_path */ \
- NULL, /* const_string *suffix */ \
- NULL, /* const_string *alt_suffix */ \
- false, /* boolean suffix_search_only */ \
- NULL, /* const_string program */ \
- 0, /* int argc */ \
- NULL, /* const_string *argv */ \
- false, /* boolean program_enabled_p */ \
- 0, /* kpse_src_type program_enable_level */ \
- false /* boolean binmode */ \
- }
-
-kpathsea_instance kpse_def_inst = {
- NULL, /* p_record_input record_input */
- NULL, /* p_record_output record_output */
- {NULL, 0}, /* hash_table_type cnf_hash */
- false, /* boolean doing_cnf_init */
- {NULL, 0}, /* hash_table_type db */
- {NULL, 0}, /* hash_table_type alias_db */
- {0, NULL}, /* str_list_type db_dir_list */
- 0, /* unsigned debug */
- {NULL, 0}, /* hash_table_type link_table */
- NULL, /* cache_entry *the_cache */
- 0, /* unsigned cache_length */
- {NULL, 0}, /* hash_table_type map */
- NULL, /* const_string map_path */
- false, /* boolean debug_hash_lookup_int */
- NULL, /* string elt */
- 0, /* unsigned elt_alloc */
- NULL, /* const_string path */
- false, /* boolean followup_search */
- NULL, /* FILE *log_file */
- false, /* boolean log_opened */
- NULL, /* string invocation_name */
- NULL, /* string invocation_short_name */
- NULL, /* string program_name */
- 0, /* int ll_verbose */
- NULL, /* const_string fallback_font */
- NULL, /* const_string fallback_resolutions_string */
- 0, /* unsigned *fallback_resolutions */
- { /* kpse_format_info_type format_info[kpse_last_format] */
- NULL_FORMAT_INFO(kpse_gf_format),
- NULL_FORMAT_INFO(kpse_pk_format),
- NULL_FORMAT_INFO(kpse_any_glyph_format),
- NULL_FORMAT_INFO(kpse_tfm_format),
- NULL_FORMAT_INFO(kpse_afm_format),
- NULL_FORMAT_INFO(kpse_base_format),
- NULL_FORMAT_INFO(kpse_bib_format),
- NULL_FORMAT_INFO(kpse_bst_format),
- NULL_FORMAT_INFO(kpse_cnf_format),
- NULL_FORMAT_INFO(kpse_db_format),
- NULL_FORMAT_INFO(kpse_fmt_format),
- NULL_FORMAT_INFO(kpse_fontmap_format),
- NULL_FORMAT_INFO(kpse_mem_format),
- NULL_FORMAT_INFO(kpse_mf_format),
- NULL_FORMAT_INFO(kpse_mfpool_format),
- NULL_FORMAT_INFO(kpse_mft_format),
- NULL_FORMAT_INFO(kpse_mp_format),
- NULL_FORMAT_INFO(kpse_mppool_format),
- NULL_FORMAT_INFO(kpse_mpsupport_format),
- NULL_FORMAT_INFO(kpse_ocp_format),
- NULL_FORMAT_INFO(kpse_ofm_format),
- NULL_FORMAT_INFO(kpse_opl_format),
- NULL_FORMAT_INFO(kpse_otp_format),
- NULL_FORMAT_INFO(kpse_ovf_format),
- NULL_FORMAT_INFO(kpse_ovp_format),
- NULL_FORMAT_INFO(kpse_pict_format),
- NULL_FORMAT_INFO(kpse_tex_format),
- NULL_FORMAT_INFO(kpse_texdoc_format),
- NULL_FORMAT_INFO(kpse_texpool_format),
- NULL_FORMAT_INFO(kpse_texsource_format),
- NULL_FORMAT_INFO(kpse_tex_ps_header_format),
- NULL_FORMAT_INFO(kpse_troff_font_format),
- NULL_FORMAT_INFO(kpse_type1_format),
- NULL_FORMAT_INFO(kpse_vf_format),
- NULL_FORMAT_INFO(kpse_dvips_config_format),
- NULL_FORMAT_INFO(kpse_ist_format),
- NULL_FORMAT_INFO(kpse_truetype_format),
- NULL_FORMAT_INFO(kpse_type42_format),
- NULL_FORMAT_INFO(kpse_web2c_format),
- NULL_FORMAT_INFO(kpse_program_text_format),
- NULL_FORMAT_INFO(kpse_program_binary_format),
- NULL_FORMAT_INFO(kpse_miscfonts_format),
- NULL_FORMAT_INFO(kpse_web_format),
- NULL_FORMAT_INFO(kpse_cweb_format),
- NULL_FORMAT_INFO(kpse_enc_format),
- NULL_FORMAT_INFO(kpse_cmap_format),
- NULL_FORMAT_INFO(kpse_sfd_format),
- NULL_FORMAT_INFO(kpse_opentype_format),
- NULL_FORMAT_INFO(kpse_pdftex_config_format),
- NULL_FORMAT_INFO(kpse_lig_format),
- NULL_FORMAT_INFO(kpse_texmfscripts_format),
- NULL_FORMAT_INFO(kpse_lua_format)
- },
- false, /* boolean make_tex_discard_errors */
- NULL, /* FILE *missfont */
- NULL, /* expansion_type *expansions */
- 0, /* unsigned expansion_len */
- NULL, /* char **saved_env */
- 0 /* int saved_count */
-};
-
-#else /* zero */
-
kpathsea_instance kpse_def_inst;
-
-#endif /* zero */
-
kpathsea kpse_def = &kpse_def_inst;
#endif /* KPSE_COMPAT_API */
diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c
index 2a8fdfb692a..d2ae4848f5f 100644
--- a/Build/source/texk/kpathsea/progname.c
+++ b/Build/source/texk/kpathsea/progname.c
@@ -417,9 +417,61 @@ kpse_selfdir (const_string argv0)
}
#endif
-
#endif /* not WIN32 */
+#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
+
+/* Create a list of executable suffixes of files not to be written. */
+#define EXE_SUFFIXES ".com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.ws;.tcl;.py;.pyw"
+
+static void
+mk_suffixlist (kpathsea kpse)
+{
+ char **p;
+ char *q, *r, *v;
+ int n;
+
+#if defined(__CYGWIN__)
+ v = xstrdup (EXE_SUFFIXES);
+#else
+ v = getenv ("PATHEXT");
+ if (v) /* strlwr() exists also in MingW */
+ v = strlwr (xstrdup (v));
+ else
+ v = xstrdup (EXE_SUFFIXES);
+#endif
+
+ q = v;
+ n = 0;
+
+ while ((r = strchr (q, ';')) != NULL) {
+ n++;
+ r++;
+ q = r;
+ }
+ if (*q)
+ n++;
+ kpse->suffixlist = (char **) xmalloc ((n + 2) * sizeof (char *));
+ p = (char **)kpse->suffixlist;
+ *p = xstrdup (".dll");
+ p++;
+ q = v;
+ while ((r = strchr (q, ';')) != NULL) {
+ *r = '\0';
+ *p = xstrdup (q);
+ p++;
+ r++;
+ q = r;
+ }
+ if (*q) {
+ *p = xstrdup (q);
+ p++;
+ }
+ *p = NULL;
+ free (v);
+}
+#endif /* WIN32 || __MINGW32__ || __CYGWIN__ */
+
void
kpathsea_set_program_name (kpathsea kpse, const_string argv0, const_string progname)
{
@@ -574,6 +626,10 @@ kpathsea_set_program_name (kpathsea kpse, const_string argv0, const_string prog
sdir_grandparent = xdirname (sdir_parent);
kpathsea_xputenv (kpse, "SELFAUTOPARENT", sdir_grandparent);
+#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
+ mk_suffixlist(kpse);
+#endif /* WIN32 || __MINGW32__ || __CYGWIN__ */
+
free (sdir);
free (sdir_parent);
free (sdir_grandparent);
diff --git a/Build/source/texk/kpathsea/tex-file.c b/Build/source/texk/kpathsea/tex-file.c
index f34f58924e8..30d7d0fca26 100644
--- a/Build/source/texk/kpathsea/tex-file.c
+++ b/Build/source/texk/kpathsea/tex-file.c
@@ -1182,91 +1182,16 @@ Isspace (char c)
return (c == ' ' || c == '\t');
}
-/* Create a list of executable suffixes of files not to be written. */
-#define EXE_SUFFIXES ".com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.ws;.tcl;.py;.pyw"
-
-static void
-mk_suffixlist (char ***ext)
-{
- char **p;
- char *q, *r, *v;
- int n;
-
-#if defined(__CYGWIN__)
- v = (char *) xmalloc (strlen (EXE_SUFFIXES) + 1);
- strcpy (v, EXE_SUFFIXES);
-#else
- v = (char *) getenv ("PATHEXT");
- if (v) /* strlwr() exists also in MingW */
- (void) strlwr (v);
- else {
- v = (char *) xmalloc (strlen (EXE_SUFFIXES) + 1);
- strcpy (v, EXE_SUFFIXES);
- }
-#endif
-
- q = v;
- n = 0;
-
- while ((r = strchr (q, ';')) != 0) {
- n++;
- r++;
- q = r;
- }
- if (*q)
- n++;
- *ext = (char **) xmalloc ((n + 2) * sizeof (char *));
- p = *ext;
- *p = (char *) xmalloc(5);
- strcpy(*p, ".dll");
- p++;
- q = v;
- while ((r = strchr (q, ';')) != 0) {
- *r = '\0';
- *p = (char *) xmalloc (strlen (q) + 1);
- strcpy (*p, q);
- *r = ';';
- r++;
- q = r;
- p++;
- }
- if (*q) {
- *p = (char *) xmalloc (strlen (q) + 1);
- strcpy (*p, q);
- p++;
- *p = NULL;
- } else
- *p = NULL;
- free (v);
-}
-
-static void
-free_suffixlist (char ***ext)
-{
- char **p;
-
- if (*ext) {
- p = *ext;
- while (*p) {
- free (*p);
- p++;
- }
- free (*ext);
- }
-}
-
static boolean
executable_filep (kpathsea kpse, const_string fname)
{
string p, q, base;
string *pp;
- char **suffixlist = NULL;
/* check openout_any */
p = kpathsea_var_value (kpse, "openout_any");
if (p && *p == 'p') {
free (p);
- mk_suffixlist (&suffixlist);
/* get base name
we cannot use xbasename() for abnormal names.
*/
@@ -1293,21 +1218,19 @@ executable_filep (kpathsea kpse, const_string fname)
*q = '\0'; /* remove trailing '.' , ' ' and '\t' */
}
q = strrchr (p, '.'); /* get extension part */
- pp = suffixlist;
+ pp = kpse->suffixlist;
if (pp && q) {
while (*pp) {
if (strchr (fname, ':') || !strcmp (q, *pp)) {
fprintf (stderr, "\nThe name %s is forbidden to open for writing.\n",
fname);
free (base);
- free_suffixlist (&suffixlist);
return true;
}
pp++;
}
}
free (base);
- free_suffixlist (&suffixlist);
} else if (p) {
free (p);
}
diff --git a/Build/source/texk/kpathsea/types.h b/Build/source/texk/kpathsea/types.h
index 19684f117e0..c70abe13ade 100644
--- a/Build/source/texk/kpathsea/types.h
+++ b/Build/source/texk/kpathsea/types.h
@@ -254,6 +254,9 @@ typedef struct kpathsea_instance {
*/
char **saved_env; /* these keep track of changed items */
int saved_count;
+#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
+ char **suffixlist;
+#endif /* WIN32 || __MINGW32__ || __CYGWIN__ */
} kpathsea_instance;
/* these come from kpathsea.c */