2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 02:49:00 +00:00

Fix shell globbing for mingw

Why did this ever work? Hard to say...perhaps a library we linked
against was setting `int _dowildcard = -1;` somewhere and no longer
is. Apparently linking with CRT_glob.o has been the way to do this for
a very long time, and we've just been lucky that it worked all this
time.
This commit is contained in:
Jay Berkenbilt 2024-12-13 07:52:43 -05:00
parent 3ea83e9993
commit 0e65d9c246
3 changed files with 20 additions and 9 deletions

View File

@ -247,6 +247,14 @@ if(MSVC)
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS -link setargv.obj) list(APPEND CMAKE_REQUIRED_LINK_OPTIONS -link setargv.obj)
list(APPEND WINDOWS_WMAIN_LINK -link wsetargv.obj) list(APPEND WINDOWS_WMAIN_LINK -link wsetargv.obj)
endif() endif()
if(MINGW)
execute_process(
COMMAND gcc --print-file-name=CRT_glob.o
OUTPUT_VARIABLE CRT_GLOB_O
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(APPEND WINDOWS_WMAIN_LINK ${CRT_GLOB_O})
endif()
include(GNUInstallDirs) include(GNUInstallDirs)

View File

@ -1,5 +1,5 @@
# Generated by generate_auto_job # Generated by generate_auto_job
CMakeLists.txt 47752f33b17fa526d46fc608a25ad6b8c61feba9deb1bd659fddf93e6e08b102 CMakeLists.txt 4aaa3d5df1713d9e3b9c6778101c6af3efa2131a2f4c069095abee269d5eaccc
generate_auto_job f64733b79dcee5a0e3e8ccc6976448e8ddf0e8b6529987a66a7d3ab2ebc10a86 generate_auto_job f64733b79dcee5a0e3e8ccc6976448e8ddf0e8b6529987a66a7d3ab2ebc10a86
include/qpdf/auto_job_c_att.hh 4c2b171ea00531db54720bf49a43f8b34481586ae7fb6cbf225099ee42bc5bb4 include/qpdf/auto_job_c_att.hh 4c2b171ea00531db54720bf49a43f8b34481586ae7fb6cbf225099ee42bc5bb4
include/qpdf/auto_job_c_copy_att.hh 50609012bff14fd82f0649185940d617d05d530cdc522185c7f3920a561ccb42 include/qpdf/auto_job_c_copy_att.hh 50609012bff14fd82f0649185940d617d05d530cdc522185c7f3920a561ccb42

View File

@ -7,14 +7,17 @@ realmain(int argc, char* argv[])
// In Windows, shell globbing is handled by the runtime, so // In Windows, shell globbing is handled by the runtime, so
// passing '*' as argument results in wildcard expansion. In // passing '*' as argument results in wildcard expansion. In
// non-Windows, globbing is done by the shell, so passing '*' // non-Windows, globbing is done by the shell, so passing '*'
// shows up as '*'. In Windows with MSVC, it is necessary to link // shows up as '*'. In Windows, it is necessary to link a certain
// a certain way for this to work. To test this, we invoke this // way for this to work. To test this, we invoke this program with
// program with a single quoted argument containing a shell glob // a single quoted argument containing a shell glob expression. In
// expression. In Windows, we expect to see multiple arguments, // Windows, we expect to see multiple arguments, none of which
// none of which contain '*'. Otherwise, we expected to see the // contain '*'. Otherwise, we expected to see the exact glob
// exact glob string that was passed in. The effectiveness of this // string that was passed in. The effectiveness of this test was
// test was exercised by manually breaking the link options for // exercised by manually breaking the link options for msvc and
// msvc and seeing that the test fails under that condition. // seeing that the test fails under that condition. Explicit link
// changes used to be needed only for MSVC, but as of late 2024,
// they are also neededed for mingw, which was found by CI failure
// of this test.
bool found_star = false; bool found_star = false;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {