Following command fails under visual studio.
    ncdump -h http://thredds.ucar.edu/thredds/dodsC/nexrad/composite/gini/n0r/1km/20170216/Level3_Composite_n0r_1km_20170216_1635.gini

The problem is that sscanf for windows does not appear to support
scanning 8bit integers: it appears to only allow scanning of characters.

Solution:
Scan the input as an integer (for type Byte) or unsigned int (for type UByte)
and then recast the result as a char or unsigned char.

Primary code fix is in libdap2/dapcvt.c#dapcvtattrval
This commit is contained in:
Dennis Heimbigner 2017-02-19 21:41:51 -07:00
parent 581737b04e
commit 96bd037560
4 changed files with 29 additions and 20 deletions

View File

@ -645,8 +645,8 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
# Find out if HDF5 was built with parallel support.
# Do that by checking for the targets H5Pget_fapl_mpiposx and
# H5Pget_fapl_mpio in ${HDF5_LIB}.
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO)
IF(HDF5_IS_PARALLEL_MPIPOSIX OR HDF5_IS_PARALLEL_MPIO)
SET(HDF5_PARALLEL ON)
ELSE()
@ -663,7 +663,7 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF()
#Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_all_coll_metadata_ops "" HDF5_HAS_COLL_METADATA_OPS)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pset_all_coll_metadata_ops "" HDF5_HAS_COLL_METADATA_OPS)
OPTION(ENABLE_DYNAMIC_LOADING "Enable Dynamic Loading" ON)
IF(ENABLE_DYNAMIC_LOADING)
@ -672,10 +672,10 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF(NOT MSVC)
# Make sure the user has built the library with zlib support.
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_deflate "" HAVE_H5PSET_DEFLATE)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pset_deflate "" HAVE_H5PSET_DEFLATE)
#Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip.
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5P_SZIP "" USE_SZIP)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5P_SZIP "" USE_SZIP)
IF(USE_SZIP)
FIND_LIBRARY(SZIP NAMES szip sz)
IF(SZIP)
@ -686,11 +686,11 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF()
ENDIF()
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5free_memory "" HDF5_HAS_H5FREE)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5free_memory "" HDF5_HAS_H5FREE)
IF(HDF5_HAS_H5FREE)
SET(HAVE_H5FREE_MEMORY TRUE)
ENDIF(HDF5_HAS_H5FREE)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_libver_bounds "" HDF5_HAS_LIBVER_BOUNDS)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pset_libver_bounds "" HDF5_HAS_LIBVER_BOUNDS)
IF(HDF5_HAS_LIBVER_BOUNDS)
SET(HAVE_H5PSET_LIBVER_BOUNDS TRUE)

View File

@ -18,6 +18,7 @@ fi
export CC
FLAGS="-DCMAKE_PREFIX_PATH=c:/tools/nccmake"
FLAGS="$FLAGS -DCMAKE_INSTALL_PREFIX=d:/ignore"
if test "x$DAP" = x ; then
FLAGS="$FLAGS -DENABLE_DAP=false"
@ -28,11 +29,16 @@ fi
FLAGS="$FLAGS -DENABLE_CONVERSION_WARNINGS=false"
FLAGS="$FLAGS -DENABLE_DAP_REMOTE_TESTS=true"
FLAGS="$FLAGS -DENABLE_TESTS=true"
FLAGS="$FLAGS -DENABLE_EXAMPLES=false"
#FLAGS="$FLAGS -DENABLE_DAP4=true"
rm -fr build
mkdir build
cd build
cmake -GVisual\ Studio\ 14\ 2015 $FLAGS ${ZLIB} ${HDF5} ${CURL} ..
#cmake --build .
CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test
cmake $FLAGS ${ZLIB} ${HDF5} ${CURL} ..
# We must use Release config here because Debug will invoke a runtime dialog box.
# If missing, appears to default to Debug
#CFG="--config RelWithDebInfo"
#cmake --build . ${CFG}
#cmake --build . ${CFG} --target RUN_TESTS

View File

@ -210,14 +210,14 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src)
ok = 0;
switch (etype) {
case NC_BYTE: {
char tmp[128];
unsigned char* p = (unsigned char*)dstmem;
char* p = (unsigned char*)dstmem;
#ifdef _MSC_VER
ok = sscanf(s,"%hC%n",p,&nread);
_ASSERTE(_CrtCheckMemory());
int ival;
ok = sscanf(s,"%d%n",&ival,&nread);
_ASSERTE(_CrtCheckMemory());
*p = (char)ival;
#else
ok = sscanf(s,"%hhu%n",p,&nread);
ok = sscanf(s,"%hhu%n",p,&nread);
#endif
} break;
case NC_CHAR: {
@ -243,12 +243,14 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src)
case NC_UBYTE: {
unsigned char* p = (unsigned char*)dstmem;
#ifdef _MSC_VER
ok = sscanf(s, "%hc%n", p,&nread);
_ASSERTE(_CrtCheckMemory());
unsigned int uval;
ok = sscanf(s,"%u%n",&uval,&nread);
_ASSERTE(_CrtCheckMemory());
*p = (unsigned char)uval;
#else
ok = sscanf(s,"%hhu%n",p,&nread);
#endif
} break;
} break;
case NC_USHORT: {
unsigned short* p = (unsigned short*)dstmem;
ok = sscanf(s,"%hu%n",p,&nread);

View File

@ -336,7 +336,8 @@ NCD2_open(const char * path, int mode,
dapcomm->oc.rawurltext = strdup(path);
#endif
ncuriparse(dapcomm->oc.rawurltext,&dapcomm->oc.url);
ncstat = ncuriparse(dapcomm->oc.rawurltext,&dapcomm->oc.url);
if (!ncstat) goto done;
/* parse the client parameters */
ncuridecodeparams(dapcomm->oc.url);