Merge branch 'master' into patch-1

This commit is contained in:
Greg Sjaardema 2017-03-29 20:19:37 -06:00 committed by GitHub
commit 97c27b1582
25 changed files with 1551 additions and 1471 deletions

View File

@ -5,12 +5,11 @@ Release Notes {#RELEASE_NOTES}
This file contains a high-level description of this package's evolution. Releases are in reverse chronological order (most recent first). Note that, as of netcdf 4.2, the `netcdf-c++` and `netcdf-fortran` libraries have been separated into their own libraries.
## Important Notes
* **The combination of netCDF-C library versions earlier than 4.4.1 and libhdf5 1.10.0+ should be avoided, as they will result in binary files not readable by systems using earlier libhdf5 versions.**
## 4.4.2 - TBD
* [Bug Fix] `NC_EGLOBAL` is now properly returned when attempting to set a global `_FillValue` attribute. See [GitHub #388](https://github.com/Unidata/netcdf-c/issues/388) and [GitHub #389](https://github.com/Unidata/netcdf-c/issues/389) for more information.
* [Bug Fix] Corrected an issue where data loss would occur when `_FillValue` was mistakenly allowed to be redefined. See [Github #390](https://github.com/Unidata/netcdf-c/issues/390), [GitHub #387](https://github.com/Unidata/netcdf-c/pull/387) for more information.
* [Enhancement] Modified netCDF4 to use ASCII for NC_CHAR. See [Github Pull request #316](https://github.com/Unidata/netcdf-c/pull/316) for more information.
* [Upgrade][Bug] Corrected an issue regarding how "orphaned" DAS attributes were handled. See [GitHub #376](https://github.com/Unidata/netcdf-c/pull/376) for more information.
* [Upgrade] Update utf8proc.[ch] to use the version now maintained by the Julia Language project (https://github.com/JuliaLang/utf8proc/blob/master/LICENSE.md).
* [Bug] Addressed conversion problem with Windows sscanf. This primarily affected some OPeNDAP URLs on Windows. See [GitHub #365](https://github.com/Unidata/netcdf-c/issues/365) and [GitHub #366](https://github.com/Unidata/netcdf-c/issues/366) for more information.

2
cf
View File

@ -4,7 +4,7 @@ DB=1
#X=-x
#FAST=1
#HDF5=1
HDF5=1
DAP=1
#HDF4=1
#PNETCDF=1

View File

@ -625,7 +625,7 @@ data are written). In that case the specified endian type will be used
in HDF5 (for example, a H5T_STD_I16LE will be used for NC_SHORT, if
little-endian has been specified for that variable.)
- NC_BYTE = H5T_NATIVE_SCHAR
- NC_UBYTE = H5T_NATIVE_SCHAR
- NC_UBYTE = H5T_NATIVE_UCHAR
- NC_CHAR = H5T_C_S1
- NC_STRING = variable length array of H5T_C_S1
- NC_SHORT = H5T_NATIVE_SHORT

View File

@ -37,7 +37,8 @@ apply.
\param value Pointer to one or more values.
\returns ::NC_NOERR No error.
\returns ::NC_EINVAL More than one value for _FillValue or trying to set global _FillValue.
\returns ::NC_EINVAL More than one value for _FillValue.
\returns ::NC_EGLOBAL Trying to set global _FillValue.
\returns ::NC_ENOTVAR Couldn't find varid.
\returns ::NC_EBADTYPE Fill value and var must be same type.
\returns ::NC_ENOMEM Out of memory
@ -53,6 +54,9 @@ nc_put_att_string(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, NC_STRING,
len, (void*)value, NC_STRING);
}
@ -87,7 +91,8 @@ apply.
\param value Pointer to one or more values.
\returns ::NC_NOERR No error.
\returns ::NC_EINVAL More than one value for _FillValue or trying to set global _FillValue.
\returns ::NC_EINVAL More than one value for _FillValue.
\returns ::NC_EGLOBAL Trying to set global _FillValue.
\returns ::NC_ENOTVAR Couldn't find varid.
\returns ::NC_EBADTYPE Fill value and var must be same type.
\returns ::NC_ENOMEM Out of memory
@ -141,6 +146,9 @@ int nc_put_att_text(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, NC_CHAR, len,
(void *)value, NC_CHAR);
}
@ -182,7 +190,8 @@ apply.
\param value Pointer to one or more values.
\returns ::NC_NOERR No error.
\returns ::NC_EINVAL More than one value for _FillValue or trying to set global _FillValue.
\returns ::NC_EINVAL More than one value for _FillValue.
\returns ::NC_EGLOBAL Trying to set global _FillValue.
\returns ::NC_ENOTVAR Couldn't find varid.
\returns ::NC_EBADTYPE Fill value and var must be same type.
\returns ::NC_ENOMEM Out of memory
@ -232,6 +241,9 @@ nc_put_att(int ncid, int varid, const char *name, nc_type xtype,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
value, xtype);
}
@ -243,6 +255,9 @@ nc_put_att_schar(int ncid, int varid, const char *name,
NC *ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_BYTE);
}
@ -254,6 +269,9 @@ nc_put_att_uchar(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UBYTE);
}
@ -265,6 +283,9 @@ nc_put_att_short(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_SHORT);
}
@ -276,6 +297,9 @@ nc_put_att_int(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_INT);
}
@ -287,6 +311,9 @@ nc_put_att_long(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, longtype);
}
@ -298,6 +325,9 @@ nc_put_att_float(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_FLOAT);
}
@ -309,6 +339,9 @@ nc_put_att_double(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_DOUBLE);
}
@ -320,6 +353,9 @@ nc_put_att_ubyte(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UBYTE);
}
@ -331,6 +367,9 @@ nc_put_att_ushort(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_USHORT);
}
@ -342,6 +381,9 @@ nc_put_att_uint(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UINT);
}
@ -354,6 +396,9 @@ nc_put_att_longlong(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_INT64);
}
@ -366,6 +411,9 @@ nc_put_att_ulonglong(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UINT64);
}

