From 68bae2c7f6e1faf46cdcbf216b91a8cde976e0b1 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 22 Oct 2014 03:10:56 +0000 Subject: [PATCH] Handle spaces and quotes in file names in MRI scripts. llvm-svn: 220364 --- llvm/test/Object/mri-addmod.test | 2 +- llvm/tools/llvm-ar/llvm-ar.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/test/Object/mri-addmod.test b/llvm/test/Object/mri-addmod.test index 3a59a3b..0e9e679 100644 --- a/llvm/test/Object/mri-addmod.test +++ b/llvm/test/Object/mri-addmod.test @@ -1,5 +1,5 @@ ; RUN: echo create %t.a > %t.mri -; RUN: echo addmod %p/Inputs/trivial-object-test.elf-x86-64 >> %t.mri +; RUN: echo "addmod \"%p/Inputs/trivial-object-test.elf-x86-64\" " >> %t.mri ; RUN: echo save >> %t.mri ; RUN: echo end >> %t.mri diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index 8411a1d..6858a94 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -961,6 +961,9 @@ static void runMRIScript() { StringRef Line = *I; StringRef CommandStr, Rest; std::tie(CommandStr, Rest) = Line.split(' '); + Rest = Rest.trim(); + if (!Rest.empty() && Rest.front() == '"' && Rest.back() == '"') + Rest = Rest.drop_front().drop_back(); auto Command = StringSwitch(CommandStr.lower()) .Case("addlib", MRICommand::AddLib) .Case("addmod", MRICommand::AddMod) -- 2.7.4