Support MSYS2/Mingw platform

re:

The current netcdf-c release has some problems with the mingw platform
on windows. Mostly they are path issues.

Changes to support mingw+msys2:
-------------------------------
* Enable option of looking into the windows registry to find
  the mingw root path. In aid of proper path handling.
* Add mingw+msys as a specific platform in configure.ac and move testing
  of the platform to the front so it is available early.
* Handle mingw X libncpoco (dynamic loader) properly even though
  mingw does not yet support it.
* Handle mingw X plugins properly even though mingw does not yet support it.
* Alias pwd='pwd -W' to better handle paths in shell scripts.
* Plus a number of other minor compile irritations.
* Disallow the use of multiple nc_open's on the same file for windows
  (and mingw) because windows does not seem to handle these properly.
  Not sure why we did not catch this earlier.
* Add mountpoint info to dpathmgr.c to help support mingw.
* Cleanup dpathmgr conversions.

Known problems:
---------------
* I have not been able to get shared libraries to work, so
  plugins/filters must be disabled.
* There is some kind of problem with libcurl that I have not solved,
  so all uses of libcurl (currently DAP+Byterange) must be disabled.

Misc. other fixes:
------------------
* Cleanup the relationship between ENABLE_PLUGINS and various other flags
  in CMakeLists.txt and configure.ac.
* Re-arrange the TESTDIRS order in Makefile.am.
* Add pseudo-breakpoint to nclog.[ch] for debugging.
* Improve the documentation of the path manager code in ncpathmgr.h
* Add better support for relative paths in dpathmgr.c
* Default the mode args to NCfopen to include "b" (binary) for windows.
* Add optional debugging output in various places.
* Make sure that everything builds with plugins disabled.
* Fix numerous (s)printf inconsistencies betweenb the format spec
  and the arguments.
This commit is contained in:
Dennis Heimbigner 2021-12-23 22:18:56 -07:00
parent dfb10a3f21
commit 9380790ea8
98 changed files with 2077 additions and 1199 deletions

29
.github/workflows/mingw.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: NetCDF-Build MinGW
on: [workflow_dispatch]
jobs:
build:
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 mingw-w64-x86_64-hdf5 unzip
- name: CI-Build
shell: msys2 {0}
run: |
echo 'Running in MSYS2!'
set -e
pwd
git clone --single-branch --branch moreosfixes.tmp https://github.com/DennisHeimbigner/netcdf-c.git
cd netcdf-c
autoreconf -i --force
./configure --prefix=/builddir -enable-shared --disable-static --disable-plugins --disable-logging --disable-dap-remote-tests --disable-byterange
make -j LDFLAGS="-no-undefined -Wl,--export-all-symbols"
make check

View File

@ -248,7 +248,7 @@ jobs:
shell: bash -l {0}
run: |
cd build
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ctest -j 12 .
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ctest --verbose -j 12 .
if: ${{ success() }}
- name: Verbose Output if CTest Failure
@ -312,7 +312,7 @@ jobs:
- name: Configure
shell: bash -l {0}
run: CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ./configure --enable-hdf4 --enable-hdf5 --enable-dap --enable-dap-long-tests
run: CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ./configure --enable-hdf4 --enable-hdf5 --enable-dap --disable-dap-remote-tests
if: ${{ success() }}
- name: Look at config.log if error
@ -410,7 +410,7 @@ jobs:
shell: bash -l {0}
run: |
cd build
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ctest -j 12 .
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ctest --output-on-failure -j 12 .
if: ${{ success() }}
- name: Verbose Output if CTest Failure

View File

