[libcxx-commits] [libcxx] [libcxx] Work around picolibc argv handling in tests. (PR #127662)

Simon Tatham via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 19 05:22:16 PST 2025


================
@@ -274,23 +274,38 @@ def hasAnyLocale(config, locales):
     %{exec} -- this means that the command may be executed on a remote host
     depending on the %{exec} substitution.
     """
-    program = """
+
+    # Convert the locale names into C string literals, by escaping \
+    # and " and wrapping each one in double quotes.
+    name_string_literals = ", ".join(
+        '"' + locale.replace("\\", r"\\").replace('"', r"\"") + '"'
----------------
statham-arm wrote:

No, I just couldn't bring myself to write code for constructing a C string literal that I _knew_ would be unable to handle such a string.

(Although I suppose I still haven't really done a proper job, because `\n` would still be mishandled :slightly_smiling_face: If there were a Python library function to make a C string literal then I'd have just called that.)

If you'd prefer, I could `assert` that the strings contain nothing but sensible characters, and then make the array declaration by just sticking quotes on the end of each one?

https://github.com/llvm/llvm-project/pull/127662


More information about the libcxx-commits mailing list