View File

@ -47,7 +47,7 @@ EXTRA_DIST = attr.m4 ncx.m4 putget.m4 $(man_MANS) CMakeLists.txt XGetopt.c
# This tells make how to turn .m4 files into .c files.
.m4.c:
m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< >${srcdir}/$@
m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< > $@
# The C API man page.
man_MANS = netcdf.3

View File

@ -2129,7 +2129,7 @@ nc4_rec_read_metadata(NC_GRP_INFO_T *grp)
hid_t pid = 0;
unsigned crt_order_flags = 0;
H5_index_t iter_index;
int retval = NC_NOERR; /* everything worked! */
int i, retval = NC_NOERR; /* everything worked! */
assert(grp && grp->name);
LOG((3, "%s: grp->name %s", __func__, grp->name));
@ -2217,6 +2217,10 @@ nc4_rec_read_metadata(NC_GRP_INFO_T *grp)
if ((retval = read_grp_atts(grp)))
BAIL(retval);
/* when exiting define mode, mark all variable written */
for (i=0; i<grp->vars.nelems; i++)
grp->vars.value[i]->written_to = NC_TRUE;
exit:
/* Clean up local information on error, if anything remains */
if (retval)
@ -2984,6 +2988,8 @@ static int NC4_enddef(int ncid)
{
NC *nc;
NC_HDF5_FILE_INFO_T* nc4_info;
NC_GRP_INFO_T *grp;
int i;
LOG((1, "%s: ncid 0x%x", __func__, ncid));
@ -2991,6 +2997,14 @@ static int NC4_enddef(int ncid)
return NC_EBADID;
assert(nc4_info);
/* Find info for this file and group */
if (!(grp = nc4_rec_find_grp(nc4_info->root_grp, (ncid & GRP_ID_MASK))))
return NC_EBADGRPID;
/* when exiting define mode, mark all variable written */
for (i=0; i<grp->vars.nelems; i++)
grp->vars.value[i]->written_to = NC_TRUE;
return nc4_enddef_netcdf4_file(nc4_info);
}

