From 9380790ea89dfdc232999c571f2ab1a82b5ef2d6 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Thu, 23 Dec 2021 22:18:56 -0700 Subject: [PATCH 1/3] 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. --- .github/workflows/mingw.yml | 29 + .github/workflows/run_tests.yml | 6 +- CMakeLists.txt | 31 +- Makefile.am | 9 +- RELEASE_NOTES.md | 1 + config.h.cmake.in | 3 + configure.ac | 71 +- include/nclog.h | 10 + include/ncpathmgr.h | 113 ++-- libdap2/dapdump.c | 6 +- libdap4/d4parser.c | 2 - libdispatch/CMakeLists.txt | 4 + libdispatch/Makefile.am | 4 + libdispatch/denum.c | 8 +- libdispatch/dfile.c | 2 +- libdispatch/dinfermodel.c | 24 +- libdispatch/dpathmgr.c | 618 ++++++++++++------ libdispatch/drc.c | 27 +- libdispatch/dreg.c | 46 ++ libdispatch/dutil.c | 8 - libdispatch/ncexhash.c | 10 +- libdispatch/nclog.c | 7 + libhdf5/hdf5debug.c | 3 +- libhdf5/hdf5debug.h | 4 +- libhdf5/hdf5open.c | 4 +- liblib/Makefile.am | 2 +- libncpoco/Makefile.am | 8 +- libncxml/Makefile.am | 45 +- libncxml/ezxml.c | 2 + libncxml/ezxml.h | 18 +- libncxml/ncxml_xml2.c | 8 +- libnczarr/Makefile.am | 5 +- libnczarr/zattr.c | 2 + libnczarr/zclose.c | 2 + libnczarr/zcreate.c | 3 +- libnczarr/zdebug.c | 10 + libnczarr/zdebug.h | 5 +- libnczarr/zdispatch.c | 33 + libnczarr/zfile.c | 2 + libnczarr/zfilter.c | 13 +- libnczarr/zinternal.c | 2 + libnczarr/zmap.c | 4 +- libnczarr/zmap_file.c | 57 +- libnczarr/zmap_zip.c | 19 + libnczarr/zopen.c | 3 +- libnczarr/zsync.c | 29 +- libnczarr/ztracedispatch.h | 2 + libnczarr/zxcache.c | 4 + libsrc/s3io.c | 2 +- libsrc/winceio.c | 11 +- nc_test/tst_inmemory.c | 13 +- nc_test4/findplugin.in | 9 +- nc_test4/tst_quantize.c | 2 +- nc_test4/tst_udf.c | 10 +- ncdap_test/t_misc.c | 2 +- ncdap_test/tst_urls.sh | 2 +- ncdump/Makefile.am | 21 +- ncdump/cdl/Makefile.am | 2 + ncdump/cdl/ref_keyword.cdl | 7 +- ncdump/ncpathcvt.c | 152 ++++- ncdump/ref_pathcvt.txt | 11 +- ncdump/run_back_comp_tests.sh | 2 +- ncdump/test_keywords.sh | 6 + ncdump/testpathcvt.sh | 29 +- ncdump/tst_nccopy3.sh | 1 + ncdump/tst_nccopy4.sh | 18 +- ncgen/bytebuffer.c | 2 +- ncgen/data.c | 23 +- ncgen/ncgen.1 | 13 + ncgen/ncgen.l | 8 + ncgen/ncgen.y | 16 +- ncgen/ncgenl.c | 19 +- ncgen/ncgeny.c | 977 ++++++++++++++-------------- ncgen/ncgeny.h | 8 +- ncgen3/Makefile.am | 3 + ncgen3/ncgen.l | 4 +- ncgen3/ncgenl.c | 34 +- ncgen3/ncgeny.c | 189 +++--- ncgen3/ncgeny.h | 6 +- ncgen3/run_tests.sh | 6 +- nctest/Makefile.am | 5 + nctest/cdftests.c | 7 +- nctest/compare_test_files.sh | 6 +- nctest/driver.c | 77 ++- nczarr_test/CMakeLists.txt | 3 +- nczarr_test/run_filter.sh | 3 + nczarr_test/run_nczarr_fill.sh | 3 + nczarr_test/test_nczarr.sh | 2 + nczarr_test/ut_map.c | 1 + oc2/dapparse.c | 2 +- oc2/ocdump.c | 16 +- plugins/Makefile.am | 7 +- test-driver-verbose | 0 test_common.in | 16 +- unit_test/CMakeLists.txt | 5 +- unit_test/Makefile.am | 8 + unit_test/nctest_netcdf4_classic.nc | Bin 0 -> 136080 bytes unit_test/test_pathcvt.c | 169 ++++- 98 files changed, 2072 insertions(+), 1194 deletions(-) create mode 100644 .github/workflows/mingw.yml create mode 100644 libdispatch/dreg.c mode change 100644 => 100755 test-driver-verbose create mode 100644 unit_test/nctest_netcdf4_classic.nc diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml new file mode 100644 index 0000000000..a6fd8ad39e --- /dev/null +++ b/.github/workflows/mingw.yml @@ -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 + diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 8f9c97221e..16ef434326 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index bbd890f211..40a5f8c4c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() #### diff --git a/Makefile.am b/Makefile.am index 7ffcee8f9c..e8f7c784dd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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. diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 63940fa366..cb3f70f392 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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). diff --git a/config.h.cmake.in b/config.h.cmake.in index 0d944a0bd3..26992697cf 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -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}" diff --git a/configure.ac b/configure.ac index 46a3e06aec..724434ee38 100644 --- a/configure.ac +++ b/configure.ac @@ -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 ]) @@ -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 diff --git a/include/nclog.h b/include/nclog.h index cb79b40274..a523d200a6 100644 --- a/include/nclog.h +++ b/include/nclog.h @@ -10,6 +10,8 @@ #include #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 diff --git a/include/ncpathmgr.h b/include/ncpathmgr.h index 2c019f3cb9..3f0bcd0ec0 100644 --- a/include/ncpathmgr.h +++ b/include/ncpathmgr.h @@ -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 +NCPD_CYGWIN | / | /cygdrive// +NCPD_WIN | / | : +NCPD_MSYS | / | : + +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/" 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 */ diff --git a/libdap2/dapdump.c b/libdap2/dapdump.c index 5109e37138..611491490d 100644 --- a/libdap2/dapdump.c +++ b/libdap2/dapdump.c @@ -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); diff --git a/libdap4/d4parser.c b/libdap4/d4parser.c index 5c648e54c6..75305a9508 100644 --- a/libdap4/d4parser.c +++ b/libdap4/d4parser.c @@ -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; diff --git a/libdispatch/CMakeLists.txt b/libdispatch/CMakeLists.txt index 156c86c7e2..899968feae 100644 --- a/libdispatch/CMakeLists.txt +++ b/libdispatch/CMakeLists.txt @@ -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}) diff --git a/libdispatch/Makefile.am b/libdispatch/Makefile.am index 1a695e1c5d..00226b407d 100644 --- a/libdispatch/Makefile.am +++ b/libdispatch/Makefile.am @@ -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: diff --git a/libdispatch/denum.c b/libdispatch/denum.c index 5e482bdb2c..d89a70cd9e 100644 --- a/libdispatch/denum.c +++ b/libdispatch/denum.c @@ -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. diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index ffc4275397..2f3fb91623 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -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) diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index 45d0f3cdc2..39387d7a08 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -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 diff --git a/libdispatch/dpathmgr.c b/libdispatch/dpathmgr.c index 546c2f2bed..564a0bd573 100644 --- a/libdispatch/dpathmgr.c +++ b/libdispatch/dpathmgr.c @@ -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;} - - /* 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 = parsepath(inpath,&inparsed))) + {REPORT(stat,"NCpathcvt: parsepath"); goto done;} + if(pathdebug > 0) + fprintf(stderr,">>> NCpathcvt: inparsed=%s\n",printPATH(&inparsed)); - 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(&inparsed,&result,target))) + {REPORT(stat,"NCpathcvt: unparsepath"); goto done;} - 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 @@ NCpathcanonical(const char* srcpath, char** canonp) 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 @@ NCpathabsolute(const char* relpath) /* 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 @@ NCmkstemp(char* base) #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 */ + } +#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; } - /* 5. look for *nix path */ +#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 @@ parsepath(const char* inpath, struct Path* path) } 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; + + 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 != 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 = NC_ENOMEM; goto done;} + {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) + 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 @@ unparsepath(struct Path* xp, char** pathp) } 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); + } +} diff --git a/libdispatch/drc.c b/libdispatch/drc.c index ad5984eba4..1fa3dee6c7 100644 --- a/libdispatch/drc.c +++ b/libdispatch/drc.c @@ -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 */ diff --git a/libdispatch/dreg.c b/libdispatch/dreg.c new file mode 100644 index 0000000000..5bb9005a18 --- /dev/null +++ b/libdispatch/dreg.c @@ -0,0 +1,46 @@ +/* + * Copyright 2018, University Corporation for Atmospheric Research + * See netcdf/COPYRIGHT file for copying and redistribution conditions. + */ + +#include "config.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +//#include + +__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); +} diff --git a/libdispatch/dutil.c b/libdispatch/dutil.c index 5ab57c9363..bf44be72c5 100644 --- a/libdispatch/dutil.c +++ b/libdispatch/dutil.c @@ -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; diff --git a/libdispatch/ncexhash.c b/libdispatch/ncexhash.c index 2d54be82e9..dcaa919dca 100644 --- a/libdispatch/ncexhash.c +++ b/libdispatch/ncexhash.c @@ -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* diff --git a/libdispatch/nclog.c b/libdispatch/nclog.c index ae685d7985..823c83228b 100644 --- a/libdispatch/nclog.c +++ b/libdispatch/nclog.c @@ -281,6 +281,13 @@ ncuntrace(const char* fcn, int err, const char* fmt, ...) return err; } +int +ncthrow(int err,const char* file,int line) +{ + if(err == 0) return err; + return ncbreakpoint(err); +} + int ncbreakpoint(int err) { diff --git a/libhdf5/hdf5debug.c b/libhdf5/hdf5debug.c index 3a497d2f9c..4eed2c5bf6 100644 --- a/libhdf5/hdf5debug.c +++ b/libhdf5/hdf5debug.c @@ -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 diff --git a/libhdf5/hdf5debug.h b/libhdf5/hdf5debug.h index caa26d25a3..996e787107 100644 --- a/libhdf5/hdf5debug.h +++ b/libhdf5/hdf5debug.h @@ -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) diff --git a/libhdf5/hdf5open.c b/libhdf5/hdf5open.c index c20e349bad..f3ede3ede4 100644 --- a/libhdf5/hdf5open.c +++ b/libhdf5/hdf5open.c @@ -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 @@ nc4_open_file(const char *path, int mode, void* parameters, int ncid) 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); diff --git a/liblib/Makefile.am b/liblib/Makefile.am index e0ff052be2..3609485903 100644 --- a/liblib/Makefile.am +++ b/liblib/Makefile.am @@ -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... diff --git a/libncpoco/Makefile.am b/libncpoco/Makefile.am index 0a553cbd43..7c71399fba 100755 --- a/libncpoco/Makefile.am +++ b/libncpoco/Makefile.am @@ -17,10 +17,14 @@ libncpoco_la_LIBADD = libncpoco_la_LDFLAGS = libncpoco_la_SOURCES = ncpoco.c ncpoco.h -if ISMSVC +if ! ISMSVC +if ! ISMINGW +libncpoco_la_SOURCES += cp_unix.c +else libncpoco_la_SOURCES += cp_win32.c +endif else -libncpoco_la_SOURCES += cp_unix.c +libncpoco_la_SOURCES += cp_win32.c endif EXTRA_DIST = CMakeLists.txt README.md COPYRIGHT diff --git a/libncxml/Makefile.am b/libncxml/Makefile.am index 7ff656932e..0c175854db 100644 --- a/libncxml/Makefile.am +++ b/libncxml/Makefile.am @@ -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 /d' | \ - sed -e 's|//\(.*\)|/*\1*/|' \ - sed -e 's|//\(.*\)|/*\1*/|' \ - cat >./ezxml.c - sed -e 's|//\(.*\)|/*\1*/|' ./ezxml.h - sed -i .bak 's//\n#ifdef HAVE_UNISTD_H\n#include \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 '//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 + diff --git a/libncxml/ezxml.c b/libncxml/ezxml.c index 96af31f97d..d64fc2ec0e 100644 --- a/libncxml/ezxml.c +++ b/libncxml/ezxml.c @@ -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*/ diff --git a/libncxml/ezxml.h b/libncxml/ezxml.h index a39334acee..f38e966fb1 100644 --- a/libncxml/ezxml.h +++ b/libncxml/ezxml.h @@ -29,9 +29,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#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); diff --git a/libncxml/ncxml_xml2.c b/libncxml/ncxml_xml2.c index 67e5f53f19..cfe49a3f3e 100644 --- a/libncxml/ncxml_xml2.c +++ b/libncxml/ncxml_xml2.c @@ -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; diff --git a/libnczarr/Makefile.am b/libnczarr/Makefile.am index 8803e30dd8..22720653f8 100644 --- a/libnczarr/Makefile.am +++ b/libnczarr/Makefile.am @@ -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 += diff --git a/libnczarr/zattr.c b/libnczarr/zattr.c index 33643e01d0..9c6e397e51 100644 --- a/libnczarr/zattr.c +++ b/libnczarr/zattr.c @@ -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; } diff --git a/libnczarr/zclose.c b/libnczarr/zclose.c index fd8234fd69..f287a2f5a0 100644 --- a/libnczarr/zclose.c +++ b/libnczarr/zclose.c @@ -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); diff --git a/libnczarr/zcreate.c b/libnczarr/zcreate.c index 896a91cb66..02da9a3309 100644 --- a/libnczarr/zcreate.c +++ b/libnczarr/zcreate.c @@ -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); diff --git a/libnczarr/zdebug.c b/libnczarr/zdebug.c index 19fdb1f6a9..26b2180d6e 100644 --- a/libnczarr/zdebug.c +++ b/libnczarr/zdebug.c @@ -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*/ /**************************************************/ diff --git a/libnczarr/zdebug.h b/libnczarr/zdebug.h index 8502cb0bc3..4ed97975dc 100644 --- a/libnczarr/zdebug.h +++ b/libnczarr/zdebug.h @@ -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 diff --git a/libnczarr/zdispatch.c b/libnczarr/zdispatch.c index 3add1431ac..e90f0291a6 100644 --- a/libnczarr/zdispatch.c +++ b/libnczarr/zdispatch.c @@ -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*/ diff --git a/libnczarr/zfile.c b/libnczarr/zfile.c index e0a90936fe..dfed6ccd5b 100644 --- a/libnczarr/zfile.c +++ b/libnczarr/zfile.c @@ -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); diff --git a/libnczarr/zfilter.c b/libnczarr/zfilter.c index 9039d45c29..3d64b66d67 100644 --- a/libnczarr/zfilter.c +++ b/libnczarr/zfilter.c @@ -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); } diff --git a/libnczarr/zinternal.c b/libnczarr/zinternal.c index 0ba9f76287..a90a144b35 100644 --- a/libnczarr/zinternal.c +++ b/libnczarr/zinternal.c @@ -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 diff --git a/libnczarr/zmap.c b/libnczarr/zmap.c index 3ef9423b53..46e1ac8345 100644 --- a/libnczarr/zmap.c +++ b/libnczarr/zmap.c @@ -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: diff --git a/libnczarr/zmap_file.c b/libnczarr/zmap_file.c index efb862190f..1cd51c5392 100755 --- a/libnczarr/zmap_file.c +++ b/libnczarr/zmap_file.c @@ -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 diff --git a/libnczarr/zmap_zip.c b/libnczarr/zmap_zip.c index d87a73fd6d..a0ad1a58ed 100755 --- a/libnczarr/zmap_zip.c +++ b/libnczarr/zmap_zip.c @@ -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); diff --git a/libnczarr/zopen.c b/libnczarr/zopen.c index 4c850c1ada..8d8644e0fa 100644 --- a/libnczarr/zopen.c +++ b/libnczarr/zopen.c @@ -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))) diff --git a/libnczarr/zsync.c b/libnczarr/zsync.c index 03f0fa4c1d..9241badea8 100644 --- a/libnczarr/zsync.c +++ b/libnczarr/zsync.c @@ -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;jdimids[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; diff --git a/libnczarr/ztracedispatch.h b/libnczarr/ztracedispatch.h index 63e81b5ef5..3db5ffb98c 100644 --- a/libnczarr/ztracedispatch.h +++ b/libnczarr/ztracedispatch.h @@ -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, }; diff --git a/libnczarr/zxcache.c b/libnczarr/zxcache.c index e8602af477..f5cbd6c24f 100644 --- a/libnczarr/zxcache.c +++ b/libnczarr/zxcache.c @@ -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); diff --git a/libsrc/s3io.c b/libsrc/s3io.c index e9a88173f4..7f120e3197 100644 --- a/libsrc/s3io.c +++ b/libsrc/s3io.c @@ -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; diff --git a/libsrc/winceio.c b/libsrc/winceio.c index 5c9652eec3..45b5d2e159 100644 --- a/libsrc/winceio.c +++ b/libsrc/winceio.c @@ -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; diff --git a/nc_test/tst_inmemory.c b/nc_test/tst_inmemory.c index 475a3060c0..fa1e8b76f3 100644 --- a/nc_test/tst_inmemory.c +++ b/nc_test/tst_inmemory.c @@ -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; diff --git a/nc_test4/findplugin.in b/nc_test4/findplugin.in index 3166b42c86..f1623e73aa 100644 --- a/nc_test4/findplugin.in +++ b/nc_test4/findplugin.in @@ -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 diff --git a/nc_test4/tst_quantize.c b/nc_test4/tst_quantize.c index a465edecf0..1c28f97aae 100644 --- a/nc_test4/tst_quantize.c +++ b/nc_test4/tst_quantize.c @@ -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; } diff --git a/nc_test4/tst_udf.c b/nc_test4/tst_udf.c index b4e390e84d..43d44a016c 100644 --- a/nc_test4/tst_udf.c +++ b/nc_test4/tst_udf.c @@ -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 diff --git a/ncdap_test/t_misc.c b/ncdap_test/t_misc.c index 44012bb693..6c01c45bba 100644 --- a/ncdap_test/t_misc.c +++ b/ncdap_test/t_misc.c @@ -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); diff --git a/ncdap_test/tst_urls.sh b/ncdap_test/tst_urls.sh index a21154ec7a..007ad53483 100644 --- a/ncdap_test/tst_urls.sh +++ b/ncdap_test/tst_urls.sh @@ -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 diff --git a/ncdump/Makefile.am b/ncdump/Makefile.am index 9c38af2481..6f1cadb191 100644 --- a/ncdump/Makefile.am +++ b/ncdump/Makefile.am @@ -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 diff --git a/ncdump/cdl/Makefile.am b/ncdump/cdl/Makefile.am index 45b76c7713..bd6f693ade 100644 --- a/ncdump/cdl/Makefile.am +++ b/ncdump/cdl/Makefile.am @@ -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 \ diff --git a/ncdump/cdl/ref_keyword.cdl b/ncdump/cdl/ref_keyword.cdl index f3c5686ef2..8963582a4e 100644 --- a/ncdump/cdl/ref_keyword.cdl +++ b/ncdump/cdl/ref_keyword.cdl @@ -1,9 +1,8 @@ netcdf file { variables: -int data; -data : _FillValue = 0; - + int data ; + data :_FillValue = 0 ; data: -data = 177; + data = 177 ; } diff --git a/ncdump/ncpathcvt.c b/ncdump/ncpathcvt.c index 54638dcbca..eb79359ad2 100755 --- a/ncdump/ncpathcvt.c +++ b/ncdump/ncpathcvt.c @@ -24,23 +24,25 @@ #include "netcdf.h" #include "ncpathmgr.h" -/* -Synopsis - -pathcvt [-u|-w|-m|-c] [-e] [-d ] PATH - -Options - -e add backslash escapes to '\' and ' ' - -d 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 ] [-B] [-k] [-p] PATH\n" +"Options\n" +" -h help" +" -e add backslash escapes to '\' and ' '\n" +" -d use driveletter when needed; defaults to 'c'\n" +" -B convert occurrences of 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; } diff --git a/ncdump/ref_pathcvt.txt b/ncdump/ref_pathcvt.txt index a883135c25..c6d2fb7dea 100644 --- a/ncdump/ref_pathcvt.txt +++ b/ncdump/ref_pathcvt.txt @@ -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| diff --git a/ncdump/run_back_comp_tests.sh b/ncdump/run_back_comp_tests.sh index fa675f8c19..3eac829ec5 100755 --- a/ncdump/run_back_comp_tests.sh +++ b/ncdump/run_back_comp_tests.sh @@ -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 diff --git a/ncdump/test_keywords.sh b/ncdump/test_keywords.sh index 24b0208ea7..5b193dfc96 100755 --- a/ncdump/test_keywords.sh +++ b/ncdump/test_keywords.sh @@ -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 diff --git a/ncdump/testpathcvt.sh b/ncdump/testpathcvt.sh index 88f952c5e5..d1e5e36a5e 100755 --- a/ncdump/testpathcvt.sh +++ b/ncdump/testpathcvt.sh @@ -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 +echo -n "path: $T: |$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 diff --git a/ncdump/tst_nccopy3.sh b/ncdump/tst_nccopy3.sh index 449e896865..0436392b47 100755 --- a/ncdump/tst_nccopy3.sh +++ b/ncdump/tst_nccopy3.sh @@ -8,6 +8,7 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi . ../test_common.sh + set -e echo "" diff --git a/ncdump/tst_nccopy4.sh b/ncdump/tst_nccopy4.sh index 4ffdb15502..9996dfbf0f 100755 --- a/ncdump/tst_nccopy4.sh +++ b/ncdump/tst_nccopy4.sh @@ -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 diff --git a/ncgen/bytebuffer.c b/ncgen/bytebuffer.c index 4acf2d5241..e0446a6c39 100644 --- a/ncgen/bytebuffer.c +++ b/ncgen/bytebuffer.c @@ -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; diff --git a/ncgen/data.c b/ncgen/data.c index 7574efae1e..b894bf84e9 100644 --- a/ncgen/data.c +++ b/ncgen/data.c @@ -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)); diff --git a/ncgen/ncgen.1 b/ncgen/ncgen.1 index a4239905ce..d527d97141 100644 --- a/ncgen/ncgen.1 +++ b/ncgen/ncgen.1 @@ -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 diff --git a/ncgen/ncgen.l b/ncgen/ncgen.l index 8166e02499..d382d8154d 100644 --- a/ncgen/ncgen.l +++ b/ncgen/ncgen.l @@ -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) { diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y index feba80248e..737bdce526 100644 --- a/ncgen/ncgen.y +++ b/ncgen/ncgen.y @@ -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 ident typename primtype dimd varspec attrdecl enumid path dimref fielddim fieldspec + varident %type typeref %type varref %type 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); diff --git a/ncgen/ncgenl.c b/ncgen/ncgenl.c index 2880e0e8d7..e2466af9a9 100644 --- a/ncgen/ncgenl.c +++ b/ncgen/ncgenl.c @@ -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) { diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c index d12ba56d54..8b70ec3e8f 100644 --- a/ncgen/ncgeny.c +++ b/ncgen/ncgeny.c @@ -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 . */ + along with this program. If not, see . */ /* 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" @@ -198,6 +198,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 @@ -215,7 +217,7 @@ static void yyerror(fmt,va_alist) const char* fmt; va_dcl; extern int lex_init(void); -#line 219 "ncgeny.c" +#line 221 "ncgeny.c" # ifndef YY_CAST # ifdef __cplusplus @@ -375,7 +377,8 @@ enum yysymbol_kind_t YYSYMBOL_constint = 129, /* constint */ YYSYMBOL_conststring = 130, /* conststring */ YYSYMBOL_constbool = 131, /* constbool */ - YYSYMBOL_ident = 132 /* ident */ + YYSYMBOL_varident = 132, /* varident */ + YYSYMBOL_ident = 133 /* ident */ }; typedef enum yysymbol_kind_t yysymbol_kind_t; @@ -533,12 +536,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 @@ -697,16 +706,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 5 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 424 +#define YYLAST 462 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 66 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 67 +#define YYNNTS 68 /* YYNRULES -- Number of rules. */ -#define YYNRULES 154 +#define YYNRULES 156 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 265 +#define YYNSTATES 267 /* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 311 @@ -758,25 +767,25 @@ 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, 237, 237, 243, 245, 252, 259, 259, 262, 271, - 261, 276, 277, 278, 282, 282, 284, 294, 294, 297, - 298, 299, 300, 303, 303, 306, 336, 338, 355, 364, - 376, 390, 423, 424, 427, 441, 442, 443, 444, 445, - 446, 447, 448, 449, 450, 451, 452, 455, 456, 457, - 460, 461, 464, 464, 466, 467, 471, 479, 489, 501, - 502, 503, 506, 507, 510, 510, 512, 534, 538, 542, - 571, 572, 575, 576, 580, 594, 598, 603, 632, 633, - 637, 638, 643, 653, 673, 684, 695, 714, 721, 721, - 724, 726, 728, 730, 732, 741, 752, 754, 756, 758, - 760, 762, 764, 766, 768, 770, 772, 774, 779, 786, - 795, 796, 797, 800, 801, 804, 808, 809, 813, 817, - 818, 823, 824, 828, 829, 830, 831, 832, 833, 837, - 841, 845, 847, 852, 853, 854, 855, 856, 857, 858, - 859, 860, 861, 862, 863, 867, 868, 872, 874, 876, - 878, 883, 887, 888, 894 + 0, 240, 240, 246, 248, 255, 262, 262, 265, 274, + 264, 279, 280, 281, 285, 285, 287, 297, 297, 300, + 301, 302, 303, 306, 306, 309, 339, 341, 358, 367, + 379, 393, 426, 427, 430, 444, 445, 446, 447, 448, + 449, 450, 451, 452, 453, 454, 455, 458, 459, 460, + 463, 464, 467, 467, 469, 470, 474, 482, 492, 504, + 505, 506, 509, 510, 513, 513, 515, 537, 541, 545, + 574, 575, 578, 579, 583, 597, 601, 606, 635, 636, + 640, 641, 646, 656, 676, 687, 698, 717, 724, 724, + 727, 729, 731, 733, 735, 744, 755, 757, 759, 761, + 763, 765, 767, 769, 771, 773, 775, 777, 782, 789, + 798, 799, 800, 803, 804, 807, 811, 812, 816, 820, + 821, 826, 827, 831, 832, 833, 834, 835, 836, 840, + 844, 848, 850, 855, 856, 857, 858, 859, 860, 861, + 862, 863, 864, 865, 866, 870, 871, 875, 877, 879, + 881, 886, 890, 891, 899, 900, 904 }; #endif @@ -816,7 +825,7 @@ static const char *const yytname[] = "datadecls", "datadecl", "datalist", "datalist0", "datalist1", "dataitem", "constdata", "econstref", "function", "arglist", "simpleconstant", "intlist", "constint", "conststring", "constbool", - "ident", YY_NULLPTR + "varident", "ident", YY_NULLPTR }; static const char * @@ -826,72 +835,57 @@ 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, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 123, 125, 59, - 44, 61, 40, 41, 42, 58 -}; -#endif - #define YYPACT_NINF (-147) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF (-109) +#define YYTABLE_NINF (-157) #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_int16 yypact[] = { - -12, -6, 56, -147, 1, -147, 229, -147, -147, -147, + -14, -35, 41, -147, -27, -147, 231, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, - -147, -147, -4, -147, -147, 385, -3, 28, 12, -147, - -147, 14, 19, 21, 26, 33, -16, 31, 143, 216, - 48, 229, 82, 82, 76, 8, 347, 84, -147, -147, - -1, 42, 43, 46, 47, 50, 52, 55, 59, 60, - 61, 62, 84, 63, 216, -147, -147, 58, 58, 58, - 58, 89, 291, 67, 229, 97, -147, -147, -147, -147, + -147, -147, -9, -147, -147, 423, -18, 15, -3, -147, + -147, 7, 25, 26, 32, 46, -25, -7, 145, 218, + 47, 231, 72, 72, 1, 49, 349, 74, -147, -147, + -4, 50, 52, 55, 56, 59, 60, 61, 62, 63, + 64, 65, 74, 35, 218, -147, -147, 45, 45, 45, + 45, 67, 293, 68, 231, 78, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, - -147, -147, -147, 347, -147, 69, -147, -147, -147, -147, - -147, -147, -147, 73, 79, 77, 78, 347, 82, 8, - 8, 76, 82, 76, 76, 82, 82, 347, 80, -147, - 119, -147, -147, -147, -147, -147, -147, 84, 81, -147, - 229, 85, 83, -147, 88, -147, 92, 229, 109, 10, - 347, 239, -147, 347, 347, 69, -147, 86, -147, -147, - -147, -147, -147, -147, -147, -147, 69, 385, 87, 98, - 91, 99, -147, 84, 64, 229, 101, -147, 385, -147, - 385, -147, -147, -147, -37, -147, 229, 69, 69, 8, - 304, 102, 84, -147, 84, 84, 84, -147, -147, -147, - -147, -147, 103, -147, 104, -147, -30, 105, -147, 385, - 108, 239, -147, -147, -147, -147, 110, -147, 111, -147, - 106, -147, 16, -147, 115, -147, -147, 84, -2, -147, - 347, 118, -147, -147, 140, -147, 84, 30, -147, -147, - 84, 8, -147, 117, 0, -147, -147, 69, -147, 122, - -147, -147, -147, 9, -147, -147, -147, -2, -147, 229, - 30, -147, -147, -147, -147 + -147, -147, -147, 349, -147, 69, -147, -147, -147, -147, + -147, -147, -147, 73, 79, 76, 77, 349, 72, 49, + 49, 1, 72, 1, 1, 72, 72, 349, 82, -147, + 109, -147, -147, -147, -147, -147, -147, 74, 81, -147, + 231, 84, 80, -147, 85, -147, 88, 231, 118, 36, + 349, 241, -147, 349, 349, 69, -147, 93, -147, -147, + -147, -147, -147, -147, -147, -147, 69, 423, 91, 98, + 95, 97, -147, 74, 29, 231, 100, -147, 387, -147, + 423, -147, -147, -147, 9, -147, 231, 69, 69, 49, + 306, 101, 74, -147, 74, 74, 74, -147, -147, -147, + -147, -147, 103, -147, 99, -147, 106, -147, 105, 107, + -147, 423, 110, 241, -147, -147, -147, -147, 112, -147, + 116, -147, 115, -147, 43, -147, 117, -147, -147, 3, + -2, -147, 349, 120, -147, -147, 142, -147, 74, 28, + -147, -147, 74, 49, -147, -147, 17, -147, -147, 69, + -147, 83, -147, -147, -147, 22, -147, -147, -147, -2, + -147, 231, 28, -147, -147, -147, -147 }; - /* 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_uint8 yydefact[] = { 0, 0, 0, 3, 0, 1, 88, 2, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 154, 109, 0, 6, 87, 0, 85, 11, 0, 86, + 156, 109, 0, 6, 87, 0, 85, 11, 0, 86, 108, 0, 0, 0, 0, 0, 0, 0, 0, 12, 47, 88, 0, 0, 0, 0, 118, 0, 4, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -909,170 +903,178 @@ static const yytype_uint8 yydefact[] = 0, 0, 50, 0, 0, 61, 0, 64, 0, 65, 111, 5, 122, 120, 0, 131, 88, 97, 94, 0, 0, 0, 0, 85, 0, 0, 0, 51, 55, 58, - 57, 56, 0, 62, 66, 67, 70, 0, 84, 112, - 0, 0, 130, 6, 146, 31, 0, 32, 34, 75, - 78, 29, 0, 26, 0, 30, 63, 0, 0, 69, - 118, 0, 113, 132, 9, 33, 0, 0, 77, 25, - 0, 0, 68, 70, 0, 72, 74, 115, 114, 0, - 76, 83, 82, 0, 80, 27, 28, 0, 71, 88, - 0, 79, 73, 10, 81 + 57, 56, 0, 62, 154, 155, 66, 67, 70, 0, + 84, 112, 0, 0, 130, 6, 146, 31, 0, 32, + 34, 75, 78, 29, 0, 26, 0, 30, 63, 0, + 0, 69, 118, 0, 113, 132, 9, 33, 0, 0, + 77, 25, 0, 0, 154, 68, 0, 72, 74, 115, + 114, 0, 76, 83, 82, 0, 80, 27, 28, 0, + 71, 88, 0, 79, 73, 10, 81 }; - /* YYPGOTO[NTERM-NUM]. */ +/* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -147, -147, -147, -147, -5, -31, -147, -147, -147, -147, - -147, -130, 131, -147, -25, -147, -147, -57, -147, -147, - -147, -147, 6, -26, -147, -147, 66, -147, 29, -147, - -147, -147, 24, -147, -147, -24, -147, -147, -56, -147, - -32, -147, -147, -53, -147, -33, -15, -40, -28, -44, - -147, -147, 2, -100, -147, -147, 65, -147, -147, -147, - -147, -146, -147, -41, -34, -103, -22 + -147, -147, -147, -147, -5, -32, -147, -147, -147, -147, + -147, -134, 121, -147, 30, -147, -147, -58, -147, -147, + -147, -147, -8, -19, -147, -147, 57, -147, 31, -147, + -147, -147, 23, -147, -147, -26, -147, -147, -54, -147, + -37, -147, -147, -56, -147, -33, -15, -40, -28, -44, + -147, -147, 0, -88, -147, -147, 58, -147, -147, -147, + -147, -146, -147, -41, -34, -60, -147, -22 }; - /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_uint8 yydefgoto[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = { - 0, 2, 4, 7, 23, 36, 49, 186, 249, 40, - 64, 128, 65, 66, 133, 67, 222, 223, 68, 69, + 0, 2, 4, 7, 23, 36, 49, 186, 251, 40, + 64, 128, 65, 66, 133, 67, 224, 225, 68, 69, 70, 190, 191, 24, 75, 140, 141, 142, 143, 144, - 148, 175, 176, 177, 204, 205, 229, 244, 245, 218, - 219, 238, 253, 254, 207, 25, 26, 27, 28, 29, - 181, 209, 210, 105, 106, 107, 108, 109, 110, 111, - 184, 112, 157, 84, 85, 86, 30 + 148, 175, 176, 177, 206, 207, 231, 246, 247, 220, + 221, 240, 255, 256, 209, 25, 26, 27, 28, 29, + 181, 211, 212, 105, 106, 107, 108, 109, 110, 111, + 184, 112, 157, 84, 85, 86, 208, 30 }; - /* 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_int16 yytable[] = { - 35, 76, 104, 149, 87, 185, 72, 169, 78, 79, - 37, 73, 20, 71, 20, 20, 61, 155, 160, 1, - 162, 163, 47, 211, 113, 114, 212, 166, 116, 80, - 81, 72, 228, 82, 83, -108, 73, 21, 71, 31, - 129, 115, 48, 134, 135, 136, 145, 32, 33, 34, - 3, 251, 146, 187, 188, 252, 5, 37, 6, 104, - 257, 39, 38, 258, 221, 233, 225, 200, 182, 260, - 150, 41, 261, 104, 239, 42, 240, 74, 158, 159, - 43, 113, 44, 104, 156, 80, 81, 45, 161, 82, - 83, 164, 165, 77, 46, 113, 50, 80, 81, 77, - 20, 82, 83, 117, 118, 113, 104, 119, 120, 104, - 104, 121, 145, 122, 178, 129, 123, 132, 146, 179, - 124, 125, 126, 127, 137, 130, 139, 147, 113, 150, - 247, 113, 113, 201, 192, 151, 152, 167, 153, 154, - 168, 180, 178, 173, 172, 170, 189, 179, 214, 174, - 194, 199, 193, -58, 196, 195, 206, 192, 197, 20, - 203, 217, 226, 37, 227, 208, 230, 232, 237, 235, - 220, 236, 129, 224, 129, 193, 241, 248, 47, 228, - 259, 213, 234, 255, 246, 51, 104, 52, 53, 54, - 55, 56, 57, 58, 208, 131, 216, 59, 60, 202, - 256, 262, 198, 242, 250, 243, 171, 264, 113, 0, - 0, 231, 0, 246, 220, 183, 0, 0, 224, 263, + 35, 76, 104, 169, 87, 185, 72, 20, 78, 79, + 37, 73, 20, 47, 20, 149, 61, 1, 77, 244, + 71, 3, 80, 81, 113, 114, 82, 83, 116, 155, + 6, 72, 200, 48, 31, 205, 73, 21, 115, 166, + 129, 5, 32, 33, 34, 71, 145, 38, 39, 253, + 80, 81, 146, 254, 82, 83, 41, 37, 50, 104, + 223, 160, 227, 162, 163, 187, 188, 235, 42, 213, + 80, 81, 214, 104, 82, 83, 74, 259, 158, 159, + 260, 113, 262, 104, 156, 263, 43, 44, 161, 77, + 20, 164, 165, 45, 182, 113, 150, 130, 134, 135, + 136, 241, 137, 242, 132, 113, 104, 46, 147, 104, + 104, 117, 145, 118, 178, 129, 119, 120, 146, 179, + 121, 122, 123, 124, 125, 126, 127, 139, 113, 150, + 168, 113, 113, 201, 192, 151, 152, 153, 154, 167, + 173, 261, 178, 172, 249, 170, 174, 179, 216, -58, + 180, 199, 193, 189, 194, 195, 197, 192, 196, 203, + 219, 20, 228, 37, -156, 210, 229, 230, 232, 234, + 222, 237, 129, 226, 129, 193, 238, 239, 243, 250, + 47, 215, 218, 236, 257, 131, 248, 51, 104, 52, + 53, 54, 55, 56, 57, 58, 210, 171, 202, 59, + 60, 252, 258, 245, 198, 264, 266, 0, 183, 0, + 113, 233, 0, 0, 0, 248, 222, 0, 0, 0, + 226, 265, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, + 0, 0, 62, 0, 63, 0, 0, 21, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 22, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, - 62, 0, 63, 0, 0, 21, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 98, 99, 21, 0, + 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 138, 0, 0, 0, 0, + 0, 0, 0, 0, 217, 20, 88, 89, 90, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 0, 0, + 0, 0, 0, 0, 0, 0, 100, 0, 21, 101, + 102, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 204, 0, 0, 103, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 205, + 0, 0, 0, 0, 0, 0, 21, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 22, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 138, 0, 0, 0, 0, 0, 0, - 0, 0, 215, 20, 88, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 98, 99, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 0, 21, 101, 102, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 0, 0, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 21 + 0, 0, 21 }; static const yytype_int16 yycheck[] = { - 22, 41, 46, 103, 45, 151, 39, 137, 42, 43, - 25, 39, 16, 39, 16, 16, 38, 117, 121, 31, - 123, 124, 38, 60, 46, 47, 63, 127, 50, 21, - 22, 64, 62, 25, 26, 65, 64, 39, 64, 43, - 62, 42, 58, 68, 69, 70, 74, 51, 52, 53, - 56, 21, 74, 153, 154, 25, 0, 72, 57, 103, - 60, 33, 65, 63, 194, 211, 196, 3, 58, 60, - 60, 59, 63, 117, 58, 61, 60, 29, 119, 120, - 61, 103, 61, 127, 118, 21, 22, 61, 122, 25, - 26, 125, 126, 17, 61, 117, 65, 21, 22, 17, - 16, 25, 26, 61, 61, 127, 150, 61, 61, 153, - 154, 61, 140, 61, 147, 137, 61, 59, 140, 147, - 61, 61, 61, 61, 35, 62, 59, 30, 150, 60, - 230, 153, 154, 174, 167, 62, 57, 57, 61, 61, - 21, 32, 175, 60, 59, 64, 60, 175, 189, 61, - 63, 173, 167, 61, 63, 57, 178, 190, 59, 16, - 59, 59, 59, 178, 60, 180, 61, 59, 62, 59, - 192, 60, 194, 195, 196, 190, 61, 59, 38, 62, - 58, 186, 213, 240, 228, 42, 230, 44, 45, 46, - 47, 48, 49, 50, 209, 64, 190, 54, 55, 175, - 241, 257, 173, 227, 236, 227, 140, 260, 230, -1, - -1, 209, -1, 257, 236, 150, -1, -1, 240, 259, + 22, 41, 46, 137, 45, 151, 39, 16, 42, 43, + 25, 39, 16, 38, 16, 103, 38, 31, 17, 16, + 39, 56, 21, 22, 46, 47, 25, 26, 50, 117, + 57, 64, 3, 58, 43, 32, 64, 39, 42, 127, + 62, 0, 51, 52, 53, 64, 74, 65, 33, 21, + 21, 22, 74, 25, 25, 26, 59, 72, 65, 103, + 194, 121, 196, 123, 124, 153, 154, 213, 61, 60, + 21, 22, 63, 117, 25, 26, 29, 60, 119, 120, + 63, 103, 60, 127, 118, 63, 61, 61, 122, 17, + 16, 125, 126, 61, 58, 117, 60, 62, 68, 69, + 70, 58, 35, 60, 59, 127, 150, 61, 30, 153, + 154, 61, 140, 61, 147, 137, 61, 61, 140, 147, + 61, 61, 61, 61, 61, 61, 61, 59, 150, 60, + 21, 153, 154, 174, 167, 62, 57, 61, 61, 57, + 60, 58, 175, 59, 232, 64, 61, 175, 189, 61, + 32, 173, 167, 60, 63, 57, 59, 190, 63, 59, + 59, 16, 59, 178, 65, 180, 60, 62, 61, 59, + 192, 59, 194, 195, 196, 190, 60, 62, 61, 59, + 38, 186, 190, 215, 242, 64, 230, 42, 232, 44, + 45, 46, 47, 48, 49, 50, 211, 140, 175, 54, + 55, 238, 243, 229, 173, 259, 262, -1, 150, -1, + 232, 211, -1, -1, -1, 259, 238, -1, -1, -1, + 242, 261, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, + -1, -1, 34, -1, 36, -1, -1, 39, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 65, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, -1, -1, -1, -1, - 34, -1, 36, -1, -1, 39, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 39, -1, + 14, 15, 16, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 39, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 62, -1, -1, -1, -1, + -1, -1, -1, -1, 58, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, -1, -1, + -1, -1, -1, -1, -1, -1, 37, -1, 39, 40, + 41, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, -1, -1, 57, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, + -1, -1, -1, -1, -1, -1, 39, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 65, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 39, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 62, -1, -1, -1, -1, -1, -1, - -1, -1, 58, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, -1, -1, -1, -1, - -1, -1, -1, -1, 37, -1, 39, 40, 41, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, -1, -1, 57, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 39 + -1, -1, 39 }; - /* 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_uint8 yystos[] = { 0, 31, 67, 56, 68, 0, 57, 69, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 39, 65, 70, 89, 111, 112, 113, 114, 115, - 132, 43, 51, 52, 53, 132, 71, 112, 65, 33, + 133, 43, 51, 52, 53, 133, 71, 112, 65, 33, 75, 59, 61, 61, 61, 61, 61, 38, 58, 72, 65, 42, 44, 45, 46, 47, 48, 49, 50, 54, - 55, 132, 34, 36, 76, 78, 79, 81, 84, 85, + 55, 133, 34, 36, 76, 78, 79, 81, 84, 85, 86, 89, 111, 114, 29, 90, 113, 17, 130, 130, 21, 22, 25, 26, 129, 130, 131, 129, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 37, 40, 41, 57, 115, 119, 120, 121, 122, 123, - 124, 125, 127, 132, 132, 42, 132, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 77, 132, + 124, 125, 127, 133, 133, 42, 133, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 77, 133, 62, 78, 59, 80, 80, 80, 80, 35, 62, 59, - 91, 92, 93, 94, 95, 114, 132, 30, 96, 119, + 91, 92, 93, 94, 95, 114, 133, 30, 96, 119, 60, 62, 57, 61, 61, 119, 130, 128, 129, 129, 131, 130, 131, 131, 130, 130, 119, 57, 21, 77, 64, 92, 59, 60, 61, 97, 98, 99, 111, 114, 32, 116, 58, 122, 126, 127, 73, 119, 119, 60, - 87, 88, 111, 112, 63, 57, 63, 59, 94, 132, - 3, 129, 98, 59, 100, 101, 132, 110, 112, 117, - 118, 60, 63, 70, 129, 58, 88, 59, 105, 106, - 132, 77, 82, 83, 132, 77, 59, 60, 62, 102, - 61, 118, 59, 127, 71, 59, 60, 62, 107, 58, - 60, 61, 101, 132, 103, 104, 115, 119, 59, 74, - 106, 21, 25, 108, 109, 83, 129, 60, 63, 58, - 60, 63, 104, 113, 109 + 87, 88, 111, 112, 63, 57, 63, 59, 94, 133, + 3, 129, 98, 59, 16, 32, 100, 101, 132, 110, + 112, 117, 118, 60, 63, 70, 129, 58, 88, 59, + 105, 106, 133, 77, 82, 83, 133, 77, 59, 60, + 62, 102, 61, 118, 59, 127, 71, 59, 60, 62, + 107, 58, 60, 61, 16, 101, 103, 104, 115, 119, + 59, 74, 106, 21, 25, 108, 109, 83, 129, 60, + 63, 58, 60, 63, 104, 113, 109 }; - /* 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_uint8 yyr1[] = { 0, 66, 67, 68, 69, 70, 71, 71, 73, 74, @@ -1090,10 +1092,10 @@ static const yytype_uint8 yyr1[] = 121, 122, 122, 123, 123, 123, 123, 123, 123, 124, 125, 126, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 129, 129, 129, - 129, 130, 131, 131, 132 + 129, 130, 131, 131, 132, 132, 133 }; - /* 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, 3, 1, 4, 5, 0, 2, 0, 0, @@ -1111,7 +1113,7 @@ static const yytype_int8 yyr2[] = 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 4, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, - 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1 }; @@ -1123,6 +1125,7 @@ enum { YYENOMEM = -2 }; #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab +#define YYNOMEM goto yyexhaustedlab #define YYRECOVERING() (!!yyerrstatus) @@ -1163,10 +1166,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) \ @@ -1193,10 +1193,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 @@ -1651,6 +1647,7 @@ yyparse (void) YYDPRINTF ((stderr, "Starting parse\n")); yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; @@ -1676,7 +1673,7 @@ yyparse (void) 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. */ @@ -1704,7 +1701,7 @@ yyparse (void) # else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + YYNOMEM; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; @@ -1715,7 +1712,7 @@ yyparse (void) 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 @@ -1737,6 +1734,7 @@ yyparse (void) } #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + if (yystate == YYFINAL) YYACCEPT; @@ -1849,19 +1847,19 @@ yyparse (void) switch (yyn) { case 2: /* ncdesc: NETCDF datasetid rootgroup */ -#line 240 "ncgen.y" +#line 243 "ncgen.y" {if (error_count > 0) YYABORT;} -#line 1855 "ncgeny.c" +#line 1853 "ncgeny.c" break; case 3: /* datasetid: DATASETID */ -#line 243 "ncgen.y" +#line 246 "ncgen.y" {createrootgroup(datasetname);} -#line 1861 "ncgeny.c" +#line 1859 "ncgeny.c" break; case 8: /* $@1: %empty */ -#line 262 "ncgen.y" +#line 265 "ncgen.y" { Symbol* id = (yyvsp[-1].sym); markcdf4("Group specification"); @@ -1869,29 +1867,29 @@ yyparse (void) yyerror("duplicate group declaration within parent group for %s", id->name); } -#line 1873 "ncgeny.c" +#line 1871 "ncgeny.c" break; case 9: /* $@2: %empty */ -#line 271 "ncgen.y" +#line 274 "ncgen.y" {listpop(groupstack);} -#line 1879 "ncgeny.c" +#line 1877 "ncgeny.c" break; case 12: /* typesection: TYPES */ -#line 277 "ncgen.y" +#line 280 "ncgen.y" {} -#line 1885 "ncgeny.c" +#line 1883 "ncgeny.c" break; case 13: /* typesection: TYPES typedecls */ -#line 279 "ncgen.y" +#line 282 "ncgen.y" {markcdf4("Type specification");} -#line 1891 "ncgeny.c" +#line 1889 "ncgeny.c" break; case 16: /* typename: ident */ -#line 285 "ncgen.y" +#line 288 "ncgen.y" { /* Use when defining a type */ (yyvsp[0].sym)->objectclass = NC_TYPE; if(dupobjectcheck(NC_TYPE,(yyvsp[0].sym))) @@ -1899,23 +1897,23 @@ yyparse (void) (yyvsp[0].sym)->name); listpush(typdefs,(void*)(yyvsp[0].sym)); } -#line 1903 "ncgeny.c" +#line 1901 "ncgeny.c" break; case 17: /* type_or_attr_decl: typedecl */ -#line 294 "ncgen.y" +#line 297 "ncgen.y" {} -#line 1909 "ncgeny.c" +#line 1907 "ncgeny.c" break; case 18: /* type_or_attr_decl: attrdecl ';' */ -#line 294 "ncgen.y" +#line 297 "ncgen.y" {} -#line 1915 "ncgeny.c" +#line 1913 "ncgeny.c" break; case 25: /* enumdecl: primtype ENUM typename '{' enumidlist '}' */ -#line 308 "ncgen.y" +#line 311 "ncgen.y" { int i; addtogroup((yyvsp[-3].sym)); /* sets prefix*/ @@ -1942,17 +1940,17 @@ yyparse (void) } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 1946 "ncgeny.c" +#line 1944 "ncgeny.c" break; case 26: /* enumidlist: enumid */ -#line 337 "ncgen.y" +#line 340 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 1952 "ncgeny.c" +#line 1950 "ncgeny.c" break; case 27: /* enumidlist: enumidlist ',' enumid */ -#line 339 "ncgen.y" +#line 342 "ncgen.y" { int i; (yyval.mark)=(yyvsp[-2].mark); @@ -1967,22 +1965,22 @@ yyparse (void) } listpush(stack,(void*)(yyvsp[0].sym)); } -#line 1971 "ncgeny.c" +#line 1969 "ncgeny.c" break; case 28: /* enumid: ident '=' constint */ -#line 356 "ncgen.y" +#line 359 "ncgen.y" { (yyvsp[-2].sym)->objectclass=NC_TYPE; (yyvsp[-2].sym)->subclass=NC_ECONST; (yyvsp[-2].sym)->typ.econst=(yyvsp[0].constant); (yyval.sym)=(yyvsp[-2].sym); } -#line 1982 "ncgeny.c" +#line 1980 "ncgeny.c" break; case 29: /* opaquedecl: OPAQUE_ '(' INT_CONST ')' typename */ -#line 365 "ncgen.y" +#line 368 "ncgen.y" { vercheck(NC_OPAQUE); addtogroup((yyvsp[0].sym)); /*sets prefix*/ @@ -1992,11 +1990,11 @@ yyparse (void) (yyvsp[0].sym)->typ.size=int32_val; (yyvsp[0].sym)->typ.alignment=ncaux_class_alignment(NC_OPAQUE); } -#line 1996 "ncgeny.c" +#line 1994 "ncgeny.c" break; case 30: /* vlendecl: typeref '(' '*' ')' typename */ -#line 377 "ncgen.y" +#line 380 "ncgen.y" { Symbol* basetype = (yyvsp[-4].sym); vercheck(NC_VLEN); @@ -2008,11 +2006,11 @@ yyparse (void) (yyvsp[0].sym)->typ.size=VLENSIZE; (yyvsp[0].sym)->typ.alignment=ncaux_class_alignment(NC_VLEN); } -#line 2012 "ncgeny.c" +#line 2010 "ncgeny.c" break; case 31: /* compounddecl: COMPOUND typename '{' fields '}' */ -#line 391 "ncgen.y" +#line 394 "ncgen.y" { int i,j; vercheck(NC_COMPOUND); @@ -2042,23 +2040,23 @@ yyparse (void) } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 2046 "ncgeny.c" +#line 2044 "ncgeny.c" break; case 32: /* fields: field ';' */ -#line 423 "ncgen.y" +#line 426 "ncgen.y" {(yyval.mark)=(yyvsp[-1].mark);} -#line 2052 "ncgeny.c" +#line 2050 "ncgeny.c" break; case 33: /* fields: fields field ';' */ -#line 424 "ncgen.y" +#line 427 "ncgen.y" {(yyval.mark)=(yyvsp[-2].mark);} -#line 2058 "ncgeny.c" +#line 2056 "ncgeny.c" break; case 34: /* field: typeref fieldlist */ -#line 428 "ncgen.y" +#line 431 "ncgen.y" { int i; (yyval.mark)=(yyvsp[0].mark); @@ -2070,107 +2068,107 @@ yyparse (void) f->typ.basetype = (yyvsp[-1].sym); } } -#line 2074 "ncgeny.c" +#line 2072 "ncgeny.c" break; case 35: /* primtype: CHAR_K */ -#line 441 "ncgen.y" +#line 444 "ncgen.y" { (yyval.sym) = primsymbols[NC_CHAR]; } -#line 2080 "ncgeny.c" +#line 2078 "ncgeny.c" break; case 36: /* primtype: BYTE_K */ -#line 442 "ncgen.y" +#line 445 "ncgen.y" { (yyval.sym) = primsymbols[NC_BYTE]; } -#line 2086 "ncgeny.c" +#line 2084 "ncgeny.c" break; case 37: /* primtype: SHORT_K */ -#line 443 "ncgen.y" +#line 446 "ncgen.y" { (yyval.sym) = primsymbols[NC_SHORT]; } -#line 2092 "ncgeny.c" +#line 2090 "ncgeny.c" break; case 38: /* primtype: INT_K */ -#line 444 "ncgen.y" +#line 447 "ncgen.y" { (yyval.sym) = primsymbols[NC_INT]; } -#line 2098 "ncgeny.c" +#line 2096 "ncgeny.c" break; case 39: /* primtype: FLOAT_K */ -#line 445 "ncgen.y" +#line 448 "ncgen.y" { (yyval.sym) = primsymbols[NC_FLOAT]; } -#line 2104 "ncgeny.c" +#line 2102 "ncgeny.c" break; case 40: /* primtype: DOUBLE_K */ -#line 446 "ncgen.y" +#line 449 "ncgen.y" { (yyval.sym) = primsymbols[NC_DOUBLE]; } -#line 2110 "ncgeny.c" +#line 2108 "ncgeny.c" break; case 41: /* primtype: UBYTE_K */ -#line 447 "ncgen.y" +#line 450 "ncgen.y" { vercheck(NC_UBYTE); (yyval.sym) = primsymbols[NC_UBYTE]; } -#line 2116 "ncgeny.c" +#line 2114 "ncgeny.c" break; case 42: /* primtype: USHORT_K */ -#line 448 "ncgen.y" +#line 451 "ncgen.y" { vercheck(NC_USHORT); (yyval.sym) = primsymbols[NC_USHORT]; } -#line 2122 "ncgeny.c" +#line 2120 "ncgeny.c" break; case 43: /* primtype: UINT_K */ -#line 449 "ncgen.y" +#line 452 "ncgen.y" { vercheck(NC_UINT); (yyval.sym) = primsymbols[NC_UINT]; } -#line 2128 "ncgeny.c" +#line 2126 "ncgeny.c" break; case 44: /* primtype: INT64_K */ -#line 450 "ncgen.y" +#line 453 "ncgen.y" { vercheck(NC_INT64); (yyval.sym) = primsymbols[NC_INT64]; } -#line 2134 "ncgeny.c" +#line 2132 "ncgeny.c" break; case 45: /* primtype: UINT64_K */ -#line 451 "ncgen.y" +#line 454 "ncgen.y" { vercheck(NC_UINT64); (yyval.sym) = primsymbols[NC_UINT64]; } -#line 2140 "ncgeny.c" +#line 2138 "ncgeny.c" break; case 46: /* primtype: STRING_K */ -#line 452 "ncgen.y" +#line 455 "ncgen.y" { vercheck(NC_STRING); (yyval.sym) = primsymbols[NC_STRING]; } -#line 2146 "ncgeny.c" +#line 2144 "ncgeny.c" break; case 48: /* dimsection: DIMENSIONS */ -#line 456 "ncgen.y" +#line 459 "ncgen.y" {} -#line 2152 "ncgeny.c" +#line 2150 "ncgeny.c" break; case 49: /* dimsection: DIMENSIONS dimdecls */ -#line 457 "ncgen.y" +#line 460 "ncgen.y" {} -#line 2158 "ncgeny.c" +#line 2156 "ncgeny.c" break; case 52: /* dim_or_attr_decl: dimdeclist */ -#line 464 "ncgen.y" +#line 467 "ncgen.y" {} -#line 2164 "ncgeny.c" +#line 2162 "ncgeny.c" break; case 53: /* dim_or_attr_decl: attrdecl */ -#line 464 "ncgen.y" +#line 467 "ncgen.y" {} -#line 2170 "ncgeny.c" +#line 2168 "ncgeny.c" break; case 56: /* dimdecl: dimd '=' constint */ -#line 472 "ncgen.y" +#line 475 "ncgen.y" { (yyvsp[-2].sym)->dim.declsize = (size_t)extractint((yyvsp[0].constant)); #ifdef GENDEBUG1 @@ -2178,11 +2176,11 @@ fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[-2].sym)->name,(unsigned long lon #endif reclaimconstant((yyvsp[0].constant)); } -#line 2182 "ncgeny.c" +#line 2180 "ncgeny.c" break; case 57: /* dimdecl: dimd '=' NC_UNLIMITED_K */ -#line 480 "ncgen.y" +#line 483 "ncgen.y" { (yyvsp[-2].sym)->dim.declsize = NC_UNLIMITED; (yyvsp[-2].sym)->dim.isunlimited = 1; @@ -2190,11 +2188,11 @@ fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[-2].sym)->name,(unsigned long lon fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); #endif } -#line 2194 "ncgeny.c" +#line 2192 "ncgeny.c" break; case 58: /* dimd: ident */ -#line 490 "ncgen.y" +#line 493 "ncgen.y" { (yyvsp[0].sym)->objectclass=NC_DIM; if(dupobjectcheck(NC_DIM,(yyvsp[0].sym))) @@ -2204,35 +2202,35 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyval.sym)=(yyvsp[0].sym); listpush(dimdefs,(void*)(yyvsp[0].sym)); } -#line 2208 "ncgeny.c" +#line 2206 "ncgeny.c" break; case 60: /* vasection: VARIABLES */ -#line 502 "ncgen.y" +#line 505 "ncgen.y" {} -#line 2214 "ncgeny.c" +#line 2212 "ncgeny.c" break; case 61: /* vasection: VARIABLES vadecls */ -#line 503 "ncgen.y" +#line 506 "ncgen.y" {} -#line 2220 "ncgeny.c" +#line 2218 "ncgeny.c" break; case 64: /* vadecl_or_attr: vardecl */ -#line 510 "ncgen.y" +#line 513 "ncgen.y" {} -#line 2226 "ncgeny.c" +#line 2224 "ncgeny.c" break; case 65: /* vadecl_or_attr: attrdecl */ -#line 510 "ncgen.y" +#line 513 "ncgen.y" {} -#line 2232 "ncgeny.c" +#line 2230 "ncgeny.c" break; case 66: /* vardecl: typeref varlist */ -#line 513 "ncgen.y" +#line 516 "ncgen.y" { int i; stackbase=(yyvsp[0].mark); @@ -2252,25 +2250,25 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 2256 "ncgeny.c" +#line 2254 "ncgeny.c" break; case 67: /* varlist: varspec */ -#line 535 "ncgen.y" +#line 538 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym)); } -#line 2264 "ncgeny.c" +#line 2262 "ncgeny.c" break; case 68: /* varlist: varlist ',' varspec */ -#line 539 "ncgen.y" +#line 542 "ncgen.y" {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2270 "ncgeny.c" +#line 2268 "ncgeny.c" break; - case 69: /* varspec: ident dimspec */ -#line 543 "ncgen.y" + case 69: /* varspec: varident dimspec */ +#line 546 "ncgen.y" { int i; Dimset dimset; @@ -2297,35 +2295,35 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); listsetlength(stack,stackbase);/* remove stack nodes*/ (yyval.sym) = var; } -#line 2301 "ncgeny.c" +#line 2299 "ncgeny.c" break; case 70: /* dimspec: %empty */ -#line 571 "ncgen.y" +#line 574 "ncgen.y" {(yyval.mark)=listlength(stack);} -#line 2307 "ncgeny.c" +#line 2305 "ncgeny.c" break; case 71: /* dimspec: '(' dimlist ')' */ -#line 572 "ncgen.y" +#line 575 "ncgen.y" {(yyval.mark)=(yyvsp[-1].mark);} -#line 2313 "ncgeny.c" +#line 2311 "ncgeny.c" break; case 72: /* dimlist: dimref */ -#line 575 "ncgen.y" +#line 578 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2319 "ncgeny.c" +#line 2317 "ncgeny.c" break; case 73: /* dimlist: dimlist ',' dimref */ -#line 577 "ncgen.y" +#line 580 "ncgen.y" {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2325 "ncgeny.c" +#line 2323 "ncgeny.c" break; case 74: /* dimref: path */ -#line 581 "ncgen.y" +#line 584 "ncgen.y" {Symbol* dimsym = (yyvsp[0].sym); dimsym->objectclass = NC_DIM; /* Find the actual dimension*/ @@ -2336,25 +2334,25 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } (yyval.sym)=dimsym; } -#line 2340 "ncgeny.c" +#line 2338 "ncgeny.c" break; case 75: /* fieldlist: fieldspec */ -#line 595 "ncgen.y" +#line 598 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym)); } -#line 2348 "ncgeny.c" +#line 2346 "ncgeny.c" break; case 76: /* fieldlist: fieldlist ',' fieldspec */ -#line 599 "ncgen.y" +#line 602 "ncgen.y" {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2354 "ncgeny.c" +#line 2352 "ncgeny.c" break; case 77: /* fieldspec: ident fielddimspec */ -#line 604 "ncgen.y" +#line 607 "ncgen.y" { int i; Dimset dimset; @@ -2381,35 +2379,35 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); listsetlength(stack,stackbase);/* remove stack nodes*/ (yyval.sym) = (yyvsp[-1].sym); } -#line 2385 "ncgeny.c" +#line 2383 "ncgeny.c" break; case 78: /* fielddimspec: %empty */ -#line 632 "ncgen.y" +#line 635 "ncgen.y" {(yyval.mark)=listlength(stack);} -#line 2391 "ncgeny.c" +#line 2389 "ncgeny.c" break; case 79: /* fielddimspec: '(' fielddimlist ')' */ -#line 633 "ncgen.y" +#line 636 "ncgen.y" {(yyval.mark)=(yyvsp[-1].mark);} -#line 2397 "ncgeny.c" +#line 2395 "ncgeny.c" break; case 80: /* fielddimlist: fielddim */ -#line 637 "ncgen.y" +#line 640 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2403 "ncgeny.c" +#line 2401 "ncgeny.c" break; case 81: /* fielddimlist: fielddimlist ',' fielddim */ -#line 639 "ncgen.y" +#line 642 "ncgen.y" {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2409 "ncgeny.c" +#line 2407 "ncgeny.c" break; case 82: /* fielddim: UINT_CONST */ -#line 644 "ncgen.y" +#line 647 "ncgen.y" { /* Anonymous integer dimension. Can only occur in type definitions*/ char anon[32]; @@ -2419,11 +2417,11 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = uint32_val; } -#line 2423 "ncgeny.c" +#line 2421 "ncgeny.c" break; case 83: /* fielddim: INT_CONST */ -#line 654 "ncgen.y" +#line 657 "ncgen.y" { /* Anonymous integer dimension. Can only occur in type definitions*/ char anon[32]; @@ -2437,11 +2435,11 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = int32_val; } -#line 2441 "ncgeny.c" +#line 2439 "ncgeny.c" break; case 84: /* varref: ambiguous_ref */ -#line 674 "ncgen.y" +#line 677 "ncgen.y" {Symbol* vsym = (yyvsp[0].sym); if(vsym->objectclass != NC_VAR) { derror("Undefined or forward referenced variable: %s",vsym->name); @@ -2449,11 +2447,11 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } (yyval.sym)=vsym; } -#line 2453 "ncgeny.c" +#line 2451 "ncgeny.c" break; case 85: /* typeref: ambiguous_ref */ -#line 685 "ncgen.y" +#line 688 "ncgen.y" {Symbol* tsym = (yyvsp[0].sym); if(tsym->objectclass != NC_TYPE) { derror("Undefined or forward referenced type: %s",tsym->name); @@ -2461,11 +2459,11 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } (yyval.sym)=tsym; } -#line 2465 "ncgeny.c" +#line 2463 "ncgeny.c" break; case 86: /* ambiguous_ref: path */ -#line 696 "ncgen.y" +#line 699 "ncgen.y" {Symbol* tvsym = (yyvsp[0].sym); Symbol* sym; /* disambiguate*/ tvsym->objectclass = NC_VAR; @@ -2484,53 +2482,53 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } (yyval.sym)=tvsym; } -#line 2488 "ncgeny.c" +#line 2486 "ncgeny.c" break; case 87: /* ambiguous_ref: primtype */ -#line 714 "ncgen.y" +#line 717 "ncgen.y" {(yyval.sym)=(yyvsp[0].sym);} -#line 2494 "ncgeny.c" +#line 2492 "ncgeny.c" break; case 88: /* attrdecllist: %empty */ -#line 721 "ncgen.y" +#line 724 "ncgen.y" {} -#line 2500 "ncgeny.c" +#line 2498 "ncgeny.c" break; case 89: /* attrdecllist: attrdecl ';' attrdecllist */ -#line 721 "ncgen.y" +#line 724 "ncgen.y" {} -#line 2506 "ncgeny.c" +#line 2504 "ncgeny.c" break; case 90: /* attrdecl: ':' _NCPROPS '=' conststring */ -#line 725 "ncgen.y" +#line 728 "ncgen.y" {(yyval.sym) = makespecial(_NCPROPS_FLAG,NULL,NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2512 "ncgeny.c" +#line 2510 "ncgeny.c" break; case 91: /* attrdecl: ':' _ISNETCDF4 '=' constbool */ -#line 727 "ncgen.y" +#line 730 "ncgen.y" {(yyval.sym) = makespecial(_ISNETCDF4_FLAG,NULL,NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2518 "ncgeny.c" +#line 2516 "ncgeny.c" break; case 92: /* attrdecl: ':' _SUPERBLOCK '=' constint */ -#line 729 "ncgen.y" +#line 732 "ncgen.y" {(yyval.sym) = makespecial(_SUPERBLOCK_FLAG,NULL,NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2524 "ncgeny.c" +#line 2522 "ncgeny.c" break; case 93: /* attrdecl: ':' ident '=' datalist */ -#line 731 "ncgen.y" +#line 734 "ncgen.y" { (yyval.sym)=makeattribute((yyvsp[-2].sym),NULL,NULL,(yyvsp[0].datalist),ATTRGLOBAL);} -#line 2530 "ncgeny.c" +#line 2528 "ncgeny.c" break; case 94: /* attrdecl: typeref ambiguous_ref ':' ident '=' datalist */ -#line 733 "ncgen.y" +#line 736 "ncgen.y" {Symbol* tsym = (yyvsp[-5].sym); Symbol* vsym = (yyvsp[-4].sym); Symbol* asym = (yyvsp[-2].sym); if(vsym->objectclass == NC_VAR) { (yyval.sym)=makeattribute(asym,vsym,tsym,(yyvsp[0].datalist),ATTRVAR); @@ -2539,11 +2537,11 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); YYABORT; } } -#line 2543 "ncgeny.c" +#line 2541 "ncgeny.c" break; case 95: /* attrdecl: ambiguous_ref ':' ident '=' datalist */ -#line 742 "ncgen.y" +#line 745 "ncgen.y" {Symbol* sym = (yyvsp[-4].sym); Symbol* asym = (yyvsp[-2].sym); if(sym->objectclass == NC_VAR) { (yyval.sym)=makeattribute(asym,sym,NULL,(yyvsp[0].datalist),ATTRVAR); @@ -2554,351 +2552,363 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); YYABORT; } } -#line 2558 "ncgeny.c" +#line 2556 "ncgeny.c" break; case 96: /* attrdecl: ambiguous_ref ':' _FILLVALUE '=' datalist */ -#line 753 "ncgen.y" +#line 756 "ncgen.y" {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),ISLIST);} -#line 2564 "ncgeny.c" +#line 2562 "ncgeny.c" break; case 97: /* attrdecl: typeref ambiguous_ref ':' _FILLVALUE '=' datalist */ -#line 755 "ncgen.y" +#line 758 "ncgen.y" {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),(yyvsp[-5].sym),(void*)(yyvsp[0].datalist),ISLIST);} -#line 2570 "ncgeny.c" +#line 2568 "ncgeny.c" break; case 98: /* attrdecl: ambiguous_ref ':' _STORAGE '=' conststring */ -#line 757 "ncgen.y" +#line 760 "ncgen.y" {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2576 "ncgeny.c" +#line 2574 "ncgeny.c" break; case 99: /* attrdecl: ambiguous_ref ':' _CHUNKSIZES '=' intlist */ -#line 759 "ncgen.y" +#line 762 "ncgen.y" {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),ISLIST);} -#line 2582 "ncgeny.c" +#line 2580 "ncgeny.c" break; case 100: /* attrdecl: ambiguous_ref ':' _FLETCHER32 '=' constbool */ -#line 761 "ncgen.y" +#line 764 "ncgen.y" {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2588 "ncgeny.c" +#line 2586 "ncgeny.c" break; case 101: /* attrdecl: ambiguous_ref ':' _DEFLATELEVEL '=' constint */ -#line 763 "ncgen.y" +#line 766 "ncgen.y" {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2594 "ncgeny.c" +#line 2592 "ncgeny.c" break; case 102: /* attrdecl: ambiguous_ref ':' _SHUFFLE '=' constbool */ -#line 765 "ncgen.y" +#line 768 "ncgen.y" {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2600 "ncgeny.c" +#line 2598 "ncgeny.c" break; case 103: /* attrdecl: ambiguous_ref ':' _ENDIANNESS '=' conststring */ -#line 767 "ncgen.y" +#line 770 "ncgen.y" {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2606 "ncgeny.c" +#line 2604 "ncgeny.c" break; case 104: /* attrdecl: ambiguous_ref ':' _FILTER '=' conststring */ -#line 769 "ncgen.y" +#line 772 "ncgen.y" {(yyval.sym) = makespecial(_FILTER_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2612 "ncgeny.c" +#line 2610 "ncgeny.c" break; case 105: /* attrdecl: ambiguous_ref ':' _CODECS '=' conststring */ -#line 771 "ncgen.y" +#line 774 "ncgen.y" {(yyval.sym) = makespecial(_CODECS_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2618 "ncgeny.c" +#line 2616 "ncgeny.c" break; case 106: /* attrdecl: ambiguous_ref ':' _NOFILL '=' constbool */ -#line 773 "ncgen.y" +#line 776 "ncgen.y" {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2624 "ncgeny.c" +#line 2622 "ncgeny.c" break; case 107: /* attrdecl: ':' _FORMAT '=' conststring */ -#line 775 "ncgen.y" +#line 778 "ncgen.y" {(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)(yyvsp[0].constant),ISCONST);} -#line 2630 "ncgeny.c" +#line 2628 "ncgeny.c" break; case 108: /* path: ident */ -#line 780 "ncgen.y" +#line 783 "ncgen.y" { (yyval.sym)=(yyvsp[0].sym); (yyvsp[0].sym)->ref.is_ref=1; (yyvsp[0].sym)->is_prefixed=0; setpathcurrent((yyvsp[0].sym)); } -#line 2641 "ncgeny.c" +#line 2639 "ncgeny.c" break; case 109: /* path: PATH */ -#line 787 "ncgen.y" +#line 790 "ncgen.y" { (yyval.sym)=(yyvsp[0].sym); (yyvsp[0].sym)->ref.is_ref=1; (yyvsp[0].sym)->is_prefixed=1; /* path is set in ncgen.l*/ } -#line 2652 "ncgeny.c" +#line 2650 "ncgeny.c" break; case 111: /* datasection: DATA */ -#line 796 "ncgen.y" +#line 799 "ncgen.y" {} -#line 2658 "ncgeny.c" +#line 2656 "ncgeny.c" break; case 112: /* datasection: DATA datadecls */ -#line 797 "ncgen.y" +#line 800 "ncgen.y" {} -#line 2664 "ncgeny.c" +#line 2662 "ncgeny.c" break; case 115: /* datadecl: varref '=' datalist */ -#line 805 "ncgen.y" +#line 808 "ncgen.y" {(yyvsp[-2].sym)->data = (yyvsp[0].datalist);} -#line 2670 "ncgeny.c" +#line 2668 "ncgeny.c" break; case 116: /* datalist: datalist0 */ -#line 808 "ncgen.y" +#line 811 "ncgen.y" {(yyval.datalist) = (yyvsp[0].datalist);} -#line 2676 "ncgeny.c" +#line 2674 "ncgeny.c" break; case 117: /* datalist: datalist1 */ -#line 809 "ncgen.y" +#line 812 "ncgen.y" {(yyval.datalist) = (yyvsp[0].datalist);} -#line 2682 "ncgeny.c" +#line 2680 "ncgeny.c" break; case 118: /* datalist0: %empty */ -#line 813 "ncgen.y" +#line 816 "ncgen.y" {(yyval.datalist) = builddatalist(0);} -#line 2688 "ncgeny.c" +#line 2686 "ncgeny.c" break; case 119: /* datalist1: dataitem */ -#line 817 "ncgen.y" +#line 820 "ncgen.y" {(yyval.datalist) = const2list((yyvsp[0].constant));} -#line 2694 "ncgeny.c" +#line 2692 "ncgeny.c" break; case 120: /* datalist1: datalist ',' dataitem */ -#line 819 "ncgen.y" +#line 822 "ncgen.y" {dlappend((yyvsp[-2].datalist),((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist); } -#line 2700 "ncgeny.c" +#line 2698 "ncgeny.c" break; case 121: /* dataitem: constdata */ -#line 823 "ncgen.y" +#line 826 "ncgen.y" {(yyval.constant)=(yyvsp[0].constant);} -#line 2706 "ncgeny.c" +#line 2704 "ncgeny.c" break; case 122: /* dataitem: '{' datalist '}' */ -#line 824 "ncgen.y" +#line 827 "ncgen.y" {(yyval.constant)=builddatasublist((yyvsp[-1].datalist));} -#line 2712 "ncgeny.c" +#line 2710 "ncgeny.c" break; case 123: /* constdata: simpleconstant */ -#line 828 "ncgen.y" +#line 831 "ncgen.y" {(yyval.constant)=(yyvsp[0].constant);} -#line 2718 "ncgeny.c" +#line 2716 "ncgeny.c" break; case 124: /* constdata: OPAQUESTRING */ -#line 829 "ncgen.y" +#line 832 "ncgen.y" {(yyval.constant)=makeconstdata(NC_OPAQUE);} -#line 2724 "ncgeny.c" +#line 2722 "ncgeny.c" break; case 125: /* constdata: FILLMARKER */ -#line 830 "ncgen.y" +#line 833 "ncgen.y" {(yyval.constant)=makeconstdata(NC_FILLVALUE);} -#line 2730 "ncgeny.c" +#line 2728 "ncgeny.c" break; case 126: /* constdata: NIL */ -#line 831 "ncgen.y" +#line 834 "ncgen.y" {(yyval.constant)=makeconstdata(NC_NIL);} -#line 2736 "ncgeny.c" +#line 2734 "ncgeny.c" break; case 127: /* constdata: econstref */ -#line 832 "ncgen.y" +#line 835 "ncgen.y" {(yyval.constant)=(yyvsp[0].constant);} -#line 2742 "ncgeny.c" +#line 2740 "ncgeny.c" break; case 129: /* econstref: path */ -#line 837 "ncgen.y" +#line 840 "ncgen.y" {(yyval.constant) = makeenumconstref((yyvsp[0].sym));} -#line 2748 "ncgeny.c" +#line 2746 "ncgeny.c" break; case 130: /* function: ident '(' arglist ')' */ -#line 841 "ncgen.y" +#line 844 "ncgen.y" {(yyval.constant)=evaluate((yyvsp[-3].sym),(yyvsp[-1].datalist));} -#line 2754 "ncgeny.c" +#line 2752 "ncgeny.c" break; case 131: /* arglist: simpleconstant */ -#line 846 "ncgen.y" +#line 849 "ncgen.y" {(yyval.datalist) = const2list((yyvsp[0].constant));} -#line 2760 "ncgeny.c" +#line 2758 "ncgeny.c" break; case 132: /* arglist: arglist ',' simpleconstant */ -#line 848 "ncgen.y" +#line 851 "ncgen.y" {dlappend((yyvsp[-2].datalist),((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);} -#line 2766 "ncgeny.c" +#line 2764 "ncgeny.c" break; case 133: /* simpleconstant: CHAR_CONST */ -#line 852 "ncgen.y" +#line 855 "ncgen.y" {(yyval.constant)=makeconstdata(NC_CHAR);} -#line 2772 "ncgeny.c" +#line 2770 "ncgeny.c" break; case 134: /* simpleconstant: BYTE_CONST */ -#line 853 "ncgen.y" +#line 856 "ncgen.y" {(yyval.constant)=makeconstdata(NC_BYTE);} -#line 2778 "ncgeny.c" +#line 2776 "ncgeny.c" break; case 135: /* simpleconstant: SHORT_CONST */ -#line 854 "ncgen.y" +#line 857 "ncgen.y" {(yyval.constant)=makeconstdata(NC_SHORT);} -#line 2784 "ncgeny.c" +#line 2782 "ncgeny.c" break; case 136: /* simpleconstant: INT_CONST */ -#line 855 "ncgen.y" +#line 858 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT);} -#line 2790 "ncgeny.c" +#line 2788 "ncgeny.c" break; case 137: /* simpleconstant: INT64_CONST */ -#line 856 "ncgen.y" +#line 859 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT64);} -#line 2796 "ncgeny.c" +#line 2794 "ncgeny.c" break; case 138: /* simpleconstant: UBYTE_CONST */ -#line 857 "ncgen.y" +#line 860 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UBYTE);} -#line 2802 "ncgeny.c" +#line 2800 "ncgeny.c" break; case 139: /* simpleconstant: USHORT_CONST */ -#line 858 "ncgen.y" +#line 861 "ncgen.y" {(yyval.constant)=makeconstdata(NC_USHORT);} -#line 2808 "ncgeny.c" +#line 2806 "ncgeny.c" break; case 140: /* simpleconstant: UINT_CONST */ -#line 859 "ncgen.y" +#line 862 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT);} -#line 2814 "ncgeny.c" +#line 2812 "ncgeny.c" break; case 141: /* simpleconstant: UINT64_CONST */ -#line 860 "ncgen.y" +#line 863 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT64);} -#line 2820 "ncgeny.c" +#line 2818 "ncgeny.c" break; case 142: /* simpleconstant: FLOAT_CONST */ -#line 861 "ncgen.y" +#line 864 "ncgen.y" {(yyval.constant)=makeconstdata(NC_FLOAT);} -#line 2826 "ncgeny.c" +#line 2824 "ncgeny.c" break; case 143: /* simpleconstant: DOUBLE_CONST */ -#line 862 "ncgen.y" +#line 865 "ncgen.y" {(yyval.constant)=makeconstdata(NC_DOUBLE);} -#line 2832 "ncgeny.c" +#line 2830 "ncgeny.c" break; case 144: /* simpleconstant: TERMSTRING */ -#line 863 "ncgen.y" +#line 866 "ncgen.y" {(yyval.constant)=makeconstdata(NC_STRING);} -#line 2838 "ncgeny.c" +#line 2836 "ncgeny.c" break; case 145: /* intlist: constint */ -#line 867 "ncgen.y" +#line 870 "ncgen.y" {(yyval.datalist) = const2list((yyvsp[0].constant));} -#line 2844 "ncgeny.c" +#line 2842 "ncgeny.c" break; case 146: /* intlist: intlist ',' constint */ -#line 868 "ncgen.y" +#line 871 "ncgen.y" {(yyval.datalist)=(yyvsp[-2].datalist); dlappend((yyvsp[-2].datalist),((yyvsp[0].constant)));} -#line 2850 "ncgeny.c" +#line 2848 "ncgeny.c" break; case 147: /* constint: INT_CONST */ -#line 873 "ncgen.y" +#line 876 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT);} -#line 2856 "ncgeny.c" +#line 2854 "ncgeny.c" break; case 148: /* constint: UINT_CONST */ -#line 875 "ncgen.y" +#line 878 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT);} -#line 2862 "ncgeny.c" +#line 2860 "ncgeny.c" break; case 149: /* constint: INT64_CONST */ -#line 877 "ncgen.y" +#line 880 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT64);} -#line 2868 "ncgeny.c" +#line 2866 "ncgeny.c" break; case 150: /* constint: UINT64_CONST */ -#line 879 "ncgen.y" +#line 882 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT64);} -#line 2874 "ncgeny.c" +#line 2872 "ncgeny.c" break; case 151: /* conststring: TERMSTRING */ -#line 883 "ncgen.y" +#line 886 "ncgen.y" {(yyval.constant)=makeconstdata(NC_STRING);} -#line 2880 "ncgeny.c" +#line 2878 "ncgeny.c" break; case 152: /* constbool: conststring */ -#line 887 "ncgen.y" +#line 890 "ncgen.y" {(yyval.constant)=(yyvsp[0].constant);} -#line 2886 "ncgeny.c" +#line 2884 "ncgeny.c" break; case 153: /* constbool: constint */ -#line 888 "ncgen.y" +#line 891 "ncgen.y" {(yyval.constant)=(yyvsp[0].constant);} -#line 2892 "ncgeny.c" +#line 2890 "ncgeny.c" + break; + + case 154: /* varident: IDENT */ +#line 899 "ncgen.y" + {(yyval.sym)=(yyvsp[0].sym);} +#line 2896 "ncgeny.c" break; - case 154: /* ident: IDENT */ -#line 894 "ncgen.y" + case 155: /* varident: DATA */ +#line 900 "ncgen.y" + {(yyval.sym)=identkeyword((yyvsp[0].sym));} +#line 2902 "ncgeny.c" + break; + + case 156: /* ident: IDENT */ +#line 904 "ncgen.y" {(yyval.sym)=(yyvsp[0].sym);} -#line 2898 "ncgeny.c" +#line 2908 "ncgeny.c" break; -#line 2902 "ncgeny.c" +#line 2912 "ncgeny.c" default: break; } @@ -2974,7 +2984,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } yyerror (yymsgp); if (yysyntax_error_status == YYENOMEM) - goto yyexhaustedlab; + YYNOMEM; } } @@ -3010,6 +3020,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); 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. */ @@ -3070,7 +3081,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); `-------------------------------------*/ yyacceptlab: yyresult = 0; - goto yyreturn; + goto yyreturnlab; /*-----------------------------------. @@ -3078,24 +3089,22 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); `-----------------------------------*/ yyabortlab: yyresult = 1; - goto yyreturn; + goto yyreturnlab; -#if 1 -/*-------------------------------------------------. -| 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 @@ -3123,7 +3132,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); return yyresult; } -#line 897 "ncgen.y" +#line 907 "ncgen.y" #ifndef NO_STDARG @@ -3524,9 +3533,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); diff --git a/ncgen/ncgeny.h b/ncgen/ncgeny.h index 8481e1292d..5c8bc03c68 100644 --- a/ncgen/ncgeny.h +++ b/ncgen/ncgeny.h @@ -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 . */ + along with this program. If not, see . */ /* 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 */ diff --git a/ncgen3/Makefile.am b/ncgen3/Makefile.am index e4de6f27f1..4940c1d0d4 100644 --- a/ncgen3/Makefile.am +++ b/ncgen3/Makefile.am @@ -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 diff --git a/ncgen3/ncgen.l b/ncgen3/ncgen.l index 01f6beb318..facaaf0f3d 100644 --- a/ncgen3/ncgen.l +++ b/ncgen3/ncgen.l @@ -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]? { diff --git a/ncgen3/ncgenl.c b/ncgen3/ncgenl.c index 8d004831d0..6412b77c3f 100644 --- a/ncgen3/ncgenl.c +++ b/ncgen3/ncgenl.c @@ -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 */ diff --git a/ncgen3/ncgeny.c b/ncgen3/ncgeny.c index d46b5d55b8..69929d57db 100644 --- a/ncgen3/ncgeny.c +++ b/ncgen3/ncgeny.c @@ -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 . */ + along with this program. If not, see . */ /* 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 @@ yyparse (void) 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 @@ yyparse (void) # 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 @@ yyparse (void) 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 @@ yyparse (void) } #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + if (yystate == YYFINAL) YYACCEPT; @@ -1293,7 +1283,7 @@ yyparse (void) 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 @@ yyparse (void) 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 @@ yyparse (void) 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 @@ yyparse (void) 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 @@ yyparse (void) 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 @@ yyparse (void) dims[ndims].size = NC_UNLIMITED; ndims++; } -#line 1353 "ncgeny.c" +#line 1343 "ncgeny.c" break; case 14: /* dimd: dim */ @@ -1369,43 +1359,43 @@ yyparse (void) /* 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 @@ yyparse (void) 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 @@ yyparse (void) vars[nvars].ndims = nvdims; nvars++; } -#line 1455 "ncgeny.c" +#line 1445 "ncgeny.c" break; case 42: /* vdim: dim */ @@ -1475,7 +1465,7 @@ yyparse (void) vars[nvars].dims[nvdims] = dimnum; nvdims++; } -#line 1479 "ncgeny.c" +#line 1469 "ncgeny.c" break; case 43: /* $@4: %empty */ @@ -1483,7 +1473,7 @@ yyparse (void) { defatt(); } -#line 1487 "ncgeny.c" +#line 1477 "ncgeny.c" break; case 44: /* attdecl: att $@4 '=' attvallist */ @@ -1491,7 +1481,7 @@ yyparse (void) { equalatt(); } -#line 1495 "ncgeny.c" +#line 1485 "ncgeny.c" break; case 45: /* $@5: %empty */ @@ -1499,7 +1489,7 @@ yyparse (void) { defatt(); } -#line 1503 "ncgeny.c" +#line 1493 "ncgeny.c" break; case 46: /* gattdecl: gatt $@5 '=' attvallist */ @@ -1507,7 +1497,7 @@ yyparse (void) { equalatt(); } -#line 1511 "ncgeny.c" +#line 1501 "ncgeny.c" break; case 48: /* gatt: ':' attr */ @@ -1515,7 +1505,7 @@ yyparse (void) { varnum = NC_GLOBAL; /* handle of "global" attribute */ } -#line 1519 "ncgeny.c" +#line 1509 "ncgeny.c" break; case 49: /* avar: var */ @@ -1528,7 +1518,7 @@ yyparse (void) YYABORT; } } -#line 1532 "ncgeny.c" +#line 1522 "ncgeny.c" break; case 50: /* attr: IDENT */ @@ -1542,7 +1532,7 @@ yyparse (void) /* 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 @@ yyparse (void) 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 @@ yyparse (void) *char_valp++ = char_val; valnum++; } -#line 1567 "ncgeny.c" +#line 1557 "ncgeny.c" break; case 55: /* attconst: TERMSTRING */ @@ -1580,7 +1570,7 @@ yyparse (void) char_valp += len; } } -#line 1584 "ncgeny.c" +#line 1574 "ncgeny.c" break; case 56: /* attconst: BYTE_CONST */ @@ -1590,7 +1580,7 @@ yyparse (void) *byte_valp++ = byte_val; valnum++; } -#line 1594 "ncgeny.c" +#line 1584 "ncgeny.c" break; case 57: /* attconst: SHORT_CONST */ @@ -1600,7 +1590,7 @@ yyparse (void) *short_valp++ = short_val; valnum++; } -#line 1604 "ncgeny.c" +#line 1594 "ncgeny.c" break; case 58: /* attconst: INT_CONST */ @@ -1610,7 +1600,7 @@ yyparse (void) *int_valp++ = int_val; valnum++; } -#line 1614 "ncgeny.c" +#line 1604 "ncgeny.c" break; case 59: /* attconst: FLOAT_CONST */ @@ -1620,7 +1610,7 @@ yyparse (void) *float_valp++ = float_val; valnum++; } -#line 1624 "ncgeny.c" +#line 1614 "ncgeny.c" break; case 60: /* attconst: DOUBLE_CONST */ @@ -1630,7 +1620,7 @@ yyparse (void) *double_valp++ = double_val; valnum++; } -#line 1634 "ncgeny.c" +#line 1624 "ncgeny.c" break; case 66: /* $@6: %empty */ @@ -1685,7 +1675,7 @@ yyparse (void) default: break; } } -#line 1689 "ncgeny.c" +#line 1679 "ncgeny.c" break; case 67: /* datadecl: avar $@6 '=' constlist */ @@ -1704,7 +1694,7 @@ yyparse (void) 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 @@ yyparse (void) } not_a_string = 1; } -#line 1737 "ncgeny.c" +#line 1727 "ncgeny.c" break; case 71: /* dconst: $@7 const */ @@ -1763,7 +1753,7 @@ yyparse (void) } } } -#line 1767 "ncgeny.c" +#line 1757 "ncgeny.c" break; case 72: /* const: CHAR_CONST */ @@ -1793,7 +1783,7 @@ yyparse (void) } valnum++; } -#line 1797 "ncgeny.c" +#line 1787 "ncgeny.c" break; case 73: /* const: TERMSTRING */ @@ -1852,7 +1842,7 @@ yyparse (void) } } } -#line 1856 "ncgeny.c" +#line 1846 "ncgeny.c" break; case 74: /* const: BYTE_CONST */ @@ -1882,7 +1872,7 @@ yyparse (void) } valnum++; } -#line 1886 "ncgeny.c" +#line 1876 "ncgeny.c" break; case 75: /* const: SHORT_CONST */ @@ -1912,7 +1902,7 @@ yyparse (void) } valnum++; } -#line 1916 "ncgeny.c" +#line 1906 "ncgeny.c" break; case 76: /* const: INT_CONST */ @@ -1942,7 +1932,7 @@ yyparse (void) } valnum++; } -#line 1946 "ncgeny.c" +#line 1936 "ncgeny.c" break; case 77: /* const: FLOAT_CONST */ @@ -1972,7 +1962,7 @@ yyparse (void) } valnum++; } -#line 1976 "ncgeny.c" +#line 1966 "ncgeny.c" break; case 78: /* const: DOUBLE_CONST */ @@ -2005,7 +1995,7 @@ yyparse (void) } valnum++; } -#line 2009 "ncgeny.c" +#line 1999 "ncgeny.c" break; case 79: /* const: FILLVALUE */ @@ -2041,11 +2031,11 @@ yyparse (void) } valnum++; } -#line 2045 "ncgeny.c" +#line 2035 "ncgeny.c" break; -#line 2049 "ncgeny.c" +#line 2039 "ncgeny.c" default: break; } @@ -2127,6 +2117,7 @@ yyparse (void) 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 @@ yyparse (void) `-------------------------------------*/ yyacceptlab: yyresult = 0; - goto yyreturn; + goto yyreturnlab; /*-----------------------------------. @@ -2195,24 +2186,22 @@ yyparse (void) `-----------------------------------*/ 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 diff --git a/ncgen3/ncgeny.h b/ncgen3/ncgeny.h index 7d4eaa3a5e..3665e03a19 100644 --- a/ncgen3/ncgeny.h +++ b/ncgen3/ncgeny.h @@ -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 . */ + along with this program. If not, see . */ /* 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 */ diff --git a/ncgen3/run_tests.sh b/ncgen3/run_tests.sh index 3289196b0a..fcba7489e5 100755 --- a/ncgen3/run_tests.sh +++ b/ncgen3/run_tests.sh @@ -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} diff --git a/nctest/Makefile.am b/nctest/Makefile.am index 506c5eece4..9532399a27 100644 --- a/nctest/Makefile.am +++ b/nctest/Makefile.am @@ -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 diff --git a/nctest/cdftests.c b/nctest/cdftests.c index c4c5165166..5f3a637cea 100644 --- a/nctest/cdftests.c +++ b/nctest/cdftests.c @@ -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 diff --git a/nctest/compare_test_files.sh b/nctest/compare_test_files.sh index 43fc0e19a0..f9712adbe1 100755 --- a/nctest/compare_test_files.sh +++ b/nctest/compare_test_files.sh @@ -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" diff --git a/nctest/driver.c b/nctest/driver.c index 4559861246..716a178092 100644 --- a/nctest/driver.c +++ b/nctest/driver.c @@ -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. */ { diff --git a/nczarr_test/CMakeLists.txt b/nczarr_test/CMakeLists.txt index 3d8662d7fa..3d0a8f93bb 100644 --- a/nczarr_test/CMakeLists.txt +++ b/nczarr_test/CMakeLists.txt @@ -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) diff --git a/nczarr_test/run_filter.sh b/nczarr_test/run_filter.sh index 78e3f0a7ff..08ce36d0a6 100755 --- a/nczarr_test/run_filter.sh +++ b/nczarr_test/run_filter.sh @@ -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() { diff --git a/nczarr_test/run_nczarr_fill.sh b/nczarr_test/run_nczarr_fill.sh index c587d0bd5c..d03c425ff3 100755 --- a/nczarr_test/run_nczarr_fill.sh +++ b/nczarr_test/run_nczarr_fill.sh @@ -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 diff --git a/nczarr_test/test_nczarr.sh b/nczarr_test/test_nczarr.sh index 8a76c5c878..489bc0512f 100755 --- a/nczarr_test/test_nczarr.sh +++ b/nczarr_test/test_nczarr.sh @@ -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 diff --git a/nczarr_test/ut_map.c b/nczarr_test/ut_map.c index d1a62ae8ee..c347ea26c5 100644 --- a/nczarr_test/ut_map.c +++ b/nczarr_test/ut_map.c @@ -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); diff --git a/oc2/dapparse.c b/oc2/dapparse.c index 5302575bfd..8d039ad557 100644 --- a/oc2/dapparse.c +++ b/oc2/dapparse.c @@ -425,7 +425,7 @@ scopeduplicates(NClist* list) 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; diff --git a/oc2/ocdump.c b/oc2/ocdump.c index 494147f954..cde4df3fd3 100644 --- a/oc2/ocdump.c +++ b/oc2/ocdump.c @@ -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;nsubnodes);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;nsubnodes);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); } diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 00422a8f8e..fc40872e50 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -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 diff --git a/test-driver-verbose b/test-driver-verbose old mode 100644 new mode 100755 diff --git a/test_common.in b/test_common.in index aee18f411c..85d22323e7 100644 --- a/test_common.in +++ b/test_common.in @@ -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 diff --git a/unit_test/CMakeLists.txt b/unit_test/CMakeLists.txt index 8fa1003b4f..b34e581639 100644 --- a/unit_test/CMakeLists.txt +++ b/unit_test/CMakeLists.txt @@ -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) diff --git a/unit_test/Makefile.am b/unit_test/Makefile.am index 5ba28767d9..67d0d566e8 100644 --- a/unit_test/Makefile.am +++ b/unit_test/Makefile.am @@ -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@ diff --git a/unit_test/nctest_netcdf4_classic.nc b/unit_test/nctest_netcdf4_classic.nc new file mode 100644 index 0000000000000000000000000000000000000000..1eb1f041d524cada0a5d592e20d75a683c355b50 GIT binary patch literal 136080 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 literal 0 HcmV?d00001 diff --git a/unit_test/test_pathcvt.c b/unit_test/test_pathcvt.c index 98d9422091..7f1d67b6be 100644 --- a/unit_test/test_pathcvt.c +++ b/unit_test/test_pathcvt.c @@ -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;kexpected[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; + } } From 1397c3407b67ea9ae9a8db16d9305d8e5bb7151e Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Thu, 23 Dec 2021 22:33:01 -0700 Subject: [PATCH 2/3] Update RELEASENOTES.md --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index cb3f70f392..98828d660c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,7 +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). +* [Enhancement] Improve support for msys2+mingw platform. See [Github #2171](https://github.com/Unidata/netcdf-c/pull/2171). * [Bug Fix] Clean up the various inter-test dependencies in ncdump for CMake. See [Github #2168](https://github.com/Unidata/netcdf-c/pull/2168). * [Enhancement] Added options to suppress the new behavior from [Github #2135](https://github.com/Unidata/netcdf-c/pull/2135). The options for `cmake` and `configure` are, respectively `-DENABLE_LIBXML2` and `--(enable/disable)-libxml2`. Both of these options defaul to 'on/enabled'. When disabled, the bundled `ezxml` XML interpreter is used regardless of whether `libxml2` is present on the system. * [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). From 43f2e51112814b40bb03f21f0fd38a8c9921c94a Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Thu, 23 Dec 2021 23:10:44 -0700 Subject: [PATCH 3/3] Fix new LGTM alerts --- libdispatch/dpathmgr.c | 1 - ncdump/ncpathcvt.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libdispatch/dpathmgr.c b/libdispatch/dpathmgr.c index 564a0bd573..597629c16f 100644 --- a/libdispatch/dpathmgr.c +++ b/libdispatch/dpathmgr.c @@ -1232,6 +1232,5 @@ 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); } } diff --git a/ncdump/ncpathcvt.c b/ncdump/ncpathcvt.c index eb79359ad2..af24809772 100755 --- a/ncdump/ncpathcvt.c +++ b/ncdump/ncpathcvt.c @@ -181,7 +181,7 @@ main(int argc, char** argv) case 'u': cvtoptions.target = NCPD_NIX; break; case 'w': cvtoptions.target = NCPD_WIN; break; case 'B': - cvtoptions.blank = optarg[0]; break; + cvtoptions.blank = optarg[0]; if(cvtoptions.blank < ' ' || cvtoptions.blank == '\177') usage("Bad -B argument"); break;