@ -1039,7 +1039,6 @@ ENDIF()
# Option to Enable DAP long tests, remote tests.
OPTION(ENABLE_DAP_REMOTE_TESTS "Enable DAP remote tests." ON)
OPTION(ENABLE_DAP_LONG_TESTS "Enable DAP long tests." OFF)
SET(REMOTETESTSERVERS "remotetest.unidata.ucar.edu" CACHE STRING "test servers to use for remote test")
@ -1092,12 +1091,19 @@ ELSE()
ENDIF()
# libdl is always available; built-in in Windows and OSX
SET(ENABLE_PLUGINS TRUE)
IF(NOT WIN32)
IF(HAVE_DLFCN_H)
INCLUDE_DIRECTORIES("dlfcn.h")
OPTION(ENABLE_PLUGINS "Enable dynamically loaded plugins (default on)." ON)
IF(MINGW)
SET(ENABLE_PLUGINS OFF CACHE BOOL "Disable plugins" FORCE)
ELSE()
IF(NOT WIN32)
IF(HAVE_DLFCN_H)
INCLUDE_DIRECTORIES("dlfcn.h")
ENDIF()
ENDIF()
ENDIF()
IF(ENABLE_PLUGINS)
SET(USEPLUGINS yes)
ENDIF()
# Enable some developer-only tests
OPTION(ENABLE_EXTRA_TESTS "Enable Extra tests. Some may not work because of known issues. Developers only." OFF)
@ -1488,6 +1494,16 @@ IF(NOT BUILD_SHARED_LIBS)
SET(ENABLE_FILTER_TESTING OFF)
ENDIF()
OPTION(ENABLE_NCZARR_FILTERS "Enable NCZarr filters" yes)
IF (NOT ENABLE_PLUGINS)
SET(ENABLE_NCZARR_FILTERS OFF CACHE BOOL "Enable NCZarr Filters." FORCE)
ENDIF()
OPTION(ENABLE_NCZARR_FILTERS_TESTING "Enable NCZarr filter testing." yes)
IF (NOT ENABLE_NCZARR_FILTERS)
SET(ENABLE_NCZARR_FILTER_TESTING OFF CACHE BOOL "Enable NCZarr Filter Testing" FORCE)
ENDIF()
SET(ENABLE_CLIENTSIDE_FILTERS OFF)
# Determine whether or not to generate documentation.
@ -1497,9 +1513,9 @@ IF(ENABLE_DOXYGEN)
# Offer the option to build internal documentation.
OPTION(ENABLE_INTERNAL_DOCS "Build internal documentation. This is of interest to developers only." OFF)
IF(ENABLE_INTERNAL_DOCS)
SET(BUILD_INTERNAL_DOCS YES CACHE STRING "")
SET(BUILD_INTERNAL_DOCS yes CACHE STRING "")
ELSE()
SET(BUILD_INTERNAL_DOCS NO CACHE STRING "")
SET(BUILD_INTERNAL_DOCS no CACHE STRING "")
ENDIF()
###
@ -2410,6 +2426,7 @@ configure_file(
SET(ISCMAKE "1")
IF(MSVC)
SET(ISMSVC "1")
SET(REGEDIT 1)
ENDIF()
####

View File

@ -94,9 +94,11 @@ ZARR = libnczarr
endif
# Optionally build test plugins
if ENABLE_PLUGINS
if ENABLE_FILTER_TESTING
PLUGIN_DIR = plugins
endif
endif
# If benchmarks were turned on, build and run a bunch more tests.
if BUILD_BENCHMARKS
@ -105,7 +107,8 @@ endif # BUILD_BENCHMARKS
# Define Test directories
if BUILD_TESTSETS
TESTDIRS = $(UNIT_TEST) $(V2_TEST) nc_test $(NC_TEST4)
TESTDIRS = $(H5_TEST_DIR)
TESTDIRS += $(UNIT_TEST) $(V2_TEST) nc_test $(NC_TEST4)
TESTDIRS += $(BENCHMARKS_DIR) $(HDF4_TEST_DIR) $(NCDAP2TESTDIR) $(NCDAP4TESTDIR)
TESTDIRS += ${ZARR_TEST_DIR}
endif
@ -113,10 +116,10 @@ endif
# This is the list of subdirs for which Makefiles will be constructed
# and run. ncgen must come before ncdump, because their tests
# depend on it.
SUBDIRS = include $(H5_TEST_DIR) ${XML} libdispatch libsrc $(LIBSRC4_DIR) \
SUBDIRS = include ${XML} libdispatch libsrc $(LIBSRC4_DIR) \
$(LIBSRCP) $(LIBHDF4) $(LIBHDF5) $(OCLIB) $(DAP2) ${DAP4} \
${NCPOCO} ${ZARR} liblib \
$(NCGEN3) $(NCGEN) $(NCDUMP) ${PLUGIN_DIR} $(TESTDIRS) docs \
$(NCGEN3) $(NCGEN) $(NCDUMP) ${PLUGIN_DIR} $(TESTDIRS) docs \
$(EXAMPLES)
# Remove these generated files, for a distclean.

View File

@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release
## 4.8.2 - TBD
* [Enhancement] Improve support for msys2+mingw platform. See [Github #2135](https://github.com/Unidata/netcdf-c/pull/2135) -- H/T to [Egbert Eich](https://github.com/e4t).
* [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.
* [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).

View File

@ -174,6 +174,9 @@ are set when opening a binary file on Windows. */
/* if true, Allow dynamically loaded plugins */
#cmakedefine ENABLE_PLUGINS 1
/* Do we have access to the Windows Registry */
#cmakedefine REGEDIT 1
/* define the possible sources for remote test servers */
#cmakedefine REMOTETESTSERVERS "${REMOTETESTSERVERS}"

View File

@ -10,7 +10,7 @@
AC_PREREQ([2.59])
# Initialize with name, version, and support email address.
AC_INIT([netCDF], [4.8.2-development], [support-netcdf@unidata.ucar.edu], [netcdf-c])
AC_INIT([netCDF],[4.8.2-development],[support-netcdf@unidata.ucar.edu],[netcdf-c])
##
# Prefer an empty CFLAGS variable instead of the default -g -O2.
@ -93,6 +93,19 @@ AM_INIT_AUTOMAKE([foreign dist-zip subdir-objects])
# Check for the existence of this file before proceeding.
AC_CONFIG_SRCDIR([include/netcdf.h])
# Figure out platforms of special interest
case "`uname`" in
CYGWIN*) ISCYGWIN=yes;;
Darwin*) ISOSX=yes;;
WIN*) ISMSVC=yes;;
MINGW*) ISMINGW=yes;;
esac
if test "x$MSYSTEM" != x ; then
ISMINGW=yes
ISMSYS=yes
fi
AC_MSG_NOTICE([checking supported formats])
# An explicit disable of netcdf-4 | netcdf4 is treated as if it was disable-hdf5
@ -521,7 +534,6 @@ CFLAGS="$SAVECFLAGS"
# --enable-dap => enable-dap4
enable_dap4=$enable_dap
# Default is to do the short remote tests.
AC_MSG_CHECKING([whether dap remote testing should be enabled])
AC_ARG_ENABLE([dap-remote-tests],
[AS_HELP_STRING([--enable-dap-remote-tests],
@ -1180,14 +1192,23 @@ fi
AC_MSG_CHECKING([whether dynamically loaded plugins is enabled])
AC_ARG_ENABLE([plugins],
[AS_HELP_STRING([--disable-plugins],
[allow dynamically loaded plugins])])
if test "x$have_libdld" = xno ; then enable_plugins=no; fi
[disallow dynamically loaded plugins])])
test "x$enable_plugins" = xno || enable_plugins=yes
AC_MSG_RESULT($enable_plugins)
AC_MSG_RESULT([$enable_plugins])
if test "x$have_libdld" = xno && test "x$ISMSVC" = xno; then
enable_plugins=no
AC_MSG_WARN([libdld required for enable-plugins.])
fi
if test "x$enable_plugins" = xyes && test "x$enable_shared" = xno; then
AC_MSG_WARN([--disable-shared => --disable-plugins])
enable_plugins=no
fi
if test "x$enable_plugins" = xyes; then
AC_DEFINE([ENABLE_PLUGINS], [1], [if true, support dynamically loaded plugins])
fi
AM_CONDITIONAL(ENABLE_PLUGINS, [test "x$enable_plugins" = xyes])
AC_SUBST(USEPLUGINS, [${enable_plugins}])
AC_FUNC_ALLOCA
AC_CHECK_DECLS([isnan, isinf, isfinite],,,[#include <math.h>])
@ -1199,22 +1220,26 @@ AC_TYPE_UINTPTR_T
AC_C_CHAR_UNSIGNED
AC_C_BIGENDIAN
# Figure out platforms of special interest
case "`uname`" in
CYGWIN*) ISCYGWIN=yes;;
Darwin*) ISOSX=yes;;
WIN*) ISMSVC=yes;;
MINGW*) ISMINGW=yes;;
esac
AM_CONDITIONAL(ISCYGWIN, [test "x$ISCYGWIN" = xyes])
AM_CONDITIONAL(ISMSVC, [test "x$ISMSVC" = xyes])
AM_CONDITIONAL(ISOSX, [test "x$ISOSX" = xyes])
AM_CONDITIONAL(ISMINGW, [test "x$ISMINGW" = xyes])
AM_CONDITIONAL(ISMSYS, [test "x$ISMSYS" = xyes])
AC_SUBST([ISMSVC], [${ISMSVC}])
AC_SUBST([ISCYGWIN], [${ISCYGWIN}])
AC_SUBST([ISOSX], [${ISOSX}])
AC_SUBST([ISMINGW], [${ISMINGW}])
AC_SUBST([ISMSYS], [${ISMSYS}])
if test "x$ISMSVC" != x ; then REGEDIT=yes; fi
if test "x$ISMSYS" != x ; then REGEDIT=yes; fi
if test "x$ISCYGWIN" != x ; then REGEDIT=yes; fi
if test "x$REGEDIT" = xyes; then
AC_DEFINE([REGEDIT], 1, [dreg.c usable])
fi
AM_CONDITIONAL(REGEDIT, [test "x$REGEDIT" = xyes])
AC_SUBST([ISREGEDIT], [yes])
###
# Crude hack to work around an issue
@ -1594,9 +1619,6 @@ AC_ARG_ENABLE([nczarr-filters], [AS_HELP_STRING([--disable-nczarr-filters],
[disable NCZarr filters])])
test "x$enable_nczarr_filters" = xno || enable_nczarr_filters=yes
AC_MSG_RESULT([$enable_nczarr_filters])
if test "x$enable_nczarr_filters" = xyes; then
AC_DEFINE([ENABLE_NCZARR_FILTERS], [1], [if true, enable NCZarr filters])
fi
# Control filter test/example
AC_MSG_CHECKING([whether filter testing should be run])
@ -1606,19 +1628,24 @@ AC_ARG_ENABLE([filter-testing],
test "x$enable_filter_testing" = xno || enable_filter_testing=yes
AC_MSG_RESULT($enable_filter_testing)
if test "x$enable_nczarr" = xno ; then
# Apply constraints
if test "x$enable_plugins" = xno ; then
AC_MSG_WARN([--disable-plugins => --disable-nczarr-filters])
enable_nczarr_filters=no
fi
if test "x$enable_hdf5" = xno && test "x$enable_nczarr" = xno ; then
AC_MSG_WARN([HDF5 and NCZarr are disabled => --disable-filter-testing])
if test "x$enable_plugins" = xno ; then
AC_MSG_WARN([--disable-plugins => --disable-filter-testing])
enable_filter_testing=no
fi
if test "x$enable_shared" = xno ; then
AC_MSG_WARN([Shared libraries are disabled => --disable-filter-testing])
enable_filter_testing=no
enable_nczarr_filters=no
if test "x$enable_filter_testing" = xno; then
AC_MSG_WARN([--disable-filter-testing => --disable-nczarr-filter-testing])
enable_nczarr_filter_testing=no
fi
if test "x$enable_nczarr_filters" = xyes; then
AC_DEFINE([ENABLE_NCZARR_FILTERS], [1], [if true, enable NCZarr filters])
fi
# Client side filter registration is permanently disabled

View File

@ -10,6 +10,8 @@
#include <stdarg.h>
#include "ncexternl.h"
#undef NCCATCH
#define NCENVLOGGING "NCLOGGING"
#define NCENVTRACING "NCTRACING"
@ -39,8 +41,16 @@ EXTERNL void nctrace(int level, const char* fcn, const char* fmt, ...);
EXTERNL void nctracemore(int level, const char* fmt, ...);
EXTERNL void ncvtrace(int level, const char* fcn, const char* fmt, va_list ap);
EXTERNL int ncuntrace(const char* fcn, int err,const char* fmt,...);
EXTERNL int ncthrow(int err,const char* file,int line);
EXTERNL int ncbreakpoint(int err);
/* Debug support */
#if defined(NCCATCH)
#define NCTHROW(e) ((e) == NC_NOERR ? (e) : ncthrow(e,__FILE__,__LINE__))
#else
#define NCTHROW(e) (e)
#endif
#ifdef HAVE_EXECINFO_H
EXTERNL void ncbacktrace(void);
#else

View File

@ -22,11 +22,71 @@
#endif
#include "ncexternl.h"
/*
The path management code attempts to take an arbitrary path and convert
it to a form acceptable to the current platform.
Assumptions about Input path:
1. It is not a URL
2. It conforms to the format expected by one of the following:
Linux (/x/y/...),
Cygwin (/cygdrive/D/...),
Windows|MINGW (D:\...),
Windows network path (\\mathworks\...)
MSYS (/D/...),
4. It is encoded in the local platform character set. Note that
for most systems, this is utf-8. But for Windows, the
encoding is most likely some form of ANSI code page, probably
the windows 1252 encoding. Note that in any case, the path
must be representable in the local Code Page.
Note that all input paths first have all back slashes (\)
converted to forward (/), so following rules are in terms of /.
Parsing Rules:
1. A relative path is left as is with no drive letter.
2. A leading '/cygdrive/D' will be converted to
drive letter D if D is alpha-char.
3. A leading D:/... is treated as a windows drive letter
4. A leading /d/... is treated as a windows drive letter
if the platform is MSYS2.
5. A leading // is a windows network path and is converted
to a drive letter using the fake drive letter "/".
So '//svc/x/y' translates to '/:/svc/x/y'.
6. All other cases are assumed to be Unix variants with no drive letter.
After parsing, the following pieces of information are kept in a struct.
a. kind: The inferred path type (e.g. cygwin, unix, etc)
b. drive: The drive letter if any
c. path: The path is everything after the drive letter
For output, NCpathcvt produces a re-written path that is acceptable
to the current platform (the one on which the code is running).
Additional root mount point information is obtained for Cygwin and MSYS.
The root mount point is found as follows (in order of precedence):
1. Registry: get the value of the key named "HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup".
2. Environment: get the value of MSYS2_PREFIX
The re-write rules (unparsing) are given the above three pieces
of info + the current platform + the root mount point (if any).
The conversion rules are as follows.
Platform | No Input Driv | Input Drive
----------------------------------------------------
NCPD_NIX | <path> | /<drive>/path
NCPD_CYGWIN | /<path> | /cygdrive/<drive>/<path>
NCPD_WIN | <mountpoint>/<path> | <drive>:<path>
NCPD_MSYS | <mountpoint>/<path> | <drive>:<path>
Notes:
1. MINGW without MSYS is treated like WIN.
2. The reason msys and win prefix the mount point is because
the IO functions are handled directly by Windows, hence
the conversion must look like a true windows path with a drive.
*/
#ifndef WINPATH
#ifdef _WIN32
#define WINPATH 1
#endif
#ifdef __MINGW32__
#if defined _WIN32 || defined __MINGW32__
#define WINPATH 1
#endif
#endif
@ -64,40 +124,13 @@
#endif
#endif /*_WIN32*/
/*
WARNING: you should never need to explictly call this function;
rather it is invoked as part of the wrappers for e.g. NCfopen, etc.
This function attempts to take an arbitrary path and convert
it to a canonical form.
Assumptions about Input path:
1. It is a relative or absolute path
2. It is not a URL
3. It conforms to the format expected by one of the following:
Linux (/x/y/...),
Cygwin (/cygdrive/D/...),
Windows (D:\...),
Windows network path (\\mathworks\...)
MSYS (/D/...),
or relative (x/y...)
4. It is encoded in the local platform character set.
Note that for most systems, this is utf-8. But for Windows,
the encoding is most likely some form of ANSI code page, probably
the windows 1252 encoding.
Note that in any case, the path must be representable in the
local Code Page.
On output it produces a re-written path that has the following
properties:
1. The path is normalized to match the platform on which the code
is running (e.g. cygwin, windows, msys, linux). So for example
using a cygwin path under visual studio will convert e.g.
/cygdrive/d/x/y to d:\x\y. See ../unit_test/test_pathcvt.c
for example conversions.
It returns the converted path.
Note that this function is intended to be Idempotent: f(f(x) == f(x).
This function is intended to be Idempotent: f(f(x) == f(x).
This means it is ok to call it repeatedly with no harm.
Unless, of course, an error occurs.
*/
EXTERNL char* NCpathcvt(const char* path);
@ -109,7 +142,7 @@ that has some desirable properties:
with a '/' separator. The exception being if the base part
may be absolute, in which case, suffixing only is allowed;
the user is responsible for getting this right.
To this end we choose the linux/cygwin format as our standard canonical form.
To this end we choose the cygwin format as our standard canonical form.
If the path has a windows drive letter, then it is represented
in the cygwin "/cygdrive/<drive-letter>" form.
If it is a windows network path, then it starts with "//".
@ -150,7 +183,7 @@ EXTERNL char* NCgetcwd(char* cwdbuf, size_t len);
EXTERNL int NCmkstemp(char* buf);
#ifdef HAVE_SYS_STAT_H
EXTERNL int NCstat(char* path, struct stat* buf);
EXTERNL int NCstat(const char* path, struct stat* buf);
#endif
#ifdef HAVE_DIRENT_H
EXTERNL DIR* NCopendir(const char* path);
@ -190,11 +223,15 @@ EXTERNL int NCclosedir(DIR* ent);
#define NCPD_MSYS 2
#define NCPD_CYGWIN 3
#define NCPD_WIN 4
#define NCPD_REL 5 /* actual kind is unknown */
/* #define NCPD_MINGW NCPD_WIN *alias*/
#define NCPD_REL 6 /* actual kind is unknown */
EXTERNL char* NCpathcvt_test(const char* path, int ukind, int udrive);
EXTERNL int NCgetlocalpathkind(void);
EXTERNL int NCgetinputpathkind(const char* inpath);
EXTERNL const char* NCgetkindname(int kind);
EXTERNL void printutf8hex(const char* s, char* sx);
EXTERNL int getmountpoint(char*, size_t);
/**************************************************/
/* From dutil.c */

View File

@ -421,7 +421,7 @@ dumpnode(CDFnode* node)
snprintf(tmp,sizeof(tmp),"%s %s {\n",
(nctype?nctype:primtype),node->ocname);
ncbytescat(buf,tmp);
snprintf(tmp,sizeof(tmp),"ocnode=%lx\n",(unsigned long)node->ocnode);
snprintf(tmp,sizeof(tmp),"ocnode=%p\n",node->ocnode);
ncbytescat(buf,tmp);
snprintf(tmp,sizeof(tmp),"container=%s\n",
(node->container?node->container->ocname:"null"));
@ -503,9 +503,9 @@ dumpcachenode(NCcachenode* node)
if(node == NULL) return strdup("cachenode{null}");
buf = ncbytesnew();
result = dcebuildconstraintstring(node->constraint);
snprintf(tmp,sizeof(tmp),"cachenode%s(%lx){size=%lu; constraint=%s; vars=",
snprintf(tmp,sizeof(tmp),"cachenode%s(%p){size=%lu; constraint=%s; vars=",
node->isprefetch?"*":"",
(unsigned long)node,
node,
(unsigned long)node->xdrsize,
result);
ncbytescat(buf,tmp);

View File

@ -993,7 +993,6 @@ Return the value.
static int
parseULL(const char* text, unsigned long long* ullp)
{
extern int errno;
char* endptr;
unsigned long long uint64 = 0;
@ -1018,7 +1017,6 @@ Return the value.
static int
parseLL(const char* text, long long* llp)
{
extern int errno;
char* endptr;
long long int64 = 0;

View File

@ -22,6 +22,10 @@ IF(ENABLE_S3_SDK)
SET(libdispatch_SOURCES ${libdispatch_SOURCES} ncs3sdk.cpp awsincludes.h)
ENDIF(ENABLE_S3_SDK)
IF(REGEDIT)
SET(libdispatch_SOURCES ${libdispatch_SOURCES} dreg.c)
ENDIF(REGEDIT)
add_library(dispatch OBJECT ${libdispatch_SOURCES})
IF(MPI_C_INCLUDE_PATH)
target_include_directories(dispatch PUBLIC ${MPI_C_INCLUDE_PATH})

View File

@ -52,6 +52,10 @@ libdispatch_la_SOURCES += ncs3sdk.cpp awsincludes.h
AM_CXXFLAGS = -std=c++11
endif
if REGEDIT
libdispatch_la_SOURCES += dreg.c
endif
EXTRA_DIST=CMakeLists.txt ncsettings.hdr utf8proc_data.c
# Build ncsettings.c as follows:

View File

@ -149,14 +149,10 @@ nc_inq_enum_member(int ncid, nc_type xtype, int idx, char *name,
/** \ingroup user_types
Get the name which is associated with an enum member value.
\param ncid \ref ncid
\param ncid
\param xtype Typeid of the enum type.
\param value Value of interest.
\param identifier The identifier (\ref object_name) of this value will
be copied here. \ref ignored_if_null.
\param identifier The identifier (\ref object_name) of this value will be copied here; ignored_if_null.
\returns ::NC_NOERR No error.
\returns ::NC_EBADID Bad \ref ncid.

View File

@ -2158,8 +2158,8 @@ int
nc__pseudofd(void)
{
if(pseudofd == 0) {
int maxfd = 32767; /* default */
#ifdef HAVE_GETRLIMIT
int maxfd = 32767; /* default */
struct rlimit rl;
if(getrlimit(RLIMIT_NOFILE,&rl) == 0) {
if(rl.rlim_max != RLIM_INFINITY)

View File

@ -1021,8 +1021,27 @@ check_file_type(const char *path, int omode, int use_parallel,
char magic[NC_MAX_MAGIC_NUMBER_LEN];
int status = NC_NOERR;
struct MagicFile magicinfo;
#ifdef _WIN32
NC* nc = NULL;
#endif
memset((void*)&magicinfo,0,sizeof(magicinfo));
#ifdef _WIN32 /* including MINGW */
/* Windows does not handle well multiple handles to the same file.
So if file is already open/created, then find it and just get the
model from that. */
if((nc = find_in_NCList_by_name(path)) != NULL) {
int format = 0;
/* Get the model from this NC */
if((status = nc_inq_format_extended(nc->ext_ncid,&format,NULL))) goto done;
model->impl = format;
if((status = nc_inq_format(nc->ext_ncid,&format))) goto done;
model->format = format;
goto done;
}
#endif
magicinfo.path = path; /* do not free */
magicinfo.uri = uri; /* do not free */
magicinfo.omode = omode;
@ -1143,11 +1162,7 @@ openmagic(struct MagicFile* file)
if(file->path == NULL || strlen(file->path)==0)
{status = NC_EINVAL; goto done;}
#ifdef _WIN32
file->fp = NCfopen(file->path, "rb");
#else
file->fp = NCfopen(file->path, "r");
#endif
if(file->fp == NULL)
{status = errno; goto done;}
/* Get its length */
@ -1252,6 +1267,7 @@ static int
closemagic(struct MagicFile* file)
{
int status = NC_NOERR;
if(fIsSet(file->omode,NC_INMEMORY)) {
/* noop */
#ifdef ENABLE_BYTERANGE

View File

@ -40,7 +40,15 @@
#include "ncuri.h"
#include "ncutf8.h"
#undef PATHFORMAT
#undef DEBUGPATH
static int pathdebug = -1;
#define DEBUG
#ifdef DEBUG
#define REPORT(e,msg) report((e),(msg),__LINE__)
#else
#define REPORT(e,msg)
#endif
#ifdef _WIN32
#define access _access
@ -51,31 +59,24 @@
/*
Code to provide some path conversion code so that
cygwin and (some) mingw paths can be passed to open/fopen
for Windows. Other cases will be added as needed.
Rules:
1. a leading single alpha-character path element (e.g. /D/...)
will be interpreted as a windows drive letter.
2. a leading '/cygdrive/X' will be converted to
a drive letter X if X is alpha-char.
3. a leading D:/... is treated as a windows drive letter
4. a leading // is a windows network path and is converted
to a drive letter using the fake drive letter "@".
5. If any of the above is encountered, then forward slashes
will be converted to backslashes.
All other cases are passed thru unchanged
paths in one format can be used on a platform that uses
a different format.
See the documentation in ncpathmgr.h for details.
*/
/* Define legal windows drive letters */
static const char* windrive = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@";
static const char* windrive = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/";
static const char netdrive = '@';
static const char netdrive = '/';
static const size_t cdlen = 10; /* strlen("/cygdrive/") */
static int pathinitialized = 0;
static int pathdebug = -1;
static const char* cygwinspecial[] =
{"/bin/","/dev/","/etc/","/home/",
"/lib/","/proc/","/sbin/","/tmp/",
"/usr/","/var/",NULL};
static const struct Path {
int kind;
@ -84,14 +85,21 @@ static const struct Path {
} empty = {NCPD_UNKNOWN,0,NULL};
/* Keep the working directory kind and drive */
static struct Path wdpath = {NCPD_UNKNOWN,0,NULL};
static char wdstaticpath[8192];
static char wdprefix[8192];
/* Keep CYGWIN/MSYS2 mount point */
static struct MountPoint {
int defined;
char prefix[8192]; /*minus leading drive */
char drive;
} mountpoint;
/* Pick the target kind for testing */
static int testkind = 0;
static int parsepath(const char* inpath, struct Path* path);
static int unparsepath(struct Path* p, char** pathp);
static int getwdpath(struct Path* wd);
static char* printPATH(struct Path* p);
static int getlocalpathkind(void);
static int unparsepath(struct Path* p, char** pathp, int target);
static int getwdpath(void);
static void clearPath(struct Path* path);
static void pathinit(void);
static int iscygwinspecial(const char* path);
@ -104,51 +112,51 @@ static int utf82wide(const char* utf8, wchar_t** u16p);
static int wide2utf8(const wchar_t* u16, char** u8p);
#endif
/*Forward*/
static void report(int stat, const char* msg, int line);
static char* printPATH(struct Path* p);
EXTERNL
char* /* caller frees */
NCpathcvt(const char* inpath)
{
int stat = NC_NOERR;
char* tmp1 = NULL;
struct Path canon = empty;
char* result = NULL;
struct Path inparsed = empty;
int target = NCgetlocalpathkind();
if(inpath == NULL) goto done; /* defensive driving */
if(!pathinitialized) pathinit();
if(testurl(inpath)) { /* Pass thru URLs */
if((tmp1 = strdup(inpath))==NULL) stat = NC_ENOMEM;
if((result = strdup(inpath))==NULL) stat = NC_ENOMEM;
goto done;
}
if((stat = parsepath(inpath,&canon))) {goto done;}
if((stat = parsepath(inpath,&inparsed)))
{REPORT(stat,"NCpathcvt: parsepath"); goto done;}
if(pathdebug > 0)
fprintf(stderr,">>> NCpathcvt: inparsed=%s\n",printPATH(&inparsed));
/* Special check for special cygwin paths: /tmp,usr etc */
if(getlocalpathkind() == NCPD_CYGWIN
&& iscygwinspecial(canon.path)
&& canon.kind == NCPD_NIX)
canon.kind = NCPD_CYGWIN;
if((stat = unparsepath(&inparsed,&result,target)))
{REPORT(stat,"NCpathcvt: unparsepath"); goto done;}
if(canon.kind != NCPD_REL && wdpath.kind != canon.kind) {
nclog(NCLOGWARN,"NCpathcvt: path mismatch: platform=%d inpath=%d\n",
wdpath.kind,canon.kind);
canon.kind = wdpath.kind; /* override */
}
if((stat = unparsepath(&canon,&tmp1))) {goto done;}
done:
if(pathdebug) {
fprintf(stderr,"xxx: inpath=|%s| outpath=|%s|\n",
inpath?inpath:"NULL",tmp1?tmp1:"NULL");
if(pathdebug > 0) {
fprintf(stderr,">>> inpath=|%s| result=|%s|\n",
inpath?inpath:"NULL",result?result:"NULL");
fflush(stderr);
}
if(stat) {
nullfree(tmp1); tmp1 = NULL;
nullfree(result); result = NULL;
nclog(NCLOGERR,"NCpathcvt: stat=%d (%s)",
stat,nc_strerror(stat));
}
clearPath(&canon);
return tmp1;
nullfree(tmp1);
clearPath(&inparsed);
return result;
}
EXTERNL
@ -157,7 +165,6 @@ NCpathcanonical(const char* srcpath, char** canonp)
{
int stat = NC_NOERR;
char* canon = NULL;
size_t len;
struct Path path = empty;
if(srcpath == NULL) goto done;
@ -166,28 +173,11 @@ NCpathcanonical(const char* srcpath, char** canonp)
/* parse the src path */
if((stat = parsepath(srcpath,&path))) {goto done;}
switch (path.kind) {
case NCPD_REL:
/* use as is */
canon = path.path; path.path = NULL;
break;
case NCPD_NIX:
case NCPD_CYGWIN:
case NCPD_MSYS:
case NCPD_WIN: /* convert to cywin form */
len = nulllen(path.path) + strlen("/cygdrive/X") + 1;
canon = (char*)malloc(len);
if(canon != NULL) {
canon[0] = '\0';
if(path.drive != 0) {
strlcat(canon,"/cygdrive/X",len);
canon[10] = path.drive;
}
if(path.path != NULL) strlcat(canon,path.path,len);
}
break;
default: goto done; /* return NULL */
}
/* Convert to cygwin form */
if((stat = unparsepath(&path,&canon, NCPD_CYGWIN)))
goto done;
if(canonp) {*canonp = canon; canon = NULL;}
done:
@ -196,7 +186,6 @@ done:
return stat;
}
EXTERNL
char* /* caller frees */
NCpathabsolute(const char* relpath)
@ -212,28 +201,31 @@ NCpathabsolute(const char* relpath)
if(!pathinitialized) pathinit();
/* Decompose path */
if((stat = parsepath(relpath,&canon))) {goto done;}
if((stat = parsepath(relpath,&canon)))
{REPORT(stat,"pathabs: parsepath"); goto done;}
/* See if relative */
if(canon.kind == NCPD_REL) {
/* prepend the wd path to the inpath, including drive letter, if any */
len = strlen(wdpath.path)+strlen(canon.path)+1+1;
len = strlen(wdprefix)+strlen(canon.path)+1+1;
if((tmp1 = (char*)malloc(len))==NULL)
{stat = NC_ENOMEM; {goto done;}}
{stat = NCTHROW(NC_ENOMEM); goto done;}
tmp1[0] = '\0';
strlcat(tmp1,wdpath.path,len);
strlcat(tmp1,wdprefix,len);
strlcat(tmp1,"/",len);
strlcat(tmp1,canon.path,len);
nullfree(canon.path);
canon.path = tmp1; tmp1 = NULL;
canon.drive = wdpath.drive;
canon.kind = wdpath.kind;
canon.path = NULL;
/* Reparse */
result = NCpathabsolute(tmp1);
goto done;
}
/* rebuild */
if((stat=unparsepath(&canon,&result))) goto done;
if((stat=unparsepath(&canon,&result,NCgetlocalpathkind())))
{REPORT(stat,"pathabs: unparsepath"); goto done;}
done:
if(pathdebug) {
fprintf(stderr,"xxx: relpath=|%s| result=|%s|\n",
if(pathdebug > 0) {
fprintf(stderr,">>> relpath=|%s| result=|%s|\n",
relpath?relpath:"NULL",result?result:"NULL");
fflush(stderr);
}
@ -249,25 +241,23 @@ done:
/* Testing support */
/* Force drive and wd before invoking NCpathcvt
and then revert */
EXTERNL
char* /* caller frees */
NCpathcvt_test(const char* inpath, int ukind, int udrive)
{
char* result = NULL;
struct Path oldwd = wdpath;
struct MountPoint old;
if(!pathinitialized) pathinit();
/* Override */
wdpath.kind = ukind;
wdpath.drive = udrive;
wdpath.path = strdup("/");
if(pathdebug)
fprintf(stderr,"xxx: wd=|%s|",printPATH(&wdpath));
old = mountpoint;
memset(&mountpoint,0,sizeof(mountpoint));
mountpoint.drive = (char)udrive;
mountpoint.defined = (mountpoint.drive || nulllen(mountpoint.prefix) > 0);
testkind = ukind;
result = NCpathcvt(inpath);
clearPath(&wdpath);
wdpath = oldwd;
mountpoint = old;
return result;
}
@ -281,14 +271,50 @@ pathinit(void)
const char* s = getenv("NCPATHDEBUG");
pathdebug = (s == NULL ? 0 : 1);
}
(void)getwdpath(&wdpath);
/* make the path static but remember to never free it (Ugh!) */
wdstaticpath[0] = '\0';
strlcat(wdstaticpath,wdpath.path,sizeof(wdstaticpath));
clearPath(&wdpath);
wdpath.path = wdstaticpath;
(void)getwdpath();
memset(&mountpoint,0,sizeof(mountpoint));
#ifdef REGEDIT
{ /* See if we can get the MSYS2 prefix from the registry */
if(getmountpoint(mountpoint.prefix,sizeof(mountpoint.prefix)))
goto next;
mountpoint.defined = 1;
if(pathdebug > 0)
fprintf(stderr,">>>> registry: mountprefix=|%s|\n",mountpoint.prefix);
}
next:
#endif
if(!mountpoint.defined) {
mountpoint.prefix[0] = '\0';
/* See if MSYS2_PREFIX is defined */
if(getenv("MSYS2_PREFIX")) {
const char* m2 = getenv("MSYS2_PREFIX");
mountpoint.prefix[0] = '\0';
strlcat(mountpoint.prefix,m2,sizeof(mountpoint.prefix));
}
if(pathdebug > 0) {
fprintf(stderr,">>>> prefix: mountprefix=|%s|\n",mountpoint.prefix);
}
}
if(mountpoint.defined) {
char* p;
size_t size = strlen(mountpoint.prefix);
for(p=mountpoint.prefix;*p;p++) {if(*p == '\\') *p = '/';} /* forward slash*/
if(mountpoint.prefix[size-1] == '/') {
size--;
mountpoint.prefix[size] = '\0'; /* no trailing slash */
}
/* Finally extract the drive letter, if any */
/* assumes mount prefix is in windows form */
mountpoint.drive = 0;
if(strchr(windrive,mountpoint.prefix[0]) != NULL
&& mountpoint.prefix[1] == ':') {
char* q = mountpoint.prefix;
mountpoint.drive = mountpoint.prefix[0];
/* Shift prefix left 2 chars */
for(p=mountpoint.prefix+2;*p;p++) {*q++ = *p;}
*q = '\0';
}
}
pathinitialized = 1;
}
@ -299,11 +325,6 @@ clearPath(struct Path* path)
path->path = NULL;
}
static const char* cygwinspecial[] =
{"/bin/","/dev/","/etc/","/home/",
"/lib/","/proc/","/sbin/","/tmp/",
"/usr/","/var/",NULL};
/* Unfortunately, not all cygwin paths start with /cygdrive.
So see if the path starts with one of the special paths.
*/
@ -346,19 +367,31 @@ NCfopen(const char* path, const char* flags)
{
int stat = NC_NOERR;
FILE* f = NULL;
char* bflags = NULL;
char* cvtpath = NULL;
wchar_t* wpath = NULL;
wchar_t* wflags = NULL;
size_t flaglen = strlen(flags)+1+1;
bflags = (char*)malloc(flaglen);
bflags[0] = '\0';
strlcat(bflags,flags,flaglen);
#ifdef _WIN32
strlcat(bflags,"b",flaglen);
#endif
cvtpath = NCpathcvt(path);
if(cvtpath == NULL) return NULL;
/* Convert from local to wide */
if((stat = utf82wide(cvtpath,&wpath))) goto done;
if((stat = ansi2wide(flags,&wflags))) goto done;
if((stat = utf82wide(cvtpath,&wpath)))
{REPORT(stat,"utf282wide"); goto done;}
if((stat = ansi2wide(bflags,&wflags)))
{REPORT(stat,"ansi2wide"); goto done;}
f = _wfopen(wpath,wflags);
done:
nullfree(cvtpath);
nullfree(wpath);
nullfree(wflags);
nullfree(bflags);
return f;
}
@ -374,6 +407,9 @@ NCopen3(const char* path, int flags, int mode)
if(cvtpath == NULL) goto done;
/* Convert from utf8 to wide */
if((stat = utf82wide(cvtpath,&wpath))) goto done;
#ifdef _WIN32
flags |= O_BINARY;
#endif
fd = _wopen(wpath,flags,mode);
done:
nullfree(cvtpath);
@ -485,19 +521,21 @@ char*
NCgetcwd(char* cwdbuf, size_t cwdlen)
{
int status = NC_NOERR;
struct Path wd = empty;
char* path = NULL;
size_t len;
struct Path wd;
errno = 0;
if(cwdlen == 0) {status = ENAMETOOLONG; goto done;}
if(!pathinitialized) pathinit();
if((status = getwdpath(&wd))) {status = ENOENT; goto done;}
if((status = unparsepath(&wd,&path))) {status = EINVAL; goto done;}
if((status = getwdpath())) {status = ENOENT; goto done;}
if((status = parsepath(wdprefix,&wd))) {status = EINVAL; goto done;}
if((status = unparsepath(&wd,&path,NCgetlocalpathkind()))) {status = EINVAL; goto done;}
len = strlen(path);
if(len >= cwdlen) {status = ENAMETOOLONG; goto done;}
if(cwdbuf == NULL) {
if((cwdbuf = malloc(cwdlen))==NULL) {status = ENOMEM; goto done;}
if((cwdbuf = malloc(cwdlen))==NULL)
{status = NCTHROW(ENOMEM); goto done;}
}
memcpy(cwdbuf,path,len+1);
done:
@ -547,14 +585,14 @@ done:
#ifdef HAVE_SYS_STAT_H
EXTERNL
int
NCstat(char* path, struct stat* buf)
NCstat(const char* path, struct stat* buf)
{
int status = 0;
char* cvtpath = NULL;
wchar_t* wpath = NULL;
if((cvtpath = NCpathcvt(path)) == NULL) {status=ENOMEM; goto done;}
if((status = utf82wide(cvtpath,&wpath))) {status = ENOENT; goto done;}
if(_wstat(wpath,buf) < 0) {status = errno; goto done;}
if(_wstat64(wpath,buf) < 0) {status = errno; goto done;}
done:
free(cvtpath);
free(wpath);
@ -596,11 +634,6 @@ NChasdriveletter(const char* path)
if(!pathinitialized) pathinit();
if((stat = parsepath(path,&canon))) goto done;
if(canon.kind == NCPD_REL) {
clearPath(&canon);
/* Get the drive letter (if any) from the local wd */
canon.drive = wdpath.drive;
}
hasdl = (canon.drive != 0);
done:
clearPath(&canon);
@ -617,11 +650,6 @@ NCisnetworkpath(const char* path)
if(!pathinitialized) pathinit();
if((stat = parsepath(path,&canon))) goto done;
if(canon.kind == NCPD_REL) {
clearPath(&canon);
/* Get the drive letter (if any) from the local wd */
canon.drive = wdpath.drive;
}
isnp = (canon.drive == netdrive);
done:
clearPath(&canon);
@ -645,13 +673,13 @@ parsepath(const char* inpath, struct Path* path)
if(inpath == NULL) goto done; /* defensive driving */
/* Convert to UTF8 */
#if 0
/* Convert to UTF8 */
if((stat = NCpath2utf8(inpath,&tmp1))) goto done;
#else
tmp1 = strdup(inpath);
#endif
/* Convert to forward slash */
/* Convert to forward slash to simplify later code */
for(p=tmp1;*p;p++) {if(*p == '\\') *p = '/';}
/* parse all paths to 2 parts:
@ -661,7 +689,8 @@ parsepath(const char* inpath, struct Path* path)
len = strlen(tmp1);
/* 1. look for Windows network path //... */
/* 1. look for Windows network path //...; drive letter is faked using
the character '/' */
if(len >= 2 && (tmp1[0] == '/') && (tmp1[1] == '/')) {
path->drive = netdrive;
/* Remainder */
@ -673,23 +702,7 @@ parsepath(const char* inpath, struct Path* path)
{stat = NC_ENOMEM; goto done;}
path->kind = NCPD_WIN;
}
/* 2. look for MSYS path /D/... */
else if(len >= 2
&& (tmp1[0] == '/')
&& strchr(windrive,tmp1[1]) != NULL
&& (tmp1[2] == '/' || tmp1[2] == '\0')) {
/* Assume this is a mingw path */
path->drive = tmp1[1];
/* Remainder */
if(tmp1[2] == '\0')
path->path = NULL;
else
path->path = strdup(tmp1+2);
if(path == NULL)
{stat = NC_ENOMEM; goto done;}
path->kind = NCPD_MSYS;
}
/* 3. Look for leading /cygdrive/D where D is a single-char drive letter */
/* 2. Look for leading /cygdrive/D where D is a single-char drive letter */
else if(len >= (cdlen+1)
&& memcmp(tmp1,"/cygdrive/",cdlen)==0
&& strchr(windrive,tmp1[cdlen]) != NULL
@ -721,13 +734,31 @@ parsepath(const char* inpath, struct Path* path)
path->path = strdup(tmp1+2);
if(path == NULL)
{stat = NC_ENOMEM; goto done;}
path->kind = NCPD_WIN;
path->kind = NCPD_WIN; /* Might be MINGW */
}
/* 5. look for *nix path */
#if 0
/* X. look for MSYS2 path /D/... */
else if(len >= 2
&& (tmp1[0] == '/')
&& strchr(windrive,tmp1[1]) != NULL
&& (tmp1[2] == '/' || tmp1[2] == '\0')) {
/* Assume this is an MSYS2 path */
path->drive = tmp1[1];
/* Remainder */
if(tmp1[2] == '\0')
path->path = NULL;
else
path->path = strdup(tmp1+2);
if(path == NULL)
{stat = NC_ENOMEM; goto done;}
path->kind = NCPD_MSYS;
}
#endif
/* 5. look for *nix* path; note this includes MSYS2 paths as well */
else if(len >= 1 && tmp1[0] == '/') {
/* Assume this is a *nix path */
path->drive = 0; /* no drive letter */
/* Remainder */
/* Remainder */
path->path = tmp1; tmp1 = NULL;
path->kind = NCPD_NIX;
} else {/* 6. Relative path of unknown type */
@ -742,90 +773,211 @@ done:
}
static int
unparsepath(struct Path* xp, char** pathp)
unparsepath(struct Path* xp, char** pathp, int target)
{
int stat = NC_NOERR;
size_t len;
char* path = NULL;
char sdrive[2] = {'\0','\0'};
char sdrive[4] = "\0\0\0\0";
char* p = NULL;
int kind = xp->kind;
int cygspecial = 0;
int drive = 0;
switch (kind) {
case NCPD_NIX:
len = nulllen(xp->path);
if(xp->drive != 0) {
len += 2;
sdrive[0] = xp->drive;
/* Short circuit a relative path */
if(xp->kind == NCPD_REL) {
/* Pass thru relative paths, but with proper slashes */
if((path = strdup(xp->path))==NULL) stat = NC_ENOMEM;
if(target == NCPD_WIN || target == NCPD_MSYS) {
char* p;
for(p=path;*p;p++) {if(*p == '/') *p = '\\';} /* back slash*/
}
len++; /* nul terminate */
goto exit;
}
/* We need a two level switch with an arm
for every pair of (xp->kind,target)
*/
#define CASE(k,t) case ((k)*10+(t))
switch (xp->kind*10 + target) {
CASE(NCPD_NIX,NCPD_NIX):
assert(xp->drive == 0);
len = nulllen(xp->path)+1;
if((path = (char*)malloc(len))==NULL)
{stat = NC_ENOMEM; goto done;}
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
if(xp->drive != 0) {
strlcat(path,"/",len);
strlcat(path,sdrive,len);
}
if(xp->path != NULL)
strlcat(path,xp->path,len);
break;
case NCPD_CYGWIN:
break;
CASE(NCPD_NIX,NCPD_MSYS):
CASE(NCPD_NIX,NCPD_WIN):
assert(xp->drive == 0);
len = nulllen(xp->path)+1;
if(!mountpoint.defined)
{stat = NC_EINVAL; goto done;} /* drive required */
len += (strlen(mountpoint.prefix) + 2);
if((path = (char*)malloc(len))==NULL)
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
assert(mountpoint.drive != 0);
sdrive[0] = mountpoint.drive;
sdrive[1] = ':';
sdrive[2] = '\0';
strlcat(path,sdrive,len);
strlcat(path,mountpoint.prefix,len);
if(xp->path != NULL) strlcat(path,xp->path,len);
for(p=path;*p;p++) {if(*p == '/') *p = '\\';} /* restore back slash */
break;
CASE(NCPD_NIX,NCPD_CYGWIN):
assert(xp->drive == 0);
/* Is this one of the special cygwin paths? */
cygspecial = iscygwinspecial(xp->path);
if(xp->drive == 0) {xp->drive = wdpath.drive;} /*may require a drive */
len = nulllen(xp->path)+cdlen+1+1;
len = 0;
if(!cygspecial && mountpoint.drive != 0) {
len = cdlen + 1+1; /* /cygdrive/D */
len += nulllen(mountpoint.prefix);
}
if(xp->path)
len += strlen(xp->path);
len++; /* nul term */
if((path = (char*)malloc(len))==NULL)
{stat = NC_ENOMEM; goto done;}
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
if(!cygspecial) {
if(!cygspecial && mountpoint.drive != 0) {
strlcat(path,"/cygdrive/",len);
sdrive[0] = xp->drive;
strlcat(path,sdrive,len);
sdrive[0] = mountpoint.drive;
sdrive[1] = '\0';
strlcat(path,sdrive,len);
strlcat(path,mountpoint.prefix,len);
}
if(xp->path)
strlcat(path,xp->path,len);
break;
case NCPD_WIN:
if(xp->drive == 0) {xp->drive = wdpath.drive;} /*requires a drive */
len = nulllen(xp->path)+2+1+1;
if((path = (char*)malloc(len))==NULL)
{stat = NC_ENOMEM; goto done;}
CASE(NCPD_CYGWIN,NCPD_NIX):
len = nulllen(xp->path);
if(xp->drive != 0)
len += (cdlen + 2); /* /cygdrive/D */
len++;
if((path = (char*)malloc(len))==NULL)
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
if(xp->drive == netdrive)
strlcat(path,"/",len); /* second slash will come from path */
else {
sdrive[0] = xp->drive;
if(xp->drive != 0) {
strlcat(path,"/cygdrive/",len);
sdrive[0] = xp->drive; sdrive[1] = '\0';
strlcat(path,sdrive,len);
}
if(xp->path)
strlcat(path,xp->path,len);
break;
CASE(NCPD_CYGWIN,NCPD_WIN):
CASE(NCPD_CYGWIN,NCPD_MSYS):
len = nulllen(xp->path)+1;
if(xp->drive == 0 && !mountpoint.defined)
{stat = NC_EINVAL; goto done;} /* drive required */
if (xp->drive == 0)
len += (strlen(mountpoint.prefix) + 2);
else
len += sizeof(sdrive);
len++;
if((path = (char*)malloc(len))==NULL)
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
if(xp->drive != 0)
drive = xp->drive;
else
drive = mountpoint.drive;
sdrive[0] = drive; sdrive[1] = ':'; sdrive[2] = '\0';
strlcat(path,sdrive,len);
if(xp->path != NULL)
strlcat(path,xp->path,len);
for(p=path;*p;p++) {if(*p == '/') *p = '\\';} /* restore back slash */
break;
CASE(NCPD_CYGWIN,NCPD_CYGWIN):
len = nulllen(xp->path)+1;
if(xp->drive != 0)
len += (cdlen + 2);
len++;
if((path = (char*)malloc(len))==NULL)
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
if(xp->drive != 0) {
sdrive[0] = xp->drive; sdrive[1] = '\0';
strlcat(path,"/cygdrive/",len);
strlcat(path,sdrive,len);
strlcat(path,":",len);
}
if(xp->path)
if(xp->path != NULL)
strlcat(path,xp->path,len);
/* Convert forward to back */
for(p=path;*p;p++) {if(*p == '/') *p = '\\';}
break;
case NCPD_MSYS:
if(xp->drive == 0) {xp->drive = wdpath.drive;} /*requires a drive */
len = nulllen(xp->path)+2+1;
CASE(NCPD_WIN, NCPD_WIN) :
CASE(NCPD_MSYS, NCPD_MSYS) :
CASE(NCPD_WIN, NCPD_MSYS) :
CASE(NCPD_MSYS, NCPD_WIN) :
if(xp->drive == 0 && !mountpoint.defined)
{stat = NC_EINVAL; goto done;} /* drive required */
len = nulllen(xp->path) + 1 + sizeof(sdrive);
if(xp->drive == 0)
len += strlen(mountpoint.prefix);
len++;
if((path = (char*)malloc(len))==NULL)
{stat = NC_ENOMEM; goto done;}
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
sdrive[0] = xp->drive;
strlcat(path,"/",len);
strlcat(path,sdrive,len);
if(xp->path)
strlcat(path,xp->path,len);
break;
case NCPD_REL:
path = strdup(xp->path);
/* Use wdpath to decide slashing */
if(wdpath.kind == NCPD_WIN) {
/* Convert forward to back */
for(p=path;*p;p++) {if(*p == '/') *p = '\\';}
if(xp->drive != 0)
drive = xp->drive;
else
drive = mountpoint.drive;
sdrive[0] = drive;
sdrive[1] = (drive == netdrive ? '\0' : ':');
sdrive[2] = '\0';
strlcat(path,sdrive,len);
if(xp->path != NULL)
strlcat(path,xp->path,len);
for(p=path;*p;p++) {if(*p == '/') *p = '\\';} /* restore back slash */
break;
CASE(NCPD_WIN,NCPD_NIX):
CASE(NCPD_MSYS,NCPD_NIX):
assert(xp->drive != 0);
len = nulllen(xp->path)+1;
if(xp->drive != 0)
len += sizeof(sdrive);
len++;
if((path = (char*)malloc(len))==NULL)
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
if(xp->drive != 0) {
sdrive[0] = '/'; sdrive[1] = xp->drive; sdrive[2] = '\0';
strlcat(path,sdrive,len);
}
break;
if(xp->path != NULL) strlcat(path,xp->path,len);
break;
CASE(NCPD_MSYS,NCPD_CYGWIN):
CASE(NCPD_WIN,NCPD_CYGWIN):
assert(xp->drive != 0);
len = nulllen(xp->path)+1;
len += (cdlen + 2);
len++;
if((path = (char*)malloc(len))==NULL)
{stat = NCTHROW(NC_ENOMEM); goto done;}
path[0] = '\0';
sdrive[0] = xp->drive; sdrive[1] = '\0';
strlcat(path,"/cygdrive/",len);
strlcat(path,sdrive,len);
if(xp->path != NULL) strlcat(path,xp->path,len);
break;
default: stat = NC_EINTERNAL; goto done;
}
if(pathdebug > 0)
fprintf(stderr,">>> unparse: target=%s xp=%s path=|%s|\n",NCgetkindname(target),printPATH(xp),path);
exit:
if(pathp) {*pathp = path; path = NULL;}
done:
nullfree(path);
@ -833,13 +985,12 @@ done:
}
static int
getwdpath(struct Path* wd)
getwdpath(void)
{
int stat = NC_NOERR;
char* path = NULL;
if(wd->path != NULL) return stat;
memset(wd,0,sizeof(struct Path));
wdprefix[0] = '\0';
#ifdef _WIN32
{
wchar_t* wcwd = NULL;
@ -850,39 +1001,70 @@ getwdpath(struct Path* wd)
stat = wide2utf8(wpath, &path);
free(wcwd);
if (stat) return stat;
strlcat(wdprefix,path,sizeof(wdprefix));
}
#else
{
char cwd[8192];
path = getcwd(cwd, sizeof(cwd));
path = strdup(path);
getcwd(wdprefix, sizeof(wdprefix));
}
#endif
stat = parsepath(path,wd);
/* Force the kind */
wd->kind = getlocalpathkind();
nullfree(path); path = NULL;
return stat;
}
static int
getlocalpathkind(void)
int
NCgetinputpathkind(const char* inpath)
{
struct Path p;
int result = NCPD_UNKNOWN;
memset(&p,0,sizeof(p));
if(inpath == NULL) goto done; /* defensive driving */
if(testurl(inpath)) goto done;
if(!pathinitialized) pathinit();
if(parsepath(inpath,&p)) goto done;
done:
result = p.kind;
clearPath(&p);
return result;
}
int
NCgetlocalpathkind(void)
{
int kind = NCPD_UNKNOWN;
if(testkind) return testkind;
#ifdef __CYGWIN__
kind = NCPD_CYGWIN;
#elif defined __MINGW32__
kind = NCPD_WIN;
#elif defined _MSC_VER /* not _WIN32 */
kind = NCPD_WIN;
#elif defined __MSYS__
kind = NCPD_MSYS;
#elif defined __MINGW32__
kind = NCPD_WIN; /* alias */
#else
kind = NCPD_NIX;
#endif
return kind;
}
const char*
NCgetkindname(int kind)
{
switch (kind) {
case NCPD_UNKNOWN: return "NCPD_UNKNOWN";
case NCPD_NIX: return "NCPD_NIX";
case NCPD_MSYS: return "NCPD_MSYS";
case NCPD_CYGWIN: return "NCPD_CYGWIN";
case NCPD_WIN: return "NCPD_WIN";
/* same as WIN case NCPD_MINGW: return "NCPD_MINGW";*/
case NCPD_REL: return "NCPD_REL";
default: break;
}
return "NCPD_UNDEF";
}
#ifdef WINPATH
/**
* Converts the filename from Locale character set (presumably some
@ -908,7 +1090,7 @@ ansi2utf8(const char* local, char** u8p)
n = MultiByteToWideChar(CP_ACP, 0, local, -1, NULL, 0);
if (!n) {stat = NC_EINVAL; goto done;}
if((u16 = malloc(sizeof(wchar_t) * n))==NULL)
{stat = NC_ENOMEM; goto done;}
{stat = NCTHROW(NC_ENOMEM); goto done;}
/* do the conversion */
if (!MultiByteToWideChar(CP_ACP, 0, local, -1, u16, n))
{stat = NC_EINVAL; goto done;}
@ -916,7 +1098,7 @@ ansi2utf8(const char* local, char** u8p)
n = WideCharToMultiByte(CP_UTF8, 0, u16, -1, NULL, 0, NULL, NULL);
if (!n) {stat = NC_EINVAL; goto done;}
if((u8 = malloc(sizeof(char) * n))==NULL)
{stat = NC_ENOMEM; goto done;}
{stat = NCTHROW(NC_ENOMEM); goto done;}
if (!WideCharToMultiByte(CP_UTF8, 0, u16, -1, u8, n, NULL, NULL))
{stat = NC_EINVAL; goto done;}
}
@ -937,7 +1119,7 @@ ansi2wide(const char* local, wchar_t** u16p)
n = MultiByteToWideChar(CP_ACP, 0, local, -1, NULL, 0);
if (!n) {stat = NC_EINVAL; goto done;}
if((u16 = malloc(sizeof(wchar_t) * n))==NULL)
{stat = NC_ENOMEM; goto done;}
{stat = NCTHROW(NC_ENOMEM); goto done;}
/* do the conversion */
if (!MultiByteToWideChar(CP_ACP, 0, local, -1, u16, n))
{stat = NC_EINVAL; goto done;}
@ -958,7 +1140,7 @@ utf82wide(const char* utf8, wchar_t** u16p)
n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
if (!n) {stat = NC_EINVAL; goto done;}
if((u16 = malloc(sizeof(wchar_t) * n))==NULL)
{stat = NC_ENOMEM; goto done;}
{stat = NCTHROW(NC_ENOMEM); goto done;}
/* do the conversion */
if (!MultiByteToWideChar(CP_UTF8, 0, utf8, -1, u16, n))
{stat = NC_EINVAL; goto done;}
@ -979,7 +1161,7 @@ wide2utf8(const wchar_t* u16, char** u8p)
n = WideCharToMultiByte(CP_UTF8, 0, u16, -1, NULL, 0, NULL, NULL);
if (!n) {stat = NC_EINVAL; goto done;}
if((u8 = malloc(sizeof(char) * n))==NULL)
{stat = NC_ENOMEM; goto done;}
{stat = NCTHROW(NC_ENOMEM); goto done;}
/* do the conversion */
if (!WideCharToMultiByte(CP_UTF8, 0, u16, -1, u8, n, NULL, NULL))
{stat = NC_EINVAL; goto done;}
@ -1043,3 +1225,13 @@ printutf8hex(const char* s, char* sx)
}
*q = '\0';
}
static void
report(int stat, const char* msg, int line)
{
if(stat) {
nclog(NCLOGERR,"NCpathcvt(%d): %s: stat=%d (%s)",
line,msg,stat,nc_strerror(stat));
ncbreakpoint(stat);
}
}

View File

@ -23,18 +23,12 @@ See COPYRIGHT for license information.
#include "ncauth.h"
#include "ncpathmgr.h"
#undef NOREAD
#undef DRCDEBUG
#undef LEXDEBUG
#undef PARSEDEBUG
#undef AWSDEBUG
#undef CATCH
#if defined(CATCH)
#define THROW(e) ((e) == NC_NOERR ? (e) : ncbreakpoint(e))
#else
#define THROW(e) (e)
#endif
#define RTAG ']'
#define LTAG '['
@ -117,6 +111,7 @@ ncrc_initialize(void)
if(NCRCinitialized) return;
NCRCinitialized = 1; /* prevent recursion */
#ifndef NOREAD
/* Load entrys */
if((stat = NC_rcload())) {
nclog(NCLOGWARN,".rc loading failed");
@ -125,6 +120,7 @@ ncrc_initialize(void)
if((stat = aws_load_credentials(ncrc_globalstate))) {
nclog(NCLOGWARN,"AWS config file not loaded");
}
#endif
}
static void
@ -197,6 +193,7 @@ NC_rcload(void)
if(!NCRCinitialized) ncrc_initialize();
globalstate = ncrc_getglobalstate();
if(globalstate->rcinfo.ignore) {
nclog(NCLOGDBG,".rc file loading suppressed");
goto done;
@ -902,7 +899,7 @@ awsparse(const char* text, NClist* profiles)
len = strlen(text);
parser->text = (char*)malloc(len+1+1+1); /* double nul term plus leading EOL */
if(parser->text == NULL)
{stat = (THROW(NC_EINVAL)); goto done;}
{stat = (NCTHROW(NC_EINVAL)); goto done;}
parser->pos = parser->text;
parser->pos[0] = '\n'; /* So we can test for comment unconditionally */
parser->pos++;
@ -920,17 +917,17 @@ awsparse(const char* text, NClist* profiles)
token = awslex(parser); /* make token always be defined */
if(token == AWS_EOF) break; /* finished */
if(token == AWS_EOL) {continue;} /* blank line */
if(token != LBR) {stat = THROW(NC_EINVAL); goto done;}
if(token != LBR) {stat = NCTHROW(NC_EINVAL); goto done;}
/* parse [profile name] */
token = awslex(parser);
if(token != AWS_WORD) {stat = THROW(NC_EINVAL); goto done;}
if(token != AWS_WORD) {stat = NCTHROW(NC_EINVAL); goto done;}
assert(profile == NULL);
if((profile = (struct AWSprofile*)calloc(1,sizeof(struct AWSprofile)))==NULL)
{stat = NC_ENOMEM; goto done;}
profile->name = ncbytesextract(parser->yytext);
profile->entries = nclistnew();
token = awslex(parser);
if(token != RBR) {stat = THROW(NC_EINVAL); goto done;}
if(token != RBR) {stat = NCTHROW(NC_EINVAL); goto done;}
#ifdef PARSEDEBUG
fprintf(stderr,">>> parse: profile=%s\n",profile->name);
#endif
@ -948,9 +945,9 @@ fprintf(stderr,">>> parse: profile=%s\n",profile->name);
} else if(token == AWS_WORD) {
key = ncbytesextract(parser->yytext);
token = awslex(parser);
if(token != '=') {stat = THROW(NC_EINVAL); goto done;}
if(token != '=') {stat = NCTHROW(NC_EINVAL); goto done;}
token = awslex(parser);
if(token != AWS_EOL && token != AWS_WORD) {stat = THROW(NC_EINVAL); goto done;}
if(token != AWS_EOL && token != AWS_WORD) {stat = NCTHROW(NC_EINVAL); goto done;}
value = ncbytesextract(parser->yytext);
if((entry = (struct AWSentry*)calloc(1,sizeof(struct AWSentry)))==NULL)
{stat = NC_ENOMEM; goto done;}
@ -962,7 +959,7 @@ fprintf(stderr,">>> parse: entry=(%s,%s)\n",entry->key,entry->value);
nclistpush(profile->entries,entry); entry = NULL;
if(token == AWS_WORD) token = awslex(parser); /* finish the line */
} else
{stat = THROW(NC_EINVAL); goto done;}
{stat = NCTHROW(NC_EINVAL); goto done;}
}
/* If this profile already exists, then ignore new one */

46
libdispatch/dreg.c Normal file
View File

@ -0,0 +1,46 @@
/*
* Copyright 2018, University Corporation for Atmospheric Research
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <windows.h>
#include <io.h>
#include <wchar.h>
#include <locale.h>
//#include <direct.h>
__declspec(dllexport)
int
getmountpoint(char* keyvalue, size_t size)
{
/* See if we can get the MSYS2|CYGWIN prefix from the registry */
LSTATUS stat;
const LPCSTR rpath = "SOFTWARE\\Cygwin\\setup\\";
const LPCSTR leaf = "rootdir";
HKEY key;
if(size == 0 || keyvalue == NULL)
return -1;
keyvalue[0] = '\0';
stat = RegOpenKeyA(HKEY_LOCAL_MACHINE, rpath, &key);
if(stat != ERROR_SUCCESS) {
// wprintf(L"RegOpenKeyA failed. Error code: %li\n", stat);
goto done;
}
stat = RegGetValueA(key, NULL, leaf, RRF_RT_REG_SZ, NULL, (PVOID)keyvalue, (LPDWORD)&size);
if(stat != ERROR_SUCCESS) {
// wprintf(L"RegGetValueA failed. Error code: %li\n", stat);
goto done;
}
done:
return (stat == ERROR_SUCCESS ? 0 : -1);
}

View File

@ -229,11 +229,7 @@ NC_readfile(const char* filename, NCbytes* content)
FILE* stream = NULL;
char part[1024];
#ifdef _WIN32
stream = NCfopen(filename,"rb");
#else
stream = NCfopen(filename,"r");
#endif
if(stream == NULL) {ret=errno; goto done;}
for(;;) {
size_t count = fread(part, 1, sizeof(part), stream);
@ -258,11 +254,7 @@ NC_writefile(const char* filename, size_t size, void* content)
if(content == NULL) {content = ""; size = 0;}
#ifdef _WIN32
stream = NCfopen(filename,"wb");
#else
stream = NCfopen(filename,"w");
#endif
if(stream == NULL) {ret=errno; goto done;}
p = content;
remain = size;

View File

@ -761,10 +761,10 @@ ncexhashprint(NCexhashmap* hm)
fprintf(stderr,"%s(%s/",(index==0?":":" "),s);
bits = MSB(hkey,leaf->depth);
s = ncexbinstr(bits,leaf->depth);
fprintf(stderr,"%s|0x%llx,%lu)",
fprintf(stderr,"%s|0x%llx,%llu)",
s,
(unsigned long long)hkey,
(uintptr_t)leaf->entries[index].data);
(unsigned long long)leaf->entries[index].data);
}
fprintf(stderr,"]\n");
}
@ -801,8 +801,8 @@ ncexhashprintleaf(NCexhashmap* map, NCexleaf* leaf)
fprintf(stderr,"%s(%s/",(index==0?":":" "),s);
bits = MSB(hkey,leaf->depth);
s = ncexbinstr(bits,leaf->depth);
fprintf(stderr,"%s|0x%llx,%lu)",
s, (unsigned long long)hkey, (uintptr_t)leaf->entries[index].data);
fprintf(stderr,"%s|0x%llx,%llu)",
s, (unsigned long long)hkey, (unsigned long long)leaf->entries[index].data);
}
fprintf(stderr,"]\n");
}
@ -811,7 +811,7 @@ void
ncexhashprintentry(NCexhashmap* map, NCexentry* entry)
{
fprintf(stderr,"{0x%llx,%lu)",(unsigned long long)entry->hashkey,(uintptr_t)entry->data);
fprintf(stderr,"{0x%llx,%llu)",(unsigned long long)entry->hashkey,(unsigned long long)entry->data);
}
char*

View File

@ -281,6 +281,13 @@ done:
return err;
}
int
ncthrow(int err,const char* file,int line)
{
if(err == 0) return err;
return ncbreakpoint(err);
}
int
ncbreakpoint(int err)
{

View File

@ -44,9 +44,10 @@ nch5breakpoint(int err)
}
int
nch5throw(int err)
nch5throw(int err, int line)
{
if(err == 0) return err;
fprintf(stderr,">>> hdf5throw: line=%d err=%d\n",line,err); fflush(stderr);
return nch5breakpoint(err);
}
#endif

View File

@ -12,10 +12,10 @@
#ifdef H5CATCH
/* Place breakpoint to catch errors close to where they occur*/
#define THROW(e) nch5throw(e)
#define THROW(e) nch5throw(e,__LINE__)
#define THROWCHK(e) (void)nch5throw(e)
extern int nch5breakpoint(int err);
extern int nch5throw(int err);
extern int nch5throw(int err, int line);
#else
#define THROW(e) (e)
#define THROWCHK(e)

View File

@ -12,6 +12,7 @@
#include "config.h"
#include "hdf5internal.h"
#include "hdf5err.h"
#include "hdf5debug.h"
#include "ncrc.h"
#include "ncauth.h"
#include "ncmodel.h"
@ -973,7 +974,7 @@ exit:
H5Pclose(fapl_id);
if (nc4_info)
nc4_close_hdf5_file(nc4_info, 1, 0); /* treat like abort*/
return retval;
return THROW(retval);
}
/**
@ -2883,6 +2884,7 @@ nc4_H5Fopen(const char *filename0, unsigned flags, hid_t fapl_id)
if((localname = NCpathcvt(filename))==NULL)
{hid = H5I_INVALID_HID; goto done;}
hid = H5Fopen(localname, flags, fapl_id);
done:
nullfree(filename);
nullfree(localname);

View File

@ -21,7 +21,7 @@ lib_LTLIBRARIES = libnetcdf.la
libnetcdf_la_LDFLAGS = -version-info 19:1:0
libnetcdf_la_CPPFLAGS = ${AM_CPPFLAGS}
libnetcdf_la_LIBADD =
libnetcdf_la_LIBADD =
CLEANFILES =
# The v2 API...

View File

@ -17,10 +17,14 @@ libncpoco_la_LIBADD =
libncpoco_la_LDFLAGS =
libncpoco_la_SOURCES = ncpoco.c ncpoco.h
if ISMSVC
libncpoco_la_SOURCES += cp_win32.c
else
if ! ISMSVC
if ! ISMINGW
libncpoco_la_SOURCES += cp_unix.c
else
libncpoco_la_SOURCES += cp_win32.c
endif
else
libncpoco_la_SOURCES += cp_win32.c
endif
EXTRA_DIST = CMakeLists.txt README.md COPYRIGHT

View File

@ -29,28 +29,33 @@ endif
EXTRA_DIST = CMakeLists.txt license.txt
# Construct ezxml from latest sources
REPO=https://downloads.sourceforge.net/project/ezxml/
EZXML=ezxml-0.8.6.tar.gz
REPO = https://downloads.sourceforge.net/project/ezxml/
EZXML = ezxml-0.8.6.tar.gz
makelib::
rm -fr ./ezxml.[ch] ./license.txt ./ezxml
tar -zxf ./${EZXML}
echo '#define EZXML_NOMMAP 1' > ezxml.c
cat <ezxml/ezxml.c | \
sed -e '/<unistd.h>/d' | \
sed -e 's|//\(.*\)|/*\1*/|' \
sed -e 's|//\(.*\)|/*\1*/|' \
cat >./ezxml.c
sed -e 's|//\(.*\)|/*\1*/|' <ezxml/ezxml.h >./ezxml.h
sed -i .bak 's/<fcntl.h>/<fcntl.h>\n#ifdef HAVE_UNISTD_H\n#include <unistd.h>\n#endif/g' ezxml.h
rm ezxml.h.bak
echo "WARNING DO NOT RUN THIS since the patches are not in the tar file"
exit 1
rm -fr ./ezxml.[ch] ./license.txt ./ezxml ./ezxml.c.? ./ezxml.h.?
tar -zxf ${EZXML}
cat ezxml/ezxml.h > ./ezxml.h
sed -i.1 -e '/ezxml_parse_fd/d' ezxml.h
sed -i.2 -e '/ezxml_parse_file/d' ezxml.h
sed -i.3 -e '/ezxml_parse_fp/d' ezxml.h
echo "#define EZXML_NOMMAP 1" > ./ezxml.c
cat ezxml/ezxml.c >> ./ezxml.c
sed -i.1 -e '/<unistd.h>/d' ezxml.c
sed -i.2 -e '/ezxml_parse_fp(FILE/i#if 0' ./ezxml.c
sed -i.3 -e '/ezxml_ampencode(const/i#endif //0' ./ezxml.c
sed -i.4 -e 's|//\(.*\)|/*\1*/|' ezxml.h
sed -i.5 -e 's|//\(.*\)|/*\1*/|' ezxml.c
cp ezxml/license.txt .
rm -fr ezxml
# Define path to the xml github dir; this value assumes it is in a parallel directory to netcdf-c (YMMV)
GITSRC=${top_srcdir}/../tinyxml2
xmakelib::
rm -f readme.md LICENSE.txt
rm -fr ./tinyxml2.cpp ./tinyxml2.h
cp ${GITSRC}/readme.md .
cp ${GITSRC}/LICENSE.txt .
cp ${GITSRC}/tinyxml2.h ${GITSRC}/tinyxml2.cpp .
TINYREPO = https://github.com/leethomason/tinyxml2.git
tinyxml2::
rm -fr ./tinyxml2 ./license.txt
git clone --depth=1 ${TINYREPO}
cat tinyxml2/tinyxml2.h > ./tinyxml2.h
cat tinyxml2/tinyxml2.cpp > ./tinyxml2.cpp
cat tinyxml2/LICENSE.txt > ./license.txt

View File

@ -620,6 +620,7 @@ ezxml_t ezxml_parse_str(char *s, size_t len)
else return ezxml_err(root, d, "unclosed tag <%s>", root->cur->name);
}
#if 0
/* Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire*/
/* stream into memory and then parses it. For xml files, use ezxml_parse_file()*/
/* or ezxml_parse_fd()*/
@ -685,6 +686,7 @@ ezxml_t ezxml_parse_file(const char *file)
if (fd >= 0) close(fd);
return xml;
}
#endif /*0*/
/* Encodes ampersand sequences appending the results to *dst, reallocating *dst*/
/* if length excedes max. a is non-zero for attribute encoding. Returns *dst*/

View File

@ -29,9 +29,6 @@
#include <stdio.h>
#include <stdarg.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef __cplusplus
extern "C" {
@ -62,19 +59,6 @@ struct ezxml {
/* pass in the copy. Returns NULL on failure.*/
ezxml_t ezxml_parse_str(char *s, size_t len);
/* A wrapper for ezxml_parse_str() that accepts a file descriptor. First*/
/* attempts to mem map the file. Failing that, reads the file into memory.*/
/* Returns NULL on failure.*/
ezxml_t ezxml_parse_fd(int fd);
/* a wrapper for ezxml_parse_fd() that accepts a file name*/
ezxml_t ezxml_parse_file(const char *file);
/* Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire*/
/* stream into memory and then parses it. For xml files, use ezxml_parse_file()*/
/* or ezxml_parse_fd()*/
ezxml_t ezxml_parse_fp(FILE *fp);
/* returns the first child tag (one level deeper) with the given name or NULL*/
/* if not found*/
ezxml_t ezxml_child(ezxml_t xml, const char *name);
@ -114,7 +98,7 @@ const char **ezxml_pi(ezxml_t xml, const char *target);
/* frees the memory allocated for an ezxml structure*/
void ezxml_free(ezxml_t xml);
/* returns parser error message or empty string if none*/
const char *ezxml_error(ezxml_t xml);

View File

@ -51,7 +51,7 @@ const char*
ncxml_name(ncxml_t xml0)
{
xmlNode* xml = (xmlNode*)xml0;
return (xml?xml->name:NULL);
return (xml?xml->name:(const char*)NULL);
}
char*
@ -61,7 +61,7 @@ ncxml_attr(ncxml_t xml0, const char* key)
xmlChar* value = NULL;
char* s = NULL;
value = xmlGetProp(xml,key);
value = xmlGetProp(xml,(const xmlChar*)key);
s = nulldup((char*)value);
xmlFree(value);
return s;
@ -75,7 +75,7 @@ ncxml_child(ncxml_t xml0, const char* name)
xmlNode* child = NULL;
for(child=xml->children;child; child = child->next) {
if(child->type == XML_ELEMENT_NODE && strcmp(child->name,name)==0)
if(child->type == XML_ELEMENT_NODE && strcmp((const char*)child->name,name)==0)
return (ncxml_t)child;
}
return NULL;
@ -88,7 +88,7 @@ ncxml_next(ncxml_t xml0, const char* name)
xmlNode* next = NULL;
for(next=xml->next;next; next = next->next) {
if(next->type == XML_ELEMENT_NODE && strcmp(next->name,name)==0)
if(next->type == XML_ELEMENT_NODE && strcmp((const char*)next->name,name)==0)
return (ncxml_t)next;
}
return NULL;

View File

@ -50,7 +50,6 @@ ztype.c \
zutil.c \
zvar.c \
zwalk.c \
zfilter.c \
zdebug.c \
zarr.h \
zcache.h \
@ -69,6 +68,10 @@ if ENABLE_NCZARR_ZIP
libnczarr_la_SOURCES += zmap_zip.c
endif
if ENABLE_NCZARR_FILTERS
libnczarr_la_SOURCES += zfilter.c
endif
if ENABLE_S3_SDK
libnczarr_la_SOURCES += zmap_s3sdk.c
libnczarr_la_SOURCES +=

View File

@ -100,6 +100,7 @@ ncz_get_att_special(NC_FILE_INFO_T* h5, NC_VAR_INFO_T* var, const char* name,
/* Handle the per-var case(s) first */
if(var != NULL) {
#ifdef ENABLE_NCZARR_FILTERS
if(strcmp(name,NC_ATT_CODECS)==0) {
NClist* filters = (NClist*)var->filters;
@ -111,6 +112,7 @@ ncz_get_att_special(NC_FILE_INFO_T* h5, NC_VAR_INFO_T* var, const char* name,
if(filters == NULL) goto done;
if((stat = NCZ_codec_attr(var,lenp,data))) goto done;
}
#endif
goto done;
}

View File

@ -164,11 +164,13 @@ zclose_vars(NC_GRP_INFO_T* grp)
nullfree(zatt);
att->format_att_info = NULL; /* avoid memory errors */
}
#ifdef ENABLE_NCZARR_FILTERS
/* Reclaim filters */
if(var->filters != NULL) {
(void)NCZ_filter_freelist(var);
}
var->filters = NULL;
#endif
/* Reclaim the type */
(void)zclose_type(var->type_info);
NCZ_free_chunk_cache(zvar->cache);

View File

@ -123,7 +123,8 @@ NCZ_create(const char* path, int cmode, size_t initialsz, int basepe,
cmode |= NC_WRITE;
/* Get the controls */
if(ncuriparse(path,&uri)) goto done;
ncuriparse(path,&uri);
if(uri == NULL) goto done;
/* Create the file */
stat = ncz_create_file(path, cmode, initialsz, ncurifragmentparams(uri), ncid);

View File

@ -29,6 +29,16 @@ zthrow(int err, const char* file, const char* fcn, int line)
ncbacktrace();
return zbreakpoint(err);
}
int
zreport(int err, const char* msg, const char* file, const char* fcn, int line)
{
if(err == 0) return err;
ZLOG(NCLOGWARN,"!!! zreport: err=%d msg=%s",err,msg);
ncbacktrace();
return zbreakpoint(err);
}
#endif /*ZCATCH*/
/**************************************************/

View File

@ -9,7 +9,7 @@
#undef ZDEBUG1 /* detailed debug */
#define ZCATCH /* Warning: significant performance impact */
#define ZTRACING /* Warning: significant performance impact */
#undef ZTRACING /* Warning: significant performance impact */
#include "ncexternl.h"
#include "nclog.h"
@ -23,12 +23,15 @@
#ifdef ZCATCH
/* Place breakpoint on zbreakpoint to catch errors close to where they occur*/
#define THROW(e) zthrow((e),__FILE__, __func__, __LINE__)
#define REPORT(e,msg) zreport((e),(msg),__FILE__, __func__, __LINE__)
#define ZCHECK(e) if((e)) {THROW(stat); goto done;} else {}
EXTERNL int zbreakpoint(int err);
EXTERNL int zthrow(int err, const char* fname, const char* fcn, int line);
EXTERNL int zreport(int err, const char* msg, const char* fname, const char* fcn, int line);
#else
#define ZCHECK(e) {if((e)) {goto done;}}
#define THROW(e) (e)
#define REPORT(e,msg) (e)
#endif
#ifdef ZTRACING

View File

@ -163,3 +163,36 @@ NCZ_show_metadata(int ncid)
return NC_NOERR;
}
#ifndef ENABLE_NCZARR_FILTERS
int
NCZ_def_var_filter(int ncid, int varid, unsigned int id , size_t n , const unsigned int *params)
{
NC_UNUSED(ncid);
NC_UNUSED(varid);
NC_UNUSED(id);
NC_UNUSED(n);
NC_UNUSED(params);
return REPORT(NC_NOERR,"def_var_filter");
}
int
NCZ_inq_var_filter_ids(int ncid, int varid, size_t* nfilters, unsigned int* filterids)
{
NC_UNUSED(ncid);
NC_UNUSED(varid);
NC_UNUSED(filterids);
if(nfilters) *nfilters = 0;
return REPORT(NC_NOERR,"inq_var_filter_ids");
}
int
NCZ_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t* nparams, unsigned int* params)
{
NC_UNUSED(ncid);
NC_UNUSED(varid);
NC_UNUSED(id);
NC_UNUSED(nparams);
NC_UNUSED(params);
return REPORT(NC_ENOFILTER,"inq_var_filter_info");
}
#endif /*ENABLE_NCZARR_FILTERS*/

View File

@ -120,8 +120,10 @@ NCZ_enddef(int ncid)
var->written_to = NC_TRUE; /* mark it written */
/* rebuild the fill chunk */
if((stat = NCZ_adjust_var_cache(var))) goto done;
#ifdef ENABLE_NCZARR_FILTERS
/* Build the filter working parameters for any filters */
if((stat = NCZ_filter_setup(var))) goto done;
#endif
}
}
stat = ncz_enddef_netcdf4_file(h5);

View File

@ -53,8 +53,8 @@
#include "netcdf_aux.h"
#undef DEBUG
#undef DEBUGF
#undef DEBUGL
#define DEBUGF
#define DEBUGL
#define NULLIFY(x) ((x)?(x):"NULL")
@ -692,7 +692,9 @@ NCZ_filter_initialize(void)
{
NCZ_filter_initialized = 1;
memset(loaded_plugins,0,sizeof(loaded_plugins));
#ifdef ENABLE_NCZARR_FILTERS
if((stat = NCZ_load_all_plugins())) goto done;
#endif
}
done:
return ZUNTRACE(stat);
@ -704,6 +706,8 @@ NCZ_filter_finalize(void)
int stat = NC_NOERR;
int i;
ZTRACE(6,"");
if(!NCZ_filter_initialized) goto done;
#ifdef ENABLE_NCZARR_FILTERS
/* Reclaim all loaded filters */
for(i=0;i<=loaded_plugins_max;i++) {
NCZ_unload_plugin(loaded_plugins[i]);
@ -711,6 +715,11 @@ NCZ_filter_finalize(void)
}
/* Reclaim the defaults library; Must occur as last act */
if(default_lib != NULL) {(void)ncpsharedlibfree(default_lib); default_lib = NULL; codec_defaults = NULL;}
#else
memset(loaded_plugins,0,sizeof(loaded_plugins));
#endif
done:
NCZ_filter_initialized = 0;
return ZUNTRACE(stat);
}

View File

@ -88,7 +88,9 @@ NCZ_finalize_internal(void)
{
/* Reclaim global resources */
ncz_initialized = 0;
#ifdef ENABLE_NCZARR_FILTERS
NCZ_filter_finalize();
#endif
#ifdef ENABLE_S3_SDK
NCZ_s3finalize();
#endif

View File

@ -59,7 +59,7 @@ nczmap_create(NCZM_IMPL impl, const char *path, int mode, size64_t flags, void*
break;
#endif
default:
{stat = NC_ENOTBUILT; goto done;}
{stat = REPORT(NC_ENOTBUILT,"nczmap_create"); goto done;}
}
if(mapp) *mapp = map;
done:
@ -97,7 +97,7 @@ nczmap_open(NCZM_IMPL impl, const char *path, int mode, size64_t flags, void* pa
break;
#endif
default:
{stat = NC_ENOTBUILT; goto done;}
{stat = REPORT(NC_ENOTBUILT,"nczmap_open"); goto done;}
}
done:

View File

@ -142,10 +142,12 @@ static int platformtestcontentbearing(ZFMAP* zfmap, const char* truepath);
#ifdef VERIFY
static int verify(const char* path, int isdir);
static int verifykey(const char* key, int isdir);
#endif
static int zfinitialized = 0;
static void zfileinitialize(void)
static void
zfileinitialize(void)
{
if(!zfinitialized) {
ZTRACE(5,NULL);
@ -180,6 +182,7 @@ zfilecreate(const char *path, int mode, size64_t flags, void* parameters, NCZMAP
{
int stat = NC_NOERR;
char* canonpath = NULL;
char* abspath = NULL;
ZFMAP* zfmap = NULL;
NCURI* url = NULL;
@ -200,8 +203,13 @@ zfilecreate(const char *path, int mode, size64_t flags, void* parameters, NCZMAP
if(strcasecmp(url->protocol,"file") != 0)
{stat = NC_EURL; goto done;}
/* Canonicalize the root path */
if((stat = NCpathcanonical(url->path,&canonpath))) goto done;
/* Convert the root path */
if((canonpath = NCpathcvt(url->path))==NULL)
{stat = NC_ENOMEM; goto done;}
/* Make the root path be absolute */
if((abspath = NCpathabsolute(canonpath)) == NULL)
{stat = NC_EURL; goto done;}
/* Build the zmap state */
if((zfmap = calloc(1,sizeof(ZFMAP))) == NULL)
@ -213,8 +221,8 @@ zfilecreate(const char *path, int mode, size64_t flags, void* parameters, NCZMAP
/* create => NC_WRITE */
zfmap->map.mode = mode;
zfmap->map.api = &zapi;
zfmap->root = canonpath;
canonpath = NULL;
zfmap->root = abspath;
abspath = NULL;
/* If NC_CLOBBER, then delete below file tree */
if(!fIsSet(mode,NC_NOCLOBBER))
@ -231,6 +239,7 @@ zfilecreate(const char *path, int mode, size64_t flags, void* parameters, NCZMAP
done:
ncurifree(url);
nullfree(canonpath);
nullfree(abspath);
if(stat)
zfileclose((NCZMAP*)zfmap,1);
return ZUNTRACE(stat);
@ -250,6 +259,7 @@ zfileopen(const char *path, int mode, size64_t flags, void* parameters, NCZMAP**
{
int stat = NC_NOERR;
char* canonpath = NULL;
char* abspath = NULL;
ZFMAP* zfmap = NULL;
NCURI*url = NULL;
@ -267,8 +277,13 @@ zfileopen(const char *path, int mode, size64_t flags, void* parameters, NCZMAP**
if(strcasecmp(url->protocol,"file") != 0)
{stat = NC_EURL; goto done;}
/* Canonicalize the root path */
if((stat = NCpathcanonical(url->path,&canonpath))) goto done;
/* Convert the root path */
if((canonpath = NCpathcvt(url->path))==NULL)
{stat = NC_ENOMEM; goto done;}
/* Make the root path be absolute */
if((abspath = NCpathabsolute(canonpath)) == NULL)
{stat = NC_EURL; goto done;}
/* Build the zmap state */
if((zfmap = calloc(1,sizeof(ZFMAP))) == NULL)
@ -279,8 +294,8 @@ zfileopen(const char *path, int mode, size64_t flags, void* parameters, NCZMAP**
zfmap->map.flags = flags;
zfmap->map.mode = mode;
zfmap->map.api = (NCZMAP_API*)&zapi;
zfmap->root = canonpath;
canonpath = NULL;
zfmap->root = abspath;
abspath = NULL;
/* Verify root dir exists */
if((stat = platformopendir(zfmap,zfmap->root)))
@ -293,6 +308,7 @@ zfileopen(const char *path, int mode, size64_t flags, void* parameters, NCZMAP**
done:
ncurifree(url);
nullfree(canonpath);
nullfree(abspath);
if(stat) zfileclose((NCZMAP*)zfmap,0);
return ZUNTRACE(stat);
}
@ -354,7 +370,7 @@ zfileread(NCZMAP* map, const char* key, size64_t start, size64_t count, void* co
ZTRACE(5,"map=%s key=%s start=%llu count=%llu",map->url,key,start,count);
#ifdef VERIFY
if(!verify(key,!FLAG_ISDIR))
if(!verifykey(key,!FLAG_ISDIR))
assert(!"expected file, have dir");
#endif
@ -384,7 +400,7 @@ zfilewrite(NCZMAP* map, const char* key, size64_t start, size64_t count, const v
ZTRACE(5,"map=%s key=%s start=%llu count=%llu",map->url,key,start,count);
#ifdef VERIFY
if(!verify(key,!FLAG_ISDIR))
if(!verifykey(key,!FLAG_ISDIR))
assert(!"expected file, have dir");
#endif
@ -858,7 +874,6 @@ platformdircontent(ZFMAP* zfmap, const char* canonpath, NClist* contents)
}
}
do {
char* p = NULL;
const char* name = NULL;
name = FindFileData.cFileName;
if(strcmp(name,".")==0 || strcmp(name,"..")==0)
@ -1195,6 +1210,24 @@ verify(const char* path, int isdir)
if(!isdir && S_ISREG(buf.st_mode)) return 1;
return 0;
}
static int
verifykey(const char* key, int isdir)
{
int ret = 0;
struct stat buf;
if(key[0] == '/') key++; /* Want relative name */
ret = NCaccess(key,ACCESS_MODE_EXISTS);
if(ret < 0)
return 1; /* If it does not exist, then it can be anything */
ret = NCstat(key,&buf);
if(ret < 0) abort();
if(isdir && S_ISDIR(buf.st_mode)) return 1;
if(!isdir && S_ISREG(buf.st_mode)) return 1;
return 0;
}
#endif
#if 0

View File

@ -106,6 +106,7 @@ zipcreate(const char *path, int mode, size64_t flags, void* parameters, NCZMAP**
zip_flags_t zipflags = 0;
int zerrno = ZIP_ER_OK;
ZINDEX zindex = -1;
char* abspath = NULL;
NC_UNUSED(parameters);
ZTRACE(6,"path=%s mode=%d flag=%llu",path,mode,flags);
@ -132,9 +133,18 @@ zipcreate(const char *path, int mode, size64_t flags, void* parameters, NCZMAP**
/* create => NC_WRITE */
zzmap->map.mode = mode;
zzmap->map.api = &zapi;
/* Since root is in canonical form, we need to convert to local form */
if((zzmap->root = NCpathcvt(url->path))==NULL)
{stat = NC_ENOMEM; goto done;}
/* Make the root path be absolute */
if((abspath = NCpathabsolute(zzmap->root)) == NULL)
{stat = NC_EURL; goto done;}
nullfree(zzmap->root);
zzmap->root = abspath;
abspath = NULL;
/* Extract the dataset name */
if((stat = nczm_basename(url->path,&zzmap->dataset))) goto done;
@ -160,6 +170,7 @@ zipcreate(const char *path, int mode, size64_t flags, void* parameters, NCZMAP**
if(mapp) {*mapp = (NCZMAP*)zzmap; zzmap = NULL;}
done:
nullfree(abspath);
ncurifree(url);
if(zzmap) zipclose((NCZMAP*)zzmap,1);
return ZUNTRACE(stat);
@ -182,6 +193,7 @@ zipopen(const char *path, int mode, size64_t flags, void* parameters, NCZMAP** m
NCURI*url = NULL;
zip_flags_t zipflags = 0;
int zerrno = ZIP_ER_OK;
char* abspath = NULL;
NC_UNUSED(parameters);
ZTRACE(6,"path=%s mode=%d flags=%llu",path,mode,flags);
@ -210,6 +222,12 @@ zipopen(const char *path, int mode, size64_t flags, void* parameters, NCZMAP** m
/* Since root is in canonical form, we need to convert to local form */
if((zzmap->root = NCpathcvt(url->path))==NULL)
{stat = NC_ENOMEM; goto done;}
/* Make the root path be absolute */
if((abspath = NCpathabsolute(zzmap->root)) == NULL)
{stat = NC_EURL; goto done;}
nullfree(zzmap->root);
zzmap->root = abspath;
abspath = NULL;
/* Set zip open flags */
zipflags |= ZIP_CHECKCONS;
@ -244,6 +262,7 @@ zipopen(const char *path, int mode, size64_t flags, void* parameters, NCZMAP** m
if(mapp) {*mapp = (NCZMAP*)zzmap; zzmap = NULL;}
done:
nullfree(abspath);
ncurifree(url);
if(zzmap) zipclose((NCZMAP*)zzmap,0);

View File

@ -177,7 +177,8 @@ NCZ_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
#endif /* LOGGING */
/* Get the controls */
if(ncuriparse(path,&uri)) goto done;
ncuriparse(path,&uri);
if(uri == NULL) goto done;
/* Open the file. */
if((stat = ncz_open_file(path, mode, ncurifragmentparams(uri), ncid)))

View File

@ -262,8 +262,10 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose)
NCjson* jfill = NULL;
size64_t shape[NC_MAX_VAR_DIMS];
NCZ_VAR_INFO_T* zvar = var->format_var_info;
#ifdef ENABLE_NCZARR_FILTERS
NClist* filterchain = NULL;
NCjson* jfilter = NULL;
#endif
zinfo = file->format_file_info;
map = zinfo->map;
@ -358,17 +360,19 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose)
if((stat = NCJaddstring(jvar,NCJ_STRING,"C"))) goto done;
/* Compressor and Filters */
filterchain = (NClist*)var->filters;
/* compressor key */
/* From V2 Spec: A JSON object identifying the primary compression codec and providing
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;
if(nclistlength(filterchain) > 0) {
struct NCZ_Filter* filter = (struct NCZ_Filter*)nclistget(filterchain,nclistlength(filterchain)-1);
/* encode up the compressor */
if((stat = NCZ_filter_jsonize(file,var,filter,&jtmp))) goto done;
} else { /* no filters at all */
} else
#endif
{ /* no filters at all */
/* Default to null */
if((stat = NCJnew(NCJ_NULL,&jtmp))) goto done;
}
@ -382,6 +386,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose)
/* A list of JSON objects providing codec configurations, or ``null``
if no filters are to be applied. */
if((stat = NCJaddstring(jvar,NCJ_STRING,"filters"))) goto done;
#ifdef ENABLE_NCZARR_FILTERS
if(nclistlength(filterchain) > 1) {
int k;
/* jtmp holds the array of filters */
@ -392,7 +397,9 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose)
if((stat = NCZ_filter_jsonize(file,var,filter,&jfilter))) goto done;
if((stat = NCJappend(jtmp,jfilter))) goto done;
}
} else { /* no filters at all */
} else
#endif
{ /* no filters at all */
if((stat = NCJnew(NCJ_NULL,&jtmp))) goto done;
}
if((stat = NCJappend(jvar,jtmp))) goto done;
@ -1379,7 +1386,6 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
NCjson* jncvar = NULL;
NCjson* jdimrefs = NULL;
NCjson* jvalue = NULL;
NCjson* jfilter = NULL;
int purezarr = 0;
int xarray = 0;
int formatv1 = 0;
@ -1387,6 +1393,9 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
size64_t* shapes = NULL;
int rank = 0;
NClist* dimnames = nclistnew();
#ifdef ENABLE_NCZARR_FILTERS
NCjson* jfilter = NULL;
#endif
zinfo = file->format_file_info;
map = zinfo->map;
@ -1547,8 +1556,9 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
object MUST contain a "id" key identifying the codec to be used. */
/* Do filters key before compressor key so final filter chain is in correct order */
{
int k;
if(var->filters == NULL) var->filters = (void*)nclistnew();
#ifdef ENABLE_NCZARR_FILTERS
{ int k;
if((stat = NCZ_filter_initialize())) goto done;
if((stat = NCJdictget(jvar,"filters",&jvalue))) goto done;
if(jvalue != NULL && NCJsort(jvalue) != NCJ_NULL) {
@ -1561,6 +1571,8 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
if((stat = NCZ_filter_build(file,var,jfilter))) goto done;
}
}
}
#endif
}
/* compressor key */
@ -1568,12 +1580,14 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
configuration parameters, or ``null`` if no compressor is to be used. */
{
if(var->filters == NULL) var->filters = (void*)nclistnew();
#ifdef ENABLE_NCZARR_FILTERS
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((stat = NCZ_filter_build(file,var,jfilter))) goto done;
}
#endif
}
if(!purezarr) {
@ -1633,9 +1647,10 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
for(j=0;j<rank;j++)
var->dimids[j] = var->dim[j]->hdr.id;
#ifdef ENABLE_NCZARR_FILTERS
/* At this point, we can finalize the filters */
if((stat = NCZ_filter_setup(var))) goto done;
#endif
/* Clean up from last cycle */
nclistfreeall(dimnames); dimnames = nclistnew();
nullfree(varpath); varpath = NULL;

View File

@ -566,5 +566,7 @@ static const NC_Dispatch NCZ_dispatcher_trace = {
NCZTR_get_var_chunk_cache,
NCZTR_inq_var_filter_ids,
NCZTR_inq_var_filter_info,
NC_NOTNC4_def_var_quantize,
NC_NOTNC4_inq_var_quantize,
};

View File

@ -520,6 +520,7 @@ put_chunk(NCZChunkCache* cache, NCZCacheEntry* entry)
zfile = file->format_file_info;
map = zfile->map;
#ifdef ENABLE_NCZARR_FILTERS
/* Make sure the entry is in filtered state */
if(!entry->isfiltered) {
NC_VAR_INFO_T* var = cache->var;
@ -537,6 +538,7 @@ put_chunk(NCZChunkCache* cache, NCZCacheEntry* entry)
entry->isfiltered = 1;
}
}
#endif
path = NCZ_chunkpath(entry->key);
stat = nczmap_write(map,path,0,entry->size,entry->data);
@ -621,6 +623,7 @@ get_chunk(NCZChunkCache* cache, NCZCacheEntry* entry)
entry->isfiltered = 0;
stat = NC_NOERR;
}
#ifdef ENABLE_NCZARR_FILTERS
/* Make sure the entry is in unfiltered state */
if(entry->isfiltered) {
NC_VAR_INFO_T* var = cache->var;
@ -639,6 +642,7 @@ get_chunk(NCZChunkCache* cache, NCZCacheEntry* entry)
entry->size = unflen;
entry->isfiltered = 0;
}
#endif
done:
nullfree(path);

View File

@ -181,7 +181,7 @@ s3io_open(const char* path,
{status = NC_EURL; goto done;}
s3io->s3client = NC_s3sdkcreateclient(&s3io->s3);
/* Get the size */
switch (status = NC_s3sdkinfo(s3io->s3client,s3io->s3.bucket,s3io->s3.rootkey,&s3io->size,&s3io->errmsg)) {
switch (status = NC_s3sdkinfo(s3io->s3client,s3io->s3.bucket,s3io->s3.rootkey,(long long unsigned*)&s3io->size,&s3io->errmsg)) {
case NC_NOERR: break;
case NC_EEMPTY:
s3io->size = 0;

View File

@ -508,11 +508,7 @@ ncio_create(const char *path, int ioflags,
if(fIsSet(ioflags, NC_NOCLOBBER)) {
/* Since we do not have use of the O_EXCL flag,
we need to fake it */
#ifdef WINCE
f = NCfopen(path,"rb");
#else
f = NCfopen(path,"r");
#endif
if(f != NULL) { /* do not overwrite */
(void)fclose(f);
return EEXIST;
@ -586,12 +582,7 @@ ncio_open(const char *path,
ncio **nciopp, void **const igetvpp)
{
ncio *nciop;
char* oflags = fIsSet(ioflags, NC_WRITE) ? "r+"
#ifdef WINCE
: "rb";
#else
: "r";
#endif
char* oflags = fIsSet(ioflags, NC_WRITE) ? "r+" : "r";
FILE* f;
int i,fd;
int status = NC_NOERR;

View File

@ -17,6 +17,7 @@ redistribution conditions.
#include "netcdf.h"
#include "netcdf_mem.h"
#include "ncbytes.h"
#include "ncpathmgr.h"
#include "nc_tests.h"
#include "err_macros.h"
@ -168,11 +169,7 @@ readfile(const char* path, NC_memio* memio)
char* p = NULL;
/* Open the file for reading */
#ifdef _MSC_VER
f = fopen(path,"rb");
#else
f = fopen(path,"r");
#endif
f = NCfopen(path,"r");
if(f == NULL)
{status = errno; goto done;}
/* get current filesize */
@ -216,11 +213,7 @@ writefile(const char* path, NC_memio* memio)
char* p = NULL;
/* Open the file for writing */
#ifdef _MSC_VER
f = fopen(path,"wb");
#else
f = fopen(path,"w");
#endif
f = NCfopen(path,"w");
if(f == NULL)
{status = errno; goto done;}
count = memio->size;

View File

@ -23,15 +23,10 @@
# variables: see hdf5plugins/CMakeLists.txt
findplugin() {
set -x
FP_NAME="$1"
# Figure out the compiler (some values from ./configure)
FP_ISCMAKE=@ISCMAKE@
FP_ISMSVC=@ISMSVC@
FP_ISCYGWIN=@ISCYGWIN@
FP_ISOSX=@ISOSX@
FP_PLUGIN_LIB=
FP_PLUGIN_PATH=
@ -39,6 +34,8 @@ FP_PLUGIN_PATH=
# Test for visual studio before cygwin since both might be true
if test "x$FP_ISMSVC" != x ; then
FP_PLUGIN_LIB="${FP_NAME}.dll"
elif test "x$FP_ISMINGW" != x || test "x$FP_ISMSYS" != x ; then
FP_PLUGIN_LIB="${FP_NAME}.dll"
elif test "x$FP_ISCYGWIN" != x ; then
FP_PLUGIN_LIB="cyg${FP_NAME}.dll"
elif test "x$FP_ISOSX" != x ; then

View File

@ -65,7 +65,7 @@ pd(double myd)
uint64_t u;
} du;
du.d = myd;
sprintf(pf_str, "0x%lx", du.u);
sprintf(pf_str, "0x%lx", (unsigned long)du.u);
return pf_str;
}

View File

@ -17,12 +17,14 @@
#define FILE_NAME "tst_udf.nc"
#if defined(_WIN32) || defined(_WIN64)
int
NC4_show_metadata(int ncid)
#ifdef _MSC_VER
static int
NC4_no_show_metadata(int ncid)
{
return 0;
return NC_NOERR;
}
#define NC4_show_metadata NC4_no_show_metadata
#endif
int

View File

@ -56,7 +56,7 @@ main()
svcurl = nc_findtestserver(servlet,serverlist);
if(svcurl == NULL) {
fprintf(stderr,"WARNING: Server not found: %s\n",servlet);
exit(1);
exit(0);
}
snprintf(url,sizeof(url),FURL,svcurl);

View File

@ -83,7 +83,7 @@ COLUMBIA="http://iridl.ldeo.columbia.edu/SOURCES/.Models/.NMME/.NASA-GMAO/.MONTH
# Known to fail
XFAILTESTS=
# Suppress some tests
# Suppress some tests because of floating point precision issues
XFAILTESTS="$XFAILTESTS test.67"
# Following tests must be run as not cached

View File

@ -7,7 +7,7 @@
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#sh_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#TESTS_ENVIRONMENT += export SETX=1;
#TESTS_ENVIRONMENT = export SETX=1;
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am
@ -85,7 +85,7 @@ test_radix.sh test_rcmerge.sh
# The tst_nccopy3.sh test uses output from a bunch of other
# tests. This records the dependency so parallel builds work.
tst_nccopy3.log: tst_calendars.log run_utf8_tests.log tst_output.log \
tst_64bit.log run_tests.log tst_lengths.log
tst_64bit.log run_tests.log tst_lengths.log
TESTS += tst_null_byte_padding.sh
if USE_STRICT_NULL_BYTE_HEADER_PADDING
@ -110,16 +110,17 @@ check_PROGRAMS += tst_vlen_demo
# Tests for netCDF-4 behavior.
TESTS += tst_fileinfo.sh tst_hdf5_offset.sh tst_inttags4.sh \
tst_netcdf4.sh tst_fillbug.sh tst_nccopy4.sh \
tst_nccopy5.sh tst_grp_spec.sh tst_mud.sh tst_h_scalar.sh tst_formatx4.sh \
tst_netcdf4.sh tst_fillbug.sh \
tst_grp_spec.sh tst_mud.sh tst_h_scalar.sh tst_formatx4.sh \
run_utf8_nc4_tests.sh run_ncgen_nc4_tests.sh \
tst_ncgen4.sh test_scope.sh
# Record interscript dependencies so parallel builds work.
tst_nccopy4.log: run_ncgen_tests.log tst_output.log tst_ncgen4.log \
tst_fillbug.log tst_netcdf4_4.log tst_h_scalar.log
tst_fillbug.log tst_netcdf4_4.log tst_h_scalar.log
tst_nccopy5.log: tst_nccopy4.log
endif #!USE_HDF5
endif #USE_HDF5
TESTS += tst_inmemory_nc3.sh tst_nccopy_w3.sh
if USE_HDF5
@ -136,12 +137,14 @@ if ENABLE_CDF5
TESTS += test_keywords.sh
endif
if ! ISMINGW
if ! ISCYGWIN
TESTS += tst_output.sh tst_nccopy3.sh
if !ISMINGW
if !ISCYGWIN
TESTS += tst_output.sh
TESTS += tst_nccopy3.sh
TESTS += test_unicode_directory.sh test_unicode_path.sh
if USE_HDF5
TESTS += run_back_comp_tests.sh tst_netcdf4_4.sh
TESTS += tst_nccopy4.sh tst_nccopy5.sh
endif
endif
endif

View File

@ -5,6 +5,8 @@
# $Id: Makefile.am,v 1.5 2010/04/27 18:50:44 dmh Exp $
# Where are these being used?
EXTRA_DIST = \
c0.cdl example_good.cdl fills.cdl nc_enddef.cdl nc_sync.cdl pres_temp_4D.cdl \
ref_const_test.cdl ref_ctest1_nc4.cdl ref_ctest1_nc4c.cdl ref_dimscope.cdl \

View File

@ -1,9 +1,8 @@
netcdf file {
variables:
int data;
data : _FillValue = 0;
int data ;
data :_FillValue = 0 ;
data:
data = 177;
data = 177 ;
}

View File

@ -24,23 +24,25 @@
#include "netcdf.h"
#include "ncpathmgr.h"
/*
Synopsis
pathcvt [-u|-w|-m|-c] [-e] [-d <driveletter>] PATH
Options
-e add backslash escapes to '\' and ' '
-d <driveletter> use driveletter when needed; defaults to 'c'
Output type options:
-u convert to Unix form of path
-w convert to Windows form of path
-m convert to MSYS form of path
-c convert to Cygwin form of path
Default is to convert to the format used by the platform.
*/
static const char* USAGE =
"ncpathcvt [-c|-C|-m|-u|-w] [-h] [-e] [-d <driveletter>] [-B<char>] [-k] [-p] PATH\n"
"Options\n"
" -h help"
" -e add backslash escapes to '\' and ' '\n"
" -d <driveletter> use driveletter when needed; defaults to 'c'\n"
" -B <char> convert occurrences of <char> to ' '\n"
"Output type options:\n"
" -c convert to Cygwin form of path\n"
" -C return canonical form of path\n"
" -m convert to MSYS form of path\n"
" -u convert to Unix form of path\n"
" -w convert to Windows form of path\n"
"Other options:\n"
" -k return kind of the local environment\n"
" -p return kind of the input path\n"
"\n"
"Default is to convert to the format used by the platform.\n"
;
#undef DEBUG
@ -49,6 +51,9 @@ struct Options {
int escapes;
int drive;
int debug;
int canon;
int blank;
int pathkind;
} cvtoptions;
static char* escape(const char* path);
@ -58,7 +63,7 @@ static void
usage(const char* msg)
{
if(msg != NULL) fprintf(stderr,"%s\n",msg);
fprintf(stderr,"pathcvt [-u|-w|-m|-c] PATH\n");
fprintf(stderr,"%s",USAGE);
if(msg == NULL) exit(0); else exit(1);
}
@ -84,6 +89,76 @@ escape(const char* path)
return epath;
}
void
printlocalkind(void)
{
const char* s = NULL;
int kind = NCgetlocalpathkind();
switch (kind) {
case NCPD_NIX: s = "unix"; break;
case NCPD_MSYS: s = "msys"; break;
case NCPD_CYGWIN: s = "cygwin"; break;
case NCPD_WIN: s = "win"; break;
default: s = "unknown"; break;
}
printf("%s",s);
exit(0);
}
void
printenv(void)
{
#ifdef __CYGWIN__
printf(" __CYGWIN__");
#else
printf(" !__CYGWIN__");
#endif
#ifdef _MSC_VER
printf(" _MSC_VER");
#else
printf(" !_MSC_VER");
#endif
#ifdef _WIN32
printf(" _WIN32");
#else
printf(" !_WIN32");
#endif
#ifdef __MSYS__
printf(" __MSYS__");
#else
printf(" !__MSYS__");
#endif
#ifdef __MSYS2__
printf(" __MSYS2__");
#else
printf(" !__MSYS2__");
#endif
#ifdef __MINGW32__
printf(" __MINGW32__");
#else
printf(" !__MINGW32__");
#endif
printf("\n");
exit(0);
}
void
printpathkind(const char* path)
{
const char* s = NULL;
int kind = NCgetinputpathkind(path);
switch (kind) {
case NCPD_NIX: s = "unix"; break;
case NCPD_MSYS: s = "msys"; break;
case NCPD_CYGWIN: s = "cygwin"; break;
case NCPD_WIN: s = "win"; break;
case NCPD_REL: s = "relative"; break;
default: s = "unknown"; break;
}
printf("%s",s);
exit(0);
}
int
main(int argc, char** argv)
{
@ -94,18 +169,27 @@ main(int argc, char** argv)
memset((void*)&cvtoptions,0,sizeof(cvtoptions));
cvtoptions.drive = 'c';
while ((c = getopt(argc, argv, "cD:d:ehmuw")) != EOF) {
while ((c = getopt(argc, argv, "B:CcD:d:ehkmpuwX")) != EOF) {
switch(c) {
case 'c': cvtoptions.target = NCPD_CYGWIN; break;
case 'd': cvtoptions.drive = optarg[0]; break;
case 'e': cvtoptions.escapes = 1; break;
case 'h': usage(NULL); break;
case 'k': printlocalkind(); break;
case 'm': cvtoptions.target = NCPD_MSYS; break;
case 'p': cvtoptions.pathkind = 1; break;
case 'u': cvtoptions.target = NCPD_NIX; break;
case 'w': cvtoptions.target = NCPD_WIN; break;
case 'B':
cvtoptions.blank = optarg[0]; break;
if(cvtoptions.blank < ' ' || cvtoptions.blank == '\177')
usage("Bad -B argument");
break;
case 'C': cvtoptions.canon = 1; break;
case 'D':
sscanf(optarg,"%d",&cvtoptions.debug);
break;
case 'X': printenv(); break;
case '?':
usage("unknown option");
break;
@ -120,23 +204,47 @@ main(int argc, char** argv)
usage("no path specified");
if (argc > 1)
usage("more than one path specified");
inpath = argv[0];
/* translate blanks */
inpath = (char*)malloc(strlen(argv[0])+1);
if(inpath == NULL) usage("Out of memory");
{
const char* p = argv[0];
char* q = inpath;
for(;*p;p++) {
char c = *p;
if(c == cvtoptions.blank) c = ' ';
*q++ = c;
}
*q = '\0';
}
if(cvtoptions.pathkind) {
printpathkind(inpath);
goto done;
}
/* Canonicalize */
if(NCpathcanonical(inpath,&canon))
usage("Could not convert to canonical form");
if(cvtoptions.target == NCPD_UNKNOWN)
if(cvtoptions.canon) {
cvtpath = canon; canon = NULL;
} else if(cvtoptions.target == NCPD_UNKNOWN) {
cvtpath = NCpathcvt(canon);
else
} else {
cvtpath = NCpathcvt_test(canon,cvtoptions.target,(char)cvtoptions.drive);
}
if(cvtpath && cvtoptions.escapes) {
char* path = cvtpath; cvtpath = NULL;
cvtpath = escape(path);
free(path);
}
printf("%s",cvtpath);
done:
if(canon) free(canon);
if(inpath) free(inpath);
if(cvtpath) free(cvtpath);
return 0;
}

View File

@ -1,36 +1,45 @@
path: -u: |/xxx/x/y| => |/xxx/x/y|
path: -c: |/xxx/x/y| => |/cygdrive/c/xxx/x/y|
path: -m: |/xxx/x/y| => |/c/xxx/x/y|
path: -m: |/xxx/x/y| => |/xxx/x/y|
path: -w: |/xxx/x/y| => |c:\\xxx\\x\\y|
path: -C: |/xxx/x/y| => |/xxx/x/y|
path: -u: |d:/x/y| => |/d/x/y|
path: -c: |d:/x/y| => |/cygdrive/d/x/y|
path: -m: |d:/x/y| => |/d/x/y|
path: -w: |d:/x/y| => |d:\\x\\y|
path: -C: |d:/x/y| => |/cygdrive/d/x/y|
path: -u: |/cygdrive/d/x/y| => |/d/x/y|
path: -c: |/cygdrive/d/x/y| => |/cygdrive/d/x/y|
path: -m: |/cygdrive/d/x/y| => |/d/x/y|
path: -w: |/cygdrive/d/x/y| => |d:\\x\\y|
path: -C: |/cygdrive/d/x/y| => |/cygdrive/d/x/y|
path: -u: |/d/x/y| => |/d/x/y|
path: -c: |/d/x/y| => |/cygdrive/d/x/y|
path: -m: |/d/x/y| => |/d/x/y|
path: -w: |/d/x/y| => |d:\\x\\y|
path: -C: |/d/x/y| => |/cygdrive/d/x/y|
path: -u: |/cygdrive/d| => |/d|
path: -c: |/cygdrive/d| => |/cygdrive/d|
path: -m: |/cygdrive/d| => |/d|
path: -w: |/cygdrive/d| => |d:|
path: -C: |/cygdrive/d| => |/cygdrive/d|
path: -u: |/d| => |/d|
path: -c: |/d| => |/cygdrive/d|
path: -m: |/d| => |/d|
path: -w: |/d| => |d:|
path: -C: |/d| => |/cygdrive/d|
path: -u: |/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn| => |/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn|
path: -c: |/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn| => |/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn|
path: -m: |/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn| => |/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn|
path: -w: |/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn| => |d:\\git\\netcdf-c\\dap4_test\\test_anon_dim.2.syn|
path: -C: |/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn| => |/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn|
path: -u: |d:\x\y| => |/d/x/y|
path: -c: |d:\x\y| => |/cygdrive/d/x/y|
path: -m: |d:\x\y| => |/d/x/y|
path: -w: |d:\x\y| => |d:\\x\\y|
path: -C: |d:\x\y| => |/cygdrive/d/x/y|
path: -u: |d:\x\y w\z| => |/d/x/y\ w/z|
path: -c: |d:\x\y w\z| => |/cygdrive/d/x/y\ w/z|
path: -m: |d:\x\y w\z| => |/d/x/y\ w/z|
path: -w: |d:\x\y w\z| => |d:\\x\\y\ w\\z|
path: -C: |d:\x\y w\z| => |/cygdrive/d/x/y\ w/z|

View File

@ -11,7 +11,7 @@ set -e
echo ""
echo "*** Testing that this version can read data produced by old versions of netCDF."
echo "*** checking ref_nc_test_netcdf4_4_0.nc..."
${NCDUMP} $srcdir/ref_nc_test_netcdf4_4_0.nc > tst_nc_test_netcdf4_4_0.cdl
${NCDUMP} -n ref_nc_test_netcdf4_4_0 $srcdir/ref_nc_test_netcdf4_4_0.nc > tst_nc_test_netcdf4_4_0.cdl
# Why drop the first two lines?
#tail -n +2 < $srcdir/ref_nc_test_netcdf4.cdl > tmp.cdl
#tail -n +2 < tst_nc_test_netcdf4_4_0.cdl > tmp_4_0.cdl

View File

@ -41,4 +41,10 @@ else
echo "***xfail: ncgen -4 X ref_keyword4"
fi
echo "*** Test use of selected keywords as variable names..."
${NCGEN} -3 -lb -o keyword5.nc $srcdir/cdl/ref_keyword.cdl
${NCDUMP} -n file keyword5.nc >tmp_keyword5.cdl
echo "*** comparing tmp_keyword5.cdl to ref_keyword.cdl..."
diff -b -w tmp_keyword5.cdl $srcdir/cdl/ref_keyword.cdl
exit 0

View File

@ -5,14 +5,21 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
set -e
# We need to find the drive letter, if any
DL=`${NCPATHCVT} -c -e / | sed -e 's|/cygdrive/\([a-zA-Z]\)/.*|\1|'`
if test "x$DL" != x ; then
# Lower case drive letter
DLL=`echo "$DL" | tr '[:upper:]' '[:lower:]'`
DL="-d $DLL"
fi
testcase1() {
T="$1"
P="$2"
echo -n "path: $T: |$P| => |" >>tmp_pathcvt.txt
${NCPATHCVT} "$T" -e "$P" >>tmp_pathcvt.txt
${NCPATHCVT} -B"@" ${DL} "$T" -e "$P" >>tmp_pathcvt.txt
echo "|" >> tmp_pathcvt.txt
}
testcase() {
@ -20,19 +27,17 @@ testcase() {
testcase1 "-c" "$1"
testcase1 "-m" "$1"
testcase1 "-w" "$1"
testcase1 "-C" "$1"
}
rm -f tmp_pathcvt.txt
testcase "/xxx/x/y"
testcase "d:/x/y"
testcase "/cygdrive/d/x/y"
testcase "/d/x/y"
testcase "/cygdrive/d"
testcase "/d"
testcase "/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn"
testcase "d:\\x\\y"
testcase "d:\\x\\y w\\z"
# '@' will get translated to embedded blank
PATHS="/xxx/x/y d:/x/y /cygdrive/d/x/y /d/x/y /cygdrive/d /d /cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn d:\\x\\y d:\\x\\y@w\\z"
for p in $PATHS ; do
testcase $p
done
exit
diff -w ${srcdir}/ref_pathcvt.txt ./tmp_pathcvt.txt

View File

@ -8,6 +8,7 @@
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
echo ""

View File

@ -3,11 +3,18 @@
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
export SETX=1
# For a netCDF-4 build, test nccopy on netCDF files in this directory
echo "@@@@@@"
if test -f tst_group_data${ext} ; then ${execdir}/tst_group_data ; fi
if test -f tst_enum_data${ext} ; then ${execdir}/tst_enum_data ; fi
if test -f tst_comp${ext} ; then ${execdir}/tst_comp ; fi
if test -f tst_comp2${ext} ; then ${execdir}/tst_comp2 ; fi
set -e
echo ""
# These files are actually in $srcdir in distcheck builds, so they
@ -24,10 +31,10 @@ fi
echo "*** Testing netCDF-4 features of nccopy on ncdump/*.nc files"
for i in $TESTFILES ; do
echo "*** Test nccopy $i.nc copy_of_$i.nc ..."
if test "x$i" = xtst_vlen_data ; then
ls -l tst_vlen_data*
ls -l *.nc
fi
# if test "x$i" = xtst_vlen_data ; then
# ls -l tst_vlen_data*
# ls -l *.nc
# fi
${NCCOPY} $i.nc copy_of_$i.nc
${NCDUMP} -n copy_of_$i $i.nc > tmp_$i.cdl
${NCDUMP} copy_of_$i.nc > copy_of_$i.cdl
@ -119,4 +126,5 @@ FILTERS=`cat tmp_nofilters.cdl | sed -e '/var1:_Filters/p' -ed | tr -d '\t \r'`
test "x$FILTERS" = 'x'
echo "*** All nccopy tests passed!"
exit 0

View File

@ -36,7 +36,7 @@ Bytebuffer*
bbNew(void)
{
Bytebuffer* bb = (Bytebuffer*)emalloc(sizeof(Bytebuffer));
if(bb == NULL) return (Bytebuffer*)bbFail();
if(bb == NULL) {bbFail(); return NULL;}
bb->alloc=0;
bb->length=0;
bb->content=NULL;

View File

@ -11,6 +11,9 @@
#include "dump.h"
#undef VERIFY
#ifndef __MINGW32__
#define HHPRINT
#endif
#define XVSNPRINTF vsnprintf
/*
@ -413,10 +416,15 @@ retry: switch ((c=*p++)) {
goto retry;
case 'u':
if(hcount == 2) {
snprintf(tmp,sizeof(tmp),"%hhu",
(unsigned char)va_arg(argv,unsigned int));
snprintf(tmp,sizeof(tmp),
#ifdef HHPRINT
"%hhu"
#else
"%2u"
#endif
,(unsigned char)va_arg(argv,unsigned int));
} else if(hcount == 1) {
snprintf(tmp,sizeof(tmp),"%hu",
snprintf(tmp,sizeof(tmp), "%hu",
(unsigned short)va_arg(argv,unsigned int));
} else if(lcount == 2) {
snprintf(tmp,sizeof(tmp),"%llu",
@ -432,8 +440,13 @@ retry: switch ((c=*p++)) {
break;
case 'd':
if(hcount == 2) {
snprintf(tmp,sizeof(tmp),"%hhd",
(signed char)va_arg(argv,signed int));
snprintf(tmp,sizeof(tmp),
#ifdef HHPRINT
"%hhd"
#else
"%2d"
#endif
,(signed char)va_arg(argv,signed int));
} else if(hcount == 1) {
snprintf(tmp,sizeof(tmp),"%hd",
(signed short)va_arg(argv,signed int));

View File

@ -984,6 +984,19 @@ variable-length strings to a netCDF variable, but the strings may simply be
concatenated into a single array of characters.
Specific use of the \fIstring\fP type specifier may solve the problem
.SH "Identifiers and Keywords"
.LP
Under certain conditions, some keywords can be used as identifiers.
.IP "\fB1.\fP
If a type keyword is not a type supported by the format of the .cdl file,
then it can be used as an identifier. So, for example, when translating a .cdl
file as a netCDF-3 file, then "string" or "uint64" can be
used as identifiers.
.IP "\fB2.\fP
The keyword "data" can be used as an identifier because it can be tested
in a context sensitive fashion to see if "data" is a keyword versus an
identifier.
.SH "CDL Grammar"
.LP
The file ncgen.y is the definitive grammar for CDL, but a stripped

View File

@ -882,6 +882,14 @@ collecttag(char* text, char** stagp)
return tag;
}
static Symbol*
identkeyword(const Symbol* kw)
{
Symbol* sym = NULL;
sym = install(kw->name);
return sym;
}
static int
identcheck(int token)
{

View File

@ -131,6 +131,8 @@ static long long extractint(NCConstant* con);
#ifdef USE_NETCDF4
static int parsefilterflag(const char* sdata0, Specialdata* special);
static int parsecodecsflag(const char* sdata0, Specialdata* special);
static Symbol* identkeyword(const Symbol*);
#ifdef GENDEBUG1
static void printfilters(int nfilters, NC_ParsedFilterSpec** filters);
#endif
@ -218,6 +220,7 @@ NCConstant* constant;
%type <sym> ident typename primtype dimd varspec
attrdecl enumid path dimref fielddim fieldspec
varident
%type <sym> typeref
%type <sym> varref
%type <sym> ambiguous_ref
@ -539,7 +542,7 @@ varlist: varspec
{$$=$1; listpush(stack,(void*)$3);}
;
varspec: ident dimspec
varspec: varident dimspec
{
int i;
Dimset dimset;
@ -889,7 +892,14 @@ constbool:
/* End OF RULES */
/* Push all idents thru here*/
/* Push all idents thru these*/
varident:
IDENT {$$=$1;}
| DATA {$$=identkeyword($1);}
;
ident:
IDENT {$$=$1;}
;
@ -1294,9 +1304,11 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
derror("_FillValue attribute not associated with variable: %s",vsym->name);
}
if(tsym == NULL) tsym = vsym->typ.basetype;
#if 0 /* No longer require matching types */
else if(vsym->typ.basetype != tsym) {
derror("_FillValue attribute type does not match variable type: %s",vsym->name);
}
#endif
special->_Fillvalue = clonedatalist(list);
/* Create the corresponding attribute */
attr = makeattribute(install("_FillValue"),vsym,tsym,list,ATTRVAR);

View File

@ -1,5 +1,5 @@
#line 3 "ncgenl.c"
#line 2 "ncgenl.c"
#define YY_INT_ALIGNED short int
@ -1541,7 +1541,7 @@ struct Specialtoken specials[] = {
{NULL,0} /* null terminate */
};
#line 1545 "ncgenl.c"
#line 1544 "ncgenl.c"
/* The most correct (validating) version of UTF8 character set
(Taken from: http://www.w3.org/2005/03/23-lex-U)
@ -1584,7 +1584,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})*
/* Note: this definition of string will work for utf8 as well,
although it is a very relaxed definition
*/
#line 1588 "ncgenl.c"
#line 1587 "ncgenl.c"
#define INITIAL 0
#define ST_C_COMMENT 1
@ -1805,7 +1805,7 @@ YY_DECL
{
#line 223 "ncgen.l"
#line 1809 "ncgenl.c"
#line 1808 "ncgenl.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@ -2432,7 +2432,7 @@ YY_RULE_SETUP
#line 595 "ncgen.l"
ECHO;
YY_BREAK
#line 2436 "ncgenl.c"
#line 2435 "ncgenl.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT):
yyterminate();
@ -3518,7 +3518,6 @@ Return the value.
static unsigned long long
parseULL(int radix, char* text, int* failp)
{
extern int errno;
char* endptr;
unsigned long long uint64 = 0;
@ -3730,6 +3729,14 @@ collecttag(char* text, char** stagp)
return tag;
}
static Symbol*
identkeyword(const Symbol* kw)
{
Symbol* sym = NULL;
sym = install(kw->name);
return sym;
}
static int
identcheck(int token)
{

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.7.5. */
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@ -116,7 +116,7 @@ extern int ncgdebug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 154 "ncgen.y"
#line 156 "ncgen.y"
Symbol* sym;
unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/
@ -136,6 +136,8 @@ typedef union YYSTYPE YYSTYPE;
extern YYSTYPE ncglval;
int ncgparse (void);
#endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */

View File

@ -2,7 +2,10 @@
# Copyright 2018, see the COPYRIGHT file for more information.
# This file builds and runs the ncgen program.
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#sh_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#TESTS_ENVIRONMENT = export SETX=1;
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am

View File

@ -207,10 +207,12 @@ FloatInf|-?Inff { /* missing value (pre-2.4 backward compatibility) */
return (FLOAT_CONST);
}
[+-]?[0-9]+[sS]|0[xX][0-9a-fA-F]+[sS] {
if (sscanf((char*)yytext, "%hd", &short_val) != 1) {
int tmp = 0;
if (sscanf((char*)yytext, "%d", &tmp) != 1) {
sprintf(errstr,"bad short constant: %s",(char*)yytext);
yyerror(errstr);
}
short_val = (short)tmp;
return (SHORT_CONST);
}
[+-]?([1-9][0-9]*|0)[lL]? {

View File

@ -1,5 +1,5 @@
#line 3 "ncgenl.c"
#line 2 "ncgenl.c"
#define YY_INT_ALIGNED short int
@ -1102,7 +1102,7 @@ char errstr[100]; /* for short error messages */
but make sure every action ends with
"return" or "break"! */
#line 1106 "ncgenl.c"
#line 1105 "ncgenl.c"
/* The most correct (validating) version of UTF8 character set
(Taken from: http://www.w3.org/2005/03/23-lex-U)
@ -1142,7 +1142,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})*
/* Note: this definition of string will work for utf8 as well,
although it is a very relaxed definition
*/
#line 1146 "ncgenl.c"
#line 1145 "ncgenl.c"
#define INITIAL 0
@ -1361,7 +1361,7 @@ YY_DECL
{
#line 107 "ncgen.l"
#line 1365 "ncgenl.c"
#line 1364 "ncgenl.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@ -1600,16 +1600,18 @@ case 21:
YY_RULE_SETUP
#line 209 "ncgen.l"
{
if (sscanf((char*)yytext, "%hd", &short_val) != 1) {
int tmp = 0;
if (sscanf((char*)yytext, "%d", &tmp) != 1) {
sprintf(errstr,"bad short constant: %s",(char*)yytext);
yyerror(errstr);
}
short_val = (short)tmp;
return (SHORT_CONST);
}
YY_BREAK
case 22:
YY_RULE_SETUP
#line 216 "ncgen.l"
#line 218 "ncgen.l"
{
char *ptr;
errno = 0;
@ -1628,7 +1630,7 @@ YY_RULE_SETUP
YY_BREAK
case 23:
YY_RULE_SETUP
#line 231 "ncgen.l"
#line 233 "ncgen.l"
{
char *ptr;
long long_val;
@ -1650,7 +1652,7 @@ YY_RULE_SETUP
case 24:
/* rule 24 can match eol */
YY_RULE_SETUP
#line 248 "ncgen.l"
#line 250 "ncgen.l"
{
(void) sscanf((char*)&yytext[1],"%c",&byte_val);
return (BYTE_CONST);
@ -1658,7 +1660,7 @@ YY_RULE_SETUP
YY_BREAK
case 25:
YY_RULE_SETUP
#line 252 "ncgen.l"
#line 254 "ncgen.l"
{
byte_val = (char) strtol((char*)&yytext[2], (char **) 0, 8);
return (BYTE_CONST);
@ -1666,7 +1668,7 @@ YY_RULE_SETUP
YY_BREAK
case 26:
YY_RULE_SETUP
#line 256 "ncgen.l"
#line 258 "ncgen.l"
{
byte_val = (char) strtol((char*)&yytext[3], (char **) 0, 16);
return (BYTE_CONST);
@ -1674,7 +1676,7 @@ YY_RULE_SETUP
YY_BREAK
case 27:
YY_RULE_SETUP
#line 260 "ncgen.l"
#line 262 "ncgen.l"
{
switch ((char)yytext[2]) {
case 'a': byte_val = '\007'; break; /* not everyone under-
@ -1695,24 +1697,24 @@ YY_RULE_SETUP
YY_BREAK
case 28:
YY_RULE_SETUP
#line 278 "ncgen.l"
#line 280 "ncgen.l"
{ /* whitespace */
break;
}
YY_BREAK
case 29:
YY_RULE_SETUP
#line 281 "ncgen.l"
#line 283 "ncgen.l"
{/* Note: this next rule will not work for UTF8 characters */
return (yytext[0]) ;
}
YY_BREAK
case 30:
YY_RULE_SETUP
#line 285 "ncgen.l"
#line 287 "ncgen.l"
ECHO;
YY_BREAK
#line 1716 "ncgenl.c"
#line 1717 "ncgenl.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -2717,7 +2719,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables"
#line 285 "ncgen.l"
#line 287 "ncgen.l"
/* Hack to keep compile quiet */

View File

@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.7.5. */
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison implementation for Yacc-like parsers in C
@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@ -46,10 +46,10 @@
USER NAME SPACE" below. */
/* Identify Bison output, and Bison version. */
#define YYBISON 30705
#define YYBISON 30802
/* Bison version string. */
#define YYBISON_VERSION "3.7.5"
#define YYBISON_VERSION "3.8.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@ -408,12 +408,18 @@ typedef int yy_state_fast_t;
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -629,7 +635,7 @@ static const yytype_int8 yytranslate[] =
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int16 yyrline[] =
{
0, 117, 117, 120, 115, 133, 134, 136, 137, 139,
@ -676,18 +682,6 @@ yysymbol_name (yysymbol_kind_t yysymbol)
}
#endif
#ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
(internal) symbol number NUM (which must be that of a token). */
static const yytype_int16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 123, 125, 59, 44, 61, 40, 41,
58
};
#endif
#define YYPACT_NINF (-73)
#define yypact_value_is_default(Yyn) \
@ -698,8 +692,8 @@ static const yytype_int16 yytoknum[] =
#define yytable_value_is_error(Yyn) \
0
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int8 yypact[] =
{
10, 3, 31, -73, -73, 19, 36, 6, -73, 36,
@ -716,9 +710,9 @@ static const yytype_int8 yypact[] =
-73, -73
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
static const yytype_int8 yydefact[] =
{
0, 0, 0, 2, 1, 5, 0, 16, 15, 6,
@ -735,7 +729,7 @@ static const yytype_int8 yydefact[] =
71, 69
};
/* YYPGOTO[NTERM-NUM]. */
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-73, -73, -73, -73, -73, -73, 49, 44, -73, -72,
@ -745,7 +739,7 @@ static const yytype_int8 yypgoto[] =
-73, -73
};
/* YYDEFGOTO[NTERM-NUM]. */
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
0, 2, 5, 42, 7, 9, 10, 11, 12, 13,
@ -755,9 +749,9 @@ static const yytype_int8 yydefgoto[] =
99, 110
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int8 yytable[] =
{
55, 24, 25, 26, 27, 28, 29, 30, 48, 95,
@ -782,8 +776,8 @@ static const yytype_int8 yycheck[] =
25, 57, 26, 88, 101, -1, 68, -1, 31
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
state STATE-NUM. */
static const yytype_int8 yystos[] =
{
0, 20, 32, 23, 0, 33, 18, 35, 10, 36,
@ -800,7 +794,7 @@ static const yytype_int8 yystos[] =
72, 70
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
static const yytype_int8 yyr1[] =
{
0, 31, 33, 34, 32, 35, 35, 36, 36, 37,
@ -813,7 +807,7 @@ static const yytype_int8 yyr1[] =
71, 70, 72, 72, 72, 72, 72, 72, 72, 72
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
static const yytype_int8 yyr2[] =
{
0, 2, 0, 0, 8, 0, 2, 2, 3, 1,
@ -835,6 +829,7 @@ enum { YYENOMEM = -2 };
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYNOMEM goto yyexhaustedlab
#define YYRECOVERING() (!!yyerrstatus)
@ -875,10 +870,7 @@ do { \
YYFPRINTF Args; \
} while (0)
/* This macro is provided for backward compatibility. */
# ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
@ -905,10 +897,6 @@ yy_symbol_value_print (FILE *yyo,
YY_USE (yyoutput);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yykind < YYNTOKENS)
YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
# endif
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YY_USE (yykind);
YY_IGNORE_MAYBE_UNINITIALIZED_END
@ -1093,6 +1081,7 @@ yyparse (void)
YYDPRINTF ((stderr, "Starting parse\n"));
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
@ -1118,7 +1107,7 @@ yysetstate:
if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
goto yyexhaustedlab;
YYNOMEM;
#else
{
/* Get the current used size of the three stacks, in elements. */
@ -1146,7 +1135,7 @@ yysetstate:
# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
YYNOMEM;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
@ -1157,7 +1146,7 @@ yysetstate:
YY_CAST (union yyalloc *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
if (! yyptr)
goto yyexhaustedlab;
YYNOMEM;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
@ -1179,6 +1168,7 @@ yysetstate:
}
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
if (yystate == YYFINAL)
YYACCEPT;
@ -1293,7 +1283,7 @@ yyreduce:
case 2: /* $@1: %empty */
#line 117 "ncgen.y"
{ init_netcdf(); }
#line 1297 "ncgeny.c"
#line 1287 "ncgeny.c"
break;
case 3: /* $@2: %empty */
@ -1304,7 +1294,7 @@ yyreduce:
if (derror_count > 0)
exit(6);
}
#line 1308 "ncgeny.c"
#line 1298 "ncgeny.c"
break;
case 4: /* ncdesc: NETCDF '{' $@1 dimsection vasection $@2 datasection '}' */
@ -1313,7 +1303,7 @@ yyreduce:
if (derror_count == 0)
close_netcdf();
}
#line 1317 "ncgeny.c"
#line 1307 "ncgeny.c"
break;
case 11: /* dimdecl: dimd '=' INT_CONST */
@ -1323,7 +1313,7 @@ yyreduce:
dims[ndims].size = int_val;
ndims++;
}
#line 1327 "ncgeny.c"
#line 1317 "ncgeny.c"
break;
case 12: /* dimdecl: dimd '=' DOUBLE_CONST */
@ -1338,7 +1328,7 @@ yyreduce:
dims[ndims].size = (size_t) double_val;
ndims++;
}
#line 1342 "ncgeny.c"
#line 1332 "ncgeny.c"
break;
case 13: /* dimdecl: dimd '=' NC_UNLIMITED_K */
@ -1349,7 +1339,7 @@ yyreduce:
dims[ndims].size = NC_UNLIMITED;
ndims++;
}
#line 1353 "ncgeny.c"
#line 1343 "ncgeny.c"
break;
case 14: /* dimd: dim */
@ -1369,43 +1359,43 @@ yyreduce:
/* name for use in generated Fortran and C variables */
dims[ndims].lname = decodify(yyvsp[0]->name);
}
#line 1373 "ncgeny.c"
#line 1363 "ncgeny.c"
break;
case 27: /* type: BYTE_K */
#line 200 "ncgen.y"
{ type_code = NC_BYTE; }
#line 1379 "ncgeny.c"
#line 1369 "ncgeny.c"
break;
case 28: /* type: CHAR_K */
#line 201 "ncgen.y"
{ type_code = NC_CHAR; }
#line 1385 "ncgeny.c"
#line 1375 "ncgeny.c"
break;
case 29: /* type: SHORT_K */
#line 202 "ncgen.y"
{ type_code = NC_SHORT; }
#line 1391 "ncgeny.c"
#line 1381 "ncgeny.c"
break;
case 30: /* type: INT_K */
#line 203 "ncgen.y"
{ type_code = NC_INT; }
#line 1397 "ncgeny.c"
#line 1387 "ncgeny.c"
break;
case 31: /* type: FLOAT_K */
#line 204 "ncgen.y"
{ type_code = NC_FLOAT; }
#line 1403 "ncgeny.c"
#line 1393 "ncgeny.c"
break;
case 32: /* type: DOUBLE_K */
#line 205 "ncgen.y"
{ type_code = NC_DOUBLE; }
#line 1409 "ncgeny.c"
#line 1399 "ncgeny.c"
break;
case 35: /* $@3: %empty */
@ -1442,7 +1432,7 @@ yyreduce:
nc_getfill(type_code, &vars[nvars].fill_value);
vars[nvars].has_data = 0; /* has no data (yet) */
}
#line 1446 "ncgeny.c"
#line 1436 "ncgeny.c"
break;
case 36: /* varspec: var $@3 dimspec */
@ -1451,7 +1441,7 @@ yyreduce:
vars[nvars].ndims = nvdims;
nvars++;
}
#line 1455 "ncgeny.c"
#line 1445 "ncgeny.c"
break;
case 42: /* vdim: dim */
@ -1475,7 +1465,7 @@ yyreduce:
vars[nvars].dims[nvdims] = dimnum;
nvdims++;
}
#line 1479 "ncgeny.c"
#line 1469 "ncgeny.c"
break;
case 43: /* $@4: %empty */
@ -1483,7 +1473,7 @@ yyreduce:
{
defatt();
}
#line 1487 "ncgeny.c"
#line 1477 "ncgeny.c"
break;
case 44: /* attdecl: att $@4 '=' attvallist */
@ -1491,7 +1481,7 @@ yyreduce:
{
equalatt();
}
#line 1495 "ncgeny.c"
#line 1485 "ncgeny.c"
break;
case 45: /* $@5: %empty */
@ -1499,7 +1489,7 @@ yyreduce:
{
defatt();
}
#line 1503 "ncgeny.c"
#line 1493 "ncgeny.c"
break;
case 46: /* gattdecl: gatt $@5 '=' attvallist */
@ -1507,7 +1497,7 @@ yyreduce:
{
equalatt();
}
#line 1511 "ncgeny.c"
#line 1501 "ncgeny.c"
break;
case 48: /* gatt: ':' attr */
@ -1515,7 +1505,7 @@ yyreduce:
{
varnum = NC_GLOBAL; /* handle of "global" attribute */
}
#line 1519 "ncgeny.c"
#line 1509 "ncgeny.c"
break;
case 49: /* avar: var */
@ -1528,7 +1518,7 @@ yyreduce:
YYABORT;
}
}
#line 1532 "ncgeny.c"
#line 1522 "ncgeny.c"
break;
case 50: /* attr: IDENT */
@ -1542,7 +1532,7 @@ yyreduce:
/* name for use in generated Fortran and C variables */
atts[natts].lname = decodify(yyvsp[0]->name);
}
#line 1546 "ncgeny.c"
#line 1536 "ncgeny.c"
break;
case 53: /* aconst: attconst */
@ -1553,7 +1543,7 @@ yyreduce:
if (valtype != atype_code)
derror("values for attribute must be all of same type");
}
#line 1557 "ncgeny.c"
#line 1547 "ncgeny.c"
break;
case 54: /* attconst: CHAR_CONST */
@ -1563,7 +1553,7 @@ yyreduce:
*char_valp++ = char_val;
valnum++;
}
#line 1567 "ncgeny.c"
#line 1557 "ncgeny.c"
break;
case 55: /* attconst: TERMSTRING */
@ -1580,7 +1570,7 @@ yyreduce:
char_valp += len;
}
}
#line 1584 "ncgeny.c"
#line 1574 "ncgeny.c"
break;
case 56: /* attconst: BYTE_CONST */
@ -1590,7 +1580,7 @@ yyreduce:
*byte_valp++ = byte_val;
valnum++;
}
#line 1594 "ncgeny.c"
#line 1584 "ncgeny.c"
break;
case 57: /* attconst: SHORT_CONST */
@ -1600,7 +1590,7 @@ yyreduce:
*short_valp++ = short_val;
valnum++;
}
#line 1604 "ncgeny.c"
#line 1594 "ncgeny.c"
break;
case 58: /* attconst: INT_CONST */
@ -1610,7 +1600,7 @@ yyreduce:
*int_valp++ = int_val;
valnum++;
}
#line 1614 "ncgeny.c"
#line 1604 "ncgeny.c"
break;
case 59: /* attconst: FLOAT_CONST */
@ -1620,7 +1610,7 @@ yyreduce:
*float_valp++ = float_val;
valnum++;
}
#line 1624 "ncgeny.c"
#line 1614 "ncgeny.c"
break;
case 60: /* attconst: DOUBLE_CONST */
@ -1630,7 +1620,7 @@ yyreduce:
*double_valp++ = double_val;
valnum++;
}
#line 1634 "ncgeny.c"
#line 1624 "ncgeny.c"
break;
case 66: /* $@6: %empty */
@ -1685,7 +1675,7 @@ yyreduce:
default: break;
}
}
#line 1689 "ncgeny.c"
#line 1679 "ncgeny.c"
break;
case 67: /* datadecl: avar $@6 '=' constlist */
@ -1704,7 +1694,7 @@ yyreduce:
put_variable(rec_start);
free ((char *) rec_start);
}
#line 1708 "ncgeny.c"
#line 1698 "ncgeny.c"
break;
case 70: /* $@7: %empty */
@ -1733,7 +1723,7 @@ yyreduce:
}
not_a_string = 1;
}
#line 1737 "ncgeny.c"
#line 1727 "ncgeny.c"
break;
case 71: /* dconst: $@7 const */
@ -1763,7 +1753,7 @@ yyreduce:
}
}
}
#line 1767 "ncgeny.c"
#line 1757 "ncgeny.c"
break;
case 72: /* const: CHAR_CONST */
@ -1793,7 +1783,7 @@ yyreduce:
}
valnum++;
}
#line 1797 "ncgeny.c"
#line 1787 "ncgeny.c"
break;
case 73: /* const: TERMSTRING */
@ -1852,7 +1842,7 @@ yyreduce:
}
}
}
#line 1856 "ncgeny.c"
#line 1846 "ncgeny.c"
break;
case 74: /* const: BYTE_CONST */
@ -1882,7 +1872,7 @@ yyreduce:
}
valnum++;
}
#line 1886 "ncgeny.c"
#line 1876 "ncgeny.c"
break;
case 75: /* const: SHORT_CONST */
@ -1912,7 +1902,7 @@ yyreduce:
}
valnum++;
}
#line 1916 "ncgeny.c"
#line 1906 "ncgeny.c"
break;
case 76: /* const: INT_CONST */
@ -1942,7 +1932,7 @@ yyreduce:
}
valnum++;
}
#line 1946 "ncgeny.c"
#line 1936 "ncgeny.c"
break;
case 77: /* const: FLOAT_CONST */
@ -1972,7 +1962,7 @@ yyreduce:
}
valnum++;
}
#line 1976 "ncgeny.c"
#line 1966 "ncgeny.c"
break;
case 78: /* const: DOUBLE_CONST */
@ -2005,7 +1995,7 @@ yyreduce:
}
valnum++;
}
#line 2009 "ncgeny.c"
#line 1999 "ncgeny.c"
break;
case 79: /* const: FILLVALUE */
@ -2041,11 +2031,11 @@ yyreduce:
}
valnum++;
}
#line 2045 "ncgeny.c"
#line 2035 "ncgeny.c"
break;
#line 2049 "ncgeny.c"
#line 2039 "ncgeny.c"
default: break;
}
@ -2127,6 +2117,7 @@ yyerrorlab:
label yyerrorlab therefore never appears in user code. */
if (0)
YYERROR;
++yynerrs;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
@ -2187,7 +2178,7 @@ yyerrlab1:
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
goto yyreturnlab;
/*-----------------------------------.
@ -2195,24 +2186,22 @@ yyacceptlab:
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
goto yyreturnlab;
#if !defined yyoverflow
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
/*-----------------------------------------------------------.
| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
`-----------------------------------------------------------*/
yyexhaustedlab:
yyerror (YY_("memory exhausted"));
yyresult = 2;
goto yyreturn;
#endif
goto yyreturnlab;
/*-------------------------------------------------------.
| yyreturn -- parsing is finished, clean up and return. |
`-------------------------------------------------------*/
yyreturn:
/*----------------------------------------------------------.
| yyreturnlab -- parsing is finished, clean up and return. |
`----------------------------------------------------------*/
yyreturnlab:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at

