2020-10-21 17:30:20 +00:00
|
|
|
#include <qpdf/QUtil.hh>
|
2022-04-02 21:14:10 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <iostream>
|
2020-10-21 17:30:20 +00:00
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
int
|
|
|
|
realmain(int argc, char* argv[])
|
2020-10-21 17:30:20 +00:00
|
|
|
{
|
|
|
|
// In Windows, shell globbing is handled by the runtime, so
|
|
|
|
// passing '*' as argument results in wildcard expansion. In
|
|
|
|
// non-Windows, globbing is done by the shell, so passing '*'
|
|
|
|
// shows up as '*'. In Windows with MSVC, it is necessary to link
|
|
|
|
// a certain way for this to work. To test this, we invoke this
|
|
|
|
// program with a single quoted argument containing a shell glob
|
|
|
|
// expression. In Windows, we expect to see multiple arguments,
|
|
|
|
// none of which contain '*'. Otherwise, we expected to see the
|
|
|
|
// exact glob string that was passed in. The effectiveness of this
|
|
|
|
// test was exercised by manually breaking the link options for
|
|
|
|
// msvc and seeing that the test fails under that condition.
|
|
|
|
|
|
|
|
bool found_star = false;
|
2022-04-02 21:14:10 +00:00
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
if (strchr(argv[i], '*') != nullptr) {
|
2020-10-21 17:30:20 +00:00
|
|
|
found_star = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef _WIN32
|
2022-04-02 21:14:10 +00:00
|
|
|
bool passed = ((!found_star) && (argc > 2));
|
2020-10-21 17:30:20 +00:00
|
|
|
#else
|
|
|
|
bool passed = (found_star && (argc == 2));
|
|
|
|
#endif
|
2022-04-02 21:14:10 +00:00
|
|
|
if (passed) {
|
2020-10-21 17:30:20 +00:00
|
|
|
std::cout << "PASSED" << std::endl;
|
2022-04-02 21:14:10 +00:00
|
|
|
} else {
|
2020-10-21 17:30:20 +00:00
|
|
|
std::cout << "FAILED" << std::endl;
|
2022-04-02 21:14:10 +00:00
|
|
|
for (int i = 1; i < argc; ++i) {
|
2020-10-21 17:30:20 +00:00
|
|
|
std::cout << argv[i] << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WINDOWS_WMAIN
|
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
extern "C" int
|
|
|
|
wmain(int argc, wchar_t* argv[])
|
2020-10-21 17:30:20 +00:00
|
|
|
{
|
|
|
|
return QUtil::call_main_from_wmain(argc, argv, realmain);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
int
|
|
|
|
main(int argc, char* argv[])
|
2020-10-21 17:30:20 +00:00
|
|
|
{
|
|
|
|
return realmain(argc, argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|