View File

@ -325,7 +325,7 @@ nc4_get_hdf_typeid(NC_HDF5_FILE_INFO_T *h5, nc_type xtype,
return NC_EHDFERR;
if (H5Tset_strpad(typeid, H5T_STR_NULLTERM) < 0)
BAIL(NC_EVARMETA);
if(H5Tset_cset(typeid, H5T_CSET_UTF8) < 0)
if(H5Tset_cset(typeid, H5T_CSET_ASCII) < 0)
BAIL(NC_EVARMETA);
/* Take ownership of the newly created HDF5 datatype */

View File

@ -22,7 +22,7 @@ TARGET_LINK_LIBRARIES(nc_test
)
# Some extra stand-alone tests
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type)
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type tst_global_fillval)
IF(NOT HAVE_BASH)
SET(TESTS ${TESTS} tst_atts3)
@ -31,6 +31,7 @@ ENDIF()
IF(USE_NETCDF4)
SET(TESTS ${TESTS} tst_atts)
SET(TESTS ${TESTS} tst_put_vars)
SET(TESTS ${TESTS} tst_elatefill)
ENDIF()
IF(USE_PNETCDF)

View File

@ -14,15 +14,16 @@ tst_*.nc t_nc.nc large_files.nc quick_large_files.nc \
tst_diskless.nc tst_diskless2.nc \
tst_diskless3.nc tst_diskless3_file.cdl tst_diskless3_memory.cdl \
tst_diskless4.cdl tst_diskless4.nc tst_formatx.nc nc_test_cdf5.nc \
unlim.nc tst_inq_type.nc
unlim.nc tst_inq_type.nc tst_elatefill.nc tst_global_fillval.nc
# These are the tests which are always run.
TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm \
tst_names tst_nofill tst_nofill2 tst_nofill3 tst_atts3 \
tst_meta tst_inq_type tst_utf8_validate tst_utf8_phrases
tst_meta tst_inq_type tst_utf8_validate tst_utf8_phrases \
tst_global_fillval
if USE_NETCDF4
TESTPROGRAMS += tst_atts tst_put_vars
TESTPROGRAMS += tst_atts tst_put_vars tst_elatefill
endif
if USE_PNETCDF

45
nc_test/tst_elatefill.c Normal file
View File

@ -0,0 +1,45 @@
/* This is part of the netCDF package. Copyright 2017 University
Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
conditions of use. See www.unidata.ucar.edu for more info.
Test proper elatefill return when fillvalue is assigned outside of
the initial define.
Contributed by wkliao, see the following for more information:
* https://github.com/Unidata/netcdf-c/issues/384
* https://github.com/Unidata/netcdf-c/pull/387
* https://github.com/Unidata/netcdf-c/issues/390
*/
#include "config.h"
#include <nc_tests.h>
#include "err_macros.h"
#include <stdio.h>
#include <netcdf.h>
#define FILE_NAME "tst_elatefill.nc"
#define ERR {if(err!=NC_NOERR)printf("Error at line %d: %s\n",__LINE__,nc_strerror(err));}
int
main(int argc, char **argv)
{
int ncid, dimid, varid, err;
int no_fill, fillv, buf[10];
err = nc_create(FILE_NAME, NC_NETCDF4, &ncid); ERR;
err = nc_def_dim(ncid, "dim", 10, &dimid); ERR;
err = nc_def_var(ncid, "var", NC_INT, 1, &dimid, &varid); ERR;
err = nc_enddef(ncid); ERR;
err = nc_redef(ncid); ERR;
/* try put attribute _FillValue and expect NC_ELATEFILL */
fillv = 9;
err = nc_put_att_int(ncid, varid, _FillValue, NC_INT, 1, &fillv);
if (err != NC_ELATEFILL)
printf("line %d expecting NC_ELATEFILL but got %d\n",__LINE__,err);
err = nc_close(ncid); ERR;
return 0;
}

