diff libinterp/corefcn/latex-text-renderer.cc @ 31210:9ad55d2e1bbf stable

Make sure we don't pass short 8.3 path to latex on Windows (bug #62779). * latex-text-renderer.cc (latex_renderer::write_tex_file): On Windows, use canonicalized path of temporary directory.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Sun, 28 Aug 2022 22:44:49 +0200
parents 796f54d4ddbf
children 8340137bb190
line wrap: on
line diff
--- a/libinterp/corefcn/latex-text-renderer.cc	Sun Aug 28 14:19:43 2022 -0700
+++ b/libinterp/corefcn/latex-text-renderer.cc	Sun Aug 28 22:44:49 2022 +0200
@@ -215,7 +215,24 @@
     if (m_tmp_dir.empty ())
       {
         //Create the temporary directory
+#if defined (OCTAVE_USE_WINDOWS_API)
+        static std::string base_tmp_dir;
+
+        if (base_tmp_dir.empty ())
+          {
+            base_tmp_dir = sys::env::get_temp_directory ();
+
+            // Make sure we don't get short 8.3 path on Windows since some
+            // versions of latex on that platform don't support them
+            // (see bug #62779)
+            if (base_tmp_dir.find ('~') != std::string::npos)
+              base_tmp_dir = sys::canonicalize_file_name (base_tmp_dir);
+          }
+
+        m_tmp_dir = sys::tempnam (base_tmp_dir, "latex");
+#else
         m_tmp_dir = sys::tempnam ("", "latex");
+#endif
 
         if (sys::mkdir (m_tmp_dir, 0700) != 0)
           {