# HG changeset patch
# User John Donoghue <john.donoghue@ieee.org>
# Date 1693354825 14400
#      Tue Aug 29 20:20:25 2023 -0400
# Node ID a54a22750e956fb9f226d11f24f9a2631dcc80a1
# Parent  a32650514d386aa773ab2a9ddbfd945fb79cd56a
mkoctfile: attempt to quote any replaced prefix parts (Bug #64609)

* src/mkoctfile.in.cc: (replace_prefix): quote prefix replacement if not already quoted and has a space

diff -r a32650514d38 -r a54a22750e95 src/mkoctfile.in.cc
--- a/src/mkoctfile.in.cc	Mon Aug 21 11:12:01 2023 +0200
+++ b/src/mkoctfile.in.cc	Tue Aug 29 20:20:25 2023 -0400
@@ -164,7 +164,11 @@
   std::size_t pos = s.find (match);
   while (pos != std::string::npos )
     {
-      s.replace (pos, match.length (), repl);
+      // quote replacement path if the input isnt quoted
+      if (pos > 0 && s[pos-1] != '"' && s[pos-1] != '\'')
+         s.replace (pos, match.length (), quote_path(repl));
+      else
+         s.replace (pos, match.length (), repl);
       pos = s.find (match);
     }
 #endif
