The SystemTools::PutEnv function tries to provide the "putenv" API
without leaking memory. However, the kwsysDeletingCharVector singleton
frees memory that may still be referenced by the environment table,
having been placed there by putenv. If any static destruction or
processing by an external tool happens after the singleton is destroyed
and accesses the environment it will read invalid memory.
Replace use of putenv with setenv/unsetenv when available. The latter
manage internal copies of the values passed instead of referencing the
original memory. When setenv/unsetenv are not available use putenv with
a singleton that removes its values from the environment before freeing
their memory. This requires an "unputenv" implementation. On at least
some platforms it must be written in terms of "putenv" because other
APIs are not available and direct modification of the "environ" global
is not safe (e.g. on Windows there is interaction with "wenviron").
Fortunately either putenv("A=") or putenv("A") will remove "A" from the
environment on these platforms. On other platforms fall back to direct
manipulation of "environ".
Also add UnPutEnv to the API and add a test for the behavior of both.
We already use GetSystemTimeAsFileTime() and gettimeofday()
unconditionally on supported Windows and non-Windows platforms,
respectively. Remove outdated portability complexity.
Document explicitly that the first component always exists. Fix the
documentation of SplitPathRootComponent to note that home directory
roots (~/ and ~u/) always have a trailing slash.
The CopyFileIfDifferent, CopyFileAlways, CopyAFile and CopyADirectory
methods should always copy permissions. The special cases in which a
caller would pass copyPermissions=false should be handled at the call
site. The parameter needlessly complicates the interface and semantics
of these methods.
This converts the KWSys license to a pure 3-clause OSI-approved BSD
License. We drop the previous license clause requiring modified
versions to be plainly marked. We also update the KWSys copyright to
cover the full development time range.
We optimize this method by using the GetFileAttributesExA native Windows
API to check for file existence when possible. For real Windows builds
we always use it. For Cygwin we use cygwin_conv_to_win32_path to get a
native Windows path if possible and otherwise fall back to 'access'.
Cygwin-to-Windows path conversion and cache by Wojciech Migda.
See issue #8826.
This patch from Philip Lowman teaches SystemTools::GetRealPath to deal
with paths that do not exist by dealing with the case that realpath
returns NULL. See issue #8423.
- Add an argument to registry read/write/delete methods to specify
a 32-bit or 64-bit view.
- Default is the bit-ness of the running program.
- See issue #7095.
1. an "abridged" version that separates protocol from dataglom in
an expression with the form protocol://dataglom
2. a "full" version that parses protocol, username, password,
hostname, port, and path in a standard URL (all of these variables
are optional, except for protocol and hostname).