Skip to content

Commit

Permalink
Use env variable USERPROFILE instead of HOME for windows and mingw.
Browse files Browse the repository at this point in the history
re: Unidata#2380
re: Unidata#2337

This PARTIALLY fixes some HOME problems because under Windows,
the HOME environment variable may not be set. In that case, use the
USERPROFILE environment variable instead.
  • Loading branch information
DennisHeimbigner committed Jun 14, 2022
1 parent d68c2ff commit fda1219
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ IF(Bz2_FOUND)
set_std_filter(Bz2)
ELSE()
# The reason we use a local version is to support a more comples test case
MESSAGE(WARNING "libbz2 not found using built-in version")
MESSAGE("libbz2 not found using built-in version")
SET(HAVE_LOCAL_BZ2 ON)
SET(HAVE_BZ2 ON)
set(STD_FILTERS "${STD_FILTERS} bz2")
Expand Down
8 changes: 6 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ Release Notes {#RELEASE_NOTES}

This file contains a high-level description of this package's evolution. Releases are in reverse chronological order (most recent first). Note that, as of netcdf 4.2, the `netcdf-c++` and `netcdf-fortran` libraries have been separated into their own libraries.

## 4.9.0 - June 10, 2022
## 4.9.1 - T.B.D.

* [Bug Fix] Use env variable USERPROFILE instead of HOME for windows and mingw. See [Github #????](https://github.com/Unidata/netcdf-c/pull/????).
* [Bug Fix] Fix the nc_def_var_fletcher32 code in hdf5 to properly test value of the fletcher32 argument. See [Github #2403](https://github.com/Unidata/netcdf-c/pull/2403).

## 4.9.0 - June 10, 2022

* [Enhancement] Improve filter installation process to avoid use of an extra shell script. See [Github #2348](https://github.com/Unidata/netcdf-c/pull/2348).
* [Bug Fix] Get "make distcheck" to work See [Github #/2343](https://github.com/Unidata/netcdf-c/pull/2343).
* [Bug Fix] Get "make distcheck" to work See [Github #2343](https://github.com/Unidata/netcdf-c/pull/2343).
* [Enhancement] Allow the read/write of JSON-valued Zarr attributes to allow
for domain specific info such as used by GDAL/Zarr. See [Github #2278](https://github.com/Unidata/netcdf-c/pull/2278).
* [Enhancement] Turn on the XArray convention for NCZarr files by default. WARNING, this means that the mode should explicitly specify nczarr" or "zarr" even if "xarray" or "noxarray" is specified. See [Github #2257](https://github.com/Unidata/netcdf-c/pull/2257).
Expand Down
24 changes: 18 additions & 6 deletions libdispatch/ddispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ See LICENSE.txt for license information.
#include "ncs3sdk.h"
#endif

#define MAXPATH 1024



/* Define vectors of zeros and ones for use with various nc_get_varX functions */
/* Note, this form of initialization fails under Cygwin */
size_t NC_coord_zero[NC_MAX_VAR_DIMS] = {0};
Expand Down Expand Up @@ -76,15 +80,23 @@ NCDISPATCH_initialize(void)

/* Capture $HOME */
{
#if defined(_WIN32) && !defined(__MINGW32__)
char* home = getenv("HOME");

#else
char* home = getenv("USERPROFILE");
#endif
if(home == NULL) {
/* use tempdir */
home = globalstate->tempdir;
}
globalstate->home = strdup(home);
/* use cwd */
home = malloc(MAXPATH+1);
NCgetcwd(home,MAXPATH);
} else
home = strdup(home); /* make it always free'able */
assert(home != NULL);
NCpathcanonical(home,&globalstate->home);
nullfree(home);
}

fprintf(stderr,">>> HOME=|%s|\n",globalstate->home); fflush(stderr);

/* Capture $CWD */
{
char cwdbuf[4096];
Expand Down
6 changes: 5 additions & 1 deletion ncdap_test/t_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ fflush(stderr);
#ifndef NOHOME
{
/* Test 1: RC in HOME */
home = getenv("HOME");
#if defined(_WIN32) && !defined(__MINGW32__)
home = getenv("HOME");
#else
home = getenv("USERPROFILE");
#endif
fprintf(stderr,"user:pwd in %s/%s\n",home,RC);
if(!testrc(home,url2)) {
fprintf(stderr,"user:pwd in %s/%s failed\n",home,RC);
Expand Down
8 changes: 8 additions & 0 deletions test_common.in
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ ncgenc04="${top_srcdir}/ncgen/c0_4.cdl"
# Set LC_ALL
if test "x$FP_ISMSVC" = xyes || test "x$FP_ISCYGWIN" = xyes; then export LC_ALL="en_US.utf8"; fi

# Set HOME
if test "x$FP_ISMSVC" = xyes || test "x$FP_MINGW" = xyes; then
if test "x$HOME" = x ; then
HOME=`echo $USERPROFILE |tr '\\\' '/'`
export HOME
fi
fi

# Test for filter availability
avail() {
if test yes = `${execdir}/../ncdump/ncfilteravail $1` ; then return 0 ; else echo "filter $1 not available" ; return 1; fi
Expand Down

0 comments on commit fda1219

Please sign in to comment.