mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-31 02:48:31 +00:00
Allow -DNO_GET_ENVIRONMENT to avoid GetEnvironmentVariable
If NO_GET_ENVIRONMENT is #defined at compile time on Windows, do not call GetEnvironmentVariable. QUtil::get_env will always return false. This option is not available through configure. This was added to support a specific user's requirements to avoid calling GetEnvironmentVariable from the Windows API. Nothing in qpdf outside the test coverage system in qtest relies on QUtil::get_env.
This commit is contained in:
parent
88c29873e5
commit
478c05fcab
@ -1,5 +1,12 @@
|
||||
2013-11-29 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* If NO_GET_ENVIRONMENT is #defined, for Windows only,
|
||||
QUtil::get_env will always return false. This was added to
|
||||
support a user who needs to avoid calling GetEnvironmentVariable
|
||||
from the Windows API. QUtil::get_env is not used for any
|
||||
functionality in qpdf and exists only to support the test suite
|
||||
including test coverage support with QTC (part of qtest).
|
||||
|
||||
* Add /FS to msvc builds to allow parallel builds to work with
|
||||
Visual C++ 2013.
|
||||
|
||||
|
@ -51,6 +51,15 @@ int main(int argc, char* argv[])
|
||||
whoami += 3;
|
||||
}
|
||||
|
||||
// For test suite
|
||||
bool static_id = false;
|
||||
if ((argc > 1) && (strcmp(argv[1], " --static-id") == 0))
|
||||
{
|
||||
static_id = true;
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (! ((argc == 3) || (argc == 4)))
|
||||
{
|
||||
usage();
|
||||
@ -88,7 +97,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
// Write out a new file
|
||||
QPDFWriter w(qpdf, outfilename);
|
||||
if (QUtil::get_env("IN_TESTSUITE"))
|
||||
if (static_id)
|
||||
{
|
||||
// For the test suite, uncompress streams and use static
|
||||
// IDs.
|
||||
|
@ -70,6 +70,15 @@ int main(int argc, char* argv[])
|
||||
whoami += 3;
|
||||
}
|
||||
|
||||
// For test suite
|
||||
bool static_id = false;
|
||||
if ((argc > 1) && (strcmp(argv[1], " --static-id") == 0))
|
||||
{
|
||||
static_id = true;
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (! ((argc == 3) || (argc == 4)))
|
||||
{
|
||||
usage();
|
||||
@ -149,7 +158,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
// Write out a new file
|
||||
QPDFWriter w(qpdf, outfilename);
|
||||
if (QUtil::get_env("IN_TESTSUITE"))
|
||||
if (static_id)
|
||||
{
|
||||
// For the test suite, uncompress streams and use static
|
||||
// IDs.
|
||||
|
@ -12,7 +12,8 @@ my $td = new TestDriver('double-page-size');
|
||||
cleanup();
|
||||
|
||||
$td->runtest("double page size",
|
||||
{$td->COMMAND => "pdf-double-page-size in.pdf a.pdf"},
|
||||
{$td->COMMAND => ['pdf-double-page-size', ' --static-id',
|
||||
'in.pdf', 'a.pdf']},
|
||||
{$td->STRING =>
|
||||
"pdf-double-page-size: new file written to a.pdf\n",
|
||||
$td->EXIT_STATUS => 0},
|
||||
|
@ -12,7 +12,8 @@ my $td = new TestDriver('invert-images');
|
||||
cleanup();
|
||||
|
||||
$td->runtest("double page size",
|
||||
{$td->COMMAND => "pdf-invert-images in.pdf a.pdf"},
|
||||
{$td->COMMAND => ['pdf-invert-images', ' --static-id',
|
||||
'in.pdf', 'a.pdf']},
|
||||
{$td->STRING =>
|
||||
"pdf-invert-images: new file written to a.pdf\n",
|
||||
$td->EXIT_STATUS => 0},
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
@ -262,6 +263,9 @@ QUtil::get_env(std::string const& var, std::string* value)
|
||||
{
|
||||
// This was basically ripped out of wxWindows.
|
||||
#ifdef _WIN32
|
||||
# ifdef NO_GET_ENVIRONMENT
|
||||
return false;
|
||||
# else
|
||||
// first get the size of the buffer
|
||||
DWORD len = ::GetEnvironmentVariable(var.c_str(), NULL, 0);
|
||||
if (len == 0)
|
||||
@ -279,6 +283,7 @@ QUtil::get_env(std::string const& var, std::string* value)
|
||||
}
|
||||
|
||||
return true;
|
||||
# endif
|
||||
#else
|
||||
char* p = getenv(var.c_str());
|
||||
if (p == 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user