View File

@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.7.5. */
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@ -88,6 +88,8 @@ typedef int YYSTYPE;
extern YYSTYPE ncglval;
int ncgparse (void);
#endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */

View File

@ -9,7 +9,11 @@ if test "x$srcdir" = x ;then srcdir=`pwd`; fi
. ../test_common.sh
echo "*** creating classic file c0.nc from c0.cdl..."
${NCGEN3} -b -o c0.nc ${ncgen3c0}
if ${NCGEN3} -b -o c0.nc ${ncgen3c0} ; then
echo "***PASS"
else
echo "***fail"
fi
echo "*** creating 64-bit offset file c0_64.nc from c0.cdl..."
#${NCGEN3} -k 64-bit-offset -b -o c0_64.nc ${ncgen3c0}

View File

@ -4,6 +4,11 @@
# This file builds and runs the nctest program, which tests the netCDF
# version 2 interface.
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#sh_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#TESTS_ENVIRONMENT = export SETX=1;
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am

View File

@ -14,6 +14,7 @@
#include "add.h" /* functions to update in-memory netcdf */
#include "error.h"
#include "tests.h"
#include "ncpathmgr.h"
#define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
@ -132,7 +133,7 @@ test_ncopen(path)
* safe, because sometimes it's a .o and sometimes a .obj. So just
* create a file!
*/
if (!(temp = fopen(TEMP_FILE_NAME, "w+")))
if (!(temp = NCfopen(TEMP_FILE_NAME, "w+")))
{
error("could not create temp file");
return ++nerrs;
@ -191,7 +192,7 @@ test_ncopen(path)
return ++nerrs;
}
if ((ncid1 = ncopen(path, NC_NOWRITE)) == -1) {
#ifndef vms
#if !defined vms && !defined _WIN32
error("%s: second ncopen failed", pname);
nerrs++;
#else
@ -725,7 +726,7 @@ test_ncsync(path)
nerrs++;
}
if ((ncid1 = ncopen(path, NC_NOWRITE)) == -1) {
#ifndef vms
#if !defined vms && !defined _WIN32
error("%s: second ncopen failed", pname);
nerrs++;
#else

View File

@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
set -e
cmp nctest_classic.nc $srcdir/ref_nctest_classic.nc
cmp nctest_64bit_offset.nc $srcdir/ref_nctest_64bit_offset.nc
WS=`${NCPATHCVT} ${srcdir}`
cmp nctest_classic.nc "$WS/ref_nctest_classic.nc"
cmp nctest_64bit_offset.nc "$WS/ref_nctest_64bit_offset.nc"

View File

@ -20,6 +20,15 @@
#define MAX_NUM_FORMATS 5
#undef DEBUG
#ifdef DEBUG
#define CATCH(x) {(x); if(nerrs > 0) breakpoint();}
static void breakpoint(void) {return;}
#else
#define CATCH(x) (x)
#endif
int current_format = 0;
/* Determine how many formats are available, and what they are. */
@ -84,40 +93,40 @@ main(int argc, char **argv)
nc_set_default_format(format[i], NULL);
/* Run all the tests for this format. */
nerrs += test_nccreate(testfile);
nerrs += test_ncopen(testfile);
nerrs += test_ncredef(testfile);
nerrs += test_ncendef(testfile);
nerrs += test_ncclose(testfile);
nerrs += test_ncinquire(testfile);
nerrs += test_ncsync(testfile);
nerrs += test_ncabort(testfile);
nerrs += test_ncdimdef(testfile);
nerrs += test_ncdimid(testfile);
nerrs += test_ncdiminq(testfile);
nerrs += test_ncdimrename(testfile);
nerrs += test_ncvardef(testfile);
nerrs += test_ncvarid(testfile);
nerrs += test_ncvarinq(testfile);
nerrs += test_ncvarputg(testfile);
nerrs += test_ncvarput1(testfile);
nerrs += test_ncvarget1(testfile);
nerrs += test_ncvarput(testfile);
nerrs += test_ncvarget(testfile);
nerrs += test_ncvarputg(testfile);
nerrs += test_ncvargetg(testfile);
nerrs += test_ncrecinq(testfile);
nerrs += test_ncrecput(testfile);
nerrs += test_ncrecget(testfile);
nerrs += test_ncvarrename(testfile);
nerrs += test_ncattput(testfile);
nerrs += test_ncattinq(testfile);
nerrs += test_ncattget(testfile);
nerrs += test_ncattcopy(testfile, "test2.nc");
nerrs += test_ncattname(testfile);
nerrs += test_ncattrename(testfile);
nerrs += test_ncattdel(testfile);
nerrs += test_nctypelen();
CATCH(nerrs += test_nccreate(testfile));
CATCH(nerrs += test_ncopen(testfile));
CATCH(nerrs += test_ncredef(testfile));
CATCH(nerrs += test_ncendef(testfile));
CATCH(nerrs += test_ncclose(testfile));
CATCH(nerrs += test_ncinquire(testfile));
CATCH(nerrs += test_ncsync(testfile));
CATCH(nerrs += test_ncabort(testfile));
CATCH(nerrs += test_ncdimdef(testfile));
CATCH(nerrs += test_ncdimid(testfile));
CATCH(nerrs += test_ncdiminq(testfile));
CATCH(nerrs += test_ncdimrename(testfile));
CATCH(nerrs += test_ncvardef(testfile));
CATCH(nerrs += test_ncvarid(testfile));
CATCH(nerrs += test_ncvarinq(testfile));
CATCH(nerrs += test_ncvarputg(testfile));
CATCH(nerrs += test_ncvarput1(testfile));
CATCH(nerrs += test_ncvarget1(testfile));
CATCH(nerrs += test_ncvarput(testfile));
CATCH(nerrs += test_ncvarget(testfile));
CATCH(nerrs += test_ncvarputg(testfile));
CATCH(nerrs += test_ncvargetg(testfile));
CATCH(nerrs += test_ncrecinq(testfile));
CATCH(nerrs += test_ncrecput(testfile));
CATCH(nerrs += test_ncrecget(testfile));
CATCH(nerrs += test_ncvarrename(testfile));
CATCH(nerrs += test_ncattput(testfile));
CATCH(nerrs += test_ncattinq(testfile));
CATCH(nerrs += test_ncattget(testfile));
CATCH(nerrs += test_ncattcopy(testfile, "test2.nc"));
CATCH(nerrs += test_ncattname(testfile));
CATCH(nerrs += test_ncattrename(testfile));
CATCH(nerrs += test_ncattdel(testfile));
CATCH(nerrs += test_nctypelen());
/* Clean up in-memory struct. */
{

View File

@ -97,15 +97,16 @@ IF(ENABLE_TESTS)
ENDIF()
IF(ENABLE_FILTER_TESTING)
add_bin_test(nczarr_test tst_nczfilter)
build_bin_test(testfilter)
build_bin_test(testfilter_misc)
build_bin_test(testfilter_multi)
build_bin_test(testfilter_order)
build_bin_test(testfilter_repeat)
ADD_SH_TEST(nczarr_test run_filter)
IF(ENABLE_BLOSC)
ADD_SH_TEST(nczarr_test run_specific_filters)
ENDIF()
ADD_SH_TEST(nczarr_test run_filter)
ENDIF(ENABLE_FILTER_TESTING)
if(ENABLE_NCZARR_ZIP)
add_sh_test(nczarr_test run_newformat)

View File

@ -60,6 +60,9 @@ MISCPATH="${HDF5_PLUGIN_PATH}/${HDF5_PLUGIN_LIB}"
if ! test -f ${BZIP2PATH} ; then echo "Unable to locate ${BZIP2PATH}"; exit 1; fi
if ! test -f ${MISCPATH} ; then echo "Unable to locate ${MISCPATH}"; exit 1; fi
echo "@@@@@@@@@@@"
find ${HDF5_PLUGIN_PATH}
# Execute the specified tests
testapi() {

View File

@ -16,6 +16,7 @@ fileargs tmp_groups_regular "mode=zarr,$zext"
deletemap $zext $file
${NCCOPY} ${srcdir}/ref_groups.h5 "$fileurl"
rm -f tmp.cdl
${ZMD} -h "$fileurl"
${NCDUMP} -s -n tmp_groups_regular "$fileurl" > tmp.cdl
sclean tmp.cdl tmp_groups_regular_$zext.cdl
diff -wb ${srcdir}/ref_groups_regular.cdl tmp_groups_regular_$zext.cdl
@ -27,6 +28,7 @@ echo "*** Test: Github issue #2062"
rm -fr ref_byte.zarr
unzip ${srcdir}/ref_byte.zarr.zip
rm -fr tmp.cdl
${ZMD} -h "file://ref_byte.zarr#mode=zarr,$zext"
${NCDUMP} -s "file://ref_byte.zarr#mode=zarr,$zext" > tmp.cdl
sclean tmp.cdl tmp_byte_$zext.cdl
diff -wb ${srcdir}/ref_byte.cdl tmp_byte_$zext.cdl
@ -39,6 +41,7 @@ echo "*** Test: Github issue #2063"
rm -fr ref_byte_fill_value_null.zarr
unzip ${srcdir}/ref_byte_fill_value_null.zarr.zip
rm -fr tmp.cdl
${ZMD} -h "file://ref_byte_fill_value_null.zarr#mode=zarr,$zext"
${NCDUMP} -s "file://ref_byte_fill_value_null.zarr#mode=zarr,$zext" > tmp.cdl
sclean tmp.cdl tmp_byte_fill_value_null_$zext.cdl
diff -wb ${srcdir}/ref_byte_fill_value_null.cdl tmp_byte_fill_value_null_$zext.cdl

View File

@ -127,6 +127,7 @@ if test "x$NCAUTH_HOMETEST" != x ; then RCHOME=1; fi
#cd ../plugins; make clean all >/dev/null; cd ../nczarr_test
if test "x$FP_USEPLUGINS" = xyes; then
# Load the findplugins function
. ${builddir}/findplugin.sh
echo "findplugin.sh loaded"
@ -138,6 +139,7 @@ findplugin h5misc
echo "final HDF5_PLUGIN_PATH=${HDF5_PLUGIN_PATH}"
export HDF5_PLUGIN_PATH
fi # USEPLUGINS
resetrc() {
if test "x$RCHOME" = x1 ; then

View File

@ -66,6 +66,7 @@ main(int argc, char** argv)
if((stat = NCpathcanonical(utoptions.output,&tmp))) goto done;
free(utoptions.output);
utoptions.output = tmp;
fprintf(stderr,"file=%s output=%s\n",utoptions.file,utoptions.output);
impl = kind2impl(utoptions.kind);
url = makeurl(utoptions.file,impl,&utoptions);

View File

@ -425,7 +425,7 @@ retry:
static OCtype
octypefor(Object etype)
{
switch ((long)etype) {
switch ((uintptr_t)etype) {
case SCAN_BYTE: return OC_Byte;
case SCAN_INT16: return OC_Int16;
case SCAN_UINT16: return OC_UInt16;

View File

@ -71,7 +71,7 @@ dumpocnode1(OCnode* node, int depth)
if(node->name == NULL) OCPANIC("prim without name");
fprintf(stdout,"%s %s",octypetostring(node->etype),node->name);
dumpdimensions(node);
fprintf(stdout," &%lx",(unsigned long)node);
fprintf(stdout," &%p",node);
fprintf(stdout,"\n");
} break;
@ -89,7 +89,7 @@ dumpocnode1(OCnode* node, int depth)
fprintf(stdout,"struct %s",
(node->name?node->name:""));
dumpdimensions(node);
fprintf(stdout," &%lx",(unsigned long)node);
fprintf(stdout," &%p",node);
fprintf(stdout,"\n");
for(n=0;n<nclistlength(node->subnodes);n++) {
dumpocnode1((OCnode*)nclistget(node->subnodes,n),depth+1);
@ -101,7 +101,7 @@ dumpocnode1(OCnode* node, int depth)
fprintf(stdout,"sequence %s",
(node->name?node->name:""));
dumpdimensions(node);
fprintf(stdout," &%lx",(unsigned long)node);
fprintf(stdout," &%p",node);
fprintf(stdout,"\n");
for(n=0;n<nclistlength(node->subnodes);n++) {
dumpocnode1((OCnode*)nclistget(node->subnodes,n),depth+1);
@ -114,7 +114,7 @@ dumpocnode1(OCnode* node, int depth)
fprintf(stdout,"grid %s",
(node->name?node->name:""));
dumpdimensions(node);
fprintf(stdout," &%lx",(unsigned long)node);
fprintf(stdout," &%p",node);
fprintf(stdout,"\n");
fprintf(stdout,"%sarray:\n",dent2(depth+1));
dumpocnode1((OCnode*)nclistget(node->subnodes,0),depth+2);
@ -133,7 +133,7 @@ dumpocnode1(OCnode* node, int depth)
if(n > 0) fprintf(stdout,",");
fprintf(stdout," %s",value);
}
fprintf(stdout," &%lx",(unsigned long)node);
fprintf(stdout," &%p",node);
fprintf(stdout,"\n");
} break;
@ -494,7 +494,7 @@ ocdumpdata(OCstate* state, OCdata* data, NCbytes* buffer, int frominstance)
OCnode* pattern = data->pattern;
char* smode = NULL;
snprintf(tmp,sizeof(tmp),"%lx:",(unsigned long)data);
snprintf(tmp,sizeof(tmp),"%p:",data);
ncbytescat(buffer,tmp);
if(!frominstance) {
ncbytescat(buffer," node=");
@ -514,7 +514,7 @@ ocdumpdata(OCstate* state, OCdata* data, NCbytes* buffer, int frominstance)
ncbytescat(buffer,tmp);
}
ncbytescat(buffer," container=");
snprintf(tmp,sizeof(tmp),"%lx",(unsigned long)data->container);
snprintf(tmp,sizeof(tmp),"%p",data->container);
ncbytescat(buffer,tmp);
ncbytescat(buffer," mode=");
ncbytescat(buffer,(smode=ocdtmodestring(data->datamode,0)));
@ -675,6 +675,6 @@ ocdumpdatapath(OCstate* state, OCdata* data, NCbytes* buffer)
ncbytescat(buffer,":");
ncbytescat(buffer,octypetoddsstring(pattern->etype));
}
snprintf(tmp,sizeof(tmp),"->0x%0lx",(unsigned long)pathdata);
snprintf(tmp,sizeof(tmp),"->0x%p",pathdata);
ncbytescat(buffer,tmp);
}

View File

@ -7,6 +7,10 @@ include $(top_srcdir)/lib_flags.am
AM_LDFLAGS += -module -avoid-version -shared -export-dynamic \
-rpath ${abs_builddir} ${NOUNDEFINED}
if ISMINGW
LDADD = ${top_builddir}/liblib/libnetcdf.la
endif
# BZIP2 version 1.0.8 (https://sourceware.org/bzip2/)
BZIP2SRC = blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c bzlib.h bzlib_private.h
@ -22,8 +26,9 @@ if ENABLE_FILTER_TESTING
lib_LTLIBRARIES = libh5bzip2.la
libh5bzip2_la_SOURCES = H5Zbzip2.c h5bzip2.h ${BZIP2SRC}
noinst_LTLIBRARIES = libh5misc.la libh5noop.la libh5noop1.la libnczmisc.la libnczdefaults.la \
noinst_LTLIBRARIES = libh5misc.la libh5noop.la libh5noop1.la libnczmisc.la \
libh5shuffle.la libh5fletcher32.la libh5deflate.la
noinst_LTLIBRARIES += libnczdefaults.la
libh5shuffle_la_SOURCES = H5Zshuffle.c
libh5fletcher32_la_SOURCES = H5Zfletcher32.c H5checksum.c

0
test-driver-verbose Normal file → Executable file
View File

View File

@ -12,6 +12,9 @@ FP_ISCMAKE=@ISCMAKE@
FP_ISMSVC=@ISMSVC@
FP_ISCYGWIN=@ISCYGWIN@
FP_ISMINGW=@ISMINGW@
FP_ISMSYS=@ISMSYS@
FP_ISREGEDIT=@ISREGEDIT@
FP_USEPLUGINS=@USEPLUGINS@
# Feature flags
FEATURE_HDF5=@HAS_HDF5@
@ -79,8 +82,14 @@ if test "x$SETX" = x1 ; then set -x ; fi
# On MINGW, bash and other POSIX utilities use a mounted root directory,
# but executables compiled for Windows do not recognise the mount point.
# Here we ensure that Windows paths are used in tests of Windows executables.
if test "x@ISMINGW@" = xyes; then
alias pwd='pwd -W'
if test "x${FP_ISMSYS}" = xyes || test "x${FP_ISCYGWIN}" = xyes ; then
if test "x${MSYS2_PREFIX}" = x ; then
MSYS2_PREFIX=`cygpath -w '/'`
export MSYS2_PREFIX
fi
fi
if test "x${FP_ISMINGW}" = xyes ; then
alias pwd='pwd -W'
fi
# We assume that TOPSRCDIR and TOPBUILDDIR are defined
@ -117,9 +126,6 @@ cd $builddir; builddir=`pwd` ; cd $WD
cd $top_builddir; top_builddir=`pwd` ; cd $WD
cd $execdir; execdir=`pwd` ; cd $WD
# If we have cygpath (which only exists under CYGWIN),
# then try to normalize selected file paths.
# For sun os
export srcdir top_srcdir builddir top_builddir execdir

View File

@ -13,7 +13,7 @@
# so we don't want to make them external, which would be required to
# run on Windows.
SET(UNIT_TESTS test_ncuri test_pathcvt)
SET(UNIT_TESTS test_ncuri)
IF(NOT MSVC)
IF(ENABLE_NETCDF_4)
@ -25,6 +25,9 @@ FOREACH(CTEST ${UNIT_TESTS})
add_bin_test(unit_test ${CTEST})
ENDFOREACH()
# Path convert test(s)
add_bin_test(unit_test test_pathcvt)
# Aws Tests
build_bin_test(test_aws)
ADD_SH_TEST(unit_test run_aws)

View File

@ -11,6 +11,11 @@
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#sh_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#TESTS_ENVIRONMENT = export SETX=1;
# Find and link to the netcdf-c library.
LDADD = ${top_builddir}/liblib/libnetcdf.la
@ -31,10 +36,13 @@ check_PROGRAMS += tst_nc4internal
TESTS += tst_nc4internal
endif # USE_NETCDF4
if ENABLE_NCZARR_S3_TESTS
check_PROGRAMS += test_aws
TESTS += run_aws.sh
endif
EXTRA_DIST = CMakeLists.txt run_aws.sh
EXTRA_DIST += nctest_netcdf4_classic.nc
# If valgrind is present, add valgrind targets.
@VALGRIND_CHECK_RULES@

Binary file not shown.

View File

@ -25,36 +25,93 @@ typedef struct Test {
/* Path conversion tests */
static Test PATHTESTS[] = {
{"/xxx/a/b",{"/xxx/a/b", "/c/xxx/a/b", "/cygdrive/c/xxx/a/b", "c:\\xxx\\a\\b"}},
{"d:/x/y",{ "/d/x/y", "/d/x/y", "/cygdrive/d/x/y", "d:\\x\\y"}},
{"d:\\x\\y",{ "/d/x/y", "/d/x/y", "/cygdrive/d/x/y", "d:\\x\\y"}},
{"/cygdrive/d/x/y",{ "/d/x/y", "/d/x/y", "/cygdrive/d/x/y", "d:\\x\\y"}},
{"/d/x/y",{ "/d/x/y", "/d/x/y", "/cygdrive/d/x/y", "d:\\x\\y"}},
{"/cygdrive/d",{ "/d", "/d", "/cygdrive/d", "d:"}},
{"/d", {"/d", "/d", "/cygdrive/d", "d:"}},
{"/xxx/a/b",{
"/xxx/a/b", /*NCPD_LINUX*/
"c:\\xxx\\a\\b", /*NCPD_MSYS*/
"/cygdrive/c/xxx/a/b", /*NCPD_CYGWIN*/
"c:\\xxx\\a\\b" /*NCPD_WIN*/
}},
{"d:/x/y",{
"/d/x/y", /*NCPD_LINUX*/
"d:\\x\\y", /*NCPD_MSYS*/
"/cygdrive/d/x/y", /*NCPD_CYGWIN*/
"d:\\x\\y" /*NCPD_WIN*/
}},
{"d:\\x\\y",{
"/d/x/y", /*NCPD_LINUX*/
"d:\\x\\y", /*NCPD_MSYS*/
"/cygdrive/d/x/y", /*NCPD_CYGWIN*/
"d:\\x\\y" /*NCPD_WIN*/
}},
{"/cygdrive/d/x/y",{
"/cygdrive/d/x/y", /*NCPD_LINUX*/
"d:\\x\\y", /*NCPD_MSYS*/
"/cygdrive/d/x/y", /*NCPD_CYGWIN*/
"d:\\x\\y" /*NCPD_WIN*/
}},
{"/d/x/y",{
"/d/x/y", /*NCPD_LINUX*/
"c:\\d\\x\\y", /*NCPD_MSYS*/
"/cygdrive/c/d/x/y", /*NCPD_CYGWIN*/
"c:\\d\\x\\y" /*NCPD_WIN*/
}},
{"/cygdrive/d",{
"/cygdrive/d", /*NCPD_LINUX*/
"d:", /*NCPD_MSYS*/
"/cygdrive/d", /*NCPD_CYGWIN*/
"d:" /*NCPD_WIN*/
}},
{"/d", {
"/d", /*NCPD_LINUX*/
"c:\\d", /*NCPD_MSYS*/
"/cygdrive/c/d", /*NCPD_CYGWIN*/
"c:\\d" /*NCPD_WIN*/
}},
{"/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn",{
"/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn",
"/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn",
"/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn",
"d:\\git\\netcdf-c\\dap4_test\\test_anon_dim.2.syn"}},
"/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn", /*NCPD_LINUX*/
"d:\\git\\netcdf-c\\dap4_test\\test_anon_dim.2.syn", /*NCPD_MSYS*/
"/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn", /*NCPD_CYGWIN*/
"d:\\git\\netcdf-c\\dap4_test\\test_anon_dim.2.syn" /*NCPD_WIN*/
}},
/* Test relative path */
{"x/y",{ "x/y", "x/y", "x/y", "x\\y"}},
{"x\\y",{ "x/y", "x/y", "x/y", "x\\y"}},
#ifndef _WIN32
{"x/y",{
"x/y", /*NCPD_LINUX*/
"x\\y", /*NCPD_MSYS*/
"x/y", /*NCPD_CYGWIN*/
"x\\y" /*NCPD_WIN*/
}},
{"x\\y",{
"x/y",/*NCPD_LINUX*/
"x\\y", /*NCPD_MSYS*/
"x/y", /*NCPD_CYGWIN*/
"x\\y" /*NCPD_WIN*/
}},
#ifndef _WIN32X
/* Test utf8 path */
{"/海/海",{ "/海/海", "/c/海/海", "/cygdrive/c/海/海", "c:\\\\"}},
{"/海/海",{
"/海/海", /*NCPD_LINUX*/
"c:\\\\", /*NCPD_MSYS*/
"/cygdrive/c/海/海", /*NCPD_CYGWIN*/
"c:\\\\" /*NCPD_WIN*/
}},
/* Test network path */
{"//git/netcdf-c/dap4_test",{
"/@/git/netcdf-c/dap4_test",
"/@/git/netcdf-c/dap4_test",
"/cygdrive/@/git/netcdf-c/dap4_test",
"\\\\git\\netcdf-c\\dap4_test"}},
NULL /*meaningless*/, /*NCPD_LINUX*/
"\\\\git\\netcdf-c\\dap4_test", /*NCPD_MSYS*/
NULL /*meaningless*/, /*NCPD_CYGWIN*/
"\\\\git\\netcdf-c\\dap4_test" /*NCPD_WIN*/
}},
#endif
{NULL, {NULL, NULL, NULL, NULL}}
};
char* macros[128];
/*Forward */
static const char* kind2string(int kind);
static char* expand(const char* s);
static void setmacros(void);
static void reclaimmacros(void);
int
main(int argc, char** argv)
@ -63,29 +120,40 @@ main(int argc, char** argv)
int failcount = 0;
char* cvt = NULL;
char* unescaped = NULL;
char* expanded = NULL;
int k;
int drive = 'c';
nc_initialize();
setmacros();
/* Test localkind X path-kind */
for(test=PATHTESTS;test->test;test++) {
int inputkind = NCgetinputpathkind(test->test);
/* Iterate over the test paths */
for(k=0;k<NKINDS;k++) {
int kind = kinds[k];
/* Compare output for the localkind */
if(test->expected[k] == NULL) {
#ifdef DEBUG
fprintf(stderr,"TEST local=%s: %s ignored\n",kind2string(kind),test->test);
fprintf(stderr,"TEST input=%s target=%s: %s ignored\n",kind2string(inputkind),kind2string(kind),test->test);
#endif
continue;
}
/* ensure that NC_shellUnescape does not affect result */
unescaped = NC_shellUnescape(test->test);
expanded = expand(test->expected[k]);
#ifdef DEBUG
fprintf(stderr,">>> unescaped=|%s| expanded=|%s|\n",unescaped,expanded);
#endif
#ifdef DEBUG
fprintf(stderr,"TEST input=%s target=%s: input: |%s|\n",
kind2string(inputkind),kind2string(kind),test->test);
#endif
cvt = NCpathcvt_test(unescaped,kind,drive);
#ifdef DEBUG
fprintf(stderr,"TEST local=%s: input: |%s| expected=|%s| actual=|%s|: ",
kind2string(kind),test->test,test->expected[k],cvt);
fprintf(stderr,"\texpected=|%s| actual=|%s|: ",expanded,cvt);
#endif
fflush(stderr); fflush(stdout);
if(cvt == NULL) {
@ -93,7 +161,7 @@ main(int argc, char** argv)
fprintf(stderr," ILLEGAL");
#endif
failcount++;
} else if(strcmp(cvt,test->expected[k]) != 0) {
} else if(strcmp(cvt,expanded) != 0) {
#ifdef DEBUG
fprintf(stderr," FAIL");
#endif
@ -107,11 +175,15 @@ main(int argc, char** argv)
fprintf(stderr,"\n");
#endif
nullfree(unescaped); unescaped = NULL;
nullfree( cvt); cvt = NULL;
nullfree(expanded); expanded = NULL;
nullfree(cvt); cvt = NULL;
}
}
nullfree(cvt); nullfree(unescaped);
fprintf(stderr,"%s test_pathcvt\n",failcount > 0 ? "***FAIL":"***PASS");
reclaimmacros();
nc_finalize();
return (failcount > 0 ? 1 : 0);
}
@ -128,7 +200,54 @@ kind2string(int kind)
return "Cygwin";
case NCPD_WIN:
return "Windows";
case NCPD_REL:
return "Relative";
default: break;
}
return "unknown";
return "Unknown";
}
static char*
expand(const char* s)
{
const char *p;
char expanded[8192];
char q[2];
q[1] = '\0';
expanded[0] = '\0';
for(p=s;*p;p++) {
char c = *p;
if(c == '%') {
p++;
c = *p;
if(macros[(int)c] != NULL)
strlcat(expanded,macros[(int)c],sizeof(expanded));
} else {
q[0] = c;
strlcat(expanded,q,sizeof(expanded));
}
}
return strdup(expanded);
}
static void
setmacros(void)
{
int i;
const char* m;
for(i=0;i<128;i++) macros[i] = NULL;
if((m=getenv("MSYS2_PREFIX"))) {
macros['m'] = strdup(m);
}
}
static void
reclaimmacros(void)
{
int i;
for(i=0;i<128;i++) {
if(macros[i]) free(macros[i]);
macros[i] = NULL;
}
}