View File

@ -0,0 +1,49 @@
/* This is part of the netCDF package. Copyright 2017 University
Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
conditions of use. See www.unidata.ucar.edu for more info.
Test proper elatefill return when fillvalue is assigned outside of
the initial define.
Contributed by wkliao, see the following for more information:
* https://github.com/Unidata/netcdf-c/issues/388
* https://github.com/Unidata/netcdf-c/pull/389
*/
#include "config.h"
#include <nc_tests.h>
#include <stdio.h>
#include <netcdf.h>
#define FILE_NAME "tst_global_fillval.nc"
#define ERR {if(err!=NC_NOERR){printf("Error at line %d: %s\n",__LINE__,nc_strerror(err)); toterrs++; break;}}
int
main(int argc, char **argv)
{
int i, ncid, cmode, err, fillv=9;
int toterrs = 0;
int formats[5]={0,
NC_64BIT_OFFSET,
NC_64BIT_DATA,
NC_NETCDF4,
NC_CLASSIC_MODEL | NC_NETCDF4};
char *formatnames[5]={"CDF-1", "CDF-2", "CDF-5", "NETCDF4", "CLASSIC_MODEL"};
for (i=0; i<5; i++) {
cmode = NC_CLOBBER | formats[i];
err = nc_create(FILE_NAME, cmode, &ncid); ERR
err = nc_put_att_int(ncid, NC_GLOBAL, "_FillValue", NC_INT, 1, &fillv);
if (err != NC_EGLOBAL) {
toterrs++;
printf("%13s Error at line %d: expecting NC_EINVAL but got %d\n",
formatnames[i],__LINE__,err);
}
err = nc_close(ncid); ERR;
}
printf("Total errors: %d\n",toterrs);
return toterrs;
}

View File

@ -33,7 +33,7 @@
*/
int main()
{
int ncid, dimids[RANK_P], time_id, p_id, test_id;
int ncid, dimids[RANK_P], time_id, p_id, test_id, status;
int ndims, dimids_in[RANK_P];
int test_data[1] = {1};
@ -95,8 +95,15 @@ int main()
}
printf("**** Adding _FillValue attribute.\n");
if (nc_put_att_int(ncid, test_id, "_FillValue", NC_INT, 1, test_fill_val)) ERR;
printf("**** Expecting NC_ELATEFILL when adding _FillValue attribute if variable exists.\n");
status = nc_put_att_int(ncid, test_id, "_FillValue", NC_INT, 1, test_fill_val);
if (status != NC_ELATEFILL) {
fflush(stdout); /* Make sure our stdout is synced with stderr. */
err++;
fprintf(stderr, "Sorry! Expecting NC_ELATEFILL but got %s, at file %s line: %d\n",
nc_strerror(status), __FILE__, __LINE__);
return 2;
}
/* Query existing attribute. */
{

View File

@ -27,8 +27,9 @@ main(int argc, char **argv)
int ncid, i;
char *data_in[ATT_LEN];
char *data[ATT_LEN] = {"An appeaser is one who feeds a crocodile — "
"hoping it will eat him last."};
"hoping it will eat him last. "
"Here are some non-ASCII characters: "
"\x00\xAA\xBB\xFF"};
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_put_att(ncid, NC_GLOBAL, ATT_NAME, NC_STRING, ATT_LEN, data)) ERR;

View File

