From d19b882a554d23733d80d058be82d1dacec4080c Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 6 Oct 2023 14:18:53 -0700 Subject: [PATCH] Fixed -flist handling for filenames with spaces (#402) --- Texassemble/texassemble.cpp | 18 ++++++++---------- Texconv/texconv.cpp | 18 ++++++++---------- Texdiag/texdiag.cpp | 18 ++++++++---------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Texassemble/texassemble.cpp b/Texassemble/texassemble.cpp index 28f2bce..bc5252b 100644 --- a/Texassemble/texassemble.cpp +++ b/Texassemble/texassemble.cpp @@ -491,10 +491,10 @@ namespace std::list flist; std::set excludes; - auto fname = std::make_unique(32768); for (;;) { - inFile >> fname.get(); + std::wstring fname; + std::getline(inFile, fname); if (!inFile) break; @@ -506,13 +506,13 @@ namespace { if (flist.empty()) { - wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname.get()); + wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname.c_str()); } else { - std::filesystem::path path(fname.get() + 1); + std::filesystem::path path(fname.c_str() + 1); auto& npath = path.make_preferred(); - if (wcspbrk(fname.get(), L"?*") != nullptr) + if (wcspbrk(fname.c_str(), L"?*") != nullptr) { std::list removeFiles; SearchForFiles(npath, removeFiles, false); @@ -532,20 +532,18 @@ namespace } } } - else if (wcspbrk(fname.get(), L"?*") != nullptr) + else if (wcspbrk(fname.c_str(), L"?*") != nullptr) { - std::filesystem::path path(fname.get()); + std::filesystem::path path(fname.c_str()); SearchForFiles(path.make_preferred(), flist, false); } else { SConversion conv = {}; - std::filesystem::path path(fname.get()); + std::filesystem::path path(fname.c_str()); conv.szSrc = path.make_preferred().native(); flist.push_back(conv); } - - inFile.ignore(1000, '\n'); } inFile.close(); diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index 53ece5c..6e7b2fc 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -639,10 +639,10 @@ namespace std::list flist; std::set excludes; - auto fname = std::make_unique(32768); for (;;) { - inFile >> fname.get(); + std::wstring fname; + std::getline(inFile, fname); if (!inFile) break; @@ -654,13 +654,13 @@ namespace { if (flist.empty()) { - wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname.get()); + wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname.c_str()); } else { - std::filesystem::path path(fname.get() + 1); + std::filesystem::path path(fname.c_str() + 1); auto& npath = path.make_preferred(); - if (wcspbrk(fname.get(), L"?*") != nullptr) + if (wcspbrk(fname.c_str(), L"?*") != nullptr) { std::list removeFiles; SearchForFiles(npath, removeFiles, false, nullptr); @@ -680,20 +680,18 @@ namespace } } } - else if (wcspbrk(fname.get(), L"?*") != nullptr) + else if (wcspbrk(fname.c_str(), L"?*") != nullptr) { - std::filesystem::path path(fname.get()); + std::filesystem::path path(fname.c_str()); SearchForFiles(path.make_preferred(), flist, false, nullptr); } else { SConversion conv = {}; - std::filesystem::path path(fname.get()); + std::filesystem::path path(fname.c_str()); conv.szSrc = path.make_preferred().native(); flist.push_back(conv); } - - inFile.ignore(1000, '\n'); } inFile.close(); diff --git a/Texdiag/texdiag.cpp b/Texdiag/texdiag.cpp index 324effb..51dc04d 100644 --- a/Texdiag/texdiag.cpp +++ b/Texdiag/texdiag.cpp @@ -481,10 +481,10 @@ namespace std::list flist; std::set excludes; - auto fname = std::make_unique(32768); for (;;) { - inFile >> fname.get(); + std::wstring fname; + std::getline(inFile, fname); if (!inFile) break; @@ -496,13 +496,13 @@ namespace { if (flist.empty()) { - wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname.get()); + wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname.c_str()); } else { - std::filesystem::path path(fname.get() + 1); + std::filesystem::path path(fname.c_str() + 1); auto& npath = path.make_preferred(); - if (wcspbrk(fname.get(), L"?*") != nullptr) + if (wcspbrk(fname.c_str(), L"?*") != nullptr) { std::list removeFiles; SearchForFiles(npath, removeFiles, false); @@ -522,20 +522,18 @@ namespace } } } - else if (wcspbrk(fname.get(), L"?*") != nullptr) + else if (wcspbrk(fname.c_str(), L"?*") != nullptr) { - std::filesystem::path path(fname.get()); + std::filesystem::path path(fname.c_str()); SearchForFiles(path.make_preferred(), flist, false); } else { SConversion conv = {}; - std::filesystem::path path(fname.get()); + std::filesystem::path path(fname.c_str()); conv.szSrc = path.make_preferred().native(); flist.push_back(conv); } - - inFile.ignore(1000, '\n'); } inFile.close();