diff --git a/.github/workflows/run_tests_win_mingw.yml b/.github/workflows/run_tests_win_mingw.yml new file mode 100644 index 0000000000..919c50f235 --- /dev/null +++ b/.github/workflows/run_tests_win_mingw.yml @@ -0,0 +1,54 @@ +### +# Build hdf4, hdf5 dependencies and cache them in a combined directory. +# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners +# for information related to github runners. +### + +name: Run MSYS2, MinGW64-based Tests + + +on: [ pull_request ] + +jobs: + + build-and-test: + + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + + steps: + + - uses: actions/checkout@v2 + - uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: git mingw-w64-x86_64-toolchain automake libtool autoconf make cmake mingw-w64-x86_64-hdf5 unzip + +### +# Configure and build +### + + - name: (Autotools) Run autoconf + run: autoreconf -if + + - name: (Autotools) Configure Build + run: ./configure --enable-hdf5 --enable-dap --disable-dap-remote-tests --disable-static --disable-plugins --disable-byterange --disable-dap-remote-tests --disable-logging + if: ${{ success() }} + + - name: (Autotools) Look at config.log if error + run: cat config.log + if: ${{ failure() }} + + - name: (Autotools) Print Summary + run: cat libnetcdf.settings + + - name: (Autotools) Build Library and Utilities + run: make -j 8 LDFLAGS="-no-undefined -Wl,--export-all-symbols" + if: ${{ success() }} + + - name: (Autotools) Build and Run Tests + run: make check -j 8 + if: ${{ success() }} diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 81a2834e6a..e64d4f4517 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -12,7 +12,8 @@ This file contains a high-level description of this package's evolution. Release * [Bug Fix] Make sure that netcdf.h accurately defines the flags in the open/create mode flags. See [Github #2183](https://github.com/Unidata/netcdf-c/pull/2183). * [Enhancement] Improve support for msys2+mingw platform. See [Github #2171](https://github.com/Unidata/netcdf-c/pull/2171). * [Bug Fix] Clean up the various inter-test dependencies in ncdump for CMake. See [Github #2168](https://github.com/Unidata/netcdf-c/pull/2168). -* [Enhancement] Added options to suppress the new behavior from [Github #2135](https://github.com/Unidata/netcdf-c/pull/2135). The options for `cmake` and `configure` are, respectively `-DENABLE_LIBXML2` and `--(enable/disable)-libxml2`. Both of these options defaul to 'on/enabled'. When disabled, the bundled `ezxml` XML interpreter is used regardless of whether `libxml2` is present on the system. +* [Bug Fix] Fix use of non-aws appliances. See [Github #2152](https://github.com/Unidata/netcdf-c/pull/2152). +* [Enhancement] Added options to suppress the new behavior from [Github #2135](https://github.com/Unidata/netcdf-c/pull/2135). The options for `cmake` and `configure` are, respectively `-DENABLE_LIBXML2` and `--(enable/disable)-libxml2`. Both of these options defaul to 'on/enabled'. When disabled, the bundled `ezxml` XML interpreter is used regardless of whether `libxml2` is present on the system. * [Enhancement] Support optional use of libxml2, otherwise default to ezxml. See [Github #2135](https://github.com/Unidata/netcdf-c/pull/2135) -- H/T to [Egbert Eich](https://github.com/e4t). * [Bug Fix] Fix several os related errors. See [Github #2138](https://github.com/Unidata/netcdf-c/pull/2138). * [Enhancement] Support byte-range reading of netcdf-3 files stored in private buckets in S3. See [Github #2134](https://github.com/Unidata/netcdf-c/pull/2134) @@ -30,24 +31,24 @@ This file contains a high-level description of this package's evolution. Release * [Enhancement] Convert to a new representation of the NCZarr meta-data extensions: version 2. Read-only backward compatibility is provided. See [Github #2032](https://github.com/Unidata/netcdf-c/pull/2032). * [Bug Fix] Fix dimension_separator bug in libnczarr. See [Github #2035](https://github.com/Unidata/netcdf-c/pull/2035). * [Bug Fix] Fix bugs in libdap4. See [Github #2005](https://github.com/Unidata/netcdf-c/pull/2005). -* [Bug Fix] Store NCZarr fillvalue as a singleton instead of a 1-element array. See [Github #2017](https://github.com/Unidata/netcdf-c/pull/2017). +* [Bug Fix] Store NCZarr fillvalue as a singleton instead of a 1-element array. See [Github #2017](https://github.com/Unidata/netcdf-c/pull/2017). * [Bug Fixes] The netcdf-c library was incorrectly determining the scope of dimension; similar to the type scope problem. See [Github #2012](https://github.com/Unidata/netcdf-c/pull/2012) for more information. -* [Bug Fix] Re-enable DAP2 authorization testing. See [Github #2011](https://github.com/Unidata/netcdf-c/issues/2011). -* [Bug Fix] Fix bug with windows version of mkstemp that causes failure to create more than 26 temp files. See [Github #1998](https://github.com/Unidata/netcdf-c/pull/1998). -* [Bug Fix] Fix ncdump bug when printing VLENs with basetype char. See [Github #1986](https://github.com/Unidata/netcdf-c/issues/1986). +* [Bug Fix] Re-enable DAP2 authorization testing. See [Github #2011](https://github.com/Unidata/netcdf-c/issues/2011). +* [Bug Fix] Fix bug with windows version of mkstemp that causes failure to create more than 26 temp files. See [Github #1998](https://github.com/Unidata/netcdf-c/pull/1998). +* [Bug Fix] Fix ncdump bug when printing VLENs with basetype char. See [Github #1986](https://github.com/Unidata/netcdf-c/issues/1986). * [Bug Fixes] The netcdf-c library was incorrectly determining the scope of types referred to by nc_inq_type_equal. See [Github #1959](https://github.com/Unidata/netcdf-c/pull/1959) for more information. * [Bug Fix] Fix bug in use of XGetopt when building under Mingw. See [Github #2009](https://github.com/Unidata/netcdf-c/issues/2009). * [Enhancement] Improve the error reporting when attempting to use a filter for which no implementation can be found in HDF5_PLUGIN_PATH. See [Github #2000](https://github.com/Unidata/netcdf-c/pull/2000) for more information. * [Bug Fix] Fix `make distcheck` issue in `nczarr_test/` directory. See [Github #2007](https://github.com/Unidata/netcdf-c/issues/2007). * [Bug Fix] Fix bug in NCclosedir in dpathmgr.c. See [Github #2003](https://github.com/Unidata/netcdf-c/issues/2003). -* [Bug Fix] Fix bug in ncdump that assumes that there is a relationship between the total number of dimensions and the max dimension id. See [Github #2004](https://github.com/Unidata/netcdf-c/issues/2004). -* [Bug Fix] Fix bug in JSON processing of strings with embedded quotes. See [Github #1993](https://github.com/Unidata/netcdf-c/issues/1993). +* [Bug Fix] Fix bug in ncdump that assumes that there is a relationship between the total number of dimensions and the max dimension id. See [Github #2004](https://github.com/Unidata/netcdf-c/issues/2004). +* [Bug Fix] Fix bug in JSON processing of strings with embedded quotes. See [Github #1993](https://github.com/Unidata/netcdf-c/issues/1993). * [Enhancement] Add support for the new "dimension_separator" enhancement to Zarr v2. See [Github #1990](https://github.com/Unidata/netcdf-c/pull/1990) for more information. -* [Bug Fix] Fix hack for handling failure of shell programs to properly handle escape characters. See [Github #1989](https://github.com/Unidata/netcdf-c/issues/1989). -* [Bug Fix] Allow some primitive type names to be used as identifiers depending on the file format. See [Github #1984](https://github.com/Unidata/netcdf-c/issues/1984). +* [Bug Fix] Fix hack for handling failure of shell programs to properly handle escape characters. See [Github #1989](https://github.com/Unidata/netcdf-c/issues/1989). +* [Bug Fix] Allow some primitive type names to be used as identifiers depending on the file format. See [Github #1984](https://github.com/Unidata/netcdf-c/issues/1984). * [Enhancement] Add support for reading/writing pure Zarr storage format that supports the XArray _ARRAY_DIMENSIONS attribute. See [Github #1952](https://github.com/Unidata/netcdf-c/pull/1952) for more information. * [Update] Updated version of bzip2 used in filter testing/functionality, in support of [Github #1969](https://github.com/Unidata/netcdf-c/issues/1969). -* [Bug Fix] Corrected HDF5 version detection logic as described in [Github #1962](https://github.com/Unidata/netcdf-c/issues/1962). +* [Bug Fix] Corrected HDF5 version detection logic as described in [Github #1962](https://github.com/Unidata/netcdf-c/issues/1962). ## 4.8.0 - March 30, 2021 diff --git a/include/ncs3sdk.h b/include/ncs3sdk.h index e9dd2b2f02..2200dcb293 100644 --- a/include/ncs3sdk.h +++ b/include/ncs3sdk.h @@ -10,8 +10,8 @@ extern "C" { #endif -EXTERNL void NC_s3sdkinitialize(void); -EXTERNL void NC_s3sdkfinalize(void); +EXTERNL int NC_s3sdkinitialize(void); +EXTERNL int NC_s3sdkfinalize(void); EXTERNL void* NC_s3sdkcreateclient(NCS3INFO* context); EXTERNL int NC_s3sdkbucketexists(void* s3client, const char* bucket, int* existsp, char** errmsgp); EXTERNL int NC_s3sdkbucketcreate(void* s3client, const char* region, const char* bucket, char** errmsgp); diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index 2f3fb91623..c2149a6396 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -40,6 +40,11 @@ #undef DEBUG +#ifndef nulldup + #define nulldup(s) ((s)?strdup(s):NULL) +#endif + + extern int NC_initialized; /**< True when dispatch table is initialized. */ /* User-defined formats. */ diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index 97eeb18a5f..fb58d18c23 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -32,6 +32,10 @@ #endif #endif +#ifndef nulldup + #define nulldup(x) ((x)?strdup(x):(x)) +#endif + #undef DEBUG /* If Defined, then use only stdio for all magic number io; @@ -251,7 +255,7 @@ processuri(const char* path, NCURI** urip, NClist* fraglenv) if(!found) {stat = NC_EINVAL; goto done;} /* unrecognized URL form */ - /* process the corresponding fragments for that protocol */ + /* process the corresponding fragments for that protocol */ if(protolist->fragments != NULL) { int i; tmp = nclistnew(); @@ -266,7 +270,7 @@ processuri(const char* path, NCURI** urip, NClist* fraglenv) } nclistfreeall(tmp); tmp = NULL; } - + /* Substitute the protocol in any case */ if(protolist->substitute) ncurisetprotocol(uri,protolist->substitute); @@ -461,7 +465,7 @@ processmacros(NClist** fraglenvp) if(fraglenvp == NULL || nclistlength(*fraglenvp) == 0) goto done; fraglenv = *fraglenvp; - expanded = nclistnew(); + expanded = nclistnew(); while(nclistlength(fraglenv) > 0) { int found = 0; char* key = NULL; @@ -606,7 +610,7 @@ mergekey(NClist** valuesp) if(strcasecmp(candidate,value)==0) {nullfree(value); value = NULL; break;} } - } + } if(value != NULL) {nclistpush(newvalues,value); value = NULL;} } /* Make sure to have at least 1 value */ @@ -679,11 +683,11 @@ cleanfragments(NClist** fraglenvp) newlist = nclistnew(); buf = ncbytesnew(); allkeys = nclistnew(); - tmp = nclistnew(); + tmp = nclistnew(); /* collect all unique keys */ collectallkeys(fraglenv,allkeys); - /* Collect all values for same key across all fragments */ + /* Collect all values for same key across all fragments */ for(i=0;iformat = format; goto done; } -#endif +#endif magicinfo.path = path; /* do not free */ magicinfo.uri = uri; /* do not free */ diff --git a/libdispatch/drc.c b/libdispatch/drc.c index 1fa3dee6c7..e4313f8615 100644 --- a/libdispatch/drc.c +++ b/libdispatch/drc.c @@ -23,6 +23,10 @@ See COPYRIGHT for license information. #include "ncauth.h" #include "ncpathmgr.h" +#ifndef nulldup + #define nulldup(x) ((x)?strdup(x):(x)) +#endif + #undef NOREAD #undef DRCDEBUG @@ -76,7 +80,7 @@ ncrc_createglobalstate(void) { int stat = NC_NOERR; const char* tmp = NULL; - + if(ncrc_globalstate == NULL) { ncrc_globalstate = calloc(1,sizeof(NCRCglobalstate)); } @@ -99,7 +103,7 @@ Initialize defaults and load: For debugging support, it is possible to change where the code looks for the .aws directory. -This is set by the environment variable NC_TEST_AWS_DIR. +This is set by the environment variable NC_TEST_AWS_DIR. */ @@ -107,10 +111,10 @@ void ncrc_initialize(void) { int stat = NC_NOERR; - + if(NCRCinitialized) return; NCRCinitialized = 1; /* prevent recursion */ - + #ifndef NOREAD /* Load entrys */ if((stat = NC_rcload())) { @@ -192,7 +196,7 @@ NC_rcload(void) if(!NCRCinitialized) ncrc_initialize(); globalstate = ncrc_getglobalstate(); - + if(globalstate->rcinfo.ignore) { nclog(NCLOGDBG,".rc file loading suppressed"); @@ -217,21 +221,21 @@ NC_rcload(void) const char** rcname; const char* dirnames[3]; const char** dir; - - + + /* Make sure rcinfo.rchome is defined */ ncrc_setrchome(); - + dirnames[0] = globalstate->rcinfo.rchome; dirnames[1] = globalstate->cwd; dirnames[2] = NULL; - for(dir=dirnames;*dir;dir++) { + for(dir=dirnames;*dir;dir++) { for(rcname=rcfilenames;*rcname;rcname++) { ret = rcsearch(*dir,*rcname,&path); if(ret == NC_NOERR && path != NULL) nclistpush(rcfileorder,path); - path = NULL; + path = NULL; } } } @@ -612,7 +616,7 @@ NC_rcfile_insert(const char* key, const char* value, const char* hostport, const if(!NCRCinitialized) ncrc_initialize(); globalstate = ncrc_getglobalstate(); rc = globalstate->rcinfo.entries; - + if(rc == NULL) { rc = nclistnew(); if(rc == NULL) {ret = NC_ENOMEM; goto done;} @@ -727,7 +731,7 @@ NC_getdefaults3region(NCURI* uri, const char** regionp) region = NC_rclookupx(uri,"AWS.REGION"); if(region == NULL) {/* See if we can find a profile */ if((stat = NC_getactives3profile(uri,&profile))==NC_NOERR) { - if(profile) + if(profile) (void)NC_s3profilelookup(profile,"aws_region",®ion); } } @@ -835,7 +839,7 @@ awslex(AWSparser* parser) } else if(c == ';') { char* p = parser->pos - 1; if(*p == '\n') { - /* Skip comment */ + /* Skip comment */ do {p++;} while(*p != '\n' && *p != '\0'); parser->pos = p; token = (*p == '\n'?AWS_EOL:AWS_EOF); @@ -952,12 +956,12 @@ fprintf(stderr,">>> parse: profile=%s\n",profile->name); if((entry = (struct AWSentry*)calloc(1,sizeof(struct AWSentry)))==NULL) {stat = NC_ENOMEM; goto done;} entry->key = key; key = NULL; - entry->value = value; value = NULL; + entry->value = value; value = NULL; #ifdef PARSEDEBUG fprintf(stderr,">>> parse: entry=(%s,%s)\n",entry->key,entry->value); #endif nclistpush(profile->entries,entry); entry = NULL; - if(token == AWS_WORD) token = awslex(parser); /* finish the line */ + if(token == AWS_WORD) token = awslex(parser); /* finish the line */ } else {stat = NCTHROW(NC_EINVAL); goto done;} } @@ -1099,7 +1103,7 @@ NC_authgets3profile(const char* profilename, struct AWSprofile** profilep) int stat = NC_NOERR; int i = -1; NCRCglobalstate* gstate = ncrc_getglobalstate(); - + for(i=0;is3creds.profiles);i++) { struct AWSprofile* profile = (struct AWSprofile*)nclistget(gstate->s3creds.profiles,i); if(strcmp(profilename,profile->name)==0) diff --git a/libdispatch/ds3util.c b/libdispatch/ds3util.c index 40bc09f58c..3d6ba67244 100644 --- a/libdispatch/ds3util.c +++ b/libdispatch/ds3util.c @@ -119,11 +119,12 @@ NC_s3urlrebuild(NCURI* url, NCURI** newurlp, char** bucketp, char** outregionp) if((stat = NC_getdefaults3region(url,®ion0))) goto done; region = strdup(region0); } - /* Construct the revised host */ - ncbytescat(buf,"s3."); - ncbytescat(buf,region); - ncbytescat(buf,AWSHOST); - host = ncbytesextract(buf); + if(host == NULL) { /* Construct the revised host */ + ncbytescat(buf,"s3."); + ncbytescat(buf,region); + ncbytescat(buf,AWSHOST); + host = ncbytesextract(buf); + } /* Construct the revised path */ ncbytesclear(buf); diff --git a/libdispatch/dutil.c b/libdispatch/dutil.c index bf44be72c5..fc8a018d1a 100644 --- a/libdispatch/dutil.c +++ b/libdispatch/dutil.c @@ -29,7 +29,9 @@ #include "ncpathmgr.h" #define NC_MAX_PATH 4096 - +#ifndef nulldup + #define nulldup(x) ((x)?strdup(x):(x)) +#endif /**************************************************/ /** * Provide a hidden interface to allow utilities @@ -281,7 +283,7 @@ NC_getmodelist(const char* modestr, NClist** modelistp) int stat=NC_NOERR; NClist* modelist = NULL; - modelist = nclistnew(); + modelist = nclistnew(); if(modestr == NULL || strlen(modestr) == 0) goto done; /* Parse the mode string at the commas or EOL */ @@ -323,7 +325,7 @@ NC_testmode(NCURI* uri, const char* tag) const char* modestr = NULL; NClist* modelist = NULL; - modestr = ncurifragmentlookup(uri,"mode"); + modestr = ncurifragmentlookup(uri,"mode"); if(modestr == NULL) goto done; /* Parse mode str */ if((stat = NC_getmodelist(modestr,&modelist))) goto done; @@ -331,14 +333,14 @@ NC_testmode(NCURI* uri, const char* tag) for(i=0;idim); i++) { NC_DIM_INFO_T* dim = (NC_DIM_INFO_T*)ncindexith(grp->dim,i); char slen[128]; @@ -182,7 +186,7 @@ ncz_sync_grp(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, int isclose) zinfo->zarr.nczarr_version.major, zinfo->zarr.nczarr_version.minor, zinfo->zarr.nczarr_version.release); - if((stat = NCJnew(NCJ_DICT,&jsuper))) goto done; + if((stat = NCJnew(NCJ_DICT,&jsuper))) goto done; if((stat-NCJnewstring(NCJ_STRING,version,&jtmp))) goto done; if((stat = NCJinsert(jsuper,"version",jtmp))) goto done; jtmp = NULL; @@ -191,7 +195,7 @@ ncz_sync_grp(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, int isclose) } if(!purezarr) { - /* Insert the "_NCZARR_GROUP" dict */ + /* Insert the "_NCZARR_GROUP" dict */ if((stat = NCJinsert(jgroup,NCZ_V2_GROUP,json))) goto done; json = NULL; } @@ -266,7 +270,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) NClist* filterchain = NULL; NCjson* jfilter = NULL; #endif - + zinfo = file->format_file_info; map = zinfo->map; @@ -353,7 +357,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) } if((stat = NCJappend(jvar,jtmp))) goto done; jtmp = NULL; - + /* fill_value key */ if(var->no_fill) { if((stat=NCJnew(NCJ_NULL,&jfill))) goto done; @@ -373,7 +377,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) if((stat = NCJaddstring(jvar,NCJ_STRING,"order"))) goto done; /* "C" means row-major order, i.e., the last dimension varies fastest; "F" means column-major order, i.e., the first dimension varies fastest.*/ - /* Default to C for now */ + /* Default to C for now */ if((stat = NCJaddstring(jvar,NCJ_STRING,"C"))) goto done; /* Compressor and Filters */ @@ -382,7 +386,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) configuration parameters, or ``null`` if no compressor is to be used. */ if((stat = NCJaddstring(jvar,NCJ_STRING,"compressor"))) goto done; #ifdef ENABLE_NCZARR_FILTERS - filterchain = (NClist*)var->filters; + filterchain = (NClist*)var->filters; if(nclistlength(filterchain) > 0) { struct NCZ_Filter* filter = (struct NCZ_Filter*)nclistget(filterchain,nclistlength(filterchain)-1); /* encode up the compressor */ @@ -390,7 +394,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) } else #endif { /* no filters at all */ - /* Default to null */ + /* Default to null */ if((stat = NCJnew(NCJ_NULL,&jtmp))) goto done; } if(jtmp && (stat = NCJappend(jvar,jtmp))) goto done; @@ -432,7 +436,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) if((stat = NCJinsert(jvar,"dimension_separator",jtmp))) goto done; jtmp = NULL; } - + /* Capture dimref names as FQNs */ if(var->ndims > 0) { if((dimrefs = nclistnew())==NULL) {stat = NC_ENOMEM; goto done;} @@ -455,14 +459,14 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) } if((stat = NCJnew(NCJ_DICT,&jncvar))) goto done; - + /* Insert dimrefs */ if((stat = NCJinsert(jncvar,"dimrefs",jdimrefs))) goto done; jdimrefs = NULL; /* Avoid memory problems */ /* Add the _Storage flag */ - /* Record if this is a scalar; use the storage field */ + /* Record if this is a scalar; use the storage field */ if(var->ndims == 0) { if((stat = NCJnewstring(NCJ_STRING,"scalar",&jtmp)))goto done; } else if(var->storage == NC_CONTIGUOUS) { @@ -471,7 +475,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) if((stat = NCJnewstring(NCJ_STRING,"compact",&jtmp)))goto done; } else {/* chunked */ if((stat = NCJnewstring(NCJ_STRING,"chunked",&jtmp)))goto done; - } + } if((stat = NCJinsert(jncvar,"storage",jtmp))) goto done; jtmp = NULL; @@ -524,7 +528,6 @@ ncz_sync_var(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) { int stat = NC_NOERR; NCZ_VAR_INFO_T* zvar = var->format_var_info; - if(isclose) { if((stat = ncz_sync_var_meta(file,var,isclose))) goto done; } @@ -554,7 +557,7 @@ ncz_write_var(NC_VAR_INFO_T* var) if(zvar->cache) { if((stat = NCZ_flush_chunk_cache(zvar->cache))) goto done; } - + #ifdef FILLONCLOSE /* If fill is enabled, then create missing chunks */ if(!var->no_fill) { @@ -562,7 +565,7 @@ ncz_write_var(NC_VAR_INFO_T* var) NCZOdometer* chunkodom = NULL; NC_FILE_INFO_T* file = var->container->nc4_info; NCZ_FILE_INFO_T* zfile = (NCZ_FILE_INFO_T*)file->format_file_info; - NCZMAP* map = zfile->map; + NCZMAP* map = zfile->map; size64_t start[NC_MAX_VAR_DIMS]; size64_t stop[NC_MAX_VAR_DIMS]; size64_t stride[NC_MAX_VAR_DIMS]; @@ -585,7 +588,7 @@ ncz_write_var(NC_VAR_INFO_T* var) if((chunkodom = nczodom_new(var->ndims+zvar->scalar,start,stop,stride,stop))==NULL) {stat = NC_ENOMEM; goto done;} for(;nczodom_more(chunkodom);nczodom_next(chunkodom)) { - size64_t* indices = nczodom_indices(chunkodom); + size64_t* indices = nczodom_indices(chunkodom); /* Convert to key */ if((stat = NCZ_buildchunkpath(zvar->cache,indices,&key))) goto done; switch (stat = nczmap_exists(map,key)) { @@ -668,7 +671,7 @@ ncz_sync_atts(NC_FILE_INFO_T* file, NC_OBJ* container, NCindex* attlist, int isc /* If reserved and hidden, then ignore */ if(ra && (ra->flags & HIDDENATTRFLAG)) continue; if(a->nc_typeid >= NC_STRING) - {stat = THROW(NC_ENCZARR); goto done;} + {stat = THROW(NC_ENCZARR); goto done;} if((stat = ncz_zarr_type_name(a->nc_typeid,1,&tname))) goto done; if((stat = NCJnewstring(NCJ_STRING,tname,&jtype))) goto done; @@ -677,7 +680,7 @@ ncz_sync_atts(NC_FILE_INFO_T* file, NC_OBJ* container, NCindex* attlist, int isc jtype = NULL; } } - + /* Construct container path */ if(container->sort == NCGRP) stat = NCZ_grpkey(grp,&fullpath); @@ -768,7 +771,7 @@ ncz_sync_atts(NC_FILE_INFO_T* file, NC_OBJ* container, NCindex* attlist, int isc @internal Convert a list of attributes to corresponding json. Note that this does not push to the file. Also note that attributes of length 1 are stored as singletons, not arrays. -This is to be more consistent with pure zarr. +This is to be more consistent with pure zarr. @param attlist - [in] the attributes to dictify @param jattrsp - [out] the json'ized att list @return NC_NOERR @@ -1032,7 +1035,7 @@ computeattrdata(nc_type* typeidp, NCjson* values, size_t* typelenp, size_t* lenp data = malloc(typelen*count); if(data == NULL) {stat = NC_ENOMEM; goto done;} - /* convert to target type */ + /* convert to target type */ if((stat = zconvert(typeid, typelen, data, values))) goto done; } @@ -1040,7 +1043,7 @@ computeattrdata(nc_type* typeidp, NCjson* values, size_t* typelenp, size_t* lenp if(typelenp) *typelenp = typelen; if(datap) {*datap = data; data = NULL;} if(typeidp) *typeidp = typeid; /* return possibly inferred type */ - + done: if(reclaimvalues) NCJreclaim(values); /* we created it */ nullfree(data); @@ -1125,7 +1128,7 @@ mininttype(unsigned long long u64, int negative) if(i64 <= NC_MAX_UINT) return NC_UINT; return NC_INT64; } - + /** * @internal Read file data from map to memory. @@ -1302,7 +1305,7 @@ ncz_read_atts(NC_FILE_INFO_T* file, NC_OBJ* container) NCjson* key = NCJith(jattrs,i); NCjson* value = NCJith(jattrs,i+1); const NC_reservedatt* ra = NULL; - + /* See if this is reserved attribute */ ra = NC_findreserved(NCJstring(key)); if(ra != NULL) { @@ -1331,7 +1334,7 @@ ncz_read_atts(NC_FILE_INFO_T* file, NC_OBJ* container) assert(k != NULL && NCJsort(k) == NCJ_STRING); nclistpush(zvar->xarray,strdup(NCJstring(k))); } - } + } /* else ignore */ continue; } @@ -1560,7 +1563,7 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames) /* Note that we do not create the _FillValue attribute here to avoid having to read all the attributes and thus foiling lazy read.*/ - } + } } /* chunks */ { @@ -1612,12 +1615,12 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames) if((stat = NCZ_filter_initialize())) goto done; if((stat = NCJdictget(jvar,"filters",&jvalue))) goto done; if(jvalue != NULL && NCJsort(jvalue) != NCJ_NULL) { - if(NCJsort(jvalue) != NCJ_ARRAY) {stat = NC_EFILTER; goto done;} + if(NCJsort(jvalue) != NCJ_ARRAY) {stat = NC_EFILTER; goto done;} for(k=0;;k++) { jfilter = NULL; jfilter = NCJith(jvalue,k); if(jfilter == NULL) break; /* done */ - if(NCJsort(jfilter) != NCJ_DICT) {stat = NC_EFILTER; goto done;} + if(NCJsort(jfilter) != NCJ_DICT) {stat = NC_EFILTER; goto done;} if((stat = NCZ_filter_build(file,var,jfilter))) goto done; } } @@ -1634,7 +1637,7 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames) if((stat = NCZ_filter_initialize())) goto done; if((stat = NCJdictget(jvar,"compressor",&jfilter))) goto done; if(jfilter != NULL && NCJsort(jfilter) != NCJ_NULL) { - if(NCJsort(jfilter) != NCJ_DICT) {stat = NC_EFILTER; goto done;} + if(NCJsort(jfilter) != NCJ_DICT) {stat = NC_EFILTER; goto done;} if((stat = NCZ_filter_build(file,var,jfilter))) goto done; } #endif @@ -1660,12 +1663,12 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames) goto done; if(jvalue != NULL) { if(strcmp(NCJstring(jvalue),"chunked") == 0) { - var->storage = NC_CHUNKED; + var->storage = NC_CHUNKED; } else if(strcmp(NCJstring(jvalue),"compact") == 0) { var->storage = NC_COMPACT; } else if(strcmp(NCJstring(jvalue),"scalar") == 0) { var->storage = NC_CONTIGUOUS; - zvar->scalar = 1; + zvar->scalar = 1; } else { /*storage = NC_CONTIGUOUS;*/ var->storage = NC_CONTIGUOUS; } @@ -1771,7 +1774,7 @@ ncz_read_superblock(NC_FILE_INFO_T* file, char** nczarrvp, char** zarrfp) char* nczarr_version = NULL; char* zarr_format = NULL; NCZ_FILE_INFO_T* zinfo = (NCZ_FILE_INFO_T*)file->format_file_info; - + /* See if the V1 META-Root is being used */ switch(stat = NCZ_downloadjson(zinfo->map, NCZMETAROOT, &jnczgroup)) { case NC_EEMPTY: /* not there */ @@ -1811,7 +1814,7 @@ ncz_read_superblock(NC_FILE_INFO_T* file, char** nczarrvp, char** zarrfp) if(jnczgroup == NULL && jsuper == NULL) { zinfo->controls.flags |= FLAG_PUREZARR; } else if(jnczgroup != NULL) { - zinfo->controls.flags |= FLAG_NCZARR_V1; + zinfo->controls.flags |= FLAG_NCZARR_V1; /* Also means file is read only */ file->no_write = 1; } else if(jsuper != NULL) { @@ -1851,7 +1854,7 @@ parse_group_content(NCjson* jcontent, NClist* dimdefs, NClist* varnames, NClist* /* check the length */ sscanf(NCJstring(jlen),"%lld",&len); if(len < 0) - {stat = NC_EDIMSIZE; goto done;} + {stat = NC_EDIMSIZE; goto done;} nclistpush(dimdefs,strdup(norm_name)); nclistpush(dimdefs,strdup(NCJstring(jlen))); } @@ -1943,7 +1946,7 @@ searchvars(NCZ_FILE_INFO_T* zfile, NC_GRP_INFO_T* grp, NClist* varnames) char* varkey = NULL; char* zarray = NULL; NClist* matches = nclistnew(); - + /* Compute the key for the grp */ if((stat = NCZ_grpkey(grp,&grpkey))) goto done; /* Get the map and search group */ @@ -1977,7 +1980,7 @@ searchsubgrps(NCZ_FILE_INFO_T* zfile, NC_GRP_INFO_T* grp, NClist* subgrpnames) char* subkey = NULL; char* zgroup = NULL; NClist* matches = nclistnew(); - + /* Compute the key for the grp */ if((stat = NCZ_grpkey(grp,&grpkey))) goto done; /* Get the map and search group */ @@ -2064,7 +2067,7 @@ locategroup(NC_FILE_INFO_T* file, size_t nsegs, NClist* segments, NC_GRP_INFO_T* break; } } - if(!found) {stat = NC_ENOGRP; goto done;} + if(!found) {stat = NC_ENOGRP; goto done;} } /* grp should be group of interest */ if(grpp) *grpp = grp; @@ -2198,7 +2201,7 @@ ncz_create_superblock(NCZ_FILE_INFO_T* zinfo) char version[1024]; ZTRACE(4,"zinfo=%s",zinfo->common.file->controller->path); - + /* If V2, then do not create a superblock per-se */ if(!(zinfo->controls.flags & FLAG_NCZARR_V1)) goto done; @@ -2240,7 +2243,7 @@ computedimrefs(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int purezarr, int xarra NCZ_FILE_INFO_T* zfile = (NCZ_FILE_INFO_T*)file->format_file_info; NCZ_VAR_INFO_T* zvar = (NCZ_VAR_INFO_T*)(var->format_var_info); NCjson* jatts = NULL; - + assert(zfile && zvar); /* xarray => purezarr */ diff --git a/nc_test/tst_inmemory.c b/nc_test/tst_inmemory.c index fa1e8b76f3..5119af820f 100644 --- a/nc_test/tst_inmemory.c +++ b/nc_test/tst_inmemory.c @@ -213,7 +213,11 @@ writefile(const char* path, NC_memio* memio) char* p = NULL; /* Open the file for writing */ - f = NCfopen(path,"w"); +#ifdef _WIN32 + f = fopen(path,"wb"); +#else + f = fopen(path,"w"); +#endif if(f == NULL) {status = errno; goto done;} count = memio->size; diff --git a/ncdap_test/Makefile.am b/ncdap_test/Makefile.am index 875c9fa5e2..b8de229ca4 100644 --- a/ncdap_test/Makefile.am +++ b/ncdap_test/Makefile.am @@ -10,6 +10,7 @@ include $(top_srcdir)/lib_flags.am #SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose #LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose #TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose +#TESTS_ENVIRONMENT += export SETX=1; # Note which tests depend on other tests. Necessary for make -j check. TEST_EXTENSIONS = .sh diff --git a/ncgen/cvt.c b/ncgen/cvt.c index a5bbd3fdd9..8224ea6ad7 100644 --- a/ncgen/cvt.c +++ b/ncgen/cvt.c @@ -10,8 +10,15 @@ #include "isnan.h" #include + +#ifndef nulldup + #define nulldup(x) ((x)?strdup(x):(x)) +#endif + static char stmp[256]; + + void convert1(NCConstant* src, NCConstant* dst) { @@ -34,7 +41,7 @@ convert1(NCConstant* src, NCConstant* dst) if(src->nctype == NC_FILLVALUE) { if(dst->nctype != NC_FILLVALUE) { nc_getfill(dst,NULL); - } + } return; } @@ -516,39 +523,39 @@ case CASE(NC_OPAQUE,NC_BYTE): tmp.uint8v = *(unsigned char*)bytes; break; case CASE(NC_OPAQUE,NC_UBYTE): - if(bytes) + if(bytes) tmp.uint8v = *(unsigned char*)bytes; break; case CASE(NC_OPAQUE,NC_USHORT): - if(bytes) + if(bytes) tmp.uint16v = *(unsigned short*)bytes; break; case CASE(NC_OPAQUE,NC_UINT): - if(bytes) + if(bytes) tmp.uint32v = *(unsigned int*)bytes; break; case CASE(NC_OPAQUE,NC_UINT64): - if(bytes) + if(bytes) tmp.uint64v = *(unsigned long long*)bytes; break; case CASE(NC_OPAQUE,NC_SHORT): - if(bytes) + if(bytes) tmp.int16v = *(short*)bytes; break; case CASE(NC_OPAQUE,NC_INT): - if(bytes) + if(bytes) tmp.int32v = *(int*)bytes; break; case CASE(NC_OPAQUE,NC_INT64): - if(bytes) + if(bytes) tmp.int64v = *(long long*)bytes; break; case CASE(NC_OPAQUE,NC_FLOAT): - if(bytes) + if(bytes) tmp.floatv = *(float*)bytes; break; case CASE(NC_OPAQUE,NC_DOUBLE): - if(bytes) + if(bytes) tmp.doublev = *(double*)bytes; break; case CASE(NC_OPAQUE,NC_OPAQUE): @@ -561,7 +568,7 @@ case CASE(NC_NIL,NC_NIL): break; /* probably will never happen */ case CASE(NC_NIL,NC_STRING): tmp.stringv.len = 0; - tmp.stringv.stringv = NULL; + tmp.stringv.stringv = NULL; break; /* We are missing all CASE(X,NC_ECONST) cases*/ @@ -605,7 +612,7 @@ setprimlength(NCConstant* prim, unsigned long len) /* Note that expansion/contraction is in terms of whole bytes = 2 nibbles */ ASSERT((len % 2) == 0); - if(prim->value.opaquev.len == len) { + if(prim->value.opaquev.len == len) { /* do nothing*/ } else if(prim->value.opaquev.len > len) { /* truncate*/ prim->value.opaquev.stringv[len] = '\0'; diff --git a/ncgen/ncgen.h b/ncgen/ncgen.h index d6b253dfbe..e2136ab5d1 100644 --- a/ncgen/ncgen.h +++ b/ncgen/ncgen.h @@ -8,6 +8,10 @@ #include "config.h" +#ifndef nulldup + #define nulldup(x) ((x)?strdup(x):(x)) +#endif + #ifdef USE_NETCDF4 #define CLASSICONLY 0 #else diff --git a/ncgen3/ncgen.h b/ncgen3/ncgen.h index 7c4e307bc7..a51b1d79a2 100644 --- a/ncgen3/ncgen.h +++ b/ncgen3/ncgen.h @@ -12,6 +12,10 @@ #include "config.h" #include "generic.h" +#ifndef nulldup + #define nulldup(x) ((x)?strdup(x):(x)) +#endif + extern int ncid; /* handle for netCDF */ extern int ndims; /* number of dimensions declared for netcdf */ extern int nvars; /* number of variables declared for netcdf */ diff --git a/nczarr_test/run_interop.sh b/nczarr_test/run_interop.sh index 7006509cc1..17d059e02c 100755 --- a/nczarr_test/run_interop.sh +++ b/nczarr_test/run_interop.sh @@ -82,8 +82,8 @@ case "$zext" in esac } -#testallcases file -#if test "x$FEATURE_NCZARR_ZIP" = xyes ; then testallcases zip; fi +testallcases file +if test "x$FEATURE_NCZARR_ZIP" = xyes ; then testallcases zip; fi if test "x$FEATURE_S3TESTS" = xyes ; then testallcases s3; fi exit # Cleanup diff --git a/nczarr_test/test_nczarr_utils.h b/nczarr_test/test_nczarr_utils.h index 98e754f75f..d23a3213dd 100644 --- a/nczarr_test/test_nczarr_utils.h +++ b/nczarr_test/test_nczarr_utils.h @@ -30,6 +30,10 @@ #include "ncbytes.h" #include "zincludes.h" +#ifndef nulldup + #define nulldup(x) ((x)?strdup(x):(x)) +#endif + static char* progname = NULL; struct ITOptions { @@ -120,8 +124,8 @@ void processoptions(int argc, char** argv, const char* base_file_name) { int c; - - if(argc == 1) test_usage(); + + if(argc == 1) test_usage(); progname = nulldup(ubasename(argv[0])); while ((c = getopt(argc, argv, "e:c:F:")) != EOF) diff --git a/nczarr_test/tst_zchunks.c b/nczarr_test/tst_zchunks.c index 7e3955cb96..e1093519fe 100644 --- a/nczarr_test/tst_zchunks.c +++ b/nczarr_test/tst_zchunks.c @@ -139,7 +139,7 @@ main(int argc, char **argv) if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; if (nvars != NUM_TYPE || ndims != NUM_DIM || ngatts != 0 || unlimdimid == 0) ERR; - + for (t = 0; t < NUM_TYPE; t++) { sprintf(var_name, "var_%d", type_id[t]); @@ -381,7 +381,7 @@ main(int argc, char **argv) /* Reopen the file. */ if (nc_open(itoptions.path, NC_NOWRITE, &ncid)) ERR; - + /* Close the file. */ if (nc_close(ncid)) ERR; } diff --git a/travis.yml b/travis.yml deleted file mode 100644 index 01a6c38249..0000000000 --- a/travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -# blocklist -branches: - except: -# - /.*[.]dmh/ - - /.*[.]wif/ - -sudo: required -language: c -services: - - docker - -env: - matrix: -# Ubuntu - - DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc CFLAGS='-fsigned-char' AC_COPTS='--disable-hdf5 --disable-hdf4 --disable-dap-remote-tests --enable-cdf5 --enable-byterange' COPTS='-DENABLE_HDF5=OFF -DENABLE_HDF4=OFF -DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF -DENABLE_CDF5=TRUE -DENABLE_BYTERANGE=TRUE' USECP=FALSE CURHOST=docker-gcc-x64-signed TESTFILTER=FALSE - - - DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc CFLAGS='-fsigned-char' AC_COPTS='--disable-hdf5 --disable-hdf4 --disable-dap-remote-tests' COPTS='-DENABLE_HDF5=OFF -DENABLE_HDF4=OFF -DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF -DENABLE_CDF5=OFF' USECP=FALSE CURHOST=docker-gcc-x86-signed TESTFILTER=FALSE - - - DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc CFLAGS='-funsigned-char' AC_COPTS='--disable-hdf5 --disable-hdf4 --disable-dap-remote-tests --enable-cdf5' COPTS='-DENABLE_HDF5=OFF -DENABLE_HDF4=OFF -DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF -DENABLE_CDF5=TRUE' USECP=FALSE CURHOST=docker-gcc-x64-unsigned TESTFILTER=FALSE - - - DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc CFLAGS='-funsigned-char' AC_COPTS='--disable-hdf5 --disable-hdf4 --disable-dap-remote-tests' COPTS='-DENABLE_HDF5=OFF -DENABLE_HDF4=OFF -DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF -DENABLE_CDF5=OFF' USECP=FALSE CURHOST=docker-gcc-x86-unsigned TESTFILTER=FALSE - - - DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc CFLAGS='-fsigned-char' AC_COPTS='--disable-dap-remote-tests --enable-cdf5' COPTS='-DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF -DENABLE_CDF5=TRUE' USECP=FALSE CURHOST=docker-gcc-x64-signed TESTFILTER=TRUE - - - DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc CFLAGS='-fsigned-char' AC_COPTS='--disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF -DENABLE_CDF5=OFF' USECP=FALSE CURHOST=docker-gcc-x86-signed TESTFILTER=TRUE - - - DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc CFLAGS='-funsigned-char' AC_COPTS='--disable-dap-remote-tests --enable-cdf5' COPTS='-DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF -DENABLE_CDF5=TRUE' USECP=FALSE CURHOST=docker-gcc-x64-unsigned TESTFILTER=TRUE - - - DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc CFLAGS='-funsigned-char' AC_COPTS='--disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF -DENABLE_CDF5=OFF' USECP=FALSE CURHOST=docker-gcc-x86-unsigned TESTFILTER=TRUE - -# Centos, Fedora - - DOCKIMG=unidata/nctests:serial.centos USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='--disable-dap-remote-tests' COPTS='-DENABLE_DAP_REMOTE_TESTS=OFF' USECP=TRUE CURHOST=docker-gcc-x64-centos TESTFILTER=TRUE - - DOCKIMG=unidata/nctests:serial.fedora USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='--disable-dap-remote-tests' COPTS='-DENABLE_DAP_REMOTE_TESTS=OFF' USECP=TRUE CURHOST=docker-gcc-x64-fedora TESTFILTER=TRUE - -before_install: - - docker pull $DOCKIMG > /dev/null - -script: - - - docker run --privileged --rm -it -h "$CURHOST" -e USEDASH=FALSE -e RUNF=OFF -e RUNCXX=OFF -e RUNP=OFF -e RUNNCO=OFF -e USECMAKE=$USECMAKE -e USEAC=$USEAC -e DISTCHECK=$DISTCHECK -e COPTS="$COPTS" -e AC_COPTS="$AC_COPTS" -e CTEST_OUTPUT_ON_FAILURE=1 -v $(pwd):/netcdf-c -e USE_LOCAL_CP=$USECP -e USE_CC=$USE_CC -e TESTPROC=100 -e ENABLE_FILTER_TESTING=$TESTFILTER -e ENABLE_C_MEMCHECK=OFF -e CFLAGS="$CFLAGS" $DOCKIMG