@ -61,13 +61,17 @@ main(int argc, char **argv)
printf("**** testing simple fill value attribute creation...");
{
int status;
/* Create a netcdf-4 file with one scalar var. Add fill
* value. */
if (nc_create(FILE_NAME, cmode, &ncid)) ERR;
if (nc_def_var(ncid, VAR_NAME, NC_BYTE, 0, NULL, &varid)) ERR;
if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR;
if (nc_enddef(ncid)) ERR;
if (nc_redef(ncid)) ERR;
if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR;
status = nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value);
if (status != NC_ELATEFILL)
printf("Error at line %d: expecting NC_ELATEFILL but got %s\n",__LINE__,nc_strerror(status));
if (nc_close(ncid)) ERR;
/* Open the file and check. */
@ -94,8 +98,6 @@ main(int argc, char **argv)
if (nc_create(FILE_NAME, cmode, &ncid)) ERR;
if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
if (nc_def_var(ncid, VAR_NAME, NC_BYTE, NUM_DIMS, dimids, &varid)) ERR;
if (nc_enddef(ncid)) ERR;
if (nc_redef(ncid)) ERR;
if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR;
if (nc_enddef(ncid)) ERR;

View File

@ -19,5 +19,5 @@ data:
i64 = 9223372036854775807LL, 9223372036854775807ll, 9223372036854775807 ;
ui64 = 18446744073709551615ULL, 18446744073709551615ull, 18446744073709551615u ;
ui64 = 18446744073709551615ULL, 18446744073709551615ull, 18446744073709551615uLL;
}

View File

@ -70,5 +70,5 @@ ADD_CUSTOM_TARGET(makeparser DEPENDS ncgentab.h)
## Specify files to be distributed by 'make dist'
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ncgen.y ncgenl.c ncgen.l internals.html c0.cdl c0_4.cdl ref_camrun.cdl ncf199.cdl CMakeLists.txt Makefile.am ncgen.1)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ncgen.y ncgenl.c ncgen.l internals.html c0.cdl c0_4.cdl ref_camrun.cdl ncf199.cdl tst_gattenum.cdl CMakeLists.txt Makefile.am ncgen.1)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -24,7 +24,8 @@ man_MANS = ncgen.1
EXTRA_DIST = ncgen.y ncgen.l ncgenl.c $(man_MANS) internals.html \
run_tests.sh run_nc4_tests.sh c0.cdl c0_4.cdl ref_camrun.cdl \
ncf199.cdl CMakeLists.txt XGetopt.c c5.cdl \
compound_datasize_test.cdl compound_datasize_test2.cdl
compound_datasize_test.cdl compound_datasize_test2.cdl \
tst_gattenum.cdl tst_usuffix.cdl
# This shell script causes ncgen to build a classic and a 64-bit
# offset file from a cdl file shipped with the distribution.
@ -38,6 +39,8 @@ endif # USE_NETCDF4
CLEANFILES = c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c \
ncf199.nc c5.nc compound_datasize_test.nc compound_datasize_test2.nc \
tst_compound_datasize_test.cdl tst_compound_datasize_test2.cdl tst_ncf199.cdl \
tst_tst_gattenum.cdl tst_gattenum.nc \
tst_tst_usuffix.cdl tst_usuffix.nc \
tst_c0.cdl tst_c0_4.cdl tst_c0_4c.cdl tst_c0_64.cdl
# These rules are used if someone wants to rebuild ncgenl.c or ncgeny.c

View File

@ -839,7 +839,7 @@ collecttag(char* text, char** stagp)
stag[MAXTAGLEN] = '\0';
if(stag[0] == 'U' || stag[0] == 'u') {
hasU = 1;
memmove(stag,stag+1,MAXTAGLEN);
memmove(stag,stag+1,MAXTAGLEN);
staglen--;
} else if(stag[staglen-1] == 'U' || stag[staglen-1] == 'u') {
hasU = 1;
@ -847,7 +847,7 @@ collecttag(char* text, char** stagp)
stag[staglen] = '\0';
}
if(strlen(stag) == 0 && hasU) {
tag = NC_UINT64;
tag = NC_UINT;
} else if(strlen(stag) == 1) {
switch (stag[0]) {
case 'B': case 'b': tag = (hasU ? NC_UBYTE : NC_BYTE); break;

View File

@ -1,5 +1,5 @@
#line 3 "lex.ncg.c"
#line 3 "ncgenl.c"
#define YY_INT_ALIGNED short int
@ -65,7 +65,6 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
typedef uint64_t flex_uint64_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
@ -172,12 +171,7 @@ typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
extern yy_size_t ncgleng;
extern int ncgleng;
extern FILE *ncgin, *ncgout;
@ -203,6 +197,11 @@ extern FILE *ncgin, *ncgout;
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
@ -220,7 +219,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
yy_size_t yy_n_chars;
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@ -290,8 +289,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when ncgtext is formed. */
static char yy_hold_char;
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
yy_size_t ncgleng;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
int ncgleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
@ -319,7 +318,7 @@ static void ncg_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE ncg_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE ncg_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,yy_size_t len );
YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,int len );
void *ncgalloc (yy_size_t );
void *ncgrealloc (void *,yy_size_t );
@ -374,7 +373,7 @@ static void yy_fatal_error (yyconst char msg[] );
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
ncgleng = (yy_size_t) (yy_cp - yy_bp); \
ncgleng = (size_t) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
@ -1320,7 +1319,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 1324 "lex.ncg.c"
#line 1323 "ncgenl.c"
#define INITIAL 0
#define ST_C_COMMENT 1
@ -1361,7 +1360,7 @@ FILE *ncgget_out (void );
void ncgset_out (FILE * out_str );
yy_size_t ncgget_leng (void );
int ncgget_leng (void );
char *ncgget_text (void );
@ -1422,7 +1421,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
yy_size_t n; \
int n; \
for ( n = 0; n < max_size && \
(c = getc( ncgin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@ -1506,7 +1505,7 @@ YY_DECL
#line 217 "ncgen.l"
#line 1510 "lex.ncg.c"
#line 1509 "ncgenl.c"
if ( !(yy_init) )
{
@ -2119,7 +2118,7 @@ YY_RULE_SETUP
#line 570 "ncgen.l"
ECHO;
YY_BREAK
#line 2123 "lex.ncg.c"
#line 2122 "ncgenl.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT):
yyterminate();
@ -2306,7 +2305,7 @@ static int yy_get_next_buffer (void)
else
{
yy_size_t num_to_read =
int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
@ -2320,7 +2319,7 @@ static int yy_get_next_buffer (void)
if ( b->yy_is_our_buffer )
{
yy_size_t new_size = b->yy_buf_size * 2;
int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@ -2351,7 +2350,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), num_to_read );
(yy_n_chars), (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
@ -2461,7 +2460,7 @@ static int yy_get_next_buffer (void)
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register yy_size_t number_to_move = (yy_n_chars) + 2;
register int number_to_move = (yy_n_chars) + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
@ -2510,7 +2509,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@ -2534,7 +2533,7 @@ static int yy_get_next_buffer (void)
case EOB_ACT_END_OF_FILE:
{
if ( ncgwrap( ) )
return 0;
return EOF;
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
@ -2786,7 +2785,7 @@ void ncgpop_buffer_state (void)
*/
static void ncgensure_buffer_stack (void)
{
yy_size_t num_to_alloc;
int num_to_alloc;
if (!(yy_buffer_stack)) {
@ -2883,11 +2882,12 @@ YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr )
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, int _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n, i;
yy_size_t n;
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
@ -2969,7 +2969,7 @@ FILE *ncgget_out (void)
/** Get the length of the current token.
*
*/
yy_size_t ncgget_leng (void)
int ncgget_leng (void)
{
return ncgleng;
}
@ -3391,7 +3391,7 @@ collecttag(char* text, char** stagp)
stag[MAXTAGLEN] = '\0';
if(stag[0] == 'U' || stag[0] == 'u') {
hasU = 1;
memmove(stag,stag+1,MAXTAGLEN);
memmove(stag,stag+1,MAXTAGLEN);
staglen--;
} else if(stag[staglen-1] == 'U' || stag[staglen-1] == 'u') {
hasU = 1;
@ -3399,7 +3399,7 @@ collecttag(char* text, char** stagp)
stag[staglen] = '\0';
}
if(strlen(stag) == 0 && hasU) {
tag = NC_UINT64;
tag = NC_UINT;
} else if(strlen(stag) == 1) {
switch (stag[0]) {
case 'B': case 'b': tag = (hasU ? NC_UBYTE : NC_BYTE); break;

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,13 @@
/* A Bison parser, made by GNU Bison 2.3. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Skeleton interface for Bison's Yacc-like parsers in C
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -16,9 +15,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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@ -33,139 +30,100 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YY_NCG_NCGEN_TAB_H_INCLUDED
# define YY_NCG_NCGEN_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int ncgdebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
NC_UNLIMITED_K = 258,
CHAR_K = 259,
BYTE_K = 260,
SHORT_K = 261,
INT_K = 262,
FLOAT_K = 263,
DOUBLE_K = 264,
UBYTE_K = 265,
USHORT_K = 266,
UINT_K = 267,
INT64_K = 268,
UINT64_K = 269,
IDENT = 270,
TERMSTRING = 271,
CHAR_CONST = 272,
BYTE_CONST = 273,
SHORT_CONST = 274,
INT_CONST = 275,
INT64_CONST = 276,
UBYTE_CONST = 277,
USHORT_CONST = 278,
UINT_CONST = 279,
UINT64_CONST = 280,
FLOAT_CONST = 281,
DOUBLE_CONST = 282,
DIMENSIONS = 283,
VARIABLES = 284,
NETCDF = 285,
DATA = 286,
TYPES = 287,
COMPOUND = 288,
ENUM = 289,
OPAQUE_ = 290,
OPAQUESTRING = 291,
GROUP = 292,
PATH = 293,
FILLMARKER = 294,
NIL = 295,
_FILLVALUE = 296,
_FORMAT = 297,
_STORAGE = 298,
_CHUNKSIZES = 299,
_DEFLATELEVEL = 300,
_SHUFFLE = 301,
_ENDIANNESS = 302,
_NOFILL = 303,
_FLETCHER32 = 304,
_NCPROPS = 305,
_ISNETCDF4 = 306,
_SUPERBLOCK = 307,
DATASETID = 308
};
enum yytokentype
{
NC_UNLIMITED_K = 258,
CHAR_K = 259,
BYTE_K = 260,
SHORT_K = 261,
INT_K = 262,
FLOAT_K = 263,
DOUBLE_K = 264,
UBYTE_K = 265,
USHORT_K = 266,
UINT_K = 267,
INT64_K = 268,
UINT64_K = 269,
IDENT = 270,
TERMSTRING = 271,
CHAR_CONST = 272,
BYTE_CONST = 273,
SHORT_CONST = 274,
INT_CONST = 275,
INT64_CONST = 276,
UBYTE_CONST = 277,
USHORT_CONST = 278,
UINT_CONST = 279,
UINT64_CONST = 280,
FLOAT_CONST = 281,
DOUBLE_CONST = 282,
DIMENSIONS = 283,
VARIABLES = 284,
NETCDF = 285,
DATA = 286,
TYPES = 287,
COMPOUND = 288,
ENUM = 289,
OPAQUE_ = 290,
OPAQUESTRING = 291,
GROUP = 292,
PATH = 293,
FILLMARKER = 294,
NIL = 295,
_FILLVALUE = 296,
_FORMAT = 297,
_STORAGE = 298,
_CHUNKSIZES = 299,
_DEFLATELEVEL = 300,
_SHUFFLE = 301,
_ENDIANNESS = 302,
_NOFILL = 303,
_FLETCHER32 = 304,
_NCPROPS = 305,
_ISNETCDF4 = 306,
_SUPERBLOCK = 307,
DATASETID = 308
};
#endif
/* Tokens. */
#define NC_UNLIMITED_K 258
#define CHAR_K 259
#define BYTE_K 260
#define SHORT_K 261
#define INT_K 262
#define FLOAT_K 263
#define DOUBLE_K 264
#define UBYTE_K 265
#define USHORT_K 266
#define UINT_K 267
#define INT64_K 268
#define UINT64_K 269
#define IDENT 270
#define TERMSTRING 271
#define CHAR_CONST 272
#define BYTE_CONST 273
#define SHORT_CONST 274
#define INT_CONST 275
#define INT64_CONST 276
#define UBYTE_CONST 277
#define USHORT_CONST 278
#define UINT_CONST 279
#define UINT64_CONST 280
#define FLOAT_CONST 281
#define DOUBLE_CONST 282
#define DIMENSIONS 283
#define VARIABLES 284
#define NETCDF 285
#define DATA 286
#define TYPES 287
#define COMPOUND 288
#define ENUM 289
#define OPAQUE_ 290
#define OPAQUESTRING 291
#define GROUP 292
#define PATH 293
#define FILLMARKER 294
#define NIL 295
#define _FILLVALUE 296
#define _FORMAT 297
#define _STORAGE 298
#define _CHUNKSIZES 299
#define _DEFLATELEVEL 300
#define _SHUFFLE 301
#define _ENDIANNESS 302
#define _NOFILL 303
#define _FLETCHER32 304
#define _NCPROPS 305
#define _ISNETCDF4 306
#define _SUPERBLOCK 307
#define DATASETID 308
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 136 "ncgen.y"
union YYSTYPE
{
#line 136 "ncgen.y" /* yacc.c:1909 */
Symbol* sym;
unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/
long mark; /* track indices into the sequence*/
int nctype; /* for tracking attribute list type*/
Datalist* datalist;
NCConstant constant;
}
/* Line 1529 of yacc.c. */
#line 164 "ncgen.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#line 117 "ncgeny.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE ncglval;
int ncgparse (void);
#endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */

View File

@ -54,5 +54,11 @@ validateNC "compound_datasize_test" "compound_datasize_test" -k nc4
echo "*** github issue 323 test 2"
validateNC "compound_datasize_test2" "compound_datasize_test2" -k nc4
echo "*** Global Attribute with Enum type"
validateNC "tst_gattenum" "tst_gattenum" -k nc4
echo "*** Integer constant with just 'u' suffix"
validateNC "tst_usuffix" "tst_usuffix" -k nc4
echo "*** Test successful!"
exit 0

View File

@ -422,6 +422,11 @@ processeconstrefs(void)
{
unsigned long i;
/* locate all the datalist and walk them recursively */
for(i=0;i<listlength(gattdefs);i++) {
Symbol* att = (Symbol*)listget(gattdefs,i);
if(att->data != NULL && listlength(att->data) > 0)
processeconstrefsR(att->data);
}
for(i=0;i<listlength(attdefs);i++) {
Symbol* att = (Symbol*)listget(attdefs,i);
if(att->data != NULL && listlength(att->data) > 0)

8
ncgen/tst_gattenum.cdl Normal file
View File

@ -0,0 +1,8 @@
netcdf tst_gattenum {
types:
ubyte enum Bradys {Mike = 0, Carol = 1, Greg = 2, Marsha = 3, Peter = 4,
Jan = 5, Bobby = 6, Whats-her-face = 7, Alice = 8} ;
// global attributes:
Bradys :brady_attribute = Mike, Marsha, Alice;
}

9
ncgen/tst_usuffix.cdl Normal file
View File

@ -0,0 +1,9 @@
netcdf tst_usuffix {
variables:
float att_var ;
att_var:uint_att = 73U ;
att_var:uint_att2 = 73U ;
data:
att_var = 10 ;
}