From 64af659fae46374cce09489d5a2c2331a6994745 Mon Sep 17 00:00:00 2001 From: Wei-keng Liao Date: Sun, 20 Aug 2017 13:53:25 -0500 Subject: [PATCH 01/36] fix vpath build for regenerating c files from m4 files --- libsrc/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/Makefile.am b/libsrc/Makefile.am index ce48785f4a..7b099aef52 100644 --- a/libsrc/Makefile.am +++ b/libsrc/Makefile.am @@ -42,12 +42,12 @@ noinst_LTLIBRARIES = libnetcdf3.la # These files are cleaned on developer workstations (and then rebuilt # with m4), but they are included in the distribution so that the user # does not have to have m4. -MAINTAINERCLEANFILES = $(man_MANS) attrx.c ncx.c putgetx.c +MAINTAINERCLEANFILES = $(man_MANS) attr.c ncx.c putget.c 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 $< > $(top_srcdir)/libsrc/$@ + m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< > $(top_srcdir)/libsrc/$(@F) # The C API man page. man_MANS = netcdf.3 From 1287e0a051d19e24f6fe42fcc0dfe55080e475be Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Mon, 30 Oct 2017 15:11:23 -0600 Subject: [PATCH 02/36] ckp --- cf | 20 ++++++-------------- ncgen/genbin.c | 4 +++- ncgen/main.c | 25 ++++++++++++++----------- ncgen/semantics.c | 6 +++++- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/cf b/cf index 40ab555bf7..9c66537c12 100644 --- a/cf +++ b/cf @@ -7,7 +7,7 @@ FAST=1 HDF5=1 DAP=1 #HDF4=1 -#PNETCDF=1 +PNETCDF=1 #PAR4=1 if test $# != 0 ; then @@ -152,19 +152,11 @@ FLAGS="$FLAGS --disable-dap" fi if test "x$MPIO" = x1 ; then - if test -f /machine/local_mpich2 ; then - MPI1=/machine/local_mpich2 - MPI2=/machine/local_par7 - MPI3=/machine/local_par - else - MPI1=/usr/local - MPI2=${MPI1} - MPI3=${MPI1} - fi - PATH=${PATH}:${MPI1}/bin - CC="${MPI1}/bin/mpicc" - CPPFLAGS="-I${MPI2}/include -I${MPI1}/include -I${MPI3}/include" - LDFLAGS="-L${MPI2}/lib -L${MPI1}/lib -L${MPI3}/lib" + MPIDIR=/usr/lib64/mpich + PATH="${PATH}:${MPIDIR}/bin" + CC="${MPIDIR}/bin/mpicc" + CPPFLAGS="-I${MPIDIR}/include" + LDFLAGS="$LDFLAGS -L${MPIDIR}" LDLIBS="-lmpich" FLAGS="$FLAGS --enable-pnetcdf" FLAGS="$FLAGS --enable-parallel-tests" diff --git a/ncgen/genbin.c b/ncgen/genbin.c index 26a85c08df..9e8bcd367f 100644 --- a/ncgen/genbin.c +++ b/ncgen/genbin.c @@ -356,6 +356,7 @@ genbin_defineattr(Symbol* asym) Bytebuffer* databuf = bbNew(); generator_reset(bin_generator,NULL); generate_attrdata(asym,bin_generator,(Writer)genbin_write,databuf); + bbFree(databuf); } @@ -368,6 +369,7 @@ genbin_definevardata(Symbol* vsym) databuf = bbNew(); generator_reset(bin_generator,NULL); generate_vardata(vsym,bin_generator,(Writer)genbin_write,databuf); + bbFree(databuf); } static int @@ -430,7 +432,7 @@ static int genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf, int rank, size_t* start, size_t* count) { - int stat; + int stat = NC_NOERR; size_t len; Datalist* list; int varid, grpid, typid; diff --git a/ncgen/main.c b/ncgen/main.c index dd6079ce61..dbc4ce6feb 100644 --- a/ncgen/main.c +++ b/ncgen/main.c @@ -27,8 +27,8 @@ extern void parse_init(void); extern int ncgparse(void); /* For error messages */ -char* progname; -char* cdlname; +char* progname; /* Global: not reclaimed */ +char* cdlname; /* Global: not reclaimed */ /* option flags */ int nofill_flag; @@ -213,7 +213,6 @@ main( int c; FILE *fp; struct Languages* langs; - char* lang_name; #ifdef __hpux setlocale(LC_CTYPE,""); #endif @@ -221,8 +220,8 @@ main( init_netcdf(); opterr = 1; /* print error message if bad option */ - progname = ubasename(argv[0]); - cdlname = "-"; + progname = nulldup(ubasename(argv[0])); + cdlname = NULL; netcdf_name = NULL; datasetname = NULL; l_flag = 0; @@ -289,6 +288,7 @@ main( exit(0); case 'l': /* specify language, instead of using -c or -f or -b */ { + char* lang_name = NULL; if(l_flag != 0) { fprintf(stderr,"Please specify only one language\n"); return 1; @@ -307,8 +307,10 @@ main( } if(langs->name == NULL) { derror("%s: output language %s not implemented",progname, lang_name); + nullfree(lang_name); return(1); } + nullfree(lang_name); }; break; case 'L': ncloglevel = atoi(optarg); @@ -363,8 +365,10 @@ main( } if(kvalue->name == NULL) { derror("Invalid format: %s",kind_name); + nullfree(kind_name); return 2; } + nullfree(kind_name); } break; case '3': /* output format is classic (netCDF-3) */ k_flag = NC_FORMAT_CLASSIC; @@ -481,13 +485,12 @@ main( break; } } + } - cdlname = (char*)emalloc(NC_MAX_NAME); - cdlname = nulldup(argv[0]); - if(cdlname != NULL) { - if(strlen(cdlname) > NC_MAX_NAME) - cdlname[NC_MAX_NAME] = '\0'; - } + cdlname = nulldup(argv[0]); + if(cdlname != NULL) { + if(strlen(cdlname) > NC_MAX_NAME) + cdlname[NC_MAX_NAME] = '\0'; } parse_init(); diff --git a/ncgen/semantics.c b/ncgen/semantics.c index 88be73c0c7..fdc5300a24 100644 --- a/ncgen/semantics.c +++ b/ncgen/semantics.c @@ -387,7 +387,9 @@ static void processenums(void) { unsigned long i,j; +#if 0 /* Unused? */ List* enumids = listnew(); +#endif for(i=0;iobjectclass == NC_TYPE); @@ -395,7 +397,9 @@ processenums(void) for(j=0;jsubnodes);j++) { Symbol* esym = (Symbol*)listget(sym->subnodes,j); ASSERT(esym->subclass == NC_ECONST); +#if 0 /* Unused? */ listpush(enumids,(void*)esym); +#endif } } /* Convert enum values to match enum type*/ @@ -443,7 +447,7 @@ processeconstrefs(void) static void processeconstrefsR(Datalist* data) { - NCConstant* con; + NCConstant* con = NULL; int i; for(i=0,con=data->data;ialloc;i++,con++) { if(con->nctype == NC_COMPOUND) { From 815f4e4a182bcc521692325e77981c2b68a3bc00 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Mon, 30 Oct 2017 15:52:08 -0600 Subject: [PATCH 03/36] Cleanup ncgen memory management --- ncgen/bindata.c | 2 +- ncgen/bytebuffer.c | 6 +- ncgen/cdfdata.c | 2 +- ncgen/cvt.c | 8 +- ncgen/data.c | 14 +-- ncgen/debug.c | 36 +++--- ncgen/debug.h | 16 ++- ncgen/escapes.c | 6 +- ncgen/genchar.c | 6 +- ncgen/generate.c | 2 +- ncgen/genjjni.c | 2 +- ncgen/genlib.c | 6 +- ncgen/genlib.h | 5 - ncgen/jdatajni.c | 2 +- ncgen/main.c | 28 ++--- ncgen/ncgen.l | 2 +- ncgen/ncgen.y | 8 +- ncgen/ncgenl.c | 201 ++++++++++++++------------------ ncgen/ncgeny.c | 280 +++++++++++++++++++++++---------------------- ncgen/ncgeny.h | 2 +- ncgen/odom.c | 4 +- ncgen/util.c | 6 +- 22 files changed, 308 insertions(+), 336 deletions(-) diff --git a/ncgen/bindata.c b/ncgen/bindata.c index 741cb601e6..7dd2d57c2b 100644 --- a/ncgen/bindata.c +++ b/ncgen/bindata.c @@ -86,7 +86,7 @@ bin_constant(Generator* generator, Symbol* sym, NCConstant* con, Bytebuffer* buf char* nil = NULL; bbAppendn(buf,(void*)&nil,sizeof(nil)); } else { - ptr = (char*)malloc(len+1); + ptr = (char*)ecalloc(len+1); memcpy(ptr,con->value.stringv.stringv,len); ptr[len] = '\0'; bbAppendn(buf,(void*)&ptr,sizeof(ptr)); diff --git a/ncgen/bytebuffer.c b/ncgen/bytebuffer.c index fd68dc630b..d4ba1d3daa 100644 --- a/ncgen/bytebuffer.c +++ b/ncgen/bytebuffer.c @@ -35,7 +35,7 @@ bbFail(void) Bytebuffer* bbNew(void) { - Bytebuffer* bb = (Bytebuffer*)emalloc(sizeof(Bytebuffer)); + Bytebuffer* bb = (Bytebuffer*)malloc(sizeof(Bytebuffer)); if(bb == NULL) return (Bytebuffer*)bbFail(); bb->alloc=0; bb->length=0; @@ -53,7 +53,7 @@ bbSetalloc(Bytebuffer* bb, const unsigned int sz0) if(sz <= 0) {sz = (bb->alloc?2*bb->alloc:DEFAULTALLOC);} else if(bb->alloc >= sz) return TRUE; else if(bb->nonextendible) return bbFail(); - newcontent=(char*)ecalloc(sz,sizeof(char)); + newcontent=(char*)calloc(sz,sizeof(char)); if(bb->alloc > 0 && bb->length > 0 && bb->content != NULL) { memcpy((void*)newcontent,(void*)bb->content,sizeof(char)*bb->length); } @@ -250,7 +250,7 @@ bbTailpeek(Bytebuffer* bb, char* pelem) char* bbDup(const Bytebuffer* bb) { - char* result = (char*)emalloc(bb->length+1); + char* result = (char*)malloc(bb->length+1); memcpy((void*)result,(const void*)bb->content,bb->length); result[bb->length] = '\0'; /* just in case it is a string*/ return result; diff --git a/ncgen/cdfdata.c b/ncgen/cdfdata.c index 45a8eb7642..95a78043c4 100644 --- a/ncgen/cdfdata.c +++ b/ncgen/cdfdata.c @@ -323,7 +323,7 @@ genbin_vlenconstants(List* vlenconstants) /* Prepare a place to store vlen constants */ nvlen = listlength(vlenconstants); if(nvlen == 0) return; - vlendata = (struct Vlendata*)emalloc(sizeof(struct Vlendata)*nvlen+1); + vlendata = (struct Vlendata*)ecalloc(sizeof(struct Vlendata)*nvlen+1); memset((void*)vlendata,0,sizeof(struct Vlendata)*nvlen+1); for(i=0;ivalue.stringv.len; - tmp.stringv.stringv = (char*)malloc(src->value.stringv.len+1); + tmp.stringv.stringv = (char*)ecalloc(src->value.stringv.len+1); memcpy((void*)tmp.stringv.stringv, (void*)src->value.stringv.stringv, tmp.stringv.len); @@ -549,7 +549,7 @@ case CASE(NC_OPAQUE,NC_DOUBLE): tmp.doublev = *(double*)bytes; break; case CASE(NC_OPAQUE,NC_OPAQUE): - tmp.opaquev.stringv = (char*)malloc(src->value.opaquev.len+1); + tmp.opaquev.stringv = (char*)ecalloc(src->value.opaquev.len+1); memcpy(tmp.opaquev.stringv,src->value.opaquev.stringv,src->value.opaquev.len); tmp.opaquev.len = src->value.opaquev.len; tmp.opaquev.stringv[tmp.opaquev.len] = '\0'; @@ -590,7 +590,7 @@ setprimlength(NCConstant* prim, unsigned long len) prim->value.stringv.len = len; } else {/* prim->value.stringv.len > srcov->len*/ char* s; - s = (char*)emalloc(len+1); + s = (char*)ecalloc(len+1); memset(s,NC_FILL_CHAR,len); s[len] = '\0'; memcpy(s,prim->value.stringv.stringv,prim->value.stringv.len); @@ -609,7 +609,7 @@ setprimlength(NCConstant* prim, unsigned long len) prim->value.opaquev.len = len; } else {/* prim->value.opaquev.len < len => expand*/ char* s; - s = (char*)emalloc(len+1); + s = (char*)ecalloc(len+1); memset(s,'0',len); memcpy(s,prim->value.opaquev.stringv,prim->value.opaquev.len); s[len] = '\0'; diff --git a/ncgen/data.c b/ncgen/data.c index c564ab416f..6420f76795 100644 --- a/ncgen/data.c +++ b/ncgen/data.c @@ -84,7 +84,7 @@ Datasrc* allocdatasrc(void) { Datasrc* src; - src = emalloc(sizeof(Datasrc)); + src = ecalloc(sizeof(Datasrc)); src->data = NULL; src->index = 0; src->length = 0; @@ -274,13 +274,13 @@ cloneconstant(NCConstant* con) char* s; switch (newcon.nctype) { case NC_STRING: - s = (char*)emalloc(newcon.value.stringv.len+1); + s = (char*)ecalloc(newcon.value.stringv.len+1); memcpy(s,newcon.value.stringv.stringv,newcon.value.stringv.len); s[newcon.value.stringv.len] = '\0'; newcon.value.stringv.stringv = s; break; case NC_OPAQUE: - s = (char*)emalloc(newcon.value.opaquev.len+1); + s = (char*)ecalloc(newcon.value.opaquev.len+1); memcpy(s,newcon.value.opaquev.stringv,newcon.value.opaquev.len); s[newcon.value.opaquev.len] = '\0'; newcon.value.opaquev.stringv = s; @@ -675,7 +675,7 @@ indented(int n) { char* indentation; if(dent == NULL) { - dent = (char*)emalloc(INDENTMAX+1); + dent = (char*)ecalloc(INDENTMAX+1); memset((void*)dent,' ',INDENTMAX); dent[INDENTMAX] = '\0'; } @@ -700,7 +700,7 @@ dlsetalloc(Datalist* dl, size_t newalloc) if(dl->alloc > 0) newdata = (NCConstant*)erealloc((void*)dl->data,sizeof(NCConstant)*newalloc); else { - newdata = (NCConstant*)emalloc(sizeof(NCConstant)*newalloc); + newdata = (NCConstant*)ecalloc(sizeof(NCConstant)*newalloc); memset((void*)newdata,0,sizeof(NCConstant)*newalloc); } dl->alloc = newalloc; @@ -714,9 +714,9 @@ builddatalist(int initial) Datalist* ci; if(initial <= 0) initial = DATALISTINIT; initial++; /* for header*/ - ci = (Datalist*)emalloc(sizeof(Datalist)); + ci = (Datalist*)ecalloc(sizeof(Datalist)); memset((void*)ci,0,sizeof(Datalist)); /* only clear the hdr*/ - ci->data = (NCConstant*)emalloc(sizeof(NCConstant)*initial); + ci->data = (NCConstant*)ecalloc(sizeof(NCConstant)*initial); memset((void*)ci->data,0,sizeof(NCConstant)*initial); ci->alloc = initial; ci->length = 0; diff --git a/ncgen/debug.c b/ncgen/debug.c index 468986f7b6..b20bd0665c 100644 --- a/ncgen/debug.c +++ b/ncgen/debug.c @@ -1,9 +1,7 @@ -/********************************************************************* - * Copyright 2009, UCAR/Unidata - * See netcdf/COPYRIGHT file for copying and redistribution conditions. - *********************************************************************/ -/* $Id: debug.c,v 1.2 2010/05/24 19:59:57 dmh Exp $ */ -/* $Header: /upc/share/CVS/netcdf-3/ncgen/debug.c,v 1.2 2010/05/24 19:59:57 dmh Exp $ */ +/* +Copyright (c) 1998-2017 University Corporation for Atmospheric Research/Unidata +See LICENSE.txt for license information. +*/ #include "includes.h" @@ -26,21 +24,23 @@ void fdebug(const char *fmt, ...) /**************************************************/ /* Support debugging of memory*/ -/* Also guarantee that calloc zeros memory*/ -void* -chkcalloc(size_t size, size_t nelems) + +void +chkfree(void* memory) { - return chkmalloc(size*nelems); + if(memory == NULL) { + panic("free: null memory"); + } + free(memory); } void* -chkmalloc(size_t size) +chkcalloc(size_t size) { void* memory = calloc(size,1); /* use calloc to zero memory*/ if(memory == NULL) { panic("malloc:out of memory"); } - memset(memory,0,size); return memory; } @@ -54,10 +54,16 @@ chkrealloc(void* ptr, size_t size) return memory; } -void -chkfree(void* mem) +char* +chkstrdup(const char* s) { - if(mem != NULL) free(mem); + char* dup = strdup(s); + if(s == NULL) { + panic("strdup: null argument"); + } + if(dup == NULL) { + panic("strdup: out of memory"); + } } int diff --git a/ncgen/debug.h b/ncgen/debug.h index 60ec1e4e8b..bf183aae62 100644 --- a/ncgen/debug.h +++ b/ncgen/debug.h @@ -43,18 +43,22 @@ extern void fdebug(const char *fmt, ...); extern int panic(const char* fmt, ...); /* -Provide wrapped versions of calloc and malloc. -The wrapped version panics if memory is exhausted. +Provide wrapped versions of XXXalloc for debugging/ +The wrapped version: +1. fails if size is zero or memory is NULL +2. fails if memory is exhausted. +3. zeros all allocated memory. */ -#define ecalloc(x,y) chkcalloc(x,y) -#define emalloc(x) chkmalloc(x) +#define ecalloc(x) chkcalloc(x) /*note only single arg */ #define erealloc(p,x) chkrealloc(p,x) #define efree(x) chkfree(x) -extern void* chkcalloc(size_t, size_t); -extern void* chkmalloc(size_t); +#define estrdup(x) chkstrdup(x) +extern void* chkcalloc(size_t); extern void* chkrealloc(void*,size_t); extern void chkfree(void*); +extern char* chkstrdup(const char* s); + #define MEMCHECK(var,throw) {if((var)==NULL) return (throw);} #endif /*NCGEN_DEBUG_H*/ diff --git a/ncgen/escapes.c b/ncgen/escapes.c index 3211728b3d..a5e66bcc2f 100644 --- a/ncgen/escapes.c +++ b/ncgen/escapes.c @@ -169,7 +169,7 @@ initcodify(void) idtlen = strlen("DIGIT_n_"); /* initial digit template */ hexlen = strlen("_XHH"); /* template for hex of non-ASCII bytes */ for(i = 0; i < 128; i++) { - rp = emalloc(2); + rp = ecalloc(2); rp[0] = i; rp[1] = '\0'; repls[i] = rp; @@ -180,7 +180,7 @@ initcodify(void) repls[j] = ctable[i].s; } for(i = 128; i < 256; i++) { - rp = emalloc(hexlen+1); + rp = ecalloc(hexlen+1); snprintf(rp, hexlen+1, "_X%2.2X", i); /* need to include null*/ rp[hexlen] = '\0'; repls[i] = rp; @@ -460,7 +460,7 @@ f77quotestring(Bytebuffer* databuf) return; } - s = (unsigned char*)emalloc(slen+1); + s = (unsigned char*)ecalloc(slen+1); memcpy((void*)s,bbContents(databuf),slen); s[slen] = '\0'; bbClear(databuf); diff --git a/ncgen/genchar.c b/ncgen/genchar.c index 17682246d6..7a96ff0694 100644 --- a/ncgen/genchar.c +++ b/ncgen/genchar.c @@ -253,7 +253,7 @@ gen_leafchararray(Dimset* dimset, int dimindex, Datalist* data, } } if(cccount > 1) { - char* accum = (char*)malloc(cccount+1); + char* accum = (char*)ecalloc(cccount+1); int len = 0; Datalist* newlist = builddatalist(datalistlen(data)); int lineno = 0; @@ -338,13 +338,13 @@ gen_leafchararray(Dimset* dimset, int dimindex, Datalist* data, static NCConstant* makeconst(int lineno, int len, char* str) { - NCConstant* con = (NCConstant*)malloc(sizeof(NCConstant)); + NCConstant* con = (NCConstant*)ecalloc(sizeof(NCConstant)); con->nctype = NC_STRING; con->lineno = lineno; con->filled = 0; con->value.stringv.len = len; /* We cannot use strdup because str might have embedded nuls */ - con->value.stringv.stringv = (char*)malloc(len+1); + con->value.stringv.stringv = (char*)ecalloc(len+1); memcpy((void*)con->value.stringv.stringv,(void*)str,len); con->value.stringv.stringv[len] = '\0'; return con; diff --git a/ncgen/generate.c b/ncgen/generate.c index 9c2449ea6b..73f234d4ea 100644 --- a/ncgen/generate.c +++ b/ncgen/generate.c @@ -450,7 +450,7 @@ normalizeopaquelength(NCConstant* prim, unsigned long nbytes) prim->value.opaquev.len = nnibs; } else {/* prim->value.opaquev.len < nnibs => expand*/ char* s; - s = (char*)emalloc(nnibs+1); + s = (char*)ecalloc(nnibs+1); memset(s,'0',nnibs); /* Fill with '0' characters */ memcpy(s,prim->value.opaquev.stringv,prim->value.opaquev.len); s[nnibs] = '\0'; diff --git a/ncgen/genjjni.c b/ncgen/genjjni.c index a47558656b..7cc3910697 100644 --- a/ncgen/genjjni.c +++ b/ncgen/genjjni.c @@ -1541,7 +1541,7 @@ jname(Symbol* sym) /* Attribute name must be prefixed with the cname of the*/ /* associated variable*/ char* lname; - lname = (char*)emalloc(strlen(sym->att.var->name) + lname = (char*)ecalloc(strlen(sym->att.var->name) +strlen(sym->name) +1+1); lname[0] = '\0'; diff --git a/ncgen/genlib.c b/ncgen/genlib.c index 98e845bb16..ff27dd7b70 100644 --- a/ncgen/genlib.c +++ b/ncgen/genlib.c @@ -116,7 +116,7 @@ topfqn(Symbol* sym) parentfqn = parent->fqn; fqnname = fqnescape(sym->name); - fqn = (char*)malloc(strlen(fqnname) + strlen(parentfqn) + 1 + 1); + fqn = (char*)ecalloc(strlen(fqnname) + strlen(parentfqn) + 1 + 1); strcpy(fqn,parentfqn); strcat(fqn,"/"); strcat(fqn,fqnname); @@ -151,7 +151,7 @@ nestedfqn(Symbol* sym) assert(parent->fqn != NULL); fqnname = fqnescape(sym->name); - fqn = (char*)malloc(strlen(fqnname) + strlen(parent->fqn) + 1 + 1); + fqn = (char*)ecalloc(strlen(fqnname) + strlen(parent->fqn) + 1 + 1); strcpy(fqn,parent->fqn); strcat(fqn,"."); strcat(fqn,fqnname); @@ -183,7 +183,7 @@ attfqn(Symbol* sym) parentfqn = parent->fqn; fqnname = fqnescape(sym->name); - fqn = (char*)malloc(strlen(fqnname) + strlen(parentfqn) + 1 + 1); + fqn = (char*)ecalloc(strlen(fqnname) + strlen(parentfqn) + 1 + 1); strcpy(fqn,parentfqn); strcat(fqn,"_"); strcat(fqn,fqnname); diff --git a/ncgen/genlib.h b/ncgen/genlib.h index 9450b0dc81..70110e397a 100644 --- a/ncgen/genlib.h +++ b/ncgen/genlib.h @@ -194,11 +194,6 @@ extern char *netcdf_name; /* command line -o file name */ extern char *datasetname; /* name from the netcdf {} */ extern char *cdlname; /* name from the command line */ -/* from: util.c */ -extern void* emalloc (size_t); -extern void* ecalloc (size_t); -extern void* erealloc(void*,size_t); - extern const char* specialname(int tag); #endif /*!NC_GENLIB_H*/ diff --git a/ncgen/jdatajni.c b/ncgen/jdatajni.c index 710a553c3a..c98ef0a2cc 100644 --- a/ncgen/jdatajni.c +++ b/ncgen/jdatajni.c @@ -446,7 +446,7 @@ jopaquestring(Symbol* tsym, Constant* prim, Constant* target) ASSERT((oplen%2) == 0); - opstring = (char*)emalloc(oplen*(2+4)); + opstring = (char*)ecalloc(oplen*(2+4)); opstring[0]='\0'; p=(unsigned char*)op; diff --git a/ncgen/main.c b/ncgen/main.c index dbc4ce6feb..73672b8ca8 100644 --- a/ncgen/main.c +++ b/ncgen/main.c @@ -297,8 +297,7 @@ main( derror("%s: output language is null", progname); return(1); } - lang_name = (char*) emalloc(strlen(optarg)+1); - (void)strcpy(lang_name, optarg); + lang_name = estrdup(optarg); for(langs=legallanguages;langs->name != NULL;langs++) { if(strcmp(lang_name,langs->name)==0) { l_flag = langs->flag; @@ -348,27 +347,20 @@ main( 5 (=> classic 64 bit data aka CDF-5) */ struct Kvalues* kvalue; - char *kind_name = (optarg != NULL - ? (char *) emalloc(strlen(optarg)+1) - : emalloc(1)); - if (! kind_name) { - derror ("%s: out of memory", progname); - return(1); - } - if(optarg != NULL) - (void)strcpy(kind_name, optarg); + if(optarg == NULL) { + derror("-k flag has no value"); + return 2; + } for(kvalue=legalkinds;kvalue->name;kvalue++) { - if(strcmp(kind_name,kvalue->name) == 0) { - k_flag = kvalue->k_flag; - break; - } + if(strcmp(optarg,kvalue->name) == 0) { + k_flag = kvalue->k_flag; + break; + } } if(kvalue->name == NULL) { - derror("Invalid format: %s",kind_name); - nullfree(kind_name); + derror("Invalid format: %s",optarg); return 2; } - nullfree(kind_name); } break; case '3': /* output format is classic (netCDF-3) */ k_flag = NC_FORMAT_CLASSIC; diff --git a/ncgen/ncgen.l b/ncgen/ncgen.l index 42ff6dca1a..7afc90f444 100644 --- a/ncgen/ncgen.l +++ b/ncgen/ncgen.l @@ -606,7 +606,7 @@ makepath(char* text0) /* split the text into IDENT chunks, convert to symbols */ Symbol* container = rootgroup; char *ident, *p; - char* text = strdup(text0); + char* text = estrdup(text0); int c,lastident; ident=text+1; p=ident; /* skip leading '/' */ do { diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y index 48bacb0658..c595da725d 100644 --- a/ncgen/ncgen.y +++ b/ncgen/ncgen.y @@ -948,7 +948,7 @@ Symbol* install(const char *sname) { Symbol* sp; - sp = (Symbol*) emalloc (sizeof (struct Symbol)); + sp = (Symbol*) ecalloc (sizeof (struct Symbol)); memset((void*)sp,0,sizeof(struct Symbol)); sp->name = nulldup(sname); sp->next = symlist; @@ -1037,7 +1037,7 @@ makeconstdata(nc_type nctype) char* s; int len; len = bbLength(lextext); - s = (char*)emalloc(len+1); + s = (char*)ecalloc(len+1); strncpy(s,bbContents(lextext),len); s[len] = '\0'; con.value.opaquev.stringv = s; @@ -1235,7 +1235,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst) else if(tag == _SUPERBLOCK_FLAG) globalspecials._Superblock = idata; else if(tag == _NCPROPS_FLAG) - globalspecials._NCProperties = strdup(sdata); + globalspecials._NCProperties = estrdup(sdata); } else { Specialdata* special; /* Set up special info */ @@ -1302,7 +1302,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst) case _CHUNKSIZES_FLAG: { int i; special->nchunks = list->length; - special->_ChunkSizes = (size_t*)emalloc(sizeof(size_t)*special->nchunks); + special->_ChunkSizes = (size_t*)ecalloc(sizeof(size_t)*special->nchunks); for(i=0;inchunks;i++) { iconst.nctype = NC_INT; convert1(&list->data[i],&iconst); diff --git a/ncgen/ncgenl.c b/ncgen/ncgenl.c index 0680ecc415..a305537300 100644 --- a/ncgen/ncgenl.c +++ b/ncgen/ncgenl.c @@ -1,5 +1,5 @@ -#line 3 "lex.ncg.c" +#line 3 "ncgenl.c" #define YY_INT_ALIGNED short int @@ -26,8 +26,8 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 0 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -72,6 +72,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -102,8 +103,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -160,15 +159,7 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -180,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; @@ -194,7 +180,6 @@ extern FILE *ncgin, *ncgout; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ @@ -212,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 @@ -300,7 +290,7 @@ 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 int yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t ncgleng; +int ncgleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; @@ -328,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 ); @@ -371,17 +361,11 @@ extern int ncglineno; int ncglineno = 1; extern char *ncgtext; -#ifdef yytext_ptr -#undef yytext_ptr -#endif #define yytext_ptr ncgtext static yy_state_type yy_get_previous_state (void ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); static int yy_get_next_buffer (void ); -#if defined(__GNUC__) && __GNUC__ >= 3 -__attribute__((__noreturn__)) -#endif static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the @@ -453,7 +437,7 @@ static yyconst flex_int16_t yy_accept[417] = 34, 34, 34, 34, 34, 0 } ; -static yyconst YY_CHAR yy_ec[256] = +static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, @@ -485,7 +469,7 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[69] = +static yyconst flex_int32_t yy_meta[69] = { 0, 1, 1, 2, 1, 1, 1, 3, 4, 5, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 1, @@ -496,7 +480,7 @@ static yyconst YY_CHAR yy_meta[69] = 11, 11, 11, 14, 1, 11, 11, 11 } ; -static yyconst flex_uint16_t yy_base[435] = +static yyconst flex_int16_t yy_base[435] = { 0, 0, 0, 325, 321, 264, 255, 318, 2347, 67, 2347, 64, 269, 61, 62, 95, 77, 136, 259, 51, 61, @@ -600,7 +584,7 @@ static yyconst flex_int16_t yy_def[435] = 416, 416, 416, 416 } ; -static yyconst flex_uint16_t yy_nxt[2416] = +static yyconst flex_int16_t yy_nxt[2416] = { 0, 8, 9, 10, 9, 8, 11, 12, 8, 13, 14, 15, 16, 17, 18, 18, 18, 18, 18, 18, 8, @@ -1335,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 1339 "lex.ncg.c" +#line 1323 "ncgenl.c" #define INITIAL 0 #define ST_C_COMMENT 1 @@ -1370,19 +1354,19 @@ void ncgset_extra (YY_EXTRA_TYPE user_defined ); FILE *ncgget_in (void ); -void ncgset_in (FILE * _in_str ); +void ncgset_in (FILE * in_str ); FILE *ncgget_out (void ); -void ncgset_out (FILE * _out_str ); +void ncgset_out (FILE * out_str ); -yy_size_t ncgget_leng (void ); +int ncgget_leng (void ); char *ncgget_text (void ); int ncgget_lineno (void ); -void ncgset_lineno (int _line_number ); +void ncgset_lineno (int line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -1396,12 +1380,8 @@ extern int ncgwrap (void ); #endif #endif -#ifndef YY_NO_UNPUT - static void yyunput (int c,char *buf_ptr ); -#endif - #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif @@ -1422,12 +1402,7 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1435,7 +1410,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( ncgtext, ncgleng, 1, ncgout )) {} } while (0) +#define ECHO fwrite( ncgtext, ncgleng, 1, ncgout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1446,7 +1421,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( ncgin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1514,7 +1489,7 @@ extern int ncglex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; +#define YY_BREAK break; #endif #define YY_RULE_SETUP \ @@ -1524,10 +1499,14 @@ extern int ncglex (void); */ YY_DECL { - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; +#line 217 "ncgen.l" + +#line 1509 "ncgenl.c" + if ( !(yy_init) ) { (yy_init) = 1; @@ -1554,12 +1533,7 @@ YY_DECL ncg_load_buffer_state( ); } - { -#line 217 "ncgen.l" - -#line 1561 "lex.ncg.c" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); @@ -1575,7 +1549,7 @@ YY_DECL yy_match: do { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2144,7 +2118,7 @@ YY_RULE_SETUP #line 570 "ncgen.l" ECHO; YY_BREAK -#line 2148 "lex.ncg.c" +#line 2122 "ncgenl.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(TEXT): yyterminate(); @@ -2276,7 +2250,6 @@ case YY_STATE_EOF(TEXT): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ - } /* end of user's declarations */ } /* end of ncglex */ /* yy_get_next_buffer - try to read in a new buffer @@ -2288,9 +2261,9 @@ case YY_STATE_EOF(TEXT): */ static int yy_get_next_buffer (void) { - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = (yytext_ptr); - yy_size_t number_to_move, i; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -2319,7 +2292,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -2332,21 +2305,21 @@ 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 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); 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; @@ -2377,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); } @@ -2401,9 +2374,9 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ncgrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); @@ -2422,14 +2395,14 @@ static int yy_get_next_buffer (void) static yy_state_type yy_get_previous_state (void) { - yy_state_type yy_current_state; - char *yy_cp; + register yy_state_type yy_current_state; + register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2454,10 +2427,10 @@ static int yy_get_next_buffer (void) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { - int yy_is_jam; - char *yy_cp = (yy_c_buf_p); + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); - YY_CHAR yy_c = 1; + register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2472,14 +2445,12 @@ static int yy_get_next_buffer (void) yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 416); - return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } -#ifndef YY_NO_UNPUT - - static void yyunput (int c, char * yy_bp ) + static void yyunput (int c, register char * yy_bp ) { - char *yy_cp; + register char *yy_cp; yy_cp = (yy_c_buf_p); @@ -2489,10 +2460,10 @@ 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. */ - yy_size_t number_to_move = (yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + 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]; - char *source = + register char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -2514,8 +2485,6 @@ static int yy_get_next_buffer (void) (yy_c_buf_p) = yy_cp; } -#endif - #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) @@ -2540,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( ) ) @@ -2665,7 +2634,7 @@ static void ncg_load_buffer_state (void) if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in ncg_create_buffer()" ); - b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. @@ -2700,6 +2669,10 @@ static void ncg_load_buffer_state (void) ncgfree((void *) b ); } +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a ncgrestart() or at EOF. @@ -2812,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)) { @@ -2820,7 +2793,7 @@ static void ncgensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)ncgalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); @@ -2837,7 +2810,7 @@ static void ncgensure_buffer_stack (void) if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; + int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)ncgrealloc @@ -2904,17 +2877,17 @@ YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to ncglex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * * @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; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; @@ -2945,7 +2918,7 @@ YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len static void yy_fatal_error (yyconst char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -2996,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; } @@ -3011,29 +2984,29 @@ char *ncgget_text (void) } /** Set the current line number. - * @param _line_number line number + * @param line_number * */ -void ncgset_lineno (int _line_number ) +void ncgset_lineno (int line_number ) { - ncglineno = _line_number; + ncglineno = line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param _in_str A readable stream. + * @param in_str A readable stream. * * @see ncg_switch_to_buffer */ -void ncgset_in (FILE * _in_str ) +void ncgset_in (FILE * in_str ) { - ncgin = _in_str ; + ncgin = in_str ; } -void ncgset_out (FILE * _out_str ) +void ncgset_out (FILE * out_str ) { - ncgout = _out_str ; + ncgout = out_str ; } int ncgget_debug (void) @@ -3041,9 +3014,9 @@ int ncgget_debug (void) return ncg_flex_debug; } -void ncgset_debug (int _bdebug ) +void ncgset_debug (int bdebug ) { - ncg_flex_debug = _bdebug ; + ncg_flex_debug = bdebug ; } static int yy_init_globals (void) @@ -3103,8 +3076,7 @@ int ncglex_destroy (void) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - - int i; + register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } @@ -3113,7 +3085,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { - int n; + register int n; for ( n = 0; s[n]; ++n ) ; @@ -3123,12 +3095,11 @@ static int yy_flex_strlen (yyconst char * s ) void *ncgalloc (yy_size_t size ) { - return (void *) malloc( size ); + return (void *) malloc( size ); } void *ncgrealloc (void * ptr, yy_size_t size ) { - /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -3141,7 +3112,7 @@ void *ncgrealloc (void * ptr, yy_size_t size ) void ncgfree (void * ptr ) { - free( (char *) ptr ); /* see ncgrealloc() for (char *) cast */ + free( (char *) ptr ); /* see ncgrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" @@ -3187,7 +3158,7 @@ makepath(char* text0) /* split the text into IDENT chunks, convert to symbols */ Symbol* container = rootgroup; char *ident, *p; - char* text = strdup(text0); + char* text = estrdup(text0); int c,lastident; ident=text+1; p=ident; /* skip leading '/' */ do { diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c index 9e21e44f1b..4ad4f9c789 100644 --- a/ncgen/ncgeny.c +++ b/ncgen/ncgeny.c @@ -195,7 +195,7 @@ static void yyerror(fmt,va_alist) const char* fmt; va_dcl; extern int lex_init(void); -#line 199 "ncgen.tab.c" /* yacc.c:339 */ +#line 199 "ncgeny.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -214,7 +214,7 @@ extern int lex_init(void); #endif /* In a future release of Bison, this section will be replaced - by #include "ncgen.tab.h". */ + by #include "ncgeny.h". */ #ifndef YY_NCG_NCGEN_TAB_H_INCLUDED # define YY_NCG_NCGEN_TAB_H_INCLUDED /* Debug traces. */ @@ -298,7 +298,7 @@ int nctype; /* for tracking attribute list type*/ Datalist* datalist; NCConstant constant; -#line 302 "ncgen.tab.c" /* yacc.c:355 */ +#line 302 "ncgeny.c" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; @@ -315,7 +315,7 @@ int ncgparse (void); /* Copy the second part of user declarations. */ -#line 319 "ncgen.tab.c" /* yacc.c:358 */ +#line 319 "ncgeny.c" /* yacc.c:358 */ #ifdef short # undef short @@ -1619,13 +1619,13 @@ yyparse (void) case 2: #line 221 "ncgen.y" /* yacc.c:1646 */ {if (error_count > 0) YYABORT;} -#line 1623 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1623 "ncgeny.c" /* yacc.c:1646 */ break; case 3: #line 224 "ncgen.y" /* yacc.c:1646 */ {createrootgroup(datasetname);} -#line 1629 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1629 "ncgeny.c" /* yacc.c:1646 */ break; case 8: @@ -1637,25 +1637,25 @@ yyparse (void) yyerror("duplicate group declaration within parent group for %s", id->name); } -#line 1641 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1641 "ncgeny.c" /* yacc.c:1646 */ break; case 9: #line 252 "ncgen.y" /* yacc.c:1646 */ {listpop(groupstack);} -#line 1647 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1647 "ncgeny.c" /* yacc.c:1646 */ break; case 12: #line 258 "ncgen.y" /* yacc.c:1646 */ {} -#line 1653 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1653 "ncgeny.c" /* yacc.c:1646 */ break; case 13: #line 260 "ncgen.y" /* yacc.c:1646 */ {markcdf4("Type specification");} -#line 1659 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1659 "ncgeny.c" /* yacc.c:1646 */ break; case 16: @@ -1667,19 +1667,19 @@ yyparse (void) (yyvsp[0].sym)->name); listpush(typdefs,(void*)(yyvsp[0].sym)); } -#line 1671 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1671 "ncgeny.c" /* yacc.c:1646 */ break; case 17: #line 275 "ncgen.y" /* yacc.c:1646 */ {} -#line 1677 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1677 "ncgeny.c" /* yacc.c:1646 */ break; case 18: #line 275 "ncgen.y" /* yacc.c:1646 */ {} -#line 1683 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1683 "ncgeny.c" /* yacc.c:1646 */ break; case 25: @@ -1710,13 +1710,13 @@ yyparse (void) } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 1714 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1714 "ncgeny.c" /* yacc.c:1646 */ break; case 26: #line 318 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 1720 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1720 "ncgeny.c" /* yacc.c:1646 */ break; case 27: @@ -1735,7 +1735,7 @@ yyparse (void) } listpush(stack,(void*)(yyvsp[0].sym)); } -#line 1739 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1739 "ncgeny.c" /* yacc.c:1646 */ break; case 28: @@ -1746,7 +1746,7 @@ yyparse (void) (yyvsp[-2].sym)->typ.econst=(yyvsp[0].constant); (yyval.sym)=(yyvsp[-2].sym); } -#line 1750 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1750 "ncgeny.c" /* yacc.c:1646 */ break; case 29: @@ -1760,7 +1760,7 @@ yyparse (void) (yyvsp[0].sym)->typ.size=int32_val; (yyvsp[0].sym)->typ.alignment=nctypealignment(NC_OPAQUE); } -#line 1764 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1764 "ncgeny.c" /* yacc.c:1646 */ break; case 30: @@ -1776,7 +1776,7 @@ yyparse (void) (yyvsp[0].sym)->typ.size=VLENSIZE; (yyvsp[0].sym)->typ.alignment=nctypealignment(NC_VLEN); } -#line 1780 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1780 "ncgeny.c" /* yacc.c:1646 */ break; case 31: @@ -1810,19 +1810,19 @@ yyparse (void) } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 1814 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1814 "ncgeny.c" /* yacc.c:1646 */ break; case 32: #line 404 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=(yyvsp[-1].mark);} -#line 1820 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1820 "ncgeny.c" /* yacc.c:1646 */ break; case 33: #line 405 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=(yyvsp[-2].mark);} -#line 1826 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1826 "ncgeny.c" /* yacc.c:1646 */ break; case 34: @@ -1838,97 +1838,97 @@ yyparse (void) f->typ.basetype = (yyvsp[-1].sym); } } -#line 1842 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1842 "ncgeny.c" /* yacc.c:1646 */ break; case 35: #line 422 "ncgen.y" /* yacc.c:1646 */ { (yyval.sym) = primsymbols[NC_CHAR]; } -#line 1848 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1848 "ncgeny.c" /* yacc.c:1646 */ break; case 36: #line 423 "ncgen.y" /* yacc.c:1646 */ { (yyval.sym) = primsymbols[NC_BYTE]; } -#line 1854 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1854 "ncgeny.c" /* yacc.c:1646 */ break; case 37: #line 424 "ncgen.y" /* yacc.c:1646 */ { (yyval.sym) = primsymbols[NC_SHORT]; } -#line 1860 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1860 "ncgeny.c" /* yacc.c:1646 */ break; case 38: #line 425 "ncgen.y" /* yacc.c:1646 */ { (yyval.sym) = primsymbols[NC_INT]; } -#line 1866 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1866 "ncgeny.c" /* yacc.c:1646 */ break; case 39: #line 426 "ncgen.y" /* yacc.c:1646 */ { (yyval.sym) = primsymbols[NC_FLOAT]; } -#line 1872 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1872 "ncgeny.c" /* yacc.c:1646 */ break; case 40: #line 427 "ncgen.y" /* yacc.c:1646 */ { (yyval.sym) = primsymbols[NC_DOUBLE]; } -#line 1878 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1878 "ncgeny.c" /* yacc.c:1646 */ break; case 41: #line 428 "ncgen.y" /* yacc.c:1646 */ { vercheck(NC_UBYTE); (yyval.sym) = primsymbols[NC_UBYTE]; } -#line 1884 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1884 "ncgeny.c" /* yacc.c:1646 */ break; case 42: #line 429 "ncgen.y" /* yacc.c:1646 */ { vercheck(NC_USHORT); (yyval.sym) = primsymbols[NC_USHORT]; } -#line 1890 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1890 "ncgeny.c" /* yacc.c:1646 */ break; case 43: #line 430 "ncgen.y" /* yacc.c:1646 */ { vercheck(NC_UINT); (yyval.sym) = primsymbols[NC_UINT]; } -#line 1896 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1896 "ncgeny.c" /* yacc.c:1646 */ break; case 44: #line 431 "ncgen.y" /* yacc.c:1646 */ { vercheck(NC_INT64); (yyval.sym) = primsymbols[NC_INT64]; } -#line 1902 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1902 "ncgeny.c" /* yacc.c:1646 */ break; case 45: #line 432 "ncgen.y" /* yacc.c:1646 */ { vercheck(NC_UINT64); (yyval.sym) = primsymbols[NC_UINT64]; } -#line 1908 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1908 "ncgeny.c" /* yacc.c:1646 */ break; case 47: #line 436 "ncgen.y" /* yacc.c:1646 */ {} -#line 1914 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1914 "ncgeny.c" /* yacc.c:1646 */ break; case 48: #line 437 "ncgen.y" /* yacc.c:1646 */ {} -#line 1920 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1920 "ncgeny.c" /* yacc.c:1646 */ break; case 51: #line 444 "ncgen.y" /* yacc.c:1646 */ {} -#line 1926 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1926 "ncgeny.c" /* yacc.c:1646 */ break; case 52: #line 444 "ncgen.y" /* yacc.c:1646 */ {} -#line 1932 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1932 "ncgeny.c" /* yacc.c:1646 */ break; case 55: @@ -1939,7 +1939,7 @@ yyparse (void) fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[-2].sym)->name,(unsigned long long)(yyvsp[-2].sym)->dim.declsize); #endif } -#line 1943 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1943 "ncgeny.c" /* yacc.c:1646 */ break; case 56: @@ -1951,7 +1951,7 @@ 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 1955 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1955 "ncgeny.c" /* yacc.c:1646 */ break; case 57: @@ -1965,31 +1965,31 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyval.sym)=(yyvsp[0].sym); listpush(dimdefs,(void*)(yyvsp[0].sym)); } -#line 1969 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1969 "ncgeny.c" /* yacc.c:1646 */ break; case 59: #line 481 "ncgen.y" /* yacc.c:1646 */ {} -#line 1975 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1975 "ncgeny.c" /* yacc.c:1646 */ break; case 60: #line 482 "ncgen.y" /* yacc.c:1646 */ {} -#line 1981 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1981 "ncgeny.c" /* yacc.c:1646 */ break; case 63: #line 489 "ncgen.y" /* yacc.c:1646 */ {} -#line 1987 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1987 "ncgeny.c" /* yacc.c:1646 */ break; case 64: #line 489 "ncgen.y" /* yacc.c:1646 */ {} -#line 1993 "ncgen.tab.c" /* yacc.c:1646 */ +#line 1993 "ncgeny.c" /* yacc.c:1646 */ break; case 65: @@ -2013,7 +2013,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 2017 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2017 "ncgeny.c" /* yacc.c:1646 */ break; case 66: @@ -2021,13 +2021,13 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym)); } -#line 2025 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2025 "ncgeny.c" /* yacc.c:1646 */ break; case 67: #line 518 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2031 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2031 "ncgeny.c" /* yacc.c:1646 */ break; case 68: @@ -2056,31 +2056,31 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyvsp[-1].sym)->objectclass=NC_VAR; listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 2060 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2060 "ncgeny.c" /* yacc.c:1646 */ break; case 69: #line 548 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=listlength(stack);} -#line 2066 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2066 "ncgeny.c" /* yacc.c:1646 */ break; case 70: #line 549 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=(yyvsp[-1].mark);} -#line 2072 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2072 "ncgeny.c" /* yacc.c:1646 */ break; case 71: #line 552 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2078 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2078 "ncgeny.c" /* yacc.c:1646 */ break; case 72: #line 554 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2084 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2084 "ncgeny.c" /* yacc.c:1646 */ break; case 73: @@ -2095,7 +2095,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } (yyval.sym)=dimsym; } -#line 2099 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2099 "ncgeny.c" /* yacc.c:1646 */ break; case 74: @@ -2103,13 +2103,13 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym)); } -#line 2107 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2107 "ncgeny.c" /* yacc.c:1646 */ break; case 75: #line 576 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2113 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2113 "ncgeny.c" /* yacc.c:1646 */ break; case 76: @@ -2140,31 +2140,31 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); listsetlength(stack,stackbase);/* remove stack nodes*/ (yyval.sym) = (yyvsp[-1].sym); } -#line 2144 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2144 "ncgeny.c" /* yacc.c:1646 */ break; case 77: #line 609 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=listlength(stack);} -#line 2150 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2150 "ncgeny.c" /* yacc.c:1646 */ break; case 78: #line 610 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=(yyvsp[-1].mark);} -#line 2156 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2156 "ncgeny.c" /* yacc.c:1646 */ break; case 79: #line 614 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2162 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2162 "ncgeny.c" /* yacc.c:1646 */ break; case 80: #line 616 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2168 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2168 "ncgeny.c" /* yacc.c:1646 */ break; case 81: @@ -2178,7 +2178,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = uint32_val; } -#line 2182 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2182 "ncgeny.c" /* yacc.c:1646 */ break; case 82: @@ -2196,7 +2196,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = int32_val; } -#line 2200 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2200 "ncgeny.c" /* yacc.c:1646 */ break; case 83: @@ -2208,7 +2208,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } (yyval.sym)=vsym; } -#line 2212 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2212 "ncgeny.c" /* yacc.c:1646 */ break; case 84: @@ -2220,7 +2220,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } (yyval.sym)=tsym; } -#line 2224 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2224 "ncgeny.c" /* yacc.c:1646 */ break; case 85: @@ -2243,49 +2243,49 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); } (yyval.sym)=tvsym; } -#line 2247 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2247 "ncgeny.c" /* yacc.c:1646 */ break; case 86: #line 691 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym)=(yyvsp[0].sym);} -#line 2253 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2253 "ncgeny.c" /* yacc.c:1646 */ break; case 87: #line 698 "ncgen.y" /* yacc.c:1646 */ {} -#line 2259 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2259 "ncgeny.c" /* yacc.c:1646 */ break; case 88: #line 698 "ncgen.y" /* yacc.c:1646 */ {} -#line 2265 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2265 "ncgeny.c" /* yacc.c:1646 */ break; case 89: #line 702 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_NCPROPS_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} -#line 2271 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2271 "ncgeny.c" /* yacc.c:1646 */ break; case 90: #line 704 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_ISNETCDF4_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} -#line 2277 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2277 "ncgeny.c" /* yacc.c:1646 */ break; case 91: #line 706 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_SUPERBLOCK_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} -#line 2283 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2283 "ncgeny.c" /* yacc.c:1646 */ break; case 92: #line 708 "ncgen.y" /* yacc.c:1646 */ { (yyval.sym)=makeattribute((yyvsp[-2].sym),NULL,NULL,(yyvsp[0].datalist),ATTRGLOBAL);} -#line 2289 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2289 "ncgeny.c" /* yacc.c:1646 */ break; case 93: @@ -2298,7 +2298,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); YYABORT; } } -#line 2302 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2302 "ncgeny.c" /* yacc.c:1646 */ break; case 94: @@ -2313,67 +2313,67 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); YYABORT; } } -#line 2317 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2317 "ncgeny.c" /* yacc.c:1646 */ break; case 95: #line 730 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),0);} -#line 2323 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2323 "ncgeny.c" /* yacc.c:1646 */ break; case 96: #line 732 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),(yyvsp[-5].sym),(void*)(yyvsp[0].datalist),0);} -#line 2329 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2329 "ncgeny.c" /* yacc.c:1646 */ break; case 97: #line 734 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2335 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2335 "ncgeny.c" /* yacc.c:1646 */ break; case 98: #line 736 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),0);} -#line 2341 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2341 "ncgeny.c" /* yacc.c:1646 */ break; case 99: #line 738 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2347 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2347 "ncgeny.c" /* yacc.c:1646 */ break; case 100: #line 740 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2353 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2353 "ncgeny.c" /* yacc.c:1646 */ break; case 101: #line 742 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2359 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2359 "ncgeny.c" /* yacc.c:1646 */ break; case 102: #line 744 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2365 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2365 "ncgeny.c" /* yacc.c:1646 */ break; case 103: #line 746 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2371 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2371 "ncgeny.c" /* yacc.c:1646 */ break; case 104: #line 748 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),1);} -#line 2377 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2377 "ncgeny.c" /* yacc.c:1646 */ break; case 105: @@ -2384,7 +2384,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyvsp[0].sym)->is_prefixed=0; setpathcurrent((yyvsp[0].sym)); } -#line 2388 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2388 "ncgeny.c" /* yacc.c:1646 */ break; case 106: @@ -2395,257 +2395,257 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyvsp[0].sym)->is_prefixed=1; /* path is set in ncgen.l*/ } -#line 2399 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2399 "ncgeny.c" /* yacc.c:1646 */ break; case 108: #line 769 "ncgen.y" /* yacc.c:1646 */ {} -#line 2405 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2405 "ncgeny.c" /* yacc.c:1646 */ break; case 109: #line 770 "ncgen.y" /* yacc.c:1646 */ {} -#line 2411 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2411 "ncgeny.c" /* yacc.c:1646 */ break; case 112: #line 778 "ncgen.y" /* yacc.c:1646 */ {(yyvsp[-2].sym)->data = (yyvsp[0].datalist);} -#line 2417 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2417 "ncgeny.c" /* yacc.c:1646 */ break; case 113: #line 781 "ncgen.y" /* yacc.c:1646 */ {(yyval.datalist) = (yyvsp[0].datalist);} -#line 2423 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2423 "ncgeny.c" /* yacc.c:1646 */ break; case 114: #line 782 "ncgen.y" /* yacc.c:1646 */ {(yyval.datalist) = (yyvsp[0].datalist);} -#line 2429 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2429 "ncgeny.c" /* yacc.c:1646 */ break; case 115: #line 786 "ncgen.y" /* yacc.c:1646 */ {(yyval.datalist) = builddatalist(0);} -#line 2435 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2435 "ncgeny.c" /* yacc.c:1646 */ break; case 116: #line 790 "ncgen.y" /* yacc.c:1646 */ {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} -#line 2441 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2441 "ncgeny.c" /* yacc.c:1646 */ break; case 117: #line 792 "ncgen.y" /* yacc.c:1646 */ {datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);} -#line 2447 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2447 "ncgeny.c" /* yacc.c:1646 */ break; case 118: #line 796 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=(yyvsp[0].constant);} -#line 2453 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2453 "ncgeny.c" /* yacc.c:1646 */ break; case 119: #line 797 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=builddatasublist((yyvsp[-1].datalist));} -#line 2459 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2459 "ncgeny.c" /* yacc.c:1646 */ break; case 120: #line 801 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=(yyvsp[0].constant);} -#line 2465 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2465 "ncgeny.c" /* yacc.c:1646 */ break; case 121: #line 802 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_OPAQUE);} -#line 2471 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2471 "ncgeny.c" /* yacc.c:1646 */ break; case 122: #line 803 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_FILLVALUE);} -#line 2477 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2477 "ncgeny.c" /* yacc.c:1646 */ break; case 123: #line 804 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_NIL);} -#line 2483 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2483 "ncgeny.c" /* yacc.c:1646 */ break; case 124: #line 805 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=(yyvsp[0].constant);} -#line 2489 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2489 "ncgeny.c" /* yacc.c:1646 */ break; case 126: #line 810 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant) = makeenumconstref((yyvsp[0].sym));} -#line 2495 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2495 "ncgeny.c" /* yacc.c:1646 */ break; case 127: #line 814 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=evaluate((yyvsp[-3].sym),(yyvsp[-1].datalist));} -#line 2501 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2501 "ncgeny.c" /* yacc.c:1646 */ break; case 128: #line 819 "ncgen.y" /* yacc.c:1646 */ {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} -#line 2507 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2507 "ncgeny.c" /* yacc.c:1646 */ break; case 129: #line 821 "ncgen.y" /* yacc.c:1646 */ {datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);} -#line 2513 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2513 "ncgeny.c" /* yacc.c:1646 */ break; case 130: #line 825 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_CHAR);} -#line 2519 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2519 "ncgeny.c" /* yacc.c:1646 */ break; case 131: #line 826 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_BYTE);} -#line 2525 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2525 "ncgeny.c" /* yacc.c:1646 */ break; case 132: #line 827 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_SHORT);} -#line 2531 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2531 "ncgeny.c" /* yacc.c:1646 */ break; case 133: #line 828 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_INT);} -#line 2537 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2537 "ncgeny.c" /* yacc.c:1646 */ break; case 134: #line 829 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_INT64);} -#line 2543 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2543 "ncgeny.c" /* yacc.c:1646 */ break; case 135: #line 830 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_UBYTE);} -#line 2549 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2549 "ncgeny.c" /* yacc.c:1646 */ break; case 136: #line 831 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_USHORT);} -#line 2555 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2555 "ncgeny.c" /* yacc.c:1646 */ break; case 137: #line 832 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_UINT);} -#line 2561 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2561 "ncgeny.c" /* yacc.c:1646 */ break; case 138: #line 833 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_UINT64);} -#line 2567 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2567 "ncgeny.c" /* yacc.c:1646 */ break; case 139: #line 834 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_FLOAT);} -#line 2573 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2573 "ncgeny.c" /* yacc.c:1646 */ break; case 140: #line 835 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_DOUBLE);} -#line 2579 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2579 "ncgeny.c" /* yacc.c:1646 */ break; case 141: #line 836 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_STRING);} -#line 2585 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2585 "ncgeny.c" /* yacc.c:1646 */ break; case 142: #line 840 "ncgen.y" /* yacc.c:1646 */ {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} -#line 2591 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2591 "ncgeny.c" /* yacc.c:1646 */ break; case 143: #line 841 "ncgen.y" /* yacc.c:1646 */ {(yyval.datalist)=(yyvsp[-2].datalist); datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant)));} -#line 2597 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2597 "ncgeny.c" /* yacc.c:1646 */ break; case 144: #line 846 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_INT);} -#line 2603 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2603 "ncgeny.c" /* yacc.c:1646 */ break; case 145: #line 848 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_UINT);} -#line 2609 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2609 "ncgeny.c" /* yacc.c:1646 */ break; case 146: #line 850 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_INT64);} -#line 2615 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2615 "ncgeny.c" /* yacc.c:1646 */ break; case 147: #line 852 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_UINT64);} -#line 2621 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2621 "ncgeny.c" /* yacc.c:1646 */ break; case 148: #line 856 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=makeconstdata(NC_STRING);} -#line 2627 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2627 "ncgeny.c" /* yacc.c:1646 */ break; case 149: #line 860 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=(yyvsp[0].constant);} -#line 2633 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2633 "ncgeny.c" /* yacc.c:1646 */ break; case 150: #line 861 "ncgen.y" /* yacc.c:1646 */ {(yyval.constant)=(yyvsp[0].constant);} -#line 2639 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2639 "ncgeny.c" /* yacc.c:1646 */ break; case 151: #line 867 "ncgen.y" /* yacc.c:1646 */ {(yyval.sym)=(yyvsp[0].sym);} -#line 2645 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2645 "ncgeny.c" /* yacc.c:1646 */ break; -#line 2649 "ncgen.tab.c" /* yacc.c:1646 */ +#line 2649 "ncgeny.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2955,7 +2955,7 @@ Symbol* install(const char *sname) { Symbol* sp; - sp = (Symbol*) emalloc (sizeof (struct Symbol)); + sp = (Symbol*) ecalloc (sizeof (struct Symbol)); memset((void*)sp,0,sizeof(struct Symbol)); sp->name = nulldup(sname); sp->next = symlist; @@ -3044,7 +3044,7 @@ makeconstdata(nc_type nctype) char* s; int len; len = bbLength(lextext); - s = (char*)emalloc(len+1); + s = (char*)ecalloc(len+1); strncpy(s,bbContents(lextext),len); s[len] = '\0'; con.value.opaquev.stringv = s; @@ -3242,7 +3242,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst) else if(tag == _SUPERBLOCK_FLAG) globalspecials._Superblock = idata; else if(tag == _NCPROPS_FLAG) - globalspecials._NCProperties = strdup(sdata); + globalspecials._NCProperties = estrdup(sdata); } else { Specialdata* special; /* Set up special info */ @@ -3309,7 +3309,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst) case _CHUNKSIZES_FLAG: { int i; special->nchunks = list->length; - special->_ChunkSizes = (size_t*)emalloc(sizeof(size_t)*special->nchunks); + special->_ChunkSizes = (size_t*)ecalloc(sizeof(size_t)*special->nchunks); for(i=0;inchunks;i++) { iconst.nctype = NC_INT; convert1(&list->data[i],&iconst); @@ -3401,15 +3401,19 @@ datalistextend(Datalist* dl, NCConstant* con) dlappend(dl,con); } +/* +Try to infer the file type from the +kinds of constructs used in the cdl file. +*/ static void vercheck(int tid) { switch (tid) { - case NC_UBYTE: markcdf5("netCDF4/5 type: UBYTE"); break; - case NC_USHORT: markcdf5("netCDF4/5 type: USHORT"); break; - case NC_UINT: markcdf5("netCDF4/5 type: UINT"); break; - case NC_INT64: markcdf5("netCDF4/5 type: INT64"); break; - case NC_UINT64: markcdf5("netCDF4/5 type: UINT64"); break; + case NC_UBYTE: markcdf4("netCDF4/5 type: UBYTE"); break; + case NC_USHORT: markcdf4("netCDF4/5 type: USHORT"); break; + case NC_UINT: markcdf4("netCDF4/5 type: UINT"); break; + case NC_INT64: markcdf4("netCDF4/5 type: INT64"); break; + case NC_UINT64: markcdf4("netCDF4/5 type: UINT64"); break; case NC_STRING: markcdf4("netCDF4 type: STRING"); break; case NC_VLEN: markcdf4("netCDF4 type: VLEN"); break; case NC_OPAQUE: markcdf4("netCDF4 type: OPAQUE"); break; diff --git a/ncgen/ncgeny.h b/ncgen/ncgeny.h index a70994c6c0..4d09af5695 100644 --- a/ncgen/ncgeny.h +++ b/ncgen/ncgeny.h @@ -113,7 +113,7 @@ int nctype; /* for tracking attribute list type*/ Datalist* datalist; NCConstant constant; -#line 117 "ncgen.tab.h" /* yacc.c:1909 */ +#line 117 "ncgeny.h" /* yacc.c:1909 */ }; typedef union YYSTYPE YYSTYPE; diff --git a/ncgen/odom.c b/ncgen/odom.c index 2f628fedfc..1e5a95fbe8 100644 --- a/ncgen/odom.c +++ b/ncgen/odom.c @@ -18,7 +18,7 @@ newodometer(Dimset* dimset, size_t* startp, size_t* countp) Odometer* odom; ASSERT(dimset != NULL); ASSERT(dimset->ndims > 0); - odom = (Odometer*)emalloc(sizeof(Odometer)); + odom = (Odometer*)ecalloc(sizeof(Odometer)); if(odom == NULL) return NULL; odom->origin = odom; odom->offset = 0; @@ -44,7 +44,7 @@ newsubodometer(Odometer* origin, Dimset* dimset, int start, int stop) ASSERT(dimset != NULL); ASSERT(dimset->ndims > 0 && dimset->ndims >= stop); ASSERT(stop > start); - odom = (Odometer*)emalloc(sizeof(Odometer)); + odom = (Odometer*)ecalloc(sizeof(Odometer)); if(odom == NULL) return NULL; odom->origin = origin; odom->offset = start; diff --git a/ncgen/util.c b/ncgen/util.c index 9b2dd70235..7ea714f23b 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -13,7 +13,7 @@ char* append(const char* s1, const char* s2) { int len = (s1?strlen(s1):0)+(s2?strlen(s2):0); - char* result = (char*)emalloc(len+1); + char* result = (char*)ecalloc(len+1); result[0] = '\0'; if(s1) strcat(result,s1); if(s2) strcat(result,s2); @@ -461,7 +461,7 @@ poolalloc(size_t length) if(poolindex == POOLMAX) poolindex=0; if(length == 0) length = POOL_DEFAULT; if(pool[poolindex] != NULL) efree(pool[poolindex]); - pool[poolindex] = (char*)emalloc(length); + pool[poolindex] = (char*)ecalloc(length); return pool[poolindex++]; } @@ -500,7 +500,7 @@ makebytestring(char* s, size_t* lenp) ASSERT((slen%2) == 0); ASSERT(blen > 0); - bytes = (unsigned char*)emalloc(blen); + bytes = (unsigned char*)ecalloc(blen); b = bytes; for(i=0;i Date: Mon, 30 Oct 2017 16:49:08 -0600 Subject: [PATCH 04/36] ckp --- cf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cf b/cf index 9c66537c12..cfd2369c6f 100644 --- a/cf +++ b/cf @@ -3,11 +3,12 @@ DB=1 #X=-x FAST=1 +MEM=1 HDF5=1 DAP=1 #HDF4=1 -PNETCDF=1 +#PNETCDF=1 #PAR4=1 if test $# != 0 ; then @@ -26,8 +27,9 @@ fi CFLAGS="" #CFLAGS="-Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-parameter -Wconversion ${CFLAGS}" CFLAGS="-Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-parameter -Wno-char-subscripts -Wno-pointer-sign -Wno-format ${CFLAGS}" -#CFLAGS="-Wall ${CFLAGS}" -#CFLAGS="-Wconversion" +if test "x$MEM" = x1 ; then +CFLAGS="-fsanitize=address -fno-omit-frame-pointer ${CFLAGS}" +fi stddir="/usr/local" PREFIX=/usr/local From 026544964aef744e5eacd813962d882bd02ed97d Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Tue, 31 Oct 2017 14:03:57 -0600 Subject: [PATCH 05/36] Cleanup some ncgen memory problems --- cf | 2 +- libdap2/ncd2dispatch.c | 1 + libdap4/ncd4dispatch.c | 1 + ncgen/bytebuffer.c | 2 +- ncgen/data.c | 24 +- ncgen/generr.c | 2 +- ncgen/genlib.h | 5 + ncgen/main.c | 26 +- ncgen/ncgen.y | 6 +- ncgen/ncgenl.c | 65 +- ncgen/ncgeny.c | 1792 ++++++++++++++++++++++------------------ ncgen/ncgeny.h | 155 ++-- ncgen/util.c | 2 +- 13 files changed, 1144 insertions(+), 939 deletions(-) diff --git a/cf b/cf index cfd2369c6f..6f8a2c2f81 100644 --- a/cf +++ b/cf @@ -3,7 +3,7 @@ DB=1 #X=-x FAST=1 -MEM=1 +#MEM=1 HDF5=1 DAP=1 diff --git a/libdap2/ncd2dispatch.c b/libdap2/ncd2dispatch.c index b6db0c8244..eddbd14644 100644 --- a/libdap2/ncd2dispatch.c +++ b/libdap2/ncd2dispatch.c @@ -209,6 +209,7 @@ NCD2_initialize(void) int NCD2_finalize(void) { + curl_global_cleanup(); return NC_NOERR; } diff --git a/libdap4/ncd4dispatch.c b/libdap4/ncd4dispatch.c index df66fa5539..0f0afc7d4b 100644 --- a/libdap4/ncd4dispatch.c +++ b/libdap4/ncd4dispatch.c @@ -71,6 +71,7 @@ NCD4_finalize(void) free(NCD4_globalstate); NCD4_globalstate = NULL; } + curl_global_cleanup(); return THROW(NC_NOERR); } diff --git a/ncgen/bytebuffer.c b/ncgen/bytebuffer.c index d4ba1d3daa..8613d09c63 100644 --- a/ncgen/bytebuffer.c +++ b/ncgen/bytebuffer.c @@ -28,7 +28,7 @@ bbFail(void) fflush(stdout); fprintf(stderr,"bytebuffer failure\n"); fflush(stderr); - if(bbdebug) exit(1); + if(bbdebug) abort(); return FALSE; } diff --git a/ncgen/data.c b/ncgen/data.c index 6420f76795..89ff41573e 100644 --- a/ncgen/data.c +++ b/ncgen/data.c @@ -688,22 +688,13 @@ void dlextend(Datalist* dl) { size_t newalloc; - newalloc = (dl->alloc > 0?2*dl->alloc:1); - dlsetalloc(dl,newalloc); -} - -void -dlsetalloc(Datalist* dl, size_t newalloc) -{ - NCConstant* newdata; - if(newalloc <= 0) newalloc = 1; - if(dl->alloc > 0) - newdata = (NCConstant*)erealloc((void*)dl->data,sizeof(NCConstant)*newalloc); - else { - newdata = (NCConstant*)ecalloc(sizeof(NCConstant)*newalloc); - memset((void*)newdata,0,sizeof(NCConstant)*newalloc); - } + NCConstant* newdata = NULL; + newalloc = (dl->alloc > 0?2*dl->alloc:2); + newdata = (NCConstant*)ecalloc(newalloc*sizeof(NCConstant)); + if(dl->length > 0) + memcpy(newdata,dl->data,sizeof(NCConstant)*dl->length); dl->alloc = newalloc; + nullfree(dl->data); dl->data = newdata; } @@ -726,7 +717,8 @@ builddatalist(int initial) void dlappend(Datalist* dl, NCConstant* constant) { - if(dl->length >= dl->alloc) dlextend(dl); + if(dl->length >= dl->alloc) + dlextend(dl); if(constant == NULL) constant = &nullconstant; dl->data[dl->length++] = *constant; } diff --git a/ncgen/generr.c b/ncgen/generr.c index 2770b5d3d6..98d82918a5 100644 --- a/ncgen/generr.c +++ b/ncgen/generr.c @@ -116,7 +116,7 @@ semerror(lno,fmt,va_alist) const int lno; const char* fmt; va_dcl vastart(argv,fmt); (void)fprintf(stderr,"%s: %s line %d: ", progname, cdlname, lno); vderror(fmt,argv); - exit(1); /* immediately fatal */ + finalize_netcdf(1); /* immediately fatal */ } /* Capture potential version errors */ diff --git a/ncgen/genlib.h b/ncgen/genlib.h index 70110e397a..56f7a82325 100644 --- a/ncgen/genlib.h +++ b/ncgen/genlib.h @@ -196,4 +196,9 @@ extern char *cdlname; /* name from the command line */ extern const char* specialname(int tag); +extern void init_netcdf(void); +extern void finalize_netcdf(int); +extern void parse_init(void); +extern int ncgparse(void); + #endif /*!NC_GENLIB_H*/ diff --git a/ncgen/main.c b/ncgen/main.c index 73672b8ca8..c79ee71ed9 100644 --- a/ncgen/main.c +++ b/ncgen/main.c @@ -22,10 +22,6 @@ int optind; /* Default is netcdf-3 mode 1 */ #define DFALTCMODE 0 -extern void init_netcdf(void); -extern void parse_init(void); -extern int ncgparse(void); - /* For error messages */ char* progname; /* Global: not reclaimed */ char* cdlname; /* Global: not reclaimed */ @@ -210,6 +206,7 @@ main( int argc, char *argv[]) { + int code = 0; int c; FILE *fp; struct Languages* langs; @@ -285,7 +282,7 @@ main( break; case 'H': usage(); - exit(0); + goto done; case 'l': /* specify language, instead of using -c or -f or -b */ { char* lang_name = NULL; @@ -410,19 +407,19 @@ main( #ifndef ENABLE_C if(c_flag) { fprintf(stderr,"C not currently supported\n"); - exit(1); + code=1; goto done; } #endif #ifndef ENABLE_BINARY if(l_flag == L_BINARY) { fprintf(stderr,"Binary netcdf not currently supported\n"); - exit(1); + code=1; goto done; } #endif #ifndef ENABLE_JAVA if(l_flag == L_JAVA) { fprintf(stderr,"Java not currently supported\n"); - exit(1); + code=1; goto done; } #else if(l_flag == L_JAVA && mainname != NULL && strcmp(mainname,"main")==0) @@ -431,7 +428,7 @@ main( #ifndef ENABLE_F77 if(l_flag == L_F77) { fprintf(stderr,"F77 not currently supported\n"); - exit(1); + code=1; goto done; } #endif @@ -576,7 +573,9 @@ main( if(!syntax_only && error_count == 0) define_netcdf(); - return 0; +done: + finalize_netcdf(code); + return code; } END_OF_MAIN() @@ -591,3 +590,10 @@ init_netcdf(void) /* initialize global counts, flags */ stmt = bbNew(); error_count = 0; /* Track # of errors */ } + +void +finalize_netcdf(int retcode) +{ + nc_finalize(); + exit(retcode); +} diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y index c595da725d..a05bf2e475 100644 --- a/ncgen/ncgen.y +++ b/ncgen/ncgen.y @@ -949,7 +949,6 @@ install(const char *sname) { Symbol* sp; sp = (Symbol*) ecalloc (sizeof (struct Symbol)); - memset((void*)sp,0,sizeof(struct Symbol)); sp->name = nulldup(sname); sp->next = symlist; sp->lineno = lineno; @@ -1048,7 +1047,7 @@ makeconstdata(nc_type nctype) break; /* no associated value*/ #endif - case NC_FILLVALUE: + case NC_FILLVALUE: break; /* no associated value*/ default: @@ -1382,7 +1381,8 @@ containsfills(Datalist* list) for(i=0;ilength;i++,con++) { if(con->nctype == NC_COMPOUND) { if(containsfills(con->value.compoundv)) return 1; - } else if(con->nctype == NC_FILLVALUE) return 1; + } else if(con->nctype == NC_FILLVALUE) + return 1; } } return 0; diff --git a/ncgen/ncgenl.c b/ncgen/ncgenl.c index a305537300..0adb63d1e3 100644 --- a/ncgen/ncgenl.c +++ b/ncgen/ncgenl.c @@ -27,7 +27,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 +#define YY_FLEX_SUBMINOR_VERSION 37 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -72,7 +72,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -103,6 +102,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -171,7 +172,12 @@ typedef unsigned int flex_uint32_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif -extern int ncgleng; +#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 FILE *ncgin, *ncgout; @@ -197,11 +203,6 @@ 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 @@ -219,7 +220,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t 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 @@ -289,8 +290,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 int yy_n_chars; /* number of characters read into yy_ch_buf */ -int ncgleng; +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +yy_size_t ncgleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; @@ -318,7 +319,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,int len ); +YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,yy_size_t len ); void *ncgalloc (yy_size_t ); void *ncgrealloc (void *,yy_size_t ); @@ -1319,7 +1320,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 1323 "ncgenl.c" +#line 1324 "ncgenl.c" #define INITIAL 0 #define ST_C_COMMENT 1 @@ -1360,7 +1361,7 @@ FILE *ncgget_out (void ); void ncgset_out (FILE * out_str ); -int ncgget_leng (void ); +yy_size_t ncgget_leng (void ); char *ncgget_text (void ); @@ -1410,7 +1411,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( ncgtext, ncgleng, 1, ncgout ) +#define ECHO do { if (fwrite( ncgtext, ncgleng, 1, ncgout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1421,7 +1422,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( ncgin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1505,7 +1506,7 @@ YY_DECL #line 217 "ncgen.l" -#line 1509 "ncgenl.c" +#line 1510 "ncgenl.c" if ( !(yy_init) ) { @@ -2118,7 +2119,7 @@ YY_RULE_SETUP #line 570 "ncgen.l" ECHO; YY_BREAK -#line 2122 "ncgenl.c" +#line 2123 "ncgenl.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(TEXT): yyterminate(); @@ -2305,21 +2306,21 @@ static int yy_get_next_buffer (void) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -2350,7 +2351,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), (size_t) num_to_read ); + (yy_n_chars), num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } @@ -2445,7 +2446,7 @@ static int yy_get_next_buffer (void) yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 416); - return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } static void yyunput (int c, register char * yy_bp ) @@ -2460,7 +2461,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 int number_to_move = (yy_n_chars) + 2; + register yy_size_t 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 = @@ -2509,7 +2510,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -2669,10 +2670,6 @@ static void ncg_load_buffer_state (void) ncgfree((void *) b ); } -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a ncgrestart() or at EOF. @@ -2785,7 +2782,7 @@ void ncgpop_buffer_state (void) */ static void ncgensure_buffer_stack (void) { - int num_to_alloc; + yy_size_t num_to_alloc; if (!(yy_buffer_stack)) { @@ -2877,12 +2874,12 @@ YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to ncglex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) { YY_BUFFER_STATE b; char *buf; @@ -2969,7 +2966,7 @@ FILE *ncgget_out (void) /** Get the length of the current token. * */ -int ncgget_leng (void) +yy_size_t ncgget_leng (void) { return ncgleng; } diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c index 4ad4f9c789..8e284765b7 100644 --- a/ncgen/ncgeny.c +++ b/ncgen/ncgeny.c @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. + 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 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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 . */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -63,14 +63,14 @@ #define yyparse ncgparse #define yylex ncglex #define yyerror ncgerror -#define yydebug ncgdebug -#define yynerrs ncgnerrs - #define yylval ncglval #define yychar ncgchar +#define yydebug ncgdebug +#define yynerrs ncgnerrs /* Copy the first part of user declarations. */ -#line 11 "ncgen.y" /* yacc.c:339 */ +/* Line 371 of yacc.c */ +#line 11 "ncgen.y" /* static char SccsId[] = "$Id: ncgen.y,v 1.42 2010/05/18 21:32:46 dmh Exp $"; @@ -195,13 +195,14 @@ static void yyerror(fmt,va_alist) const char* fmt; va_dcl; extern int lex_init(void); -#line 199 "ncgeny.c" /* yacc.c:339 */ +/* Line 371 of yacc.c */ +#line 200 "ncgeny.c" -# ifndef YY_NULLPTR +# ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# define YY_NULL nullptr # else -# define YY_NULLPTR 0 +# define YY_NULL 0 # endif # endif @@ -217,7 +218,7 @@ extern int lex_init(void); by #include "ncgeny.h". */ #ifndef YY_NCG_NCGEN_TAB_H_INCLUDED # define YY_NCG_NCGEN_TAB_H_INCLUDED -/* Debug traces. */ +/* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif @@ -225,71 +226,72 @@ extern int lex_init(void); extern int ncgdebug; #endif -/* Token type. */ +/* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - 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 - }; + /* 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 + }; #endif -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -union YYSTYPE +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE { -#line 138 "ncgen.y" /* yacc.c:355 */ +/* Line 387 of yacc.c */ +#line 138 "ncgen.y" Symbol* sym; unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/ @@ -298,24 +300,37 @@ int nctype; /* for tracking attribute list type*/ Datalist* datalist; NCConstant constant; -#line 302 "ncgeny.c" /* yacc.c:355 */ -}; -typedef union YYSTYPE YYSTYPE; +/* Line 387 of yacc.c */ +#line 306 "ncgeny.c" +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif - extern YYSTYPE ncglval; +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int ncgparse (void *YYPARSE_PARAM); +#else +int ncgparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus int ncgparse (void); +#else +int ncgparse (); +#endif +#endif /* ! YYPARSE_PARAM */ #endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */ /* Copy the second part of user declarations. */ -#line 319 "ncgeny.c" /* yacc.c:358 */ +/* Line 390 of yacc.c */ +#line 334 "ncgeny.c" #ifdef short # undef short @@ -329,8 +344,11 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#else +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; +#else +typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -350,7 +368,8 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -372,33 +391,6 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif - -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -406,26 +398,24 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(N) (N) #else -# define YY_INITIAL_VALUE(Value) Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; #endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ +{ + return yyi; +} #endif - #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -443,7 +433,8 @@ typedef short int yytype_int16; # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS @@ -455,8 +446,8 @@ typedef short int yytype_int16; # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's 'empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -472,7 +463,7 @@ typedef short int yytype_int16; # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -480,13 +471,15 @@ typedef short int yytype_int16; # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -496,7 +489,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -521,16 +514,16 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) #endif @@ -549,7 +542,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif #endif /* !YYCOPY_NEEDED */ @@ -565,19 +558,17 @@ union yyalloc #define YYNNTS 67 /* YYNRULES -- Number of rules. */ #define YYNRULES 151 -/* YYNSTATES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES 258 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 308 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -614,7 +605,79 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 7, 9, 14, 20, 21, 24, 25, + 26, 36, 37, 39, 42, 44, 47, 49, 51, 54, + 57, 60, 63, 66, 67, 69, 76, 78, 82, 86, + 92, 98, 104, 107, 111, 114, 116, 118, 120, 122, + 124, 126, 128, 130, 132, 134, 136, 137, 139, 142, + 145, 149, 151, 153, 155, 159, 163, 167, 169, 170, + 172, 175, 178, 182, 184, 186, 189, 191, 195, 198, + 199, 203, 205, 209, 211, 213, 217, 220, 221, 225, + 227, 231, 233, 235, 237, 239, 241, 243, 244, 248, + 253, 258, 263, 268, 275, 281, 287, 294, 300, 306, + 312, 318, 324, 330, 336, 341, 343, 345, 346, 348, + 351, 354, 358, 362, 364, 366, 367, 369, 373, 375, + 379, 381, 383, 385, 387, 389, 391, 393, 398, 400, + 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, + 424, 426, 428, 430, 434, 436, 438, 440, 442, 444, + 446, 448 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 64, 0, -1, 30, 65, 66, -1, 53, -1, 54, + 67, 68, 55, -1, 110, 72, 87, 93, 113, -1, + -1, 68, 69, -1, -1, -1, 37, 129, 54, 70, + 67, 68, 71, 55, 110, -1, -1, 32, -1, 32, + 73, -1, 75, -1, 73, 75, -1, 129, -1, 76, + -1, 111, 56, -1, 78, 77, -1, 83, 77, -1, + 82, 77, -1, 81, 77, -1, -1, 56, -1, 86, + 34, 74, 54, 79, 55, -1, 80, -1, 79, 57, + 80, -1, 129, 58, 126, -1, 35, 59, 20, 60, + 74, -1, 108, 59, 61, 60, 74, -1, 33, 74, + 54, 84, 55, -1, 85, 56, -1, 84, 85, 56, + -1, 108, 102, -1, 4, -1, 5, -1, 6, -1, + 7, -1, 8, -1, 9, -1, 10, -1, 11, -1, + 12, -1, 13, -1, 14, -1, -1, 28, -1, 28, + 88, -1, 89, 56, -1, 88, 89, 56, -1, 90, + -1, 111, -1, 91, -1, 90, 57, 91, -1, 92, + 58, 126, -1, 92, 58, 3, -1, 129, -1, -1, + 29, -1, 29, 94, -1, 95, 56, -1, 94, 95, + 56, -1, 96, -1, 111, -1, 108, 97, -1, 98, + -1, 97, 57, 98, -1, 129, 99, -1, -1, 59, + 100, 60, -1, 101, -1, 100, 57, 101, -1, 112, + -1, 103, -1, 102, 57, 103, -1, 129, 104, -1, + -1, 59, 105, 60, -1, 106, -1, 105, 57, 106, + -1, 24, -1, 20, -1, 109, -1, 109, -1, 112, + -1, 86, -1, -1, 111, 56, 110, -1, 62, 50, + 58, 127, -1, 62, 51, 58, 128, -1, 62, 52, + 58, 126, -1, 62, 129, 58, 116, -1, 108, 109, + 62, 129, 58, 116, -1, 109, 62, 129, 58, 116, + -1, 109, 62, 41, 58, 116, -1, 108, 109, 62, + 41, 58, 116, -1, 109, 62, 43, 58, 127, -1, + 109, 62, 44, 58, 125, -1, 109, 62, 49, 58, + 128, -1, 109, 62, 45, 58, 126, -1, 109, 62, + 46, 58, 128, -1, 109, 62, 47, 58, 127, -1, + 109, 62, 48, 58, 128, -1, 62, 42, 58, 127, + -1, 129, -1, 38, -1, -1, 31, -1, 31, 114, + -1, 115, 56, -1, 114, 115, 56, -1, 107, 58, + 116, -1, 117, -1, 118, -1, -1, 119, -1, 116, + 57, 119, -1, 120, -1, 54, 116, 55, -1, 124, + -1, 36, -1, 39, -1, 40, -1, 121, -1, 122, + -1, 112, -1, 129, 59, 123, 60, -1, 124, -1, + 123, 57, 124, -1, 17, -1, 18, -1, 19, -1, + 20, -1, 21, -1, 22, -1, 23, -1, 24, -1, + 25, -1, 26, -1, 27, -1, 16, -1, 126, -1, + 125, 57, 126, -1, 20, -1, 24, -1, 21, -1, + 25, -1, 16, -1, 127, -1, 126, -1, 15, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 218, 218, 224, 226, 233, 240, 240, 243, 252, @@ -664,13 +727,13 @@ static const char *const yytname[] = "attrdecllist", "attrdecl", "path", "datasection", "datadecls", "datadecl", "datalist", "datalist0", "datalist1", "dataitem", "constdata", "econstref", "function", "arglist", "simpleconstant", - "intlist", "constint", "conststring", "constbool", "ident", YY_NULLPTR + "intlist", "constint", "conststring", "constbool", "ident", YY_NULL }; #endif # ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -683,51 +746,51 @@ static const yytype_uint16 yytoknum[] = }; # endif -#define YYPACT_NINF -133 - -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-133))) - -#define YYTABLE_NINF -106 - -#define yytable_value_is_error(Yytable_value) \ - 0 +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 63, 64, 65, 66, 67, 68, 68, 70, 71, + 69, 72, 72, 72, 73, 73, 74, 75, 75, 76, + 76, 76, 76, 77, 77, 78, 79, 79, 80, 81, + 82, 83, 84, 84, 85, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 87, 87, 87, 88, + 88, 89, 89, 90, 90, 91, 91, 92, 93, 93, + 93, 94, 94, 95, 95, 96, 97, 97, 98, 99, + 99, 100, 100, 101, 102, 102, 103, 104, 104, 105, + 105, 106, 106, 107, 108, 109, 109, 110, 110, 111, + 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, + 111, 111, 111, 111, 111, 112, 112, 113, 113, 113, + 114, 114, 115, 116, 116, 117, 118, 118, 119, 119, + 120, 120, 120, 120, 120, 120, 121, 122, 123, 123, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 125, 125, 126, 126, 126, 126, 127, 128, + 128, 129 +}; - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int16 yypact[] = +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = { - -11, -48, 20, -133, -19, -133, 210, -133, -133, -133, - -133, -133, -133, -133, -133, -133, -133, -133, -133, -133, - -133, -3, -133, -133, 332, -16, 8, -4, -133, -133, - 18, 19, 29, 41, 48, -22, 47, 128, 56, 75, - 210, 94, 94, 136, 33, 281, 102, -133, -133, 2, - 63, 64, 65, 68, 71, 74, 76, 77, 78, 102, - 82, 56, -133, -133, 81, 81, 81, 81, 99, 222, - 88, 210, 117, -133, -133, -133, -133, -133, -133, -133, - -133, -133, -133, -133, -133, -133, -133, -133, -133, -133, - -133, -133, -133, -133, -133, -133, -133, -133, -133, -133, - 281, -133, 90, -133, -133, -133, -133, -133, -133, -133, - 89, 97, 91, 100, 281, 94, 33, 33, 136, 94, - 136, 136, 281, 105, -133, 142, -133, -133, -133, -133, - -133, -133, 102, 109, -133, 210, 107, 121, -133, 123, - -133, 125, 210, 148, 35, 281, 333, -133, 281, 281, - 90, -133, 129, -133, -133, -133, -133, -133, -133, 90, - 332, 127, 131, 130, 132, -133, 102, 95, 210, 133, - -133, 332, -133, 332, -133, -133, -133, -23, -133, 210, - 90, 90, 33, 278, 135, 102, -133, 102, 102, 102, - -133, -133, -133, -133, -133, 137, -133, 138, -133, -32, - 139, -133, 332, 140, 333, -133, -133, -133, -133, 144, - -133, 141, -133, 145, -133, 45, -133, 143, -133, -133, - 102, -12, -133, 281, 147, -133, -133, 157, -133, 102, - -2, -133, -133, 102, 33, -133, 146, 25, -133, -133, - 90, -133, 151, -133, -133, -133, 26, -133, -133, -133, - -12, -133, 210, -2, -133, -133, -133, -133 + 0, 2, 3, 1, 4, 5, 0, 2, 0, 0, + 9, 0, 1, 2, 1, 2, 1, 1, 2, 2, + 2, 2, 2, 0, 1, 6, 1, 3, 3, 5, + 5, 5, 2, 3, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 2, 2, + 3, 1, 1, 1, 3, 3, 3, 1, 0, 1, + 2, 2, 3, 1, 1, 2, 1, 3, 2, 0, + 3, 1, 3, 1, 1, 3, 2, 0, 3, 1, + 3, 1, 1, 1, 1, 1, 1, 0, 3, 4, + 4, 4, 4, 6, 5, 5, 6, 5, 5, 5, + 5, 5, 5, 5, 4, 1, 1, 0, 1, 2, + 2, 3, 3, 1, 1, 0, 1, 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 }; - /* 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-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ static const yytype_uint8 yydefact[] = { 0, 0, 0, 3, 0, 1, 87, 2, 35, 36, @@ -758,19 +821,7 @@ static const yytype_uint8 yydefact[] = 0, 70, 87, 0, 78, 72, 10, 80 }; - /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -133, -133, -133, -133, 28, 4, -133, -133, -133, -133, - -133, -109, 150, -133, 30, -133, -133, 5, -133, -133, - -133, -133, 57, -25, -133, -133, 104, -133, 79, -133, - -133, -133, 73, -133, -133, 22, -133, -133, -7, -133, - 15, -133, -133, -6, -133, -29, -18, -39, -30, -41, - -133, -133, 44, -93, -133, -133, 106, -133, -133, -133, - -133, -132, -133, -42, -31, -76, -21 -}; - - /* YYDEFGOTO[NTERM-NUM]. */ +/* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 2, 4, 7, 22, 35, 48, 179, 242, 39, @@ -782,9 +833,55 @@ static const yytype_int16 yydefgoto[] = 177, 109, 152, 81, 82, 83, 29 }; - /* 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. */ +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -133 +static const yytype_int16 yypact[] = +{ + -11, -48, 20, -133, -19, -133, 210, -133, -133, -133, + -133, -133, -133, -133, -133, -133, -133, -133, -133, -133, + -133, -3, -133, -133, 332, -16, 8, -4, -133, -133, + 18, 19, 29, 41, 48, -22, 47, 128, 56, 75, + 210, 94, 94, 136, 33, 281, 102, -133, -133, 2, + 63, 64, 65, 68, 71, 74, 76, 77, 78, 102, + 82, 56, -133, -133, 81, 81, 81, 81, 99, 222, + 88, 210, 117, -133, -133, -133, -133, -133, -133, -133, + -133, -133, -133, -133, -133, -133, -133, -133, -133, -133, + -133, -133, -133, -133, -133, -133, -133, -133, -133, -133, + 281, -133, 90, -133, -133, -133, -133, -133, -133, -133, + 89, 97, 91, 100, 281, 94, 33, 33, 136, 94, + 136, 136, 281, 105, -133, 142, -133, -133, -133, -133, + -133, -133, 102, 109, -133, 210, 107, 121, -133, 123, + -133, 125, 210, 148, 35, 281, 333, -133, 281, 281, + 90, -133, 129, -133, -133, -133, -133, -133, -133, 90, + 332, 127, 131, 130, 132, -133, 102, 95, 210, 133, + -133, 332, -133, 332, -133, -133, -133, -23, -133, 210, + 90, 90, 33, 278, 135, 102, -133, 102, 102, 102, + -133, -133, -133, -133, -133, 137, -133, 138, -133, -32, + 139, -133, 332, 140, 333, -133, -133, -133, -133, 144, + -133, 141, -133, 145, -133, 45, -133, 143, -133, -133, + 102, -12, -133, 281, 147, -133, -133, 157, -133, 102, + -2, -133, -133, 102, 33, -133, 146, 25, -133, -133, + 90, -133, 151, -133, -133, -133, 26, -133, -133, -133, + -12, -133, 210, -2, -133, -133, -133, -133 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -133, -133, -133, -133, 28, 4, -133, -133, -133, -133, + -133, -109, 150, -133, 30, -133, -133, 5, -133, -133, + -133, -133, 57, -25, -133, -133, 104, -133, 79, -133, + -133, -133, 73, -133, -133, 22, -133, -133, -7, -133, + 15, -133, -133, -6, -133, -29, -18, -39, -30, -41, + -133, -133, 44, -93, -133, -133, 106, -133, -133, -133, + -133, -132, -133, -42, -31, -76, -21 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -106 static const yytype_int16 yytable[] = { 34, 73, 84, 19, 101, 3, 36, 144, 70, 69, @@ -827,6 +924,12 @@ static const yytype_int16 yytable[] = 20 }; +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-133))) + +#define yytable_value_is_error(Yytable_value) \ + YYID (0) + static const yytype_int16 yycheck[] = { 21, 40, 44, 15, 45, 53, 24, 100, 38, 38, @@ -869,8 +972,8 @@ static const yytype_int16 yycheck[] = 38 }; - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 30, 64, 53, 65, 0, 54, 66, 4, 5, @@ -901,58 +1004,30 @@ static const yytype_uint8 yystos[] = 57, 60, 55, 57, 60, 101, 110, 106 }; - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 63, 64, 65, 66, 67, 68, 68, 70, 71, - 69, 72, 72, 72, 73, 73, 74, 75, 75, 76, - 76, 76, 76, 77, 77, 78, 79, 79, 80, 81, - 82, 83, 84, 84, 85, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 87, 87, 87, 88, - 88, 89, 89, 90, 90, 91, 91, 92, 93, 93, - 93, 94, 94, 95, 95, 96, 97, 97, 98, 99, - 99, 100, 100, 101, 102, 102, 103, 104, 104, 105, - 105, 106, 106, 107, 108, 109, 109, 110, 110, 111, - 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 112, 112, 113, 113, 113, - 114, 114, 115, 116, 116, 117, 118, 118, 119, 119, - 120, 120, 120, 120, 120, 120, 121, 122, 123, 123, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 125, 125, 126, 126, 126, 126, 127, 128, - 128, 129 -}; - - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 3, 1, 4, 5, 0, 2, 0, 0, - 9, 0, 1, 2, 1, 2, 1, 1, 2, 2, - 2, 2, 2, 0, 1, 6, 1, 3, 3, 5, - 5, 5, 2, 3, 2, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, 2, 2, - 3, 1, 1, 1, 3, 3, 3, 1, 0, 1, - 2, 2, 3, 1, 1, 2, 1, 3, 2, 0, - 3, 1, 3, 1, 1, 3, 2, 0, 3, 1, - 3, 1, 1, 1, 1, 1, 1, 0, 3, 4, - 4, 4, 4, 6, 5, 5, 6, 5, 5, 5, - 5, 5, 5, 5, 4, 1, 1, 0, 1, 2, - 2, 3, 3, 1, 1, 0, 1, 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 -}; - - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ + +#define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -969,15 +1044,27 @@ do \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) + YYERROR; \ + } \ +while (YYID (0)) /* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYTERROR 1 +#define YYERRCODE 256 +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -987,36 +1074,40 @@ while (0) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - 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 YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif { FILE *yyo = yyoutput; YYUSE (yyo); @@ -1025,8 +1116,14 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); # endif - YYUSE (yytype); + switch (yytype) + { + default: + break; + } } @@ -1034,11 +1131,22 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue | Print this symbol on YYOUTPUT. | `--------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); @@ -1049,8 +1157,16 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) | TOP (included). | `------------------------------------------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -1061,42 +1177,49 @@ yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif { - unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; + unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, Rule); \ -} while (0) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -1110,7 +1233,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -1133,8 +1256,15 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -1150,8 +1280,16 @@ yystrlen (const char *yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif { char *yyd = yydest; const char *yys = yysrc; @@ -1181,27 +1319,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1224,11 +1362,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1236,6 +1374,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, int yycount = 0; /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + + for details. YYERROR is fine as it does not invoke this + function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected @@ -1285,7 +1427,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1352,17 +1494,31 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | Release the memory associated to this symbol. | `-----------------------------------------------*/ +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif { YYUSE (yyvaluep); + if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); - YY_IGNORE_MAYBE_UNINITIALIZED_END + switch (yytype) + { + + default: + break; + } } @@ -1371,8 +1527,18 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) /* The lookahead symbol. */ int yychar; + +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + /* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; +YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); + /* Number of syntax errors so far. */ int yynerrs; @@ -1381,16 +1547,35 @@ int yynerrs; | yyparse. | `----------*/ +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (void) +#else +int +yyparse () + +#endif +#endif { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. + `yyss': related to states. + `yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ @@ -1458,23 +1643,23 @@ yyparse (void) #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1482,22 +1667,22 @@ yyparse (void) # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1506,10 +1691,10 @@ yyparse (void) yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1538,7 +1723,7 @@ yyparse (void) if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = yylex (); + yychar = YYLEX; } if (yychar <= YYEOF) @@ -1603,7 +1788,7 @@ yyparse (void) yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. + `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -1617,84 +1802,85 @@ yyparse (void) switch (yyn) { case 2: -#line 221 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 221 "ncgen.y" {if (error_count > 0) YYABORT;} -#line 1623 "ncgeny.c" /* yacc.c:1646 */ break; case 3: -#line 224 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 224 "ncgen.y" {createrootgroup(datasetname);} -#line 1629 "ncgeny.c" /* yacc.c:1646 */ break; case 8: -#line 243 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 243 "ncgen.y" { - Symbol* id = (yyvsp[-1].sym); + Symbol* id = (yyvsp[(2) - (3)].sym); markcdf4("Group specification"); if(creategroup(id) == NULL) yyerror("duplicate group declaration within parent group for %s", id->name); } -#line 1641 "ncgeny.c" /* yacc.c:1646 */ break; case 9: -#line 252 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 252 "ncgen.y" {listpop(groupstack);} -#line 1647 "ncgeny.c" /* yacc.c:1646 */ break; case 12: -#line 258 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 258 "ncgen.y" {} -#line 1653 "ncgeny.c" /* yacc.c:1646 */ break; case 13: -#line 260 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 260 "ncgen.y" {markcdf4("Type specification");} -#line 1659 "ncgeny.c" /* yacc.c:1646 */ break; case 16: -#line 266 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 266 "ncgen.y" { /* Use when defining a type */ - (yyvsp[0].sym)->objectclass = NC_TYPE; - if(dupobjectcheck(NC_TYPE,(yyvsp[0].sym))) + (yyvsp[(1) - (1)].sym)->objectclass = NC_TYPE; + if(dupobjectcheck(NC_TYPE,(yyvsp[(1) - (1)].sym))) yyerror("duplicate type declaration for %s", - (yyvsp[0].sym)->name); - listpush(typdefs,(void*)(yyvsp[0].sym)); + (yyvsp[(1) - (1)].sym)->name); + listpush(typdefs,(void*)(yyvsp[(1) - (1)].sym)); } -#line 1671 "ncgeny.c" /* yacc.c:1646 */ break; case 17: -#line 275 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 275 "ncgen.y" {} -#line 1677 "ncgeny.c" /* yacc.c:1646 */ break; case 18: -#line 275 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 275 "ncgen.y" {} -#line 1683 "ncgeny.c" /* yacc.c:1646 */ break; case 25: -#line 289 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 289 "ncgen.y" { int i; - addtogroup((yyvsp[-3].sym)); /* sets prefix*/ - (yyvsp[-3].sym)->objectclass=NC_TYPE; - (yyvsp[-3].sym)->subclass=NC_ENUM; - (yyvsp[-3].sym)->typ.basetype=(yyvsp[-5].sym); - (yyvsp[-3].sym)->typ.size = (yyvsp[-5].sym)->typ.size; - (yyvsp[-3].sym)->typ.alignment = (yyvsp[-5].sym)->typ.alignment; - stackbase=(yyvsp[-1].mark); + addtogroup((yyvsp[(3) - (6)].sym)); /* sets prefix*/ + (yyvsp[(3) - (6)].sym)->objectclass=NC_TYPE; + (yyvsp[(3) - (6)].sym)->subclass=NC_ENUM; + (yyvsp[(3) - (6)].sym)->typ.basetype=(yyvsp[(1) - (6)].sym); + (yyvsp[(3) - (6)].sym)->typ.size = (yyvsp[(1) - (6)].sym)->typ.size; + (yyvsp[(3) - (6)].sym)->typ.alignment = (yyvsp[(1) - (6)].sym)->typ.alignment; + stackbase=(yyvsp[(5) - (6)].mark); stacklen=listlength(stack); - (yyvsp[-3].sym)->subnodes = listnew(); + (yyvsp[(3) - (6)].sym)->subnodes = listnew(); /* Variety of field fixups*/ /* 1. add in the enum values*/ /* 2. make this type be their container*/ @@ -1704,89 +1890,89 @@ yyparse (void) Symbol* eid = (Symbol*)listget(stack,i); assert(eid->subclass == NC_ECONST); addtogroup(eid); - listpush((yyvsp[-3].sym)->subnodes,(void*)eid); - eid->container = (yyvsp[-3].sym); - eid->typ.basetype = (yyvsp[-3].sym)->typ.basetype; + listpush((yyvsp[(3) - (6)].sym)->subnodes,(void*)eid); + eid->container = (yyvsp[(3) - (6)].sym); + eid->typ.basetype = (yyvsp[(3) - (6)].sym)->typ.basetype; } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 1714 "ncgeny.c" /* yacc.c:1646 */ break; case 26: -#line 318 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 1720 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 318 "ncgen.y" + {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[(1) - (1)].sym));} break; case 27: -#line 320 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 320 "ncgen.y" { int i; - (yyval.mark)=(yyvsp[-2].mark); + (yyval.mark)=(yyvsp[(1) - (3)].mark); /* check for duplicates*/ - stackbase=(yyvsp[-2].mark); + stackbase=(yyvsp[(1) - (3)].mark); stacklen=listlength(stack); for(i=stackbase;iname,elem->name)==0) + if(strcmp((yyvsp[(3) - (3)].sym)->name,elem->name)==0) yyerror("duplicate enum declaration for %s", elem->name); } - listpush(stack,(void*)(yyvsp[0].sym)); + listpush(stack,(void*)(yyvsp[(3) - (3)].sym)); } -#line 1739 "ncgeny.c" /* yacc.c:1646 */ break; case 28: -#line 337 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 337 "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); + (yyvsp[(1) - (3)].sym)->objectclass=NC_TYPE; + (yyvsp[(1) - (3)].sym)->subclass=NC_ECONST; + (yyvsp[(1) - (3)].sym)->typ.econst=(yyvsp[(3) - (3)].constant); + (yyval.sym)=(yyvsp[(1) - (3)].sym); } -#line 1750 "ncgeny.c" /* yacc.c:1646 */ break; case 29: -#line 346 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 346 "ncgen.y" { vercheck(NC_OPAQUE); - addtogroup((yyvsp[0].sym)); /*sets prefix*/ - (yyvsp[0].sym)->objectclass=NC_TYPE; - (yyvsp[0].sym)->subclass=NC_OPAQUE; - (yyvsp[0].sym)->typ.typecode=NC_OPAQUE; - (yyvsp[0].sym)->typ.size=int32_val; - (yyvsp[0].sym)->typ.alignment=nctypealignment(NC_OPAQUE); + addtogroup((yyvsp[(5) - (5)].sym)); /*sets prefix*/ + (yyvsp[(5) - (5)].sym)->objectclass=NC_TYPE; + (yyvsp[(5) - (5)].sym)->subclass=NC_OPAQUE; + (yyvsp[(5) - (5)].sym)->typ.typecode=NC_OPAQUE; + (yyvsp[(5) - (5)].sym)->typ.size=int32_val; + (yyvsp[(5) - (5)].sym)->typ.alignment=nctypealignment(NC_OPAQUE); } -#line 1764 "ncgeny.c" /* yacc.c:1646 */ break; case 30: -#line 358 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 358 "ncgen.y" { - Symbol* basetype = (yyvsp[-4].sym); + Symbol* basetype = (yyvsp[(1) - (5)].sym); vercheck(NC_VLEN); - addtogroup((yyvsp[0].sym)); /*sets prefix*/ - (yyvsp[0].sym)->objectclass=NC_TYPE; - (yyvsp[0].sym)->subclass=NC_VLEN; - (yyvsp[0].sym)->typ.basetype=basetype; - (yyvsp[0].sym)->typ.typecode=NC_VLEN; - (yyvsp[0].sym)->typ.size=VLENSIZE; - (yyvsp[0].sym)->typ.alignment=nctypealignment(NC_VLEN); + addtogroup((yyvsp[(5) - (5)].sym)); /*sets prefix*/ + (yyvsp[(5) - (5)].sym)->objectclass=NC_TYPE; + (yyvsp[(5) - (5)].sym)->subclass=NC_VLEN; + (yyvsp[(5) - (5)].sym)->typ.basetype=basetype; + (yyvsp[(5) - (5)].sym)->typ.typecode=NC_VLEN; + (yyvsp[(5) - (5)].sym)->typ.size=VLENSIZE; + (yyvsp[(5) - (5)].sym)->typ.alignment=nctypealignment(NC_VLEN); } -#line 1780 "ncgeny.c" /* yacc.c:1646 */ break; case 31: -#line 372 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 372 "ncgen.y" { int i,j; vercheck(NC_COMPOUND); - addtogroup((yyvsp[-3].sym)); + addtogroup((yyvsp[(2) - (5)].sym)); /* check for duplicate field names*/ - stackbase=(yyvsp[-1].mark); + stackbase=(yyvsp[(4) - (5)].mark); stacklen=listlength(stack); for(i=stackbase;iobjectclass=NC_TYPE; - (yyvsp[-3].sym)->subclass=NC_COMPOUND; - (yyvsp[-3].sym)->typ.basetype=NULL; - (yyvsp[-3].sym)->typ.typecode=NC_COMPOUND; - (yyvsp[-3].sym)->subnodes = listnew(); + (yyvsp[(2) - (5)].sym)->objectclass=NC_TYPE; + (yyvsp[(2) - (5)].sym)->subclass=NC_COMPOUND; + (yyvsp[(2) - (5)].sym)->typ.basetype=NULL; + (yyvsp[(2) - (5)].sym)->typ.typecode=NC_COMPOUND; + (yyvsp[(2) - (5)].sym)->subnodes = listnew(); /* Add in the fields*/ for(i=stackbase;icontainer = (yyvsp[-3].sym); - listpush((yyvsp[-3].sym)->subnodes,(void*)fsym); + fsym->container = (yyvsp[(2) - (5)].sym); + listpush((yyvsp[(2) - (5)].sym)->subnodes,(void*)fsym); } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 1814 "ncgeny.c" /* yacc.c:1646 */ break; case 32: -#line 404 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=(yyvsp[-1].mark);} -#line 1820 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 404 "ncgen.y" + {(yyval.mark)=(yyvsp[(1) - (2)].mark);} break; case 33: -#line 405 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=(yyvsp[-2].mark);} -#line 1826 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 405 "ncgen.y" + {(yyval.mark)=(yyvsp[(1) - (3)].mark);} break; case 34: -#line 409 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 409 "ncgen.y" { int i; - (yyval.mark)=(yyvsp[0].mark); - stackbase=(yyvsp[0].mark); + (yyval.mark)=(yyvsp[(2) - (2)].mark); + stackbase=(yyvsp[(2) - (2)].mark); stacklen=listlength(stack); /* process each field in the fieldlist*/ for(i=stackbase;ityp.basetype = (yyvsp[-1].sym); + f->typ.basetype = (yyvsp[(1) - (2)].sym); } } -#line 1842 "ncgeny.c" /* yacc.c:1646 */ break; case 35: -#line 422 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 422 "ncgen.y" { (yyval.sym) = primsymbols[NC_CHAR]; } -#line 1848 "ncgeny.c" /* yacc.c:1646 */ break; case 36: -#line 423 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 423 "ncgen.y" { (yyval.sym) = primsymbols[NC_BYTE]; } -#line 1854 "ncgeny.c" /* yacc.c:1646 */ break; case 37: -#line 424 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 424 "ncgen.y" { (yyval.sym) = primsymbols[NC_SHORT]; } -#line 1860 "ncgeny.c" /* yacc.c:1646 */ break; case 38: -#line 425 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 425 "ncgen.y" { (yyval.sym) = primsymbols[NC_INT]; } -#line 1866 "ncgeny.c" /* yacc.c:1646 */ break; case 39: -#line 426 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 426 "ncgen.y" { (yyval.sym) = primsymbols[NC_FLOAT]; } -#line 1872 "ncgeny.c" /* yacc.c:1646 */ break; case 40: -#line 427 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 427 "ncgen.y" { (yyval.sym) = primsymbols[NC_DOUBLE]; } -#line 1878 "ncgeny.c" /* yacc.c:1646 */ break; case 41: -#line 428 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 428 "ncgen.y" { vercheck(NC_UBYTE); (yyval.sym) = primsymbols[NC_UBYTE]; } -#line 1884 "ncgeny.c" /* yacc.c:1646 */ break; case 42: -#line 429 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 429 "ncgen.y" { vercheck(NC_USHORT); (yyval.sym) = primsymbols[NC_USHORT]; } -#line 1890 "ncgeny.c" /* yacc.c:1646 */ break; case 43: -#line 430 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 430 "ncgen.y" { vercheck(NC_UINT); (yyval.sym) = primsymbols[NC_UINT]; } -#line 1896 "ncgeny.c" /* yacc.c:1646 */ break; case 44: -#line 431 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 431 "ncgen.y" { vercheck(NC_INT64); (yyval.sym) = primsymbols[NC_INT64]; } -#line 1902 "ncgeny.c" /* yacc.c:1646 */ break; case 45: -#line 432 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 432 "ncgen.y" { vercheck(NC_UINT64); (yyval.sym) = primsymbols[NC_UINT64]; } -#line 1908 "ncgeny.c" /* yacc.c:1646 */ break; case 47: -#line 436 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 436 "ncgen.y" {} -#line 1914 "ncgeny.c" /* yacc.c:1646 */ break; case 48: -#line 437 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 437 "ncgen.y" {} -#line 1920 "ncgeny.c" /* yacc.c:1646 */ break; case 51: -#line 444 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 444 "ncgen.y" {} -#line 1926 "ncgeny.c" /* yacc.c:1646 */ break; case 52: -#line 444 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 444 "ncgen.y" {} -#line 1932 "ncgeny.c" /* yacc.c:1646 */ break; case 55: -#line 452 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 452 "ncgen.y" { - (yyvsp[-2].sym)->dim.declsize = (size_t)extractint((yyvsp[0].constant)); + (yyvsp[(1) - (3)].sym)->dim.declsize = (size_t)extractint((yyvsp[(3) - (3)].constant)); #ifdef GENDEBUG1 -fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[-2].sym)->name,(unsigned long long)(yyvsp[-2].sym)->dim.declsize); +fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[(1) - (3)].sym)->name,(unsigned long long)(yyvsp[(1) - (3)].sym)->dim.declsize); #endif } -#line 1943 "ncgeny.c" /* yacc.c:1646 */ break; case 56: -#line 459 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 459 "ncgen.y" { - (yyvsp[-2].sym)->dim.declsize = NC_UNLIMITED; - (yyvsp[-2].sym)->dim.isunlimited = 1; + (yyvsp[(1) - (3)].sym)->dim.declsize = NC_UNLIMITED; + (yyvsp[(1) - (3)].sym)->dim.isunlimited = 1; #ifdef GENDEBUG1 -fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); +fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); #endif } -#line 1955 "ncgeny.c" /* yacc.c:1646 */ break; case 57: -#line 469 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 469 "ncgen.y" { - (yyvsp[0].sym)->objectclass=NC_DIM; - if(dupobjectcheck(NC_DIM,(yyvsp[0].sym))) + (yyvsp[(1) - (1)].sym)->objectclass=NC_DIM; + if(dupobjectcheck(NC_DIM,(yyvsp[(1) - (1)].sym))) yyerror( "Duplicate dimension declaration for %s", - (yyvsp[0].sym)->name); - addtogroup((yyvsp[0].sym)); - (yyval.sym)=(yyvsp[0].sym); - listpush(dimdefs,(void*)(yyvsp[0].sym)); + (yyvsp[(1) - (1)].sym)->name); + addtogroup((yyvsp[(1) - (1)].sym)); + (yyval.sym)=(yyvsp[(1) - (1)].sym); + listpush(dimdefs,(void*)(yyvsp[(1) - (1)].sym)); } -#line 1969 "ncgeny.c" /* yacc.c:1646 */ break; case 59: -#line 481 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 481 "ncgen.y" {} -#line 1975 "ncgeny.c" /* yacc.c:1646 */ break; case 60: -#line 482 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 482 "ncgen.y" {} -#line 1981 "ncgeny.c" /* yacc.c:1646 */ break; case 63: -#line 489 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 489 "ncgen.y" {} -#line 1987 "ncgeny.c" /* yacc.c:1646 */ break; case 64: -#line 489 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 489 "ncgen.y" {} -#line 1993 "ncgeny.c" /* yacc.c:1646 */ break; case 65: -#line 492 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 492 "ncgen.y" { int i; - stackbase=(yyvsp[0].mark); + stackbase=(yyvsp[(2) - (2)].mark); stacklen=listlength(stack); /* process each variable in the varlist*/ for(i=stackbase;iname); yyerror("Duplicate variable declaration for %s", sym->name); } else { - sym->typ.basetype = (yyvsp[-1].sym); + sym->typ.basetype = (yyvsp[(1) - (2)].sym); addtogroup(sym); listpush(vardefs,(void*)sym); } } listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 2017 "ncgeny.c" /* yacc.c:1646 */ break; case 66: -#line 514 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 514 "ncgen.y" {(yyval.mark)=listlength(stack); - listpush(stack,(void*)(yyvsp[0].sym)); + listpush(stack,(void*)(yyvsp[(1) - (1)].sym)); } -#line 2025 "ncgeny.c" /* yacc.c:1646 */ break; case 67: -#line 518 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2031 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 518 "ncgen.y" + {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(void*)(yyvsp[(3) - (3)].sym));} break; case 68: -#line 522 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 522 "ncgen.y" { int i; Dimset dimset; stacklen=listlength(stack); - stackbase=(yyvsp[0].mark); + stackbase=(yyvsp[(2) - (2)].mark); count = stacklen - stackbase; if(count >= NC_MAX_VAR_DIMS) { - yyerror("%s has too many dimensions",(yyvsp[-1].sym)->name); + yyerror("%s has too many dimensions",(yyvsp[(1) - (2)].sym)->name); count = NC_MAX_VAR_DIMS - 1; stacklen = stackbase + count; } @@ -2050,78 +2236,78 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); Symbol* dsym = (Symbol*)listget(stack,stackbase+i); dimset.dimsyms[i] = dsym; } - (yyvsp[-1].sym)->typ.dimset = dimset; + (yyvsp[(1) - (2)].sym)->typ.dimset = dimset; } - (yyvsp[-1].sym)->typ.basetype = NULL; /* not yet known*/ - (yyvsp[-1].sym)->objectclass=NC_VAR; + (yyvsp[(1) - (2)].sym)->typ.basetype = NULL; /* not yet known*/ + (yyvsp[(1) - (2)].sym)->objectclass=NC_VAR; listsetlength(stack,stackbase);/* remove stack nodes*/ } -#line 2060 "ncgeny.c" /* yacc.c:1646 */ break; case 69: -#line 548 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 548 "ncgen.y" {(yyval.mark)=listlength(stack);} -#line 2066 "ncgeny.c" /* yacc.c:1646 */ break; case 70: -#line 549 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=(yyvsp[-1].mark);} -#line 2072 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 549 "ncgen.y" + {(yyval.mark)=(yyvsp[(2) - (3)].mark);} break; case 71: -#line 552 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2078 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 552 "ncgen.y" + {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[(1) - (1)].sym));} break; case 72: -#line 554 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2084 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 554 "ncgen.y" + {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(void*)(yyvsp[(3) - (3)].sym));} break; case 73: -#line 558 "ncgen.y" /* yacc.c:1646 */ - {Symbol* dimsym = (yyvsp[0].sym); +/* Line 1792 of yacc.c */ +#line 558 "ncgen.y" + {Symbol* dimsym = (yyvsp[(1) - (1)].sym); dimsym->objectclass = NC_DIM; /* Find the actual dimension*/ dimsym = locate(dimsym); if(dimsym == NULL) { - derror("Undefined or forward referenced dimension: %s",(yyvsp[0].sym)->name); + derror("Undefined or forward referenced dimension: %s",(yyvsp[(1) - (1)].sym)->name); YYABORT; } (yyval.sym)=dimsym; } -#line 2099 "ncgeny.c" /* yacc.c:1646 */ break; case 74: -#line 572 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 572 "ncgen.y" {(yyval.mark)=listlength(stack); - listpush(stack,(void*)(yyvsp[0].sym)); + listpush(stack,(void*)(yyvsp[(1) - (1)].sym)); } -#line 2107 "ncgeny.c" /* yacc.c:1646 */ break; case 75: -#line 576 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2113 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 576 "ncgen.y" + {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(void*)(yyvsp[(3) - (3)].sym));} break; case 76: -#line 581 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 581 "ncgen.y" { int i; Dimset dimset; - stackbase=(yyvsp[0].mark); + stackbase=(yyvsp[(2) - (2)].mark); stacklen=listlength(stack); count = stacklen - stackbase; if(count >= NC_MAX_VAR_DIMS) { - yyerror("%s has too many dimensions",(yyvsp[-1].sym)->name); + yyerror("%s has too many dimensions",(yyvsp[(1) - (2)].sym)->name); count = NC_MAX_VAR_DIMS - 1; stacklen = stackbase + count; } @@ -2132,43 +2318,43 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); Symbol* dsym = (Symbol*)listget(stack,stackbase+i); dimset.dimsyms[i] = dsym; } - (yyvsp[-1].sym)->typ.dimset = dimset; + (yyvsp[(1) - (2)].sym)->typ.dimset = dimset; } - (yyvsp[-1].sym)->typ.basetype = NULL; /* not yet known*/ - (yyvsp[-1].sym)->objectclass=NC_TYPE; - (yyvsp[-1].sym)->subclass=NC_FIELD; + (yyvsp[(1) - (2)].sym)->typ.basetype = NULL; /* not yet known*/ + (yyvsp[(1) - (2)].sym)->objectclass=NC_TYPE; + (yyvsp[(1) - (2)].sym)->subclass=NC_FIELD; listsetlength(stack,stackbase);/* remove stack nodes*/ - (yyval.sym) = (yyvsp[-1].sym); + (yyval.sym) = (yyvsp[(1) - (2)].sym); } -#line 2144 "ncgeny.c" /* yacc.c:1646 */ break; case 77: -#line 609 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 609 "ncgen.y" {(yyval.mark)=listlength(stack);} -#line 2150 "ncgeny.c" /* yacc.c:1646 */ break; case 78: -#line 610 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=(yyvsp[-1].mark);} -#line 2156 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 610 "ncgen.y" + {(yyval.mark)=(yyvsp[(2) - (3)].mark);} break; case 79: -#line 614 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2162 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 614 "ncgen.y" + {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[(1) - (1)].sym));} break; case 80: -#line 616 "ncgen.y" /* yacc.c:1646 */ - {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} -#line 2168 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 616 "ncgen.y" + {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(void*)(yyvsp[(3) - (3)].sym));} break; case 81: -#line 621 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 621 "ncgen.y" { /* Anonymous integer dimension. Can only occur in type definitions*/ char anon[32]; @@ -2178,11 +2364,11 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = uint32_val; } -#line 2182 "ncgeny.c" /* yacc.c:1646 */ break; case 82: -#line 631 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 631 "ncgen.y" { /* Anonymous integer dimension. Can only occur in type definitions*/ char anon[32]; @@ -2196,36 +2382,36 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = int32_val; } -#line 2200 "ncgeny.c" /* yacc.c:1646 */ break; case 83: -#line 651 "ncgen.y" /* yacc.c:1646 */ - {Symbol* vsym = (yyvsp[0].sym); +/* Line 1792 of yacc.c */ +#line 651 "ncgen.y" + {Symbol* vsym = (yyvsp[(1) - (1)].sym); if(vsym->objectclass != NC_VAR) { derror("Undefined or forward referenced variable: %s",vsym->name); YYABORT; } (yyval.sym)=vsym; } -#line 2212 "ncgeny.c" /* yacc.c:1646 */ break; case 84: -#line 662 "ncgen.y" /* yacc.c:1646 */ - {Symbol* tsym = (yyvsp[0].sym); +/* Line 1792 of yacc.c */ +#line 662 "ncgen.y" + {Symbol* tsym = (yyvsp[(1) - (1)].sym); if(tsym->objectclass != NC_TYPE) { derror("Undefined or forward referenced type: %s",tsym->name); YYABORT; } (yyval.sym)=tsym; } -#line 2224 "ncgeny.c" /* yacc.c:1646 */ break; case 85: -#line 673 "ncgen.y" /* yacc.c:1646 */ - {Symbol* tvsym = (yyvsp[0].sym); Symbol* sym; +/* Line 1792 of yacc.c */ +#line 673 "ncgen.y" + {Symbol* tvsym = (yyvsp[(1) - (1)].sym); Symbol* sym; /* disambiguate*/ tvsym->objectclass = NC_VAR; sym = locate(tvsym); @@ -2233,419 +2419,419 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); tvsym->objectclass = NC_TYPE; sym = locate(tvsym); if(tvsym == NULL) { - derror("Undefined or forward referenced name: %s",(yyvsp[0].sym)->name); + derror("Undefined or forward referenced name: %s",(yyvsp[(1) - (1)].sym)->name); YYABORT; } else tvsym = sym; } else tvsym = sym; if(tvsym == NULL) { - derror("Undefined name (line %d): %s",(yyvsp[0].sym)->lineno,(yyvsp[0].sym)->name); + derror("Undefined name (line %d): %s",(yyvsp[(1) - (1)].sym)->lineno,(yyvsp[(1) - (1)].sym)->name); YYABORT; } (yyval.sym)=tvsym; } -#line 2247 "ncgeny.c" /* yacc.c:1646 */ break; case 86: -#line 691 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym)=(yyvsp[0].sym);} -#line 2253 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 691 "ncgen.y" + {(yyval.sym)=(yyvsp[(1) - (1)].sym);} break; case 87: -#line 698 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 698 "ncgen.y" {} -#line 2259 "ncgeny.c" /* yacc.c:1646 */ break; case 88: -#line 698 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 698 "ncgen.y" {} -#line 2265 "ncgeny.c" /* yacc.c:1646 */ break; case 89: -#line 702 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_NCPROPS_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} -#line 2271 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 702 "ncgen.y" + {(yyval.sym) = makespecial(_NCPROPS_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),ATTRGLOBAL);} break; case 90: -#line 704 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_ISNETCDF4_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} -#line 2277 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 704 "ncgen.y" + {(yyval.sym) = makespecial(_ISNETCDF4_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),ATTRGLOBAL);} break; case 91: -#line 706 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_SUPERBLOCK_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} -#line 2283 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 706 "ncgen.y" + {(yyval.sym) = makespecial(_SUPERBLOCK_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),ATTRGLOBAL);} break; case 92: -#line 708 "ncgen.y" /* yacc.c:1646 */ - { (yyval.sym)=makeattribute((yyvsp[-2].sym),NULL,NULL,(yyvsp[0].datalist),ATTRGLOBAL);} -#line 2289 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 708 "ncgen.y" + { (yyval.sym)=makeattribute((yyvsp[(2) - (4)].sym),NULL,NULL,(yyvsp[(4) - (4)].datalist),ATTRGLOBAL);} break; case 93: -#line 710 "ncgen.y" /* yacc.c:1646 */ - {Symbol* tsym = (yyvsp[-5].sym); Symbol* vsym = (yyvsp[-4].sym); Symbol* asym = (yyvsp[-2].sym); +/* Line 1792 of yacc.c */ +#line 710 "ncgen.y" + {Symbol* tsym = (yyvsp[(1) - (6)].sym); Symbol* vsym = (yyvsp[(2) - (6)].sym); Symbol* asym = (yyvsp[(4) - (6)].sym); if(vsym->objectclass == NC_VAR) { - (yyval.sym)=makeattribute(asym,vsym,tsym,(yyvsp[0].datalist),ATTRVAR); + (yyval.sym)=makeattribute(asym,vsym,tsym,(yyvsp[(6) - (6)].datalist),ATTRVAR); } else { derror("Doubly typed attribute: %s",asym->name); YYABORT; } } -#line 2302 "ncgeny.c" /* yacc.c:1646 */ break; case 94: -#line 719 "ncgen.y" /* yacc.c:1646 */ - {Symbol* sym = (yyvsp[-4].sym); Symbol* asym = (yyvsp[-2].sym); +/* Line 1792 of yacc.c */ +#line 719 "ncgen.y" + {Symbol* sym = (yyvsp[(1) - (5)].sym); Symbol* asym = (yyvsp[(3) - (5)].sym); if(sym->objectclass == NC_VAR) { - (yyval.sym)=makeattribute(asym,sym,NULL,(yyvsp[0].datalist),ATTRVAR); + (yyval.sym)=makeattribute(asym,sym,NULL,(yyvsp[(5) - (5)].datalist),ATTRVAR); } else if(sym->objectclass == NC_TYPE) { - (yyval.sym)=makeattribute(asym,NULL,sym,(yyvsp[0].datalist),ATTRGLOBAL); + (yyval.sym)=makeattribute(asym,NULL,sym,(yyvsp[(5) - (5)].datalist),ATTRGLOBAL); } else { derror("Attribute prefix not a variable or type: %s",asym->name); YYABORT; } } -#line 2317 "ncgeny.c" /* yacc.c:1646 */ break; case 95: -#line 730 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),0);} -#line 2323 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 730 "ncgen.y" + {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);} break; case 96: -#line 732 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),(yyvsp[-5].sym),(void*)(yyvsp[0].datalist),0);} -#line 2329 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 732 "ncgen.y" + {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(2) - (6)].sym),(yyvsp[(1) - (6)].sym),(void*)(yyvsp[(6) - (6)].datalist),0);} break; case 97: -#line 734 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2335 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 734 "ncgen.y" + {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 98: -#line 736 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),0);} -#line 2341 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 736 "ncgen.y" + {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);} break; case 99: -#line 738 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2347 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 738 "ncgen.y" + {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 100: -#line 740 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2353 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 740 "ncgen.y" + {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 101: -#line 742 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2359 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 742 "ncgen.y" + {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 102: -#line 744 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2365 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 744 "ncgen.y" + {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 103: -#line 746 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} -#line 2371 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 746 "ncgen.y" + {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 104: -#line 748 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),1);} -#line 2377 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 748 "ncgen.y" + {(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),1);} break; case 105: -#line 753 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 753 "ncgen.y" { - (yyval.sym)=(yyvsp[0].sym); - (yyvsp[0].sym)->ref.is_ref=1; - (yyvsp[0].sym)->is_prefixed=0; - setpathcurrent((yyvsp[0].sym)); + (yyval.sym)=(yyvsp[(1) - (1)].sym); + (yyvsp[(1) - (1)].sym)->ref.is_ref=1; + (yyvsp[(1) - (1)].sym)->is_prefixed=0; + setpathcurrent((yyvsp[(1) - (1)].sym)); } -#line 2388 "ncgeny.c" /* yacc.c:1646 */ break; case 106: -#line 760 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 760 "ncgen.y" { - (yyval.sym)=(yyvsp[0].sym); - (yyvsp[0].sym)->ref.is_ref=1; - (yyvsp[0].sym)->is_prefixed=1; + (yyval.sym)=(yyvsp[(1) - (1)].sym); + (yyvsp[(1) - (1)].sym)->ref.is_ref=1; + (yyvsp[(1) - (1)].sym)->is_prefixed=1; /* path is set in ncgen.l*/ } -#line 2399 "ncgeny.c" /* yacc.c:1646 */ break; case 108: -#line 769 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 769 "ncgen.y" {} -#line 2405 "ncgeny.c" /* yacc.c:1646 */ break; case 109: -#line 770 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 770 "ncgen.y" {} -#line 2411 "ncgeny.c" /* yacc.c:1646 */ break; case 112: -#line 778 "ncgen.y" /* yacc.c:1646 */ - {(yyvsp[-2].sym)->data = (yyvsp[0].datalist);} -#line 2417 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 778 "ncgen.y" + {(yyvsp[(1) - (3)].sym)->data = (yyvsp[(3) - (3)].datalist);} break; case 113: -#line 781 "ncgen.y" /* yacc.c:1646 */ - {(yyval.datalist) = (yyvsp[0].datalist);} -#line 2423 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 781 "ncgen.y" + {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);} break; case 114: -#line 782 "ncgen.y" /* yacc.c:1646 */ - {(yyval.datalist) = (yyvsp[0].datalist);} -#line 2429 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 782 "ncgen.y" + {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);} break; case 115: -#line 786 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 786 "ncgen.y" {(yyval.datalist) = builddatalist(0);} -#line 2435 "ncgeny.c" /* yacc.c:1646 */ break; case 116: -#line 790 "ncgen.y" /* yacc.c:1646 */ - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} -#line 2441 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 790 "ncgen.y" + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));} break; case 117: -#line 792 "ncgen.y" /* yacc.c:1646 */ - {datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);} -#line 2447 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 792 "ncgen.y" + {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);} break; case 118: -#line 796 "ncgen.y" /* yacc.c:1646 */ - {(yyval.constant)=(yyvsp[0].constant);} -#line 2453 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 796 "ncgen.y" + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 119: -#line 797 "ncgen.y" /* yacc.c:1646 */ - {(yyval.constant)=builddatasublist((yyvsp[-1].datalist));} -#line 2459 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 797 "ncgen.y" + {(yyval.constant)=builddatasublist((yyvsp[(2) - (3)].datalist));} break; case 120: -#line 801 "ncgen.y" /* yacc.c:1646 */ - {(yyval.constant)=(yyvsp[0].constant);} -#line 2465 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 801 "ncgen.y" + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 121: -#line 802 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 802 "ncgen.y" {(yyval.constant)=makeconstdata(NC_OPAQUE);} -#line 2471 "ncgeny.c" /* yacc.c:1646 */ break; case 122: -#line 803 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 803 "ncgen.y" {(yyval.constant)=makeconstdata(NC_FILLVALUE);} -#line 2477 "ncgeny.c" /* yacc.c:1646 */ break; case 123: -#line 804 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 804 "ncgen.y" {(yyval.constant)=makeconstdata(NC_NIL);} -#line 2483 "ncgeny.c" /* yacc.c:1646 */ break; case 124: -#line 805 "ncgen.y" /* yacc.c:1646 */ - {(yyval.constant)=(yyvsp[0].constant);} -#line 2489 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 805 "ncgen.y" + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 126: -#line 810 "ncgen.y" /* yacc.c:1646 */ - {(yyval.constant) = makeenumconstref((yyvsp[0].sym));} -#line 2495 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 810 "ncgen.y" + {(yyval.constant) = makeenumconstref((yyvsp[(1) - (1)].sym));} break; case 127: -#line 814 "ncgen.y" /* yacc.c:1646 */ - {(yyval.constant)=evaluate((yyvsp[-3].sym),(yyvsp[-1].datalist));} -#line 2501 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 814 "ncgen.y" + {(yyval.constant)=evaluate((yyvsp[(1) - (4)].sym),(yyvsp[(3) - (4)].datalist));} break; case 128: -#line 819 "ncgen.y" /* yacc.c:1646 */ - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} -#line 2507 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 819 "ncgen.y" + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));} break; case 129: -#line 821 "ncgen.y" /* yacc.c:1646 */ - {datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);} -#line 2513 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 821 "ncgen.y" + {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);} break; case 130: -#line 825 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 825 "ncgen.y" {(yyval.constant)=makeconstdata(NC_CHAR);} -#line 2519 "ncgeny.c" /* yacc.c:1646 */ break; case 131: -#line 826 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 826 "ncgen.y" {(yyval.constant)=makeconstdata(NC_BYTE);} -#line 2525 "ncgeny.c" /* yacc.c:1646 */ break; case 132: -#line 827 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 827 "ncgen.y" {(yyval.constant)=makeconstdata(NC_SHORT);} -#line 2531 "ncgeny.c" /* yacc.c:1646 */ break; case 133: -#line 828 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 828 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT);} -#line 2537 "ncgeny.c" /* yacc.c:1646 */ break; case 134: -#line 829 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 829 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT64);} -#line 2543 "ncgeny.c" /* yacc.c:1646 */ break; case 135: -#line 830 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 830 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UBYTE);} -#line 2549 "ncgeny.c" /* yacc.c:1646 */ break; case 136: -#line 831 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 831 "ncgen.y" {(yyval.constant)=makeconstdata(NC_USHORT);} -#line 2555 "ncgeny.c" /* yacc.c:1646 */ break; case 137: -#line 832 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 832 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT);} -#line 2561 "ncgeny.c" /* yacc.c:1646 */ break; case 138: -#line 833 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 833 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT64);} -#line 2567 "ncgeny.c" /* yacc.c:1646 */ break; case 139: -#line 834 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 834 "ncgen.y" {(yyval.constant)=makeconstdata(NC_FLOAT);} -#line 2573 "ncgeny.c" /* yacc.c:1646 */ break; case 140: -#line 835 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 835 "ncgen.y" {(yyval.constant)=makeconstdata(NC_DOUBLE);} -#line 2579 "ncgeny.c" /* yacc.c:1646 */ break; case 141: -#line 836 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 836 "ncgen.y" {(yyval.constant)=makeconstdata(NC_STRING);} -#line 2585 "ncgeny.c" /* yacc.c:1646 */ break; case 142: -#line 840 "ncgen.y" /* yacc.c:1646 */ - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} -#line 2591 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 840 "ncgen.y" + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));} break; case 143: -#line 841 "ncgen.y" /* yacc.c:1646 */ - {(yyval.datalist)=(yyvsp[-2].datalist); datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant)));} -#line 2597 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 841 "ncgen.y" + {(yyval.datalist)=(yyvsp[(1) - (3)].datalist); datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant)));} break; case 144: -#line 846 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 846 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT);} -#line 2603 "ncgeny.c" /* yacc.c:1646 */ break; case 145: -#line 848 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 848 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT);} -#line 2609 "ncgeny.c" /* yacc.c:1646 */ break; case 146: -#line 850 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 850 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT64);} -#line 2615 "ncgeny.c" /* yacc.c:1646 */ break; case 147: -#line 852 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 852 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT64);} -#line 2621 "ncgeny.c" /* yacc.c:1646 */ break; case 148: -#line 856 "ncgen.y" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 856 "ncgen.y" {(yyval.constant)=makeconstdata(NC_STRING);} -#line 2627 "ncgeny.c" /* yacc.c:1646 */ break; case 149: -#line 860 "ncgen.y" /* yacc.c:1646 */ - {(yyval.constant)=(yyvsp[0].constant);} -#line 2633 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 860 "ncgen.y" + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 150: -#line 861 "ncgen.y" /* yacc.c:1646 */ - {(yyval.constant)=(yyvsp[0].constant);} -#line 2639 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 861 "ncgen.y" + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 151: -#line 867 "ncgen.y" /* yacc.c:1646 */ - {(yyval.sym)=(yyvsp[0].sym);} -#line 2645 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 867 "ncgen.y" + {(yyval.sym)=(yyvsp[(1) - (1)].sym);} break; -#line 2649 "ncgeny.c" /* yacc.c:1646 */ +/* Line 1792 of yacc.c */ +#line 2835 "ncgeny.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2667,7 +2853,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); *++yyvsp = yyval; - /* Now 'shift' the result of the reduction. Determine what state + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -2682,9 +2868,9 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); goto yynewstate; -/*--------------------------------------. -| yyerrlab -- here on detecting error. | -`--------------------------------------*/ +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ @@ -2735,20 +2921,20 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -2767,7 +2953,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -2780,29 +2966,29 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp); + yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -2853,14 +3039,14 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); } - /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -2871,9 +3057,13 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - return yyresult; + /* Make sure YYID is used. */ + return YYID (yyresult); } -#line 870 "ncgen.y" /* yacc.c:1906 */ + + +/* Line 2055 of yacc.c */ +#line 870 "ncgen.y" #ifndef NO_STDARG @@ -2956,7 +3146,6 @@ install(const char *sname) { Symbol* sp; sp = (Symbol*) ecalloc (sizeof (struct Symbol)); - memset((void*)sp,0,sizeof(struct Symbol)); sp->name = nulldup(sname); sp->next = symlist; sp->lineno = lineno; @@ -3055,7 +3244,7 @@ makeconstdata(nc_type nctype) break; /* no associated value*/ #endif - case NC_FILLVALUE: + case NC_FILLVALUE: break; /* no associated value*/ default: @@ -3389,7 +3578,8 @@ containsfills(Datalist* list) for(i=0;ilength;i++,con++) { if(con->nctype == NC_COMPOUND) { if(containsfills(con->value.compoundv)) return 1; - } else if(con->nctype == NC_FILLVALUE) return 1; + } else if(con->nctype == NC_FILLVALUE) + return 1; } } return 0; diff --git a/ncgen/ncgeny.h b/ncgen/ncgeny.h index 4d09af5695..fd7bf1eba9 100644 --- a/ncgen/ncgeny.h +++ b/ncgen/ncgeny.h @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. + 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 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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 . */ @@ -26,13 +26,13 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ #ifndef YY_NCG_NCGEN_TAB_H_INCLUDED # define YY_NCG_NCGEN_TAB_H_INCLUDED -/* Debug traces. */ +/* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif @@ -40,71 +40,72 @@ extern int ncgdebug; #endif -/* Token type. */ +/* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - 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 - }; + /* 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 + }; #endif -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -union YYSTYPE +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE { -#line 138 "ncgen.y" /* yacc.c:1909 */ +/* Line 2058 of yacc.c */ +#line 138 "ncgen.y" Symbol* sym; unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/ @@ -113,17 +114,29 @@ int nctype; /* for tracking attribute list type*/ Datalist* datalist; NCConstant constant; -#line 117 "ncgeny.h" /* yacc.c:1909 */ -}; -typedef union YYSTYPE YYSTYPE; +/* Line 2058 of yacc.c */ +#line 120 "ncgeny.h" +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif - extern YYSTYPE ncglval; +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int ncgparse (void *YYPARSE_PARAM); +#else +int ncgparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus int ncgparse (void); +#else +int ncgparse (); +#endif +#endif /* ! YYPARSE_PARAM */ #endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */ diff --git a/ncgen/util.c b/ncgen/util.c index 7ea714f23b..89571d8bf3 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -632,7 +632,7 @@ void check_err2(const int stat, const int cdlline, const int line, const char* f H5Eprint1(stderr); #endif fflush(stderr); - exit(1); + finalize_netcdf(1); } } From 1b1c441b6d0860f5edd94c9993be0aa20231bb3c Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 1 Nov 2017 16:55:13 -0600 Subject: [PATCH 06/36] Updated release notes --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 0497fcff57..917869bbe8 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -8,6 +8,7 @@ This file contains a high-level description of this package's evolution. Release ## 4.5.1 - TBD +* Corrected a number of memory issues identified in `ncgen`. See [GitHub #558 for more information](https://github.com/Unidata/netcdf-c/pull/558). * Corrected a memory overflow in `tst_h_dimscales`, see [Github #511](https://github.com/Unidata/netcdf-c/issues/511), [Github #505](https://github.com/Unidata/netcdf-c/issues/505), [Github #363](https://github.com/Unidata/netcdf-c/issues/363) and [Github #244](https://github.com/Unidata/netcdf-c/issues/244) for more information. ## 4.5.0 - October 20, 2017 From 3074cc782414cc1e0c6bed6e8ba550628dbd2c82 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Wed, 8 Nov 2017 19:02:13 -0700 Subject: [PATCH 07/36] re: esupport AVS-567793 Some parameters like stringlength actually affect a dimension named maxStrlen. So, add some aliasing so maxstrlen can be specified as a parameter and as an alias for stringlength. The affected parameters (case insensitive): stringlength has alias maxstrlen stringlength_ has alias maxstrlen_ Also: 1. added a test case in ncdap_test/testurl.sh 2. added note to documentation --- docs/OPeNDAP.dox | 28 +++++++++++++++------------- libdap2/ncd2dispatch.c | 17 +++++++++++++---- libdispatch/ncuri.c | 6 ++++-- ncdap_test/testurl.sh | 19 ++++++++++++++++--- 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/docs/OPeNDAP.dox b/docs/OPeNDAP.dox index 59f383953c..7b17a09409 100644 --- a/docs/OPeNDAP.dox +++ b/docs/OPeNDAP.dox @@ -1,4 +1,5 @@ -/*! \page dap2 DAP2 Support +/*! +\page dap2 DAP2 Support \tableofcontents @@ -35,7 +36,7 @@ See the following pages for more information. - \subpage var_dim_trans - \subpage var_name_trans -\page dap_accessing_data Accessing OPeNDAP Data +\section dap_accessing_data Accessing OPeNDAP Data In order to access an OPeNDAP data source through the netCDF API, the file name normally used is replaced with a URL with a specific @@ -177,13 +178,13 @@ variables: } \endcode -\page dap_to_netcdf DAP to NetCDF Translation Rules +\section dap_to_netcdf DAP to NetCDF Translation Rules Currently only one translation available: DAP 2 Protocol to netCDF-3. There used to be a DAP 2 Protocol to netCDF-4 translation but that has been removed until the DAP4 protocol is available. -\section nc3_trans_rules netCDF-3 Translation Rules +\subsection nc3_trans_rules netCDF-3 Translation Rules The current default translation code translates the OPeNDAP protocol to netCDF-3 (classic). This netCDF-3 translation converts an OPeNDAP @@ -225,7 +226,7 @@ Dataset { } D1; \endcode -\section var_def Variable Definition +\subsection var_def Variable Definition The set of netCDF variables is derived from the fields with primitive base types as they occur in Sequences, Grids, and Structures. The @@ -244,7 +245,7 @@ within grids are left out in order to mimic the behavior of libnc-dap. lon \endcode -\page dap2_reserved_keywords DAP2 Reserved Keywords +\section dap2_reserved_keywords DAP2 Reserved Keywords In the OPeNDAP DAP2 protocol, there are a number of reserved keywords. These keywords are case insensitive and if you use one as a netCDF variable name, you may encounter odd behavior such as case changes (depending on the client DDS/DAS parser). The list of reserved keywords as used by the netCDF-C library parser are as follows: @@ -272,7 +273,7 @@ In the OPeNDAP DAP2 protocol, there are a number of reserved keywords. These ke - program -\page var_dim_trans Variable Dimension Translation +\section var_dim_trans Variable Dimension Translation A variable's rank is determined from three sources. - The variable has the dimensions associated with the field it @@ -287,7 +288,7 @@ containers is a DAP DDS Sequence. This is discussed more fully below. If the type of the netCDF variable is char, then an extra string dimension is added as the last dimension. -\section dim_trans Dimension translation +\subsection dim_trans Dimension translation For dimensions, the rules are as follows. @@ -366,7 +367,7 @@ dimensions: S1.FS2.f2_0 = 2 ; \endcode -\page var_name_trans Variable Name Translation +\section var_name_trans Variable Name Translation The steps for variable name translation are as follows. @@ -435,7 +436,7 @@ int S1.FS2.f1(lat, lat) ; Note that this is incorrect because it dimensions S1.FS2.f1(2,2) rather than S1.FS2.f1(2,3). -\section dap_translation Translating DAP DDS Sequences +\subsection dap_translation Translating DAP DDS Sequences Any variable (as determined above) that is contained directly or indirectly by a Sequence is subject to revision of its rank using the @@ -552,7 +553,7 @@ performance. Currently, a limited set of client parameters is recognized. Parameters not listed here are ignored, but no error is -signalled. +signalled. All names are case insensitive. Parameter Name Legal Values Semantics - "log" | "log=" - Turn on logging and send the log output to @@ -568,10 +569,11 @@ Parameter Name Legal Values Semantics enabled, then this can be helpful in checking to see the access behavior of the netCDF code. - "stringlength=NN" - Specify the default string length to use for - string dimensions. The default is 64. + string dimensions. The default is 64. The name "maxstrlen" is an + alias for "stringlength". - "stringlength_=NN" - Specify the default string length to use for a string dimension for the specified variable. The default is - 64. + 64. The name "maxstrlen_" is an alias for "stringlength_". - "cache" - This enables caching. - "cachelimit=NN" - Specify the maximum amount of space allowed for the cache. diff --git a/libdap2/ncd2dispatch.c b/libdap2/ncd2dispatch.c index e97c31239f..ac623f7201 100644 --- a/libdap2/ncd2dispatch.c +++ b/libdap2/ncd2dispatch.c @@ -1192,6 +1192,7 @@ constrainable(NCURI* durl) return 0; } +/* Lookup a parameter key; case insensitive */ static const char* paramlookup(NCDAPCOMMON* state, const char* key) { @@ -1260,21 +1261,29 @@ applyclientparams(NCDAPCOMMON* nccomm) /* allow embedded _ */ value = paramlookup(nccomm,"stringlength"); + if(value == NULL) + value = paramlookup(nccomm,"maxstrlen"); if(value != NULL && strlen(value) != 0) { if(sscanf(value,"%d",&len) && len > 0) dfaltstrlen = len; - } + } nccomm->cdf.defaultstringlength = dfaltstrlen; /* String dimension limits apply to variables */ for(i=0;icdf.ddsroot->tree->varnodes);i++) { CDFnode* var = (CDFnode*)nclistget(nccomm->cdf.ddsroot->tree->varnodes,i); - /* Define the client param stringlength for this variable*/ + /* Define the client param stringlength/maxstrlen for this variable*/ + /* create the variable path name */ + pathstr = makeocpathstring(conn,var->ocnode,"."); var->maxstringlength = 0; /* => use global dfalt */ strcpy(tmpname,"stringlength_"); - pathstr = makeocpathstring(conn,var->ocnode,"."); strncat(tmpname,pathstr,NC_MAX_NAME); - nullfree(pathstr); value = paramlookup(nccomm,tmpname); + if(value == NULL) { + strcpy(tmpname,"maxstrlen_"); + strncat(tmpname,pathstr,NC_MAX_NAME); + value = paramlookup(nccomm,tmpname); + } + nullfree(pathstr); if(value != NULL && strlen(value) != 0) { if(sscanf(value,"%d",&len) && len > 0) var->maxstringlength = len; } diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c index fe80097e7a..f802e7da8d 100644 --- a/libdispatch/ncuri.c +++ b/libdispatch/ncuri.c @@ -659,14 +659,16 @@ ncuriremoveparam(NCURI* uri, const char* key) #endif -/* Internal version of lookup; returns the paired index of the key */ +/* Internal version of lookup; returns the paired index of the key; + case insensitive + */ static int ncfind(char** params, const char* key) { int i; char** p; for(i=0,p=params;*p;p+=2,i++) { - if(strcmp(key,*p)==0) return i; + if(strcasecmp(key,*p)==0) return i; } return -1; } diff --git a/ncdap_test/testurl.sh b/ncdap_test/testurl.sh index 4f10caf6de..a99fa96082 100755 --- a/ncdap_test/testurl.sh +++ b/ncdap_test/testurl.sh @@ -1,6 +1,6 @@ #!/bin/sh -#NOP=1 +#NOP=1 #NOS=1 #NOB=1 @@ -30,6 +30,7 @@ PREFIX="[log][show=fetch]" SUFFIX="log&show=fetch" BOTHP="[log][show=fetch]" BOTHS="noprefetch&fetch=disk" +STRLEN="[maxstrlen=16]" locreset () { rm -f ./tmp ./errtmp @@ -60,6 +61,20 @@ buildurl $PREFIX "" echo "command: ${NCDUMP} -h $url" ${NCDUMP} -h "$url" >./tmp 2> ./errtmp if test "x${SHOW}" = x1 ; then cat ./tmp ; fi + +# Test that maxstrlen works as alias for stringlength +echo "***Testing maxstrlen=stringlength alias" +buildurl $STRLEN "" +# Invoke ncdump to extract the URL +echo "command: ${NCDUMP} -h $url" +${NCDUMP} "$url" >./tmp 2> ./errtmp +if test "x${SHOW}" = x1 ; then cat ./tmp ; fi +# Look for the value of maxStrlen in output cdl +if ! fgrep -i "maxstrlen = 16" ./tmp ; then +echo "***Fail: maxStrlen not recognized" +fgrep -i "maxstrlen16 = 16" ./tmp > ./errtmp +fi + fi locreset @@ -90,5 +105,3 @@ if test "x$pass" = x0 ; then fi echo "***PASS" exit 0 - - From fa67d1ea70cb3a769df098d22217b499e3a32334 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Thu, 30 Nov 2017 14:36:58 -0700 Subject: [PATCH 08/36] re: github issue https://github.com/Unidata/netcdf-c/issues/697 From that issue, fix the identified errors in the following files: libdap4/d4file.c libdap4/d4read.c ncgen/genc.c ncgen/ncgen.l ncgen/ncgen.y --- CMakeLists.txt | 2 - libdap4/d4file.c | 6 +- libdap4/d4read.c | 1 - ncgen/genc.c | 6 +- ncgen/ncgen.l | 5 +- ncgen/ncgen.y | 1 - ncgen/ncgenl.c | 165 ++- ncgen/ncgeny.c | 2488 ++++++++++++++++++++++------------------------ ncgen/ncgeny.h | 222 ++--- 9 files changed, 1385 insertions(+), 1511 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e39490fca..56cb46fbad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,8 +268,6 @@ SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR}/libsrc) # End Compiler Configuration ################################ - - ## # Configuration for post-install RPath # Adapted from http://www.cmake.org/Wiki/CMake_RPATH_handling diff --git a/libdap4/d4file.c b/libdap4/d4file.c index f8089937c1..a16053f55c 100644 --- a/libdap4/d4file.c +++ b/libdap4/d4file.c @@ -90,6 +90,9 @@ NCD4_open(const char * path, int mode, { char tmpname[NC_MAX_NAME]; + /* Guarantee tmpname is a legitimate string */ + tmpname[0] = '\0'; + /* Create fake file name: exact name must be unique, but is otherwise irrelevant because we are using NC_DISKLESS */ @@ -122,7 +125,7 @@ NCD4_open(const char * path, int mode, nc_set_default_format(old,&new); /* restore */ d4info->substrate.realfile = ((ncflags & NC_DISKLESS) == 0); d4info->substrate.filename = strdup(tmpname); - if(tmpname == NULL) ret = NC_ENOMEM; + if(d4info->substrate.filename == NULL) ret = NC_ENOMEM; d4info->substrate.nc4id = ncid; } if(ret != NC_NOERR) goto done; @@ -369,7 +372,6 @@ set_curl_properties(NCD4INFO* d4info) if(d4info->auth.curlflags.cookiejar == NULL) { /* If no cookie file was defined, define a default */ - int ok; char* path = NULL; char* newpath = NULL; int len; diff --git a/libdap4/d4read.c b/libdap4/d4read.c index dae6ff7c2d..b3d87b5a10 100644 --- a/libdap4/d4read.c +++ b/libdap4/d4read.c @@ -150,7 +150,6 @@ static int readfile(const NCURI* uri, const char* suffix, NCbytes* packet) { int stat = NC_NOERR; - char buf[1024]; NCbytes* tmp = ncbytesnew(); char* filename = NULL; diff --git a/ncgen/genc.c b/ncgen/genc.c index 58eaf4e81d..cbec6c9562 100644 --- a/ncgen/genc.c +++ b/ncgen/genc.c @@ -512,11 +512,11 @@ genc_definespecialattributes(Symbol* vsym) if(special->flags & _FILTER_FLAG) { /* Special check for alternate way to specify _Deflate */ if(special->_FilterID == ZIP_ID) { - unsigned int level; + int level; if(special->nparams == 0 || special->_FilterParams == NULL) level = 9; /* default */ else - level = special->_FilterParams[0]; + level = (int)special->_FilterParams[0]; if(level < 0 || level > 9) derror("Illegal deflate level"); else { @@ -525,7 +525,7 @@ genc_definespecialattributes(Symbol* vsym) groupncid(vsym->container), varncid(vsym), (special->_Shuffle == 1?"NC_SHUFFLE":"NC_NOSHUFFLE"), - (level >= 0?1:0), + 1, level); codedump(stmt); } diff --git a/ncgen/ncgen.l b/ncgen/ncgen.l index 4b854af380..b0df3dbac4 100644 --- a/ncgen/ncgen.l +++ b/ncgen/ncgen.l @@ -88,6 +88,8 @@ static unsigned int MAX_UINT = NC_MAX_UINT; no tag was specified */ #define NC_NOTAG (-1) +extern int errno; + char errstr[100]; /* for short error messages */ int lineno; /* line number for error messages */ @@ -385,7 +387,6 @@ NIL|nil|Nil { int slen = strlen(ncgtext); char* stag = NULL; int tag = NC_NAT; - int signchar = 0; int isneg = 0; int c = ncgtext[0]; int fail = 0; @@ -659,8 +660,6 @@ Return the value. static unsigned long long parseULL(char* text, int* failp) { - int result = 0; - extern int errno; char* endptr; unsigned long long uint64 = 0; diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y index 5d4fc51c3e..c0ae0f9190 100644 --- a/ncgen/ncgen.y +++ b/ncgen/ncgen.y @@ -1160,7 +1160,6 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst) int tf = 0; char* sdata = NULL; int idata = -1; - unsigned int udata = 0; if((GLOBAL_SPECIAL & tag) != 0) { if(vsym != NULL) { diff --git a/ncgen/ncgenl.c b/ncgen/ncgenl.c index 6c5da63d13..0200d5ae8e 100644 --- a/ncgen/ncgenl.c +++ b/ncgen/ncgenl.c @@ -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; @@ -1239,6 +1238,8 @@ static unsigned int MAX_UINT = NC_MAX_UINT; no tag was specified */ #define NC_NOTAG (-1) +extern int errno; + char errstr[100]; /* for short error messages */ int lineno; /* line number for error messages */ @@ -1330,7 +1331,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 1334 "lex.ncg.c" +#line 1335 "ncgenl.c" #define INITIAL 0 #define ST_C_COMMENT 1 @@ -1371,7 +1372,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 ); @@ -1432,7 +1433,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; \ @@ -1514,9 +1515,9 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 218 "ncgen.l" +#line 220 "ncgen.l" -#line 1520 "lex.ncg.c" +#line 1521 "ncgenl.c" if ( !(yy_init) ) { @@ -1601,14 +1602,14 @@ YY_DECL case 1: YY_RULE_SETUP -#line 219 "ncgen.l" +#line 221 "ncgen.l" { /* whitespace */ break; } YY_BREAK case 2: YY_RULE_SETUP -#line 223 "ncgen.l" +#line 225 "ncgen.l" { /* comment */ break; } @@ -1616,7 +1617,7 @@ YY_RULE_SETUP case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 227 "ncgen.l" +#line 229 "ncgen.l" {int len; /* In netcdf4, this will be used in a variety of places, so only remove escapes */ @@ -1643,7 +1644,7 @@ ncgtext[MAXTRST-1] = '\0'; YY_BREAK case 4: YY_RULE_SETUP -#line 251 "ncgen.l" +#line 253 "ncgen.l" { /* drop leading 0x; pad to even number of chars */ char* p = ncgtext+2; int len = ncgleng - 2; @@ -1658,118 +1659,118 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 263 "ncgen.l" +#line 265 "ncgen.l" {return lexdebug(COMPOUND);} YY_BREAK case 6: YY_RULE_SETUP -#line 264 "ncgen.l" +#line 266 "ncgen.l" {return lexdebug(ENUM);} YY_BREAK case 7: YY_RULE_SETUP -#line 265 "ncgen.l" +#line 267 "ncgen.l" {return lexdebug(OPAQUE_);} YY_BREAK case 8: YY_RULE_SETUP -#line 267 "ncgen.l" +#line 269 "ncgen.l" {return lexdebug(FLOAT_K);} YY_BREAK case 9: YY_RULE_SETUP -#line 268 "ncgen.l" +#line 270 "ncgen.l" {return lexdebug(CHAR_K);} YY_BREAK case 10: YY_RULE_SETUP -#line 269 "ncgen.l" +#line 271 "ncgen.l" {return lexdebug(BYTE_K);} YY_BREAK case 11: YY_RULE_SETUP -#line 270 "ncgen.l" +#line 272 "ncgen.l" {return lexdebug(UBYTE_K);} YY_BREAK case 12: YY_RULE_SETUP -#line 271 "ncgen.l" +#line 273 "ncgen.l" {return lexdebug(SHORT_K);} YY_BREAK case 13: YY_RULE_SETUP -#line 272 "ncgen.l" +#line 274 "ncgen.l" {return lexdebug(USHORT_K);} YY_BREAK case 14: YY_RULE_SETUP -#line 273 "ncgen.l" +#line 275 "ncgen.l" {return lexdebug(INT_K);} YY_BREAK case 15: YY_RULE_SETUP -#line 274 "ncgen.l" +#line 276 "ncgen.l" {return lexdebug(UINT_K);} YY_BREAK case 16: YY_RULE_SETUP -#line 275 "ncgen.l" +#line 277 "ncgen.l" {return lexdebug(INT64_K);} YY_BREAK case 17: YY_RULE_SETUP -#line 276 "ncgen.l" +#line 278 "ncgen.l" {return lexdebug(UINT64_K);} YY_BREAK case 18: YY_RULE_SETUP -#line 277 "ncgen.l" +#line 279 "ncgen.l" {return lexdebug(DOUBLE_K);} YY_BREAK case 19: YY_RULE_SETUP -#line 278 "ncgen.l" +#line 280 "ncgen.l" {return lexdebug(STRING_K);} YY_BREAK case 20: YY_RULE_SETUP -#line 280 "ncgen.l" +#line 282 "ncgen.l" {int32_val = -1; return lexdebug(NC_UNLIMITED_K);} YY_BREAK case 21: YY_RULE_SETUP -#line 283 "ncgen.l" +#line 285 "ncgen.l" {return lexdebug(TYPES);} YY_BREAK case 22: YY_RULE_SETUP -#line 284 "ncgen.l" +#line 286 "ncgen.l" {return lexdebug(DIMENSIONS);} YY_BREAK case 23: YY_RULE_SETUP -#line 285 "ncgen.l" +#line 287 "ncgen.l" {return lexdebug(VARIABLES);} YY_BREAK case 24: YY_RULE_SETUP -#line 286 "ncgen.l" +#line 288 "ncgen.l" {return lexdebug(DATA);} YY_BREAK case 25: YY_RULE_SETUP -#line 287 "ncgen.l" +#line 289 "ncgen.l" {return lexdebug(GROUP);} YY_BREAK case 26: YY_RULE_SETUP -#line 289 "ncgen.l" +#line 291 "ncgen.l" {BEGIN(TEXT);return lexdebug(NETCDF);} YY_BREAK case 27: YY_RULE_SETUP -#line 291 "ncgen.l" +#line 293 "ncgen.l" { /* missing value (pre-2.4 backward compatibility) */ if (ncgtext[0] == '-') { double_val = NEGNC_INFINITE; @@ -1782,7 +1783,7 @@ YY_RULE_SETUP YY_BREAK case 28: YY_RULE_SETUP -#line 300 "ncgen.l" +#line 302 "ncgen.l" { /* missing value (pre-2.4 backward compatibility) */ double_val = NAN; specialconstants = 1; @@ -1791,7 +1792,7 @@ YY_RULE_SETUP YY_BREAK case 29: YY_RULE_SETUP -#line 306 "ncgen.l" +#line 308 "ncgen.l" {/* missing value (pre-2.4 backward compatibility)*/ if (ncgtext[0] == '-') { float_val = NEGNC_INFINITEF; @@ -1804,7 +1805,7 @@ YY_RULE_SETUP YY_BREAK case 30: YY_RULE_SETUP -#line 315 "ncgen.l" +#line 317 "ncgen.l" { /* missing value (pre-2.4 backward compatibility) */ float_val = NANF; specialconstants = 1; @@ -1813,7 +1814,7 @@ YY_RULE_SETUP YY_BREAK case 31: YY_RULE_SETUP -#line 321 "ncgen.l" +#line 323 "ncgen.l" { #ifdef USE_NETCDF4 if(l_flag == L_C || l_flag == L_BINARY) @@ -1826,7 +1827,7 @@ YY_RULE_SETUP YY_BREAK case 32: YY_RULE_SETUP -#line 331 "ncgen.l" +#line 333 "ncgen.l" { bbClear(lextext); bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */ @@ -1837,7 +1838,7 @@ YY_RULE_SETUP YY_BREAK case 33: YY_RULE_SETUP -#line 340 "ncgen.l" +#line 342 "ncgen.l" {struct Specialtoken* st; bbClear(lextext); bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */ @@ -1851,7 +1852,7 @@ YY_RULE_SETUP case 34: /* rule 34 can match eol */ YY_RULE_SETUP -#line 350 "ncgen.l" +#line 352 "ncgen.l" { int c; char* p; char* q; @@ -1871,7 +1872,7 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 367 "ncgen.l" +#line 369 "ncgen.l" { char* id; int len; bbClear(lextext); bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */ @@ -1886,7 +1887,7 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 379 "ncgen.l" +#line 381 "ncgen.l" { /* We need to try to see what size of integer ((u)int). @@ -1896,7 +1897,6 @@ YY_RULE_SETUP int slen = strlen(ncgtext); char* stag = NULL; int tag = NC_NAT; - int signchar = 0; int isneg = 0; int c = ncgtext[0]; int fail = 0; @@ -1955,7 +1955,7 @@ done: return 0; YY_BREAK case 37: YY_RULE_SETUP -#line 445 "ncgen.l" +#line 446 "ncgen.l" { int c; int token = 0; @@ -2006,7 +2006,7 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 492 "ncgen.l" +#line 493 "ncgen.l" { if (sscanf((char*)ncgtext, "%le", &double_val) != 1) { sprintf(errstr,"bad long or double constant: %s",(char*)ncgtext); @@ -2017,7 +2017,7 @@ YY_RULE_SETUP YY_BREAK case 39: YY_RULE_SETUP -#line 499 "ncgen.l" +#line 500 "ncgen.l" { if (sscanf((char*)ncgtext, "%e", &float_val) != 1) { sprintf(errstr,"bad float constant: %s",(char*)ncgtext); @@ -2029,7 +2029,7 @@ YY_RULE_SETUP case 40: /* rule 40 can match eol */ YY_RULE_SETUP -#line 506 "ncgen.l" +#line 507 "ncgen.l" { (void) sscanf((char*)&ncgtext[1],"%c",&byte_val); return lexdebug(BYTE_CONST); @@ -2037,7 +2037,7 @@ YY_RULE_SETUP YY_BREAK case 41: YY_RULE_SETUP -#line 510 "ncgen.l" +#line 511 "ncgen.l" { int oct = unescapeoct(&ncgtext[2]); if(oct < 0) { @@ -2050,7 +2050,7 @@ YY_RULE_SETUP YY_BREAK case 42: YY_RULE_SETUP -#line 519 "ncgen.l" +#line 520 "ncgen.l" { int hex = unescapehex(&ncgtext[3]); if(byte_val < 0) { @@ -2063,7 +2063,7 @@ YY_RULE_SETUP YY_BREAK case 43: YY_RULE_SETUP -#line 528 "ncgen.l" +#line 529 "ncgen.l" { switch ((char)ncgtext[2]) { case 'a': byte_val = '\007'; break; /* not everyone under- @@ -2085,7 +2085,7 @@ YY_RULE_SETUP case 44: /* rule 44 can match eol */ YY_RULE_SETUP -#line 546 "ncgen.l" +#line 547 "ncgen.l" { lineno++ ; break; @@ -2093,7 +2093,7 @@ YY_RULE_SETUP YY_BREAK case 45: YY_RULE_SETUP -#line 551 "ncgen.l" +#line 552 "ncgen.l" {/*initial*/ BEGIN(ST_C_COMMENT); break; @@ -2102,21 +2102,21 @@ YY_RULE_SETUP case 46: /* rule 46 can match eol */ YY_RULE_SETUP -#line 556 "ncgen.l" +#line 557 "ncgen.l" {/* continuation */ break; } YY_BREAK case 47: YY_RULE_SETUP -#line 560 "ncgen.l" +#line 561 "ncgen.l" {/* final */ BEGIN(INITIAL); break; } YY_BREAK case YY_STATE_EOF(ST_C_COMMENT): -#line 565 "ncgen.l" +#line 566 "ncgen.l" {/* final, error */ fprintf(stderr,"unterminated /**/ comment"); BEGIN(INITIAL); @@ -2125,17 +2125,17 @@ case YY_STATE_EOF(ST_C_COMMENT): YY_BREAK case 48: YY_RULE_SETUP -#line 571 "ncgen.l" +#line 572 "ncgen.l" {/* Note: this next rule will not work for UTF8 characters */ return lexdebug(ncgtext[0]) ; } YY_BREAK case 49: YY_RULE_SETUP -#line 574 "ncgen.l" +#line 575 "ncgen.l" ECHO; YY_BREAK -#line 2139 "lex.ncg.c" +#line 2139 "ncgenl.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(TEXT): yyterminate(); @@ -2322,7 +2322,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 ) @@ -2336,7 +2336,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; @@ -2367,7 +2367,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); } @@ -2477,7 +2477,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 = @@ -2526,7 +2526,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( ) ) @@ -2550,7 +2550,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; @@ -2802,7 +2802,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)) { @@ -2899,11 +2899,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; @@ -2985,7 +2986,7 @@ FILE *ncgget_out (void) /** Get the length of the current token. * */ -yy_size_t ncgget_leng (void) +int ncgget_leng (void) { return ncgleng; } @@ -3133,7 +3134,7 @@ void ncgfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 574 "ncgen.l" +#line 575 "ncgen.l" static int @@ -3223,8 +3224,6 @@ Return the value. static unsigned long long parseULL(char* text, int* failp) { - int result = 0; - extern int errno; char* endptr; unsigned long long uint64 = 0; diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c index bc856f89d3..d39ae3ddd3 100644 --- a/ncgen/ncgeny.c +++ b/ncgen/ncgeny.c @@ -1,14 +1,13 @@ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* Bison implementation 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 . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -47,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,140 +52,25 @@ /* Pure parsers. */ #define YYPURE 0 -/* Using locations. */ -#define YYLSP_NEEDED 0 +/* Push parsers. */ +#define YYPUSH 0 -/* Substitute the variable and function names. */ -#define yyparse ncgparse -#define yylex ncglex -#define yyerror ncgerror -#define yylval ncglval -#define yychar ncgchar -#define yydebug ncgdebug -#define yynerrs ncgnerrs - - -/* Tokens. */ -#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, - STRING_K = 270, - IDENT = 271, - TERMSTRING = 272, - CHAR_CONST = 273, - BYTE_CONST = 274, - SHORT_CONST = 275, - INT_CONST = 276, - INT64_CONST = 277, - UBYTE_CONST = 278, - USHORT_CONST = 279, - UINT_CONST = 280, - UINT64_CONST = 281, - FLOAT_CONST = 282, - DOUBLE_CONST = 283, - DIMENSIONS = 284, - VARIABLES = 285, - NETCDF = 286, - DATA = 287, - TYPES = 288, - COMPOUND = 289, - ENUM = 290, - OPAQUE_ = 291, - OPAQUESTRING = 292, - GROUP = 293, - PATH = 294, - FILLMARKER = 295, - NIL = 296, - _FILLVALUE = 297, - _FORMAT = 298, - _STORAGE = 299, - _CHUNKSIZES = 300, - _DEFLATELEVEL = 301, - _SHUFFLE = 302, - _ENDIANNESS = 303, - _NOFILL = 304, - _FLETCHER32 = 305, - _NCPROPS = 306, - _ISNETCDF4 = 307, - _SUPERBLOCK = 308, - _FILTER = 309, - DATASETID = 310 - }; -#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 STRING_K 270 -#define IDENT 271 -#define TERMSTRING 272 -#define CHAR_CONST 273 -#define BYTE_CONST 274 -#define SHORT_CONST 275 -#define INT_CONST 276 -#define INT64_CONST 277 -#define UBYTE_CONST 278 -#define USHORT_CONST 279 -#define UINT_CONST 280 -#define UINT64_CONST 281 -#define FLOAT_CONST 282 -#define DOUBLE_CONST 283 -#define DIMENSIONS 284 -#define VARIABLES 285 -#define NETCDF 286 -#define DATA 287 -#define TYPES 288 -#define COMPOUND 289 -#define ENUM 290 -#define OPAQUE_ 291 -#define OPAQUESTRING 292 -#define GROUP 293 -#define PATH 294 -#define FILLMARKER 295 -#define NIL 296 -#define _FILLVALUE 297 -#define _FORMAT 298 -#define _STORAGE 299 -#define _CHUNKSIZES 300 -#define _DEFLATELEVEL 301 -#define _SHUFFLE 302 -#define _ENDIANNESS 303 -#define _NOFILL 304 -#define _FLETCHER32 305 -#define _NCPROPS 306 -#define _ISNETCDF4 307 -#define _SUPERBLOCK 308 -#define _FILTER 309 -#define DATASETID 310 +/* Pull parsers. */ +#define YYPULL 1 +/* Substitute the variable and function names. */ +#define yyparse ncgparse +#define yylex ncglex +#define yyerror ncgerror +#define yydebug ncgdebug +#define yynerrs ncgnerrs +#define yylval ncglval +#define yychar ncgchar /* Copy the first part of user declarations. */ -#line 11 "ncgen.y" +#line 11 "ncgen.y" /* yacc.c:339 */ /* static char SccsId[] = "$Id: ncgen.y,v 1.42 2010/05/18 21:32:46 dmh Exp $"; @@ -317,11 +199,15 @@ static void yyerror(fmt,va_alist) const char* fmt; va_dcl; extern int lex_init(void); +#line 203 "ncgeny.c" /* yacc.c:339 */ -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE @@ -331,37 +217,111 @@ extern int lex_init(void); # define YYERROR_VERBOSE 1 #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +/* In a future release of Bison, this section will be replaced + by #include "ncgeny.h". */ +#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 + 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, + STRING_K = 270, + IDENT = 271, + TERMSTRING = 272, + CHAR_CONST = 273, + BYTE_CONST = 274, + SHORT_CONST = 275, + INT_CONST = 276, + INT64_CONST = 277, + UBYTE_CONST = 278, + USHORT_CONST = 279, + UINT_CONST = 280, + UINT64_CONST = 281, + FLOAT_CONST = 282, + DOUBLE_CONST = 283, + DIMENSIONS = 284, + VARIABLES = 285, + NETCDF = 286, + DATA = 287, + TYPES = 288, + COMPOUND = 289, + ENUM = 290, + OPAQUE_ = 291, + OPAQUESTRING = 292, + GROUP = 293, + PATH = 294, + FILLMARKER = 295, + NIL = 296, + _FILLVALUE = 297, + _FORMAT = 298, + _STORAGE = 299, + _CHUNKSIZES = 300, + _DEFLATELEVEL = 301, + _SHUFFLE = 302, + _ENDIANNESS = 303, + _NOFILL = 304, + _FLETCHER32 = 305, + _NCPROPS = 306, + _ISNETCDF4 = 307, + _SUPERBLOCK = 308, + _FILTER = 309, + DATASETID = 310 + }; +#endif + +/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 142 "ncgen.y" + +union YYSTYPE { +#line 142 "ncgen.y" /* yacc.c:355 */ + 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 193 of yacc.c. */ -#line 352 "ncgen.tab.c" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 + +#line 308 "ncgeny.c" /* yacc.c:355 */ +}; + +typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 #endif +extern YYSTYPE ncglval; -/* Copy the second part of user declarations. */ +int ncgparse (void); +#endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */ -/* Line 216 of yacc.c. */ -#line 365 "ncgen.tab.c" +/* Copy the second part of user declarations. */ + +#line 325 "ncgeny.c" /* yacc.c:358 */ #ifdef short # undef short @@ -375,11 +335,8 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; #else -typedef short int yytype_int8; +typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -399,8 +356,7 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -414,38 +370,67 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") #else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int i) -#else -static int -YYID (i) - int i; +# define YY_INITIAL_VALUE(Value) Value #endif -{ - return i; -} +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + #if ! defined yyoverflow || YYERROR_VERBOSE @@ -464,11 +449,11 @@ YYID (i) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # endif @@ -476,8 +461,8 @@ YYID (i) # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -491,25 +476,23 @@ YYID (i) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -519,14 +502,14 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -537,42 +520,46 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif +# define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) #endif +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + /* YYFINAL -- State number of the termination state. */ #define YYFINAL 5 /* YYLAST -- Last index in YYTABLE. */ @@ -584,17 +571,19 @@ union yyalloc #define YYNNTS 67 /* YYNRULES -- Number of rules. */ #define YYNRULES 153 -/* YYNRULES -- Number of states. */ +/* YYNSTATES -- Number of states. */ #define YYNSTATES 262 -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 310 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -632,80 +621,7 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 7, 9, 14, 20, 21, 24, 25, - 26, 36, 37, 39, 42, 44, 47, 49, 51, 54, - 57, 60, 63, 66, 67, 69, 76, 78, 82, 86, - 92, 98, 104, 107, 111, 114, 116, 118, 120, 122, - 124, 126, 128, 130, 132, 134, 136, 138, 139, 141, - 144, 147, 151, 153, 155, 157, 161, 165, 169, 171, - 172, 174, 177, 180, 184, 186, 188, 191, 193, 197, - 200, 201, 205, 207, 211, 213, 215, 219, 222, 223, - 227, 229, 233, 235, 237, 239, 241, 243, 245, 246, - 250, 255, 260, 265, 270, 277, 283, 289, 296, 302, - 308, 314, 320, 326, 332, 338, 344, 349, 351, 353, - 354, 356, 359, 362, 366, 370, 372, 374, 375, 377, - 381, 383, 387, 389, 391, 393, 395, 397, 399, 401, - 406, 408, 412, 414, 416, 418, 420, 422, 424, 426, - 428, 430, 432, 434, 436, 438, 442, 444, 446, 448, - 450, 452, 454, 456 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 66, 0, -1, 31, 67, 68, -1, 55, -1, 56, - 69, 70, 57, -1, 112, 74, 89, 95, 115, -1, - -1, 70, 71, -1, -1, -1, 38, 131, 56, 72, - 69, 70, 73, 57, 112, -1, -1, 33, -1, 33, - 75, -1, 77, -1, 75, 77, -1, 131, -1, 78, - -1, 113, 58, -1, 80, 79, -1, 85, 79, -1, - 84, 79, -1, 83, 79, -1, -1, 58, -1, 88, - 35, 76, 56, 81, 57, -1, 82, -1, 81, 59, - 82, -1, 131, 60, 128, -1, 36, 61, 21, 62, - 76, -1, 110, 61, 63, 62, 76, -1, 34, 76, - 56, 86, 57, -1, 87, 58, -1, 86, 87, 58, - -1, 110, 104, -1, 4, -1, 5, -1, 6, -1, - 7, -1, 8, -1, 9, -1, 10, -1, 11, -1, - 12, -1, 13, -1, 14, -1, 15, -1, -1, 29, - -1, 29, 90, -1, 91, 58, -1, 90, 91, 58, - -1, 92, -1, 113, -1, 93, -1, 92, 59, 93, - -1, 94, 60, 128, -1, 94, 60, 3, -1, 131, - -1, -1, 30, -1, 30, 96, -1, 97, 58, -1, - 96, 97, 58, -1, 98, -1, 113, -1, 110, 99, - -1, 100, -1, 99, 59, 100, -1, 131, 101, -1, - -1, 61, 102, 62, -1, 103, -1, 102, 59, 103, - -1, 114, -1, 105, -1, 104, 59, 105, -1, 131, - 106, -1, -1, 61, 107, 62, -1, 108, -1, 107, - 59, 108, -1, 25, -1, 21, -1, 111, -1, 111, - -1, 114, -1, 88, -1, -1, 113, 58, 112, -1, - 64, 51, 60, 129, -1, 64, 52, 60, 130, -1, - 64, 53, 60, 128, -1, 64, 131, 60, 118, -1, - 110, 111, 64, 131, 60, 118, -1, 111, 64, 131, - 60, 118, -1, 111, 64, 42, 60, 118, -1, 110, - 111, 64, 42, 60, 118, -1, 111, 64, 44, 60, - 129, -1, 111, 64, 45, 60, 127, -1, 111, 64, - 50, 60, 130, -1, 111, 64, 46, 60, 128, -1, - 111, 64, 47, 60, 130, -1, 111, 64, 48, 60, - 129, -1, 111, 64, 54, 60, 129, -1, 111, 64, - 49, 60, 130, -1, 64, 43, 60, 129, -1, 131, - -1, 39, -1, -1, 32, -1, 32, 116, -1, 117, - 58, -1, 116, 117, 58, -1, 109, 60, 118, -1, - 119, -1, 120, -1, -1, 121, -1, 118, 59, 121, - -1, 122, -1, 56, 118, 57, -1, 126, -1, 37, - -1, 40, -1, 41, -1, 123, -1, 124, -1, 114, - -1, 131, 61, 125, 62, -1, 126, -1, 125, 59, - 126, -1, 18, -1, 19, -1, 20, -1, 21, -1, - 22, -1, 23, -1, 24, -1, 25, -1, 26, -1, - 27, -1, 28, -1, 17, -1, 128, -1, 127, 59, - 128, -1, 21, -1, 25, -1, 22, -1, 26, -1, - 17, -1, 129, -1, 128, -1, 16, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 224, 224, 230, 232, 239, 246, 246, 249, 258, @@ -727,7 +643,7 @@ static const yytype_uint16 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if YYDEBUG || YYERROR_VERBOSE || 1 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -744,7 +660,7 @@ static const char *const yytname[] = "_FLETCHER32", "_NCPROPS", "_ISNETCDF4", "_SUPERBLOCK", "_FILTER", "DATASETID", "'{'", "'}'", "';'", "','", "'='", "'('", "')'", "'*'", "':'", "$accept", "ncdesc", "datasetid", "rootgroup", "groupbody", - "subgrouplist", "namedgroup", "@1", "@2", "typesection", "typedecls", + "subgrouplist", "namedgroup", "$@1", "$@2", "typesection", "typedecls", "typename", "type_or_attr_decl", "typedecl", "optsemicolon", "enumdecl", "enumidlist", "enumid", "opaquedecl", "vlendecl", "compounddecl", "fields", "field", "primtype", "dimsection", "dimdecls", @@ -755,13 +671,13 @@ static const char *const yytname[] = "attrdecllist", "attrdecl", "path", "datasection", "datadecls", "datadecl", "datalist", "datalist0", "datalist1", "dataitem", "constdata", "econstref", "function", "arglist", "simpleconstant", - "intlist", "constint", "conststring", "constbool", "ident", 0 + "intlist", "constint", "conststring", "constbool", "ident", YY_NULLPTR }; #endif # ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -774,97 +690,18 @@ static const yytype_uint16 yytoknum[] = }; # endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 65, 66, 67, 68, 69, 70, 70, 72, 73, - 71, 74, 74, 74, 75, 75, 76, 77, 77, 78, - 78, 78, 78, 79, 79, 80, 81, 81, 82, 83, - 84, 85, 86, 86, 87, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 89, 89, 89, - 90, 90, 91, 91, 92, 92, 93, 93, 94, 95, - 95, 95, 96, 96, 97, 97, 98, 99, 99, 100, - 101, 101, 102, 102, 103, 104, 104, 105, 106, 106, - 107, 107, 108, 108, 109, 110, 111, 111, 112, 112, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 114, 114, 115, - 115, 115, 116, 116, 117, 118, 118, 119, 120, 120, - 121, 121, 122, 122, 122, 122, 122, 122, 123, 124, - 125, 125, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 127, 127, 128, 128, 128, 128, - 129, 130, 130, 131 -}; +#define YYPACT_NINF -145 -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 3, 1, 4, 5, 0, 2, 0, 0, - 9, 0, 1, 2, 1, 2, 1, 1, 2, 2, - 2, 2, 2, 0, 1, 6, 1, 3, 3, 5, - 5, 5, 2, 3, 2, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, - 2, 3, 1, 1, 1, 3, 3, 3, 1, 0, - 1, 2, 2, 3, 1, 1, 2, 1, 3, 2, - 0, 3, 1, 3, 1, 1, 3, 2, 0, 3, - 1, 3, 1, 1, 1, 1, 1, 1, 0, 3, - 4, 4, 4, 4, 6, 5, 5, 6, 5, 5, - 5, 5, 5, 5, 5, 5, 4, 1, 1, 0, - 1, 2, 2, 3, 3, 1, 1, 0, 1, 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 -}; +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-145))) -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't 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, - 153, 108, 0, 6, 87, 0, 85, 11, 0, 86, - 107, 0, 0, 0, 0, 0, 0, 0, 0, 12, - 47, 88, 0, 0, 0, 0, 117, 0, 4, 7, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 13, 14, 17, 23, 23, 23, 23, - 87, 0, 0, 48, 59, 89, 150, 106, 90, 146, - 148, 147, 149, 152, 151, 91, 92, 143, 132, 133, - 134, 135, 136, 137, 138, 139, 140, 141, 142, 123, - 124, 125, 117, 128, 93, 115, 116, 118, 120, 126, - 127, 122, 107, 0, 0, 0, 117, 0, 0, 0, - 0, 0, 0, 0, 0, 117, 0, 16, 0, 15, - 24, 19, 22, 21, 20, 0, 0, 18, 49, 0, - 52, 54, 0, 53, 107, 60, 109, 0, 0, 0, - 8, 117, 117, 96, 98, 99, 144, 101, 102, 103, - 105, 100, 104, 95, 0, 0, 0, 0, 0, 50, - 0, 0, 61, 0, 64, 0, 65, 110, 5, 121, - 119, 0, 130, 88, 97, 94, 0, 0, 0, 0, - 85, 0, 0, 0, 51, 55, 58, 57, 56, 0, - 62, 66, 67, 70, 0, 84, 111, 0, 0, 129, - 6, 145, 31, 0, 32, 34, 75, 78, 29, 0, - 26, 0, 30, 63, 0, 0, 69, 117, 0, 112, - 131, 9, 33, 0, 0, 77, 25, 0, 0, 68, - 70, 0, 72, 74, 114, 113, 0, 76, 83, 82, - 0, 80, 27, 28, 0, 71, 88, 0, 79, 73, - 10, 81 -}; +#define YYTABLE_NINF -108 -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 2, 4, 7, 23, 36, 49, 183, 246, 40, - 63, 126, 64, 65, 131, 66, 219, 220, 67, 68, - 69, 187, 188, 24, 74, 138, 139, 140, 141, 142, - 146, 172, 173, 174, 201, 202, 226, 241, 242, 215, - 216, 235, 250, 251, 204, 25, 26, 27, 28, 29, - 178, 206, 207, 104, 105, 106, 107, 108, 109, 110, - 181, 111, 155, 83, 84, 85, 30 -}; +#define yytable_value_is_error(Yytable_value) \ + 0 -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -145 + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const yytype_int16 yypact[] = { -10, -19, 54, -145, 12, -145, 219, -145, -145, -145, @@ -896,7 +733,41 @@ static const yytype_int16 yypact[] = -145, -145 }; -/* YYPGOTO[NTERM-NUM]. */ + /* 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, + 153, 108, 0, 6, 87, 0, 85, 11, 0, 86, + 107, 0, 0, 0, 0, 0, 0, 0, 0, 12, + 47, 88, 0, 0, 0, 0, 117, 0, 4, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 13, 14, 17, 23, 23, 23, 23, + 87, 0, 0, 48, 59, 89, 150, 106, 90, 146, + 148, 147, 149, 152, 151, 91, 92, 143, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 123, + 124, 125, 117, 128, 93, 115, 116, 118, 120, 126, + 127, 122, 107, 0, 0, 0, 117, 0, 0, 0, + 0, 0, 0, 0, 0, 117, 0, 16, 0, 15, + 24, 19, 22, 21, 20, 0, 0, 18, 49, 0, + 52, 54, 0, 53, 107, 60, 109, 0, 0, 0, + 8, 117, 117, 96, 98, 99, 144, 101, 102, 103, + 105, 100, 104, 95, 0, 0, 0, 0, 0, 50, + 0, 0, 61, 0, 64, 0, 65, 110, 5, 121, + 119, 0, 130, 88, 97, 94, 0, 0, 0, 0, + 85, 0, 0, 0, 51, 55, 58, 57, 56, 0, + 62, 66, 67, 70, 0, 84, 111, 0, 0, 129, + 6, 145, 31, 0, 32, 34, 75, 78, 29, 0, + 26, 0, 30, 63, 0, 0, 69, 117, 0, 112, + 131, 9, 33, 0, 0, 77, 25, 0, 0, 68, + 70, 0, 72, 74, 114, 113, 0, 76, 83, 82, + 0, 80, 27, 28, 0, 71, 88, 0, 79, 73, + 10, 81 +}; + + /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -145, -145, -145, -145, 24, -2, -145, -145, -145, -145, @@ -908,11 +779,21 @@ static const yytype_int16 yypgoto[] = -145, -144, -145, -35, -31, -100, -22 }; -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -108 + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 2, 4, 7, 23, 36, 49, 183, 246, 40, + 63, 126, 64, 65, 131, 66, 219, 220, 67, 68, + 69, 187, 188, 24, 74, 138, 139, 140, 141, 142, + 146, 172, 173, 174, 201, 202, 226, 241, 242, 215, + 216, 235, 250, 251, 204, 25, 26, 27, 28, 29, + 178, 206, 207, 104, 105, 106, 107, 108, 109, 110, + 181, 111, 155, 83, 84, 85, 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. */ static const yytype_int16 yytable[] = { 35, 75, 103, 147, 37, 182, 72, 166, 20, 71, @@ -1001,8 +882,8 @@ static const yytype_int16 yycheck[] = -1, -1, -1, 39 }; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 31, 66, 55, 67, 0, 56, 68, 4, 5, @@ -1034,95 +915,83 @@ static const yytype_uint8 yystos[] = 112, 108 }; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 65, 66, 67, 68, 69, 70, 70, 72, 73, + 71, 74, 74, 74, 75, 75, 76, 77, 77, 78, + 78, 78, 78, 79, 79, 80, 81, 81, 82, 83, + 84, 85, 86, 86, 87, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 89, 89, 89, + 90, 90, 91, 91, 92, 92, 93, 93, 94, 95, + 95, 95, 96, 96, 97, 97, 98, 99, 99, 100, + 101, 101, 102, 102, 103, 104, 104, 105, 106, 106, + 107, 107, 108, 108, 109, 110, 111, 111, 112, 112, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 114, 114, 115, + 115, 115, 116, 116, 117, 118, 118, 119, 120, 120, + 121, 121, 122, 122, 122, 122, 122, 122, 123, 124, + 125, 125, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 127, 127, 128, 128, 128, 128, + 129, 130, 130, 131 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 3, 1, 4, 5, 0, 2, 0, 0, + 9, 0, 1, 2, 1, 2, 1, 1, 2, 2, + 2, 2, 2, 0, 1, 6, 1, 3, 3, 5, + 5, 5, 2, 3, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, + 2, 3, 1, 1, 1, 3, 3, 3, 1, 0, + 1, 2, 2, 3, 1, 1, 2, 1, 3, 2, + 0, 3, 1, 3, 1, 1, 3, 2, 0, 3, + 1, 3, 1, 1, 1, 1, 1, 1, 0, 3, + 4, 4, 4, 4, 6, 5, 5, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 4, 1, 1, 0, + 1, 2, 2, 3, 3, 1, 1, 0, 1, 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 +}; -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab -#define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif + YYERROR; \ + } \ +while (0) +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -1132,54 +1001,46 @@ while (YYID (0)) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + 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, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif { + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); # endif - switch (yytype) - { - default: - break; - } + YYUSE (yytype); } @@ -1187,22 +1048,11 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) | Print this symbol on YYOUTPUT. | `--------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif { - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); @@ -1213,66 +1063,54 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) | TOP (included). | `------------------------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) -#else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; -#endif +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { + unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -1286,7 +1124,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -1301,7 +1139,6 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE @@ -1310,15 +1147,8 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -1334,16 +1164,8 @@ yystrlen (yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif { char *yyd = yydest; const char *yys = yysrc; @@ -1373,27 +1195,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1404,211 +1226,209 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) { - int yyn = yypact[yystate]; + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else + switch (yycount) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; } #endif /* YYERROR_VERBOSE */ - /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif { YYUSE (yyvaluep); - if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { - - default: - break; - } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END } - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ -/* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; - /* Number of syntax errors so far. */ int yynerrs; - /*----------. | yyparse. | `----------*/ -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) int yyparse (void) -#else -int -yyparse () - -#endif -#endif { - - int yystate; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ + /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1616,54 +1436,22 @@ yyparse () YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - + yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. @@ -1684,25 +1472,23 @@ yyparse () #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1710,23 +1496,22 @@ yyparse () # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1734,16 +1519,18 @@ yyparse () yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1752,20 +1539,20 @@ yyparse () yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; + yychar = yylex (); } if (yychar <= YYEOF) @@ -1787,29 +1574,27 @@ yyparse () yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + if (yytable_value_is_error (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; @@ -1832,7 +1617,7 @@ yyparse () yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. + '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -1846,75 +1631,84 @@ yyparse () switch (yyn) { case 2: -#line 227 "ncgen.y" - {if (error_count > 0) YYABORT;;} +#line 227 "ncgen.y" /* yacc.c:1646 */ + {if (error_count > 0) YYABORT;} +#line 1637 "ncgeny.c" /* yacc.c:1646 */ break; case 3: -#line 230 "ncgen.y" - {createrootgroup(datasetname);;} +#line 230 "ncgen.y" /* yacc.c:1646 */ + {createrootgroup(datasetname);} +#line 1643 "ncgeny.c" /* yacc.c:1646 */ break; case 8: -#line 249 "ncgen.y" +#line 249 "ncgen.y" /* yacc.c:1646 */ { - Symbol* id = (yyvsp[(2) - (3)].sym); + Symbol* id = (yyvsp[-1].sym); markcdf4("Group specification"); if(creategroup(id) == NULL) yyerror("duplicate group declaration within parent group for %s", id->name); - ;} + } +#line 1655 "ncgeny.c" /* yacc.c:1646 */ break; case 9: -#line 258 "ncgen.y" - {listpop(groupstack);;} +#line 258 "ncgen.y" /* yacc.c:1646 */ + {listpop(groupstack);} +#line 1661 "ncgeny.c" /* yacc.c:1646 */ break; case 12: -#line 264 "ncgen.y" - {;} +#line 264 "ncgen.y" /* yacc.c:1646 */ + {} +#line 1667 "ncgeny.c" /* yacc.c:1646 */ break; case 13: -#line 266 "ncgen.y" - {markcdf4("Type specification");;} +#line 266 "ncgen.y" /* yacc.c:1646 */ + {markcdf4("Type specification");} +#line 1673 "ncgeny.c" /* yacc.c:1646 */ break; case 16: -#line 272 "ncgen.y" +#line 272 "ncgen.y" /* yacc.c:1646 */ { /* Use when defining a type */ - (yyvsp[(1) - (1)].sym)->objectclass = NC_TYPE; - if(dupobjectcheck(NC_TYPE,(yyvsp[(1) - (1)].sym))) + (yyvsp[0].sym)->objectclass = NC_TYPE; + if(dupobjectcheck(NC_TYPE,(yyvsp[0].sym))) yyerror("duplicate type declaration for %s", - (yyvsp[(1) - (1)].sym)->name); - listpush(typdefs,(void*)(yyvsp[(1) - (1)].sym)); - ;} + (yyvsp[0].sym)->name); + listpush(typdefs,(void*)(yyvsp[0].sym)); + } +#line 1685 "ncgeny.c" /* yacc.c:1646 */ break; case 17: -#line 281 "ncgen.y" - {;} +#line 281 "ncgen.y" /* yacc.c:1646 */ + {} +#line 1691 "ncgeny.c" /* yacc.c:1646 */ break; case 18: -#line 281 "ncgen.y" - {;} +#line 281 "ncgen.y" /* yacc.c:1646 */ + {} +#line 1697 "ncgeny.c" /* yacc.c:1646 */ break; case 25: -#line 295 "ncgen.y" +#line 295 "ncgen.y" /* yacc.c:1646 */ { int i; - addtogroup((yyvsp[(3) - (6)].sym)); /* sets prefix*/ - (yyvsp[(3) - (6)].sym)->objectclass=NC_TYPE; - (yyvsp[(3) - (6)].sym)->subclass=NC_ENUM; - (yyvsp[(3) - (6)].sym)->typ.basetype=(yyvsp[(1) - (6)].sym); - (yyvsp[(3) - (6)].sym)->typ.size = (yyvsp[(1) - (6)].sym)->typ.size; - (yyvsp[(3) - (6)].sym)->typ.alignment = (yyvsp[(1) - (6)].sym)->typ.alignment; - stackbase=(yyvsp[(5) - (6)].mark); + addtogroup((yyvsp[-3].sym)); /* sets prefix*/ + (yyvsp[-3].sym)->objectclass=NC_TYPE; + (yyvsp[-3].sym)->subclass=NC_ENUM; + (yyvsp[-3].sym)->typ.basetype=(yyvsp[-5].sym); + (yyvsp[-3].sym)->typ.size = (yyvsp[-5].sym)->typ.size; + (yyvsp[-3].sym)->typ.alignment = (yyvsp[-5].sym)->typ.alignment; + stackbase=(yyvsp[-1].mark); stacklen=listlength(stack); - (yyvsp[(3) - (6)].sym)->subnodes = listnew(); + (yyvsp[-3].sym)->subnodes = listnew(); /* Variety of field fixups*/ /* 1. add in the enum values*/ /* 2. make this type be their container*/ @@ -1924,83 +1718,89 @@ yyparse () Symbol* eid = (Symbol*)listget(stack,i); assert(eid->subclass == NC_ECONST); addtogroup(eid); - listpush((yyvsp[(3) - (6)].sym)->subnodes,(void*)eid); - eid->container = (yyvsp[(3) - (6)].sym); - eid->typ.basetype = (yyvsp[(3) - (6)].sym)->typ.basetype; + listpush((yyvsp[-3].sym)->subnodes,(void*)eid); + eid->container = (yyvsp[-3].sym); + eid->typ.basetype = (yyvsp[-3].sym)->typ.basetype; } listsetlength(stack,stackbase);/* remove stack nodes*/ - ;} + } +#line 1728 "ncgeny.c" /* yacc.c:1646 */ break; case 26: -#line 324 "ncgen.y" - {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[(1) - (1)].sym));;} +#line 324 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} +#line 1734 "ncgeny.c" /* yacc.c:1646 */ break; case 27: -#line 326 "ncgen.y" +#line 326 "ncgen.y" /* yacc.c:1646 */ { int i; - (yyval.mark)=(yyvsp[(1) - (3)].mark); + (yyval.mark)=(yyvsp[-2].mark); /* check for duplicates*/ - stackbase=(yyvsp[(1) - (3)].mark); + stackbase=(yyvsp[-2].mark); stacklen=listlength(stack); for(i=stackbase;iname,elem->name)==0) + if(strcmp((yyvsp[0].sym)->name,elem->name)==0) yyerror("duplicate enum declaration for %s", elem->name); } - listpush(stack,(void*)(yyvsp[(3) - (3)].sym)); - ;} + listpush(stack,(void*)(yyvsp[0].sym)); + } +#line 1753 "ncgeny.c" /* yacc.c:1646 */ break; case 28: -#line 343 "ncgen.y" +#line 343 "ncgen.y" /* yacc.c:1646 */ { - (yyvsp[(1) - (3)].sym)->objectclass=NC_TYPE; - (yyvsp[(1) - (3)].sym)->subclass=NC_ECONST; - (yyvsp[(1) - (3)].sym)->typ.econst=(yyvsp[(3) - (3)].constant); - (yyval.sym)=(yyvsp[(1) - (3)].sym); - ;} + (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 1764 "ncgeny.c" /* yacc.c:1646 */ break; case 29: -#line 352 "ncgen.y" +#line 352 "ncgen.y" /* yacc.c:1646 */ { vercheck(NC_OPAQUE); - addtogroup((yyvsp[(5) - (5)].sym)); /*sets prefix*/ - (yyvsp[(5) - (5)].sym)->objectclass=NC_TYPE; - (yyvsp[(5) - (5)].sym)->subclass=NC_OPAQUE; - (yyvsp[(5) - (5)].sym)->typ.typecode=NC_OPAQUE; - (yyvsp[(5) - (5)].sym)->typ.size=int32_val; - (yyvsp[(5) - (5)].sym)->typ.alignment=nctypealignment(NC_OPAQUE); - ;} + addtogroup((yyvsp[0].sym)); /*sets prefix*/ + (yyvsp[0].sym)->objectclass=NC_TYPE; + (yyvsp[0].sym)->subclass=NC_OPAQUE; + (yyvsp[0].sym)->typ.typecode=NC_OPAQUE; + (yyvsp[0].sym)->typ.size=int32_val; + (yyvsp[0].sym)->typ.alignment=nctypealignment(NC_OPAQUE); + } +#line 1778 "ncgeny.c" /* yacc.c:1646 */ break; case 30: -#line 364 "ncgen.y" +#line 364 "ncgen.y" /* yacc.c:1646 */ { - Symbol* basetype = (yyvsp[(1) - (5)].sym); + Symbol* basetype = (yyvsp[-4].sym); vercheck(NC_VLEN); - addtogroup((yyvsp[(5) - (5)].sym)); /*sets prefix*/ - (yyvsp[(5) - (5)].sym)->objectclass=NC_TYPE; - (yyvsp[(5) - (5)].sym)->subclass=NC_VLEN; - (yyvsp[(5) - (5)].sym)->typ.basetype=basetype; - (yyvsp[(5) - (5)].sym)->typ.typecode=NC_VLEN; - (yyvsp[(5) - (5)].sym)->typ.size=VLENSIZE; - (yyvsp[(5) - (5)].sym)->typ.alignment=nctypealignment(NC_VLEN); - ;} + addtogroup((yyvsp[0].sym)); /*sets prefix*/ + (yyvsp[0].sym)->objectclass=NC_TYPE; + (yyvsp[0].sym)->subclass=NC_VLEN; + (yyvsp[0].sym)->typ.basetype=basetype; + (yyvsp[0].sym)->typ.typecode=NC_VLEN; + (yyvsp[0].sym)->typ.size=VLENSIZE; + (yyvsp[0].sym)->typ.alignment=nctypealignment(NC_VLEN); + } +#line 1794 "ncgeny.c" /* yacc.c:1646 */ break; case 31: -#line 378 "ncgen.y" +#line 378 "ncgen.y" /* yacc.c:1646 */ { int i,j; vercheck(NC_COMPOUND); - addtogroup((yyvsp[(2) - (5)].sym)); + addtogroup((yyvsp[-3].sym)); /* check for duplicate field names*/ - stackbase=(yyvsp[(4) - (5)].mark); + stackbase=(yyvsp[-1].mark); stacklen=listlength(stack); for(i=stackbase;iobjectclass=NC_TYPE; - (yyvsp[(2) - (5)].sym)->subclass=NC_COMPOUND; - (yyvsp[(2) - (5)].sym)->typ.basetype=NULL; - (yyvsp[(2) - (5)].sym)->typ.typecode=NC_COMPOUND; - (yyvsp[(2) - (5)].sym)->subnodes = listnew(); + (yyvsp[-3].sym)->objectclass=NC_TYPE; + (yyvsp[-3].sym)->subclass=NC_COMPOUND; + (yyvsp[-3].sym)->typ.basetype=NULL; + (yyvsp[-3].sym)->typ.typecode=NC_COMPOUND; + (yyvsp[-3].sym)->subnodes = listnew(); /* Add in the fields*/ for(i=stackbase;icontainer = (yyvsp[(2) - (5)].sym); - listpush((yyvsp[(2) - (5)].sym)->subnodes,(void*)fsym); + fsym->container = (yyvsp[-3].sym); + listpush((yyvsp[-3].sym)->subnodes,(void*)fsym); } listsetlength(stack,stackbase);/* remove stack nodes*/ - ;} + } +#line 1828 "ncgeny.c" /* yacc.c:1646 */ break; case 32: -#line 410 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (2)].mark);;} +#line 410 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=(yyvsp[-1].mark);} +#line 1834 "ncgeny.c" /* yacc.c:1646 */ break; case 33: -#line 411 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark);;} +#line 411 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=(yyvsp[-2].mark);} +#line 1840 "ncgeny.c" /* yacc.c:1646 */ break; case 34: -#line 415 "ncgen.y" +#line 415 "ncgen.y" /* yacc.c:1646 */ { int i; - (yyval.mark)=(yyvsp[(2) - (2)].mark); - stackbase=(yyvsp[(2) - (2)].mark); + (yyval.mark)=(yyvsp[0].mark); + stackbase=(yyvsp[0].mark); stacklen=listlength(stack); /* process each field in the fieldlist*/ for(i=stackbase;ityp.basetype = (yyvsp[(1) - (2)].sym); + f->typ.basetype = (yyvsp[-1].sym); } - ;} + } +#line 1856 "ncgeny.c" /* yacc.c:1646 */ break; case 35: -#line 428 "ncgen.y" - { (yyval.sym) = primsymbols[NC_CHAR]; ;} +#line 428 "ncgen.y" /* yacc.c:1646 */ + { (yyval.sym) = primsymbols[NC_CHAR]; } +#line 1862 "ncgeny.c" /* yacc.c:1646 */ break; case 36: -#line 429 "ncgen.y" - { (yyval.sym) = primsymbols[NC_BYTE]; ;} +#line 429 "ncgen.y" /* yacc.c:1646 */ + { (yyval.sym) = primsymbols[NC_BYTE]; } +#line 1868 "ncgeny.c" /* yacc.c:1646 */ break; case 37: -#line 430 "ncgen.y" - { (yyval.sym) = primsymbols[NC_SHORT]; ;} +#line 430 "ncgen.y" /* yacc.c:1646 */ + { (yyval.sym) = primsymbols[NC_SHORT]; } +#line 1874 "ncgeny.c" /* yacc.c:1646 */ break; case 38: -#line 431 "ncgen.y" - { (yyval.sym) = primsymbols[NC_INT]; ;} +#line 431 "ncgen.y" /* yacc.c:1646 */ + { (yyval.sym) = primsymbols[NC_INT]; } +#line 1880 "ncgeny.c" /* yacc.c:1646 */ break; case 39: -#line 432 "ncgen.y" - { (yyval.sym) = primsymbols[NC_FLOAT]; ;} +#line 432 "ncgen.y" /* yacc.c:1646 */ + { (yyval.sym) = primsymbols[NC_FLOAT]; } +#line 1886 "ncgeny.c" /* yacc.c:1646 */ break; case 40: -#line 433 "ncgen.y" - { (yyval.sym) = primsymbols[NC_DOUBLE]; ;} +#line 433 "ncgen.y" /* yacc.c:1646 */ + { (yyval.sym) = primsymbols[NC_DOUBLE]; } +#line 1892 "ncgeny.c" /* yacc.c:1646 */ break; case 41: -#line 434 "ncgen.y" - { vercheck(NC_UBYTE); (yyval.sym) = primsymbols[NC_UBYTE]; ;} +#line 434 "ncgen.y" /* yacc.c:1646 */ + { vercheck(NC_UBYTE); (yyval.sym) = primsymbols[NC_UBYTE]; } +#line 1898 "ncgeny.c" /* yacc.c:1646 */ break; case 42: -#line 435 "ncgen.y" - { vercheck(NC_USHORT); (yyval.sym) = primsymbols[NC_USHORT]; ;} +#line 435 "ncgen.y" /* yacc.c:1646 */ + { vercheck(NC_USHORT); (yyval.sym) = primsymbols[NC_USHORT]; } +#line 1904 "ncgeny.c" /* yacc.c:1646 */ break; case 43: -#line 436 "ncgen.y" - { vercheck(NC_UINT); (yyval.sym) = primsymbols[NC_UINT]; ;} +#line 436 "ncgen.y" /* yacc.c:1646 */ + { vercheck(NC_UINT); (yyval.sym) = primsymbols[NC_UINT]; } +#line 1910 "ncgeny.c" /* yacc.c:1646 */ break; case 44: -#line 437 "ncgen.y" - { vercheck(NC_INT64); (yyval.sym) = primsymbols[NC_INT64]; ;} +#line 437 "ncgen.y" /* yacc.c:1646 */ + { vercheck(NC_INT64); (yyval.sym) = primsymbols[NC_INT64]; } +#line 1916 "ncgeny.c" /* yacc.c:1646 */ break; case 45: -#line 438 "ncgen.y" - { vercheck(NC_UINT64); (yyval.sym) = primsymbols[NC_UINT64]; ;} +#line 438 "ncgen.y" /* yacc.c:1646 */ + { vercheck(NC_UINT64); (yyval.sym) = primsymbols[NC_UINT64]; } +#line 1922 "ncgeny.c" /* yacc.c:1646 */ break; case 46: -#line 439 "ncgen.y" - { vercheck(NC_STRING); (yyval.sym) = primsymbols[NC_STRING]; ;} +#line 439 "ncgen.y" /* yacc.c:1646 */ + { vercheck(NC_STRING); (yyval.sym) = primsymbols[NC_STRING]; } +#line 1928 "ncgeny.c" /* yacc.c:1646 */ break; case 48: -#line 443 "ncgen.y" - {;} +#line 443 "ncgen.y" /* yacc.c:1646 */ + {} +#line 1934 "ncgeny.c" /* yacc.c:1646 */ break; case 49: -#line 444 "ncgen.y" - {;} +#line 444 "ncgen.y" /* yacc.c:1646 */ + {} +#line 1940 "ncgeny.c" /* yacc.c:1646 */ break; case 52: -#line 451 "ncgen.y" - {;} +#line 451 "ncgen.y" /* yacc.c:1646 */ + {} +#line 1946 "ncgeny.c" /* yacc.c:1646 */ break; case 53: -#line 451 "ncgen.y" - {;} +#line 451 "ncgen.y" /* yacc.c:1646 */ + {} +#line 1952 "ncgeny.c" /* yacc.c:1646 */ break; case 56: -#line 459 "ncgen.y" +#line 459 "ncgen.y" /* yacc.c:1646 */ { - (yyvsp[(1) - (3)].sym)->dim.declsize = (size_t)extractint((yyvsp[(3) - (3)].constant)); + (yyvsp[-2].sym)->dim.declsize = (size_t)extractint((yyvsp[0].constant)); #ifdef GENDEBUG1 -fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[(1) - (3)].sym)->name,(unsigned long long)(yyvsp[(1) - (3)].sym)->dim.declsize); +fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[-2].sym)->name,(unsigned long long)(yyvsp[-2].sym)->dim.declsize); #endif - ;} + } +#line 1963 "ncgeny.c" /* yacc.c:1646 */ break; case 57: -#line 466 "ncgen.y" +#line 466 "ncgen.y" /* yacc.c:1646 */ { - (yyvsp[(1) - (3)].sym)->dim.declsize = NC_UNLIMITED; - (yyvsp[(1) - (3)].sym)->dim.isunlimited = 1; + (yyvsp[-2].sym)->dim.declsize = NC_UNLIMITED; + (yyvsp[-2].sym)->dim.isunlimited = 1; #ifdef GENDEBUG1 -fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); +fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); #endif - ;} + } +#line 1975 "ncgeny.c" /* yacc.c:1646 */ break; case 58: -#line 476 "ncgen.y" +#line 476 "ncgen.y" /* yacc.c:1646 */ { - (yyvsp[(1) - (1)].sym)->objectclass=NC_DIM; - if(dupobjectcheck(NC_DIM,(yyvsp[(1) - (1)].sym))) + (yyvsp[0].sym)->objectclass=NC_DIM; + if(dupobjectcheck(NC_DIM,(yyvsp[0].sym))) yyerror( "Duplicate dimension declaration for %s", - (yyvsp[(1) - (1)].sym)->name); - addtogroup((yyvsp[(1) - (1)].sym)); - (yyval.sym)=(yyvsp[(1) - (1)].sym); - listpush(dimdefs,(void*)(yyvsp[(1) - (1)].sym)); - ;} + (yyvsp[0].sym)->name); + addtogroup((yyvsp[0].sym)); + (yyval.sym)=(yyvsp[0].sym); + listpush(dimdefs,(void*)(yyvsp[0].sym)); + } +#line 1989 "ncgeny.c" /* yacc.c:1646 */ break; case 60: -#line 488 "ncgen.y" - {;} +#line 488 "ncgen.y" /* yacc.c:1646 */ + {} +#line 1995 "ncgeny.c" /* yacc.c:1646 */ break; case 61: -#line 489 "ncgen.y" - {;} +#line 489 "ncgen.y" /* yacc.c:1646 */ + {} +#line 2001 "ncgeny.c" /* yacc.c:1646 */ break; case 64: -#line 496 "ncgen.y" - {;} +#line 496 "ncgen.y" /* yacc.c:1646 */ + {} +#line 2007 "ncgeny.c" /* yacc.c:1646 */ break; case 65: -#line 496 "ncgen.y" - {;} +#line 496 "ncgen.y" /* yacc.c:1646 */ + {} +#line 2013 "ncgeny.c" /* yacc.c:1646 */ break; case 66: -#line 499 "ncgen.y" +#line 499 "ncgen.y" /* yacc.c:1646 */ { int i; - stackbase=(yyvsp[(2) - (2)].mark); + stackbase=(yyvsp[0].mark); stacklen=listlength(stack); /* process each variable in the varlist*/ for(i=stackbase;iname); yyerror("Duplicate variable declaration for %s", sym->name); } else { - sym->typ.basetype = (yyvsp[(1) - (2)].sym); + sym->typ.basetype = (yyvsp[-1].sym); addtogroup(sym); listpush(vardefs,(void*)sym); } } listsetlength(stack,stackbase);/* remove stack nodes*/ - ;} + } +#line 2037 "ncgeny.c" /* yacc.c:1646 */ break; case 67: -#line 521 "ncgen.y" +#line 521 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=listlength(stack); - listpush(stack,(void*)(yyvsp[(1) - (1)].sym)); - ;} + listpush(stack,(void*)(yyvsp[0].sym)); + } +#line 2045 "ncgeny.c" /* yacc.c:1646 */ break; case 68: -#line 525 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(void*)(yyvsp[(3) - (3)].sym));;} +#line 525 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} +#line 2051 "ncgeny.c" /* yacc.c:1646 */ break; case 69: -#line 529 "ncgen.y" +#line 529 "ncgen.y" /* yacc.c:1646 */ { int i; Dimset dimset; stacklen=listlength(stack); - stackbase=(yyvsp[(2) - (2)].mark); + stackbase=(yyvsp[0].mark); count = stacklen - stackbase; if(count >= NC_MAX_VAR_DIMS) { - yyerror("%s has too many dimensions",(yyvsp[(1) - (2)].sym)->name); + yyerror("%s has too many dimensions",(yyvsp[-1].sym)->name); count = NC_MAX_VAR_DIMS - 1; stacklen = stackbase + count; } @@ -2240,70 +2070,78 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); Symbol* dsym = (Symbol*)listget(stack,stackbase+i); dimset.dimsyms[i] = dsym; } - (yyvsp[(1) - (2)].sym)->typ.dimset = dimset; + (yyvsp[-1].sym)->typ.dimset = dimset; } - (yyvsp[(1) - (2)].sym)->typ.basetype = NULL; /* not yet known*/ - (yyvsp[(1) - (2)].sym)->objectclass=NC_VAR; + (yyvsp[-1].sym)->typ.basetype = NULL; /* not yet known*/ + (yyvsp[-1].sym)->objectclass=NC_VAR; listsetlength(stack,stackbase);/* remove stack nodes*/ - ;} + } +#line 2080 "ncgeny.c" /* yacc.c:1646 */ break; case 70: -#line 555 "ncgen.y" - {(yyval.mark)=listlength(stack);;} +#line 555 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=listlength(stack);} +#line 2086 "ncgeny.c" /* yacc.c:1646 */ break; case 71: -#line 556 "ncgen.y" - {(yyval.mark)=(yyvsp[(2) - (3)].mark);;} +#line 556 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=(yyvsp[-1].mark);} +#line 2092 "ncgeny.c" /* yacc.c:1646 */ break; case 72: -#line 559 "ncgen.y" - {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[(1) - (1)].sym));;} +#line 559 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} +#line 2098 "ncgeny.c" /* yacc.c:1646 */ break; case 73: -#line 561 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(void*)(yyvsp[(3) - (3)].sym));;} +#line 561 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} +#line 2104 "ncgeny.c" /* yacc.c:1646 */ break; case 74: -#line 565 "ncgen.y" - {Symbol* dimsym = (yyvsp[(1) - (1)].sym); +#line 565 "ncgen.y" /* yacc.c:1646 */ + {Symbol* dimsym = (yyvsp[0].sym); dimsym->objectclass = NC_DIM; /* Find the actual dimension*/ dimsym = locate(dimsym); if(dimsym == NULL) { - derror("Undefined or forward referenced dimension: %s",(yyvsp[(1) - (1)].sym)->name); + derror("Undefined or forward referenced dimension: %s",(yyvsp[0].sym)->name); YYABORT; } (yyval.sym)=dimsym; - ;} + } +#line 2119 "ncgeny.c" /* yacc.c:1646 */ break; case 75: -#line 579 "ncgen.y" +#line 579 "ncgen.y" /* yacc.c:1646 */ {(yyval.mark)=listlength(stack); - listpush(stack,(void*)(yyvsp[(1) - (1)].sym)); - ;} + listpush(stack,(void*)(yyvsp[0].sym)); + } +#line 2127 "ncgeny.c" /* yacc.c:1646 */ break; case 76: -#line 583 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(void*)(yyvsp[(3) - (3)].sym));;} +#line 583 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} +#line 2133 "ncgeny.c" /* yacc.c:1646 */ break; case 77: -#line 588 "ncgen.y" +#line 588 "ncgen.y" /* yacc.c:1646 */ { int i; Dimset dimset; - stackbase=(yyvsp[(2) - (2)].mark); + stackbase=(yyvsp[0].mark); stacklen=listlength(stack); count = stacklen - stackbase; if(count >= NC_MAX_VAR_DIMS) { - yyerror("%s has too many dimensions",(yyvsp[(1) - (2)].sym)->name); + yyerror("%s has too many dimensions",(yyvsp[-1].sym)->name); count = NC_MAX_VAR_DIMS - 1; stacklen = stackbase + count; } @@ -2314,38 +2152,43 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); Symbol* dsym = (Symbol*)listget(stack,stackbase+i); dimset.dimsyms[i] = dsym; } - (yyvsp[(1) - (2)].sym)->typ.dimset = dimset; + (yyvsp[-1].sym)->typ.dimset = dimset; } - (yyvsp[(1) - (2)].sym)->typ.basetype = NULL; /* not yet known*/ - (yyvsp[(1) - (2)].sym)->objectclass=NC_TYPE; - (yyvsp[(1) - (2)].sym)->subclass=NC_FIELD; + (yyvsp[-1].sym)->typ.basetype = NULL; /* not yet known*/ + (yyvsp[-1].sym)->objectclass=NC_TYPE; + (yyvsp[-1].sym)->subclass=NC_FIELD; listsetlength(stack,stackbase);/* remove stack nodes*/ - (yyval.sym) = (yyvsp[(1) - (2)].sym); - ;} + (yyval.sym) = (yyvsp[-1].sym); + } +#line 2164 "ncgeny.c" /* yacc.c:1646 */ break; case 78: -#line 616 "ncgen.y" - {(yyval.mark)=listlength(stack);;} +#line 616 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=listlength(stack);} +#line 2170 "ncgeny.c" /* yacc.c:1646 */ break; case 79: -#line 617 "ncgen.y" - {(yyval.mark)=(yyvsp[(2) - (3)].mark);;} +#line 617 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=(yyvsp[-1].mark);} +#line 2176 "ncgeny.c" /* yacc.c:1646 */ break; case 80: -#line 621 "ncgen.y" - {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[(1) - (1)].sym));;} +#line 621 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));} +#line 2182 "ncgeny.c" /* yacc.c:1646 */ break; case 81: -#line 623 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(void*)(yyvsp[(3) - (3)].sym));;} +#line 623 "ncgen.y" /* yacc.c:1646 */ + {(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));} +#line 2188 "ncgeny.c" /* yacc.c:1646 */ break; case 82: -#line 628 "ncgen.y" +#line 628 "ncgen.y" /* yacc.c:1646 */ { /* Anonymous integer dimension. Can only occur in type definitions*/ char anon[32]; @@ -2354,11 +2197,12 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); (yyval.sym)->objectclass = NC_DIM; (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = uint32_val; - ;} + } +#line 2202 "ncgeny.c" /* yacc.c:1646 */ break; case 83: -#line 638 "ncgen.y" +#line 638 "ncgen.y" /* yacc.c:1646 */ { /* Anonymous integer dimension. Can only occur in type definitions*/ char anon[32]; @@ -2371,34 +2215,37 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); (yyval.sym)->objectclass = NC_DIM; (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = int32_val; - ;} + } +#line 2220 "ncgeny.c" /* yacc.c:1646 */ break; case 84: -#line 658 "ncgen.y" - {Symbol* vsym = (yyvsp[(1) - (1)].sym); +#line 658 "ncgen.y" /* yacc.c:1646 */ + {Symbol* vsym = (yyvsp[0].sym); if(vsym->objectclass != NC_VAR) { derror("Undefined or forward referenced variable: %s",vsym->name); YYABORT; } (yyval.sym)=vsym; - ;} + } +#line 2232 "ncgeny.c" /* yacc.c:1646 */ break; case 85: -#line 669 "ncgen.y" - {Symbol* tsym = (yyvsp[(1) - (1)].sym); +#line 669 "ncgen.y" /* yacc.c:1646 */ + {Symbol* tsym = (yyvsp[0].sym); if(tsym->objectclass != NC_TYPE) { derror("Undefined or forward referenced type: %s",tsym->name); YYABORT; } (yyval.sym)=tsym; - ;} + } +#line 2244 "ncgeny.c" /* yacc.c:1646 */ break; case 86: -#line 680 "ncgen.y" - {Symbol* tvsym = (yyvsp[(1) - (1)].sym); Symbol* sym; +#line 680 "ncgen.y" /* yacc.c:1646 */ + {Symbol* tvsym = (yyvsp[0].sym); Symbol* sym; /* disambiguate*/ tvsym->objectclass = NC_VAR; sym = locate(tvsym); @@ -2406,364 +2253,438 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); tvsym->objectclass = NC_TYPE; sym = locate(tvsym); if(tvsym == NULL) { - derror("Undefined or forward referenced name: %s",(yyvsp[(1) - (1)].sym)->name); + derror("Undefined or forward referenced name: %s",(yyvsp[0].sym)->name); YYABORT; } else tvsym = sym; } else tvsym = sym; if(tvsym == NULL) { - derror("Undefined name (line %d): %s",(yyvsp[(1) - (1)].sym)->lineno,(yyvsp[(1) - (1)].sym)->name); + derror("Undefined name (line %d): %s",(yyvsp[0].sym)->lineno,(yyvsp[0].sym)->name); YYABORT; } (yyval.sym)=tvsym; - ;} + } +#line 2267 "ncgeny.c" /* yacc.c:1646 */ break; case 87: -#line 698 "ncgen.y" - {(yyval.sym)=(yyvsp[(1) - (1)].sym);;} +#line 698 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym)=(yyvsp[0].sym);} +#line 2273 "ncgeny.c" /* yacc.c:1646 */ break; case 88: -#line 705 "ncgen.y" - {;} +#line 705 "ncgen.y" /* yacc.c:1646 */ + {} +#line 2279 "ncgeny.c" /* yacc.c:1646 */ break; case 89: -#line 705 "ncgen.y" - {;} +#line 705 "ncgen.y" /* yacc.c:1646 */ + {} +#line 2285 "ncgeny.c" /* yacc.c:1646 */ break; case 90: -#line 709 "ncgen.y" - {(yyval.sym) = makespecial(_NCPROPS_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),ATTRGLOBAL);;} +#line 709 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_NCPROPS_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} +#line 2291 "ncgeny.c" /* yacc.c:1646 */ break; case 91: -#line 711 "ncgen.y" - {(yyval.sym) = makespecial(_ISNETCDF4_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),ATTRGLOBAL);;} +#line 711 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_ISNETCDF4_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} +#line 2297 "ncgeny.c" /* yacc.c:1646 */ break; case 92: -#line 713 "ncgen.y" - {(yyval.sym) = makespecial(_SUPERBLOCK_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),ATTRGLOBAL);;} +#line 713 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_SUPERBLOCK_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);} +#line 2303 "ncgeny.c" /* yacc.c:1646 */ break; case 93: -#line 715 "ncgen.y" - { (yyval.sym)=makeattribute((yyvsp[(2) - (4)].sym),NULL,NULL,(yyvsp[(4) - (4)].datalist),ATTRGLOBAL);;} +#line 715 "ncgen.y" /* yacc.c:1646 */ + { (yyval.sym)=makeattribute((yyvsp[-2].sym),NULL,NULL,(yyvsp[0].datalist),ATTRGLOBAL);} +#line 2309 "ncgeny.c" /* yacc.c:1646 */ break; case 94: -#line 717 "ncgen.y" - {Symbol* tsym = (yyvsp[(1) - (6)].sym); Symbol* vsym = (yyvsp[(2) - (6)].sym); Symbol* asym = (yyvsp[(4) - (6)].sym); +#line 717 "ncgen.y" /* yacc.c:1646 */ + {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[(6) - (6)].datalist),ATTRVAR); + (yyval.sym)=makeattribute(asym,vsym,tsym,(yyvsp[0].datalist),ATTRVAR); } else { derror("Doubly typed attribute: %s",asym->name); YYABORT; } - ;} + } +#line 2322 "ncgeny.c" /* yacc.c:1646 */ break; case 95: -#line 726 "ncgen.y" - {Symbol* sym = (yyvsp[(1) - (5)].sym); Symbol* asym = (yyvsp[(3) - (5)].sym); +#line 726 "ncgen.y" /* yacc.c:1646 */ + {Symbol* sym = (yyvsp[-4].sym); Symbol* asym = (yyvsp[-2].sym); if(sym->objectclass == NC_VAR) { - (yyval.sym)=makeattribute(asym,sym,NULL,(yyvsp[(5) - (5)].datalist),ATTRVAR); + (yyval.sym)=makeattribute(asym,sym,NULL,(yyvsp[0].datalist),ATTRVAR); } else if(sym->objectclass == NC_TYPE) { - (yyval.sym)=makeattribute(asym,NULL,sym,(yyvsp[(5) - (5)].datalist),ATTRGLOBAL); + (yyval.sym)=makeattribute(asym,NULL,sym,(yyvsp[0].datalist),ATTRGLOBAL); } else { derror("Attribute prefix not a variable or type: %s",asym->name); YYABORT; } - ;} + } +#line 2337 "ncgeny.c" /* yacc.c:1646 */ break; case 96: -#line 737 "ncgen.y" - {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);;} +#line 737 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),0);} +#line 2343 "ncgeny.c" /* yacc.c:1646 */ break; case 97: -#line 739 "ncgen.y" - {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(2) - (6)].sym),(yyvsp[(1) - (6)].sym),(void*)(yyvsp[(6) - (6)].datalist),0);;} +#line 739 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),(yyvsp[-5].sym),(void*)(yyvsp[0].datalist),0);} +#line 2349 "ncgeny.c" /* yacc.c:1646 */ break; case 98: -#line 741 "ncgen.y" - {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} +#line 741 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} +#line 2355 "ncgeny.c" /* yacc.c:1646 */ break; case 99: -#line 743 "ncgen.y" - {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);;} +#line 743 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),0);} +#line 2361 "ncgeny.c" /* yacc.c:1646 */ break; case 100: -#line 745 "ncgen.y" - {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} +#line 745 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} +#line 2367 "ncgeny.c" /* yacc.c:1646 */ break; case 101: -#line 747 "ncgen.y" - {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} +#line 747 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} +#line 2373 "ncgeny.c" /* yacc.c:1646 */ break; case 102: -#line 749 "ncgen.y" - {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} +#line 749 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} +#line 2379 "ncgeny.c" /* yacc.c:1646 */ break; case 103: -#line 751 "ncgen.y" - {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} +#line 751 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} +#line 2385 "ncgeny.c" /* yacc.c:1646 */ break; case 104: -#line 753 "ncgen.y" - {(yyval.sym) = makespecial(_FILTER_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} +#line 753 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_FILTER_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} +#line 2391 "ncgeny.c" /* yacc.c:1646 */ break; case 105: -#line 755 "ncgen.y" - {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} +#line 755 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);} +#line 2397 "ncgeny.c" /* yacc.c:1646 */ break; case 106: -#line 757 "ncgen.y" - {(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),1);;} +#line 757 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),1);} +#line 2403 "ncgeny.c" /* yacc.c:1646 */ break; case 107: -#line 762 "ncgen.y" +#line 762 "ncgen.y" /* yacc.c:1646 */ { - (yyval.sym)=(yyvsp[(1) - (1)].sym); - (yyvsp[(1) - (1)].sym)->ref.is_ref=1; - (yyvsp[(1) - (1)].sym)->is_prefixed=0; - setpathcurrent((yyvsp[(1) - (1)].sym)); - ;} + (yyval.sym)=(yyvsp[0].sym); + (yyvsp[0].sym)->ref.is_ref=1; + (yyvsp[0].sym)->is_prefixed=0; + setpathcurrent((yyvsp[0].sym)); + } +#line 2414 "ncgeny.c" /* yacc.c:1646 */ break; case 108: -#line 769 "ncgen.y" +#line 769 "ncgen.y" /* yacc.c:1646 */ { - (yyval.sym)=(yyvsp[(1) - (1)].sym); - (yyvsp[(1) - (1)].sym)->ref.is_ref=1; - (yyvsp[(1) - (1)].sym)->is_prefixed=1; + (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 2425 "ncgeny.c" /* yacc.c:1646 */ break; case 110: -#line 778 "ncgen.y" - {;} +#line 778 "ncgen.y" /* yacc.c:1646 */ + {} +#line 2431 "ncgeny.c" /* yacc.c:1646 */ break; case 111: -#line 779 "ncgen.y" - {;} +#line 779 "ncgen.y" /* yacc.c:1646 */ + {} +#line 2437 "ncgeny.c" /* yacc.c:1646 */ break; case 114: -#line 787 "ncgen.y" - {(yyvsp[(1) - (3)].sym)->data = (yyvsp[(3) - (3)].datalist);;} +#line 787 "ncgen.y" /* yacc.c:1646 */ + {(yyvsp[-2].sym)->data = (yyvsp[0].datalist);} +#line 2443 "ncgeny.c" /* yacc.c:1646 */ break; case 115: -#line 790 "ncgen.y" - {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);;} +#line 790 "ncgen.y" /* yacc.c:1646 */ + {(yyval.datalist) = (yyvsp[0].datalist);} +#line 2449 "ncgeny.c" /* yacc.c:1646 */ break; case 116: -#line 791 "ncgen.y" - {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);;} +#line 791 "ncgen.y" /* yacc.c:1646 */ + {(yyval.datalist) = (yyvsp[0].datalist);} +#line 2455 "ncgeny.c" /* yacc.c:1646 */ break; case 117: -#line 795 "ncgen.y" - {(yyval.datalist) = builddatalist(0);;} +#line 795 "ncgen.y" /* yacc.c:1646 */ + {(yyval.datalist) = builddatalist(0);} +#line 2461 "ncgeny.c" /* yacc.c:1646 */ break; case 118: -#line 799 "ncgen.y" - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));;} +#line 799 "ncgen.y" /* yacc.c:1646 */ + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} +#line 2467 "ncgeny.c" /* yacc.c:1646 */ break; case 119: -#line 801 "ncgen.y" - {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);;} +#line 801 "ncgen.y" /* yacc.c:1646 */ + {datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);} +#line 2473 "ncgeny.c" /* yacc.c:1646 */ break; case 120: -#line 805 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} +#line 805 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=(yyvsp[0].constant);} +#line 2479 "ncgeny.c" /* yacc.c:1646 */ break; case 121: -#line 806 "ncgen.y" - {(yyval.constant)=builddatasublist((yyvsp[(2) - (3)].datalist));;} +#line 806 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=builddatasublist((yyvsp[-1].datalist));} +#line 2485 "ncgeny.c" /* yacc.c:1646 */ break; case 122: -#line 810 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} +#line 810 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=(yyvsp[0].constant);} +#line 2491 "ncgeny.c" /* yacc.c:1646 */ break; case 123: -#line 811 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_OPAQUE);;} +#line 811 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_OPAQUE);} +#line 2497 "ncgeny.c" /* yacc.c:1646 */ break; case 124: -#line 812 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_FILLVALUE);;} +#line 812 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_FILLVALUE);} +#line 2503 "ncgeny.c" /* yacc.c:1646 */ break; case 125: -#line 813 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_NIL);;} +#line 813 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_NIL);} +#line 2509 "ncgeny.c" /* yacc.c:1646 */ break; case 126: -#line 814 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} +#line 814 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=(yyvsp[0].constant);} +#line 2515 "ncgeny.c" /* yacc.c:1646 */ break; case 128: -#line 819 "ncgen.y" - {(yyval.constant) = makeenumconstref((yyvsp[(1) - (1)].sym));;} +#line 819 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant) = makeenumconstref((yyvsp[0].sym));} +#line 2521 "ncgeny.c" /* yacc.c:1646 */ break; case 129: -#line 823 "ncgen.y" - {(yyval.constant)=evaluate((yyvsp[(1) - (4)].sym),(yyvsp[(3) - (4)].datalist));;} +#line 823 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=evaluate((yyvsp[-3].sym),(yyvsp[-1].datalist));} +#line 2527 "ncgeny.c" /* yacc.c:1646 */ break; case 130: -#line 828 "ncgen.y" - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));;} +#line 828 "ncgen.y" /* yacc.c:1646 */ + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} +#line 2533 "ncgeny.c" /* yacc.c:1646 */ break; case 131: -#line 830 "ncgen.y" - {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);;} +#line 830 "ncgen.y" /* yacc.c:1646 */ + {datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);} +#line 2539 "ncgeny.c" /* yacc.c:1646 */ break; case 132: -#line 834 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_CHAR);;} +#line 834 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_CHAR);} +#line 2545 "ncgeny.c" /* yacc.c:1646 */ break; case 133: -#line 835 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_BYTE);;} +#line 835 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_BYTE);} +#line 2551 "ncgeny.c" /* yacc.c:1646 */ break; case 134: -#line 836 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_SHORT);;} +#line 836 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_SHORT);} +#line 2557 "ncgeny.c" /* yacc.c:1646 */ break; case 135: -#line 837 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_INT);;} +#line 837 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_INT);} +#line 2563 "ncgeny.c" /* yacc.c:1646 */ break; case 136: -#line 838 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_INT64);;} +#line 838 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_INT64);} +#line 2569 "ncgeny.c" /* yacc.c:1646 */ break; case 137: -#line 839 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UBYTE);;} +#line 839 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_UBYTE);} +#line 2575 "ncgeny.c" /* yacc.c:1646 */ break; case 138: -#line 840 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_USHORT);;} +#line 840 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_USHORT);} +#line 2581 "ncgeny.c" /* yacc.c:1646 */ break; case 139: -#line 841 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UINT);;} +#line 841 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_UINT);} +#line 2587 "ncgeny.c" /* yacc.c:1646 */ break; case 140: -#line 842 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UINT64);;} +#line 842 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_UINT64);} +#line 2593 "ncgeny.c" /* yacc.c:1646 */ break; case 141: -#line 843 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_FLOAT);;} +#line 843 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_FLOAT);} +#line 2599 "ncgeny.c" /* yacc.c:1646 */ break; case 142: -#line 844 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_DOUBLE);;} +#line 844 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_DOUBLE);} +#line 2605 "ncgeny.c" /* yacc.c:1646 */ break; case 143: -#line 845 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_STRING);;} +#line 845 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_STRING);} +#line 2611 "ncgeny.c" /* yacc.c:1646 */ break; case 144: -#line 849 "ncgen.y" - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));;} +#line 849 "ncgen.y" /* yacc.c:1646 */ + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));} +#line 2617 "ncgeny.c" /* yacc.c:1646 */ break; case 145: -#line 850 "ncgen.y" - {(yyval.datalist)=(yyvsp[(1) - (3)].datalist); datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant)));;} +#line 850 "ncgen.y" /* yacc.c:1646 */ + {(yyval.datalist)=(yyvsp[-2].datalist); datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant)));} +#line 2623 "ncgeny.c" /* yacc.c:1646 */ break; case 146: -#line 855 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_INT);;} +#line 855 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_INT);} +#line 2629 "ncgeny.c" /* yacc.c:1646 */ break; case 147: -#line 857 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UINT);;} +#line 857 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_UINT);} +#line 2635 "ncgeny.c" /* yacc.c:1646 */ break; case 148: -#line 859 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_INT64);;} +#line 859 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_INT64);} +#line 2641 "ncgeny.c" /* yacc.c:1646 */ break; case 149: -#line 861 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UINT64);;} +#line 861 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_UINT64);} +#line 2647 "ncgeny.c" /* yacc.c:1646 */ break; case 150: -#line 865 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_STRING);;} +#line 865 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=makeconstdata(NC_STRING);} +#line 2653 "ncgeny.c" /* yacc.c:1646 */ break; case 151: -#line 869 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} +#line 869 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=(yyvsp[0].constant);} +#line 2659 "ncgeny.c" /* yacc.c:1646 */ break; case 152: -#line 870 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} +#line 870 "ncgen.y" /* yacc.c:1646 */ + {(yyval.constant)=(yyvsp[0].constant);} +#line 2665 "ncgeny.c" /* yacc.c:1646 */ break; case 153: -#line 876 "ncgen.y" - {(yyval.sym)=(yyvsp[(1) - (1)].sym);;} +#line 876 "ncgen.y" /* yacc.c:1646 */ + {(yyval.sym)=(yyvsp[0].sym);} +#line 2671 "ncgeny.c" /* yacc.c:1646 */ break; -/* Line 1267 of yacc.c. */ -#line 2765 "ncgen.tab.c" +#line 2675 "ncgeny.c" /* yacc.c:1646 */ default: break; } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -2772,8 +2693,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); *++yyvsp = yyval; - - /* Now `shift' the result of the reduction. Determine what state + /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -2788,10 +2708,14 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); goto yynewstate; -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -2799,37 +2723,36 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; } +# undef YYSYNTAX_ERROR #endif } @@ -2837,24 +2760,24 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -2870,7 +2793,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule which action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -2883,38 +2806,37 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp); + yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ @@ -2938,7 +2860,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -2949,17 +2871,22 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* Do not reclaim the symbols of the rule which action triggered + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -2970,12 +2897,9 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } - - -#line 879 "ncgen.y" +#line 879 "ncgen.y" /* yacc.c:1906 */ #ifndef NO_STDARG @@ -3260,7 +3184,6 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst) int tf = 0; char* sdata = NULL; int idata = -1; - unsigned int udata = 0; if((GLOBAL_SPECIAL & tag) != 0) { if(vsym != NULL) { @@ -3671,4 +3594,3 @@ evaluate(Symbol* fcn, Datalist* arglist) done: return result; } - diff --git a/ncgen/ncgeny.h b/ncgen/ncgeny.h index 46842d41b1..3c59b97951 100644 --- a/ncgen/ncgeny.h +++ b/ncgen/ncgeny.h @@ -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 . */ /* 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,143 +30,102 @@ 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, - STRING_K = 270, - IDENT = 271, - TERMSTRING = 272, - CHAR_CONST = 273, - BYTE_CONST = 274, - SHORT_CONST = 275, - INT_CONST = 276, - INT64_CONST = 277, - UBYTE_CONST = 278, - USHORT_CONST = 279, - UINT_CONST = 280, - UINT64_CONST = 281, - FLOAT_CONST = 282, - DOUBLE_CONST = 283, - DIMENSIONS = 284, - VARIABLES = 285, - NETCDF = 286, - DATA = 287, - TYPES = 288, - COMPOUND = 289, - ENUM = 290, - OPAQUE_ = 291, - OPAQUESTRING = 292, - GROUP = 293, - PATH = 294, - FILLMARKER = 295, - NIL = 296, - _FILLVALUE = 297, - _FORMAT = 298, - _STORAGE = 299, - _CHUNKSIZES = 300, - _DEFLATELEVEL = 301, - _SHUFFLE = 302, - _ENDIANNESS = 303, - _NOFILL = 304, - _FLETCHER32 = 305, - _NCPROPS = 306, - _ISNETCDF4 = 307, - _SUPERBLOCK = 308, - _FILTER = 309, - DATASETID = 310 - }; + 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, + STRING_K = 270, + IDENT = 271, + TERMSTRING = 272, + CHAR_CONST = 273, + BYTE_CONST = 274, + SHORT_CONST = 275, + INT_CONST = 276, + INT64_CONST = 277, + UBYTE_CONST = 278, + USHORT_CONST = 279, + UINT_CONST = 280, + UINT64_CONST = 281, + FLOAT_CONST = 282, + DOUBLE_CONST = 283, + DIMENSIONS = 284, + VARIABLES = 285, + NETCDF = 286, + DATA = 287, + TYPES = 288, + COMPOUND = 289, + ENUM = 290, + OPAQUE_ = 291, + OPAQUESTRING = 292, + GROUP = 293, + PATH = 294, + FILLMARKER = 295, + NIL = 296, + _FILLVALUE = 297, + _FORMAT = 298, + _STORAGE = 299, + _CHUNKSIZES = 300, + _DEFLATELEVEL = 301, + _SHUFFLE = 302, + _ENDIANNESS = 303, + _NOFILL = 304, + _FLETCHER32 = 305, + _NCPROPS = 306, + _ISNETCDF4 = 307, + _SUPERBLOCK = 308, + _FILTER = 309, + DATASETID = 310 + }; #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 STRING_K 270 -#define IDENT 271 -#define TERMSTRING 272 -#define CHAR_CONST 273 -#define BYTE_CONST 274 -#define SHORT_CONST 275 -#define INT_CONST 276 -#define INT64_CONST 277 -#define UBYTE_CONST 278 -#define USHORT_CONST 279 -#define UINT_CONST 280 -#define UINT64_CONST 281 -#define FLOAT_CONST 282 -#define DOUBLE_CONST 283 -#define DIMENSIONS 284 -#define VARIABLES 285 -#define NETCDF 286 -#define DATA 287 -#define TYPES 288 -#define COMPOUND 289 -#define ENUM 290 -#define OPAQUE_ 291 -#define OPAQUESTRING 292 -#define GROUP 293 -#define PATH 294 -#define FILLMARKER 295 -#define NIL 296 -#define _FILLVALUE 297 -#define _FORMAT 298 -#define _STORAGE 299 -#define _CHUNKSIZES 300 -#define _DEFLATELEVEL 301 -#define _SHUFFLE 302 -#define _ENDIANNESS 303 -#define _NOFILL 304 -#define _FLETCHER32 305 -#define _NCPROPS 306 -#define _ISNETCDF4 307 -#define _SUPERBLOCK 308 -#define _FILTER 309 -#define DATASETID 310 - - - +/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 142 "ncgen.y" + +union YYSTYPE { +#line 142 "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 168 "ncgen.tab.h" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 + +#line 119 "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 */ From 3fa3d3f9f95634967ece6b18f9cf362438665ec5 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 5 Jan 2018 06:01:22 -0700 Subject: [PATCH 09/36] ported rename fix changes from branch ejh_fill_values for easy merging --- include/nc4internal.h | 9 +- libsrc4/nc4dim.c | 48 ++-- libsrc4/nc4internal.c | 111 +++++++-- libsrc4/nc4var.c | 49 ++-- nc_test4/tst_rename.c | 533 ++++++++++++++++++++++++++++++------------ 5 files changed, 540 insertions(+), 210 deletions(-) diff --git a/include/nc4internal.h b/include/nc4internal.h index bb1b889176..53375082c0 100644 --- a/include/nc4internal.h +++ b/include/nc4internal.h @@ -102,6 +102,12 @@ typedef enum {VAR, DIM, ATT} NC_OBJ_T; * as the netCDF dimid. */ #define NC_DIMID_ATT_NAME "_Netcdf4Dimid" +/** This is the name of the class HDF5 dimension scale attribute. */ +#define HDF5_DIMSCALE_CLASS_ATT_NAME "CLASS" + +/** This is the name of the name HDF5 dimension scale attribute. */ +#define HDF5_DIMSCALE_NAME_ATT_NAME "NAME" + /* Boolean type, to make the code easier to read */ typedef enum {NC_FALSE = 0, NC_TRUE = 1} nc_bool_t; @@ -126,7 +132,7 @@ typedef struct NC_DIM_INFO nc_bool_t unlimited; /* True if the dimension is unlimited */ nc_bool_t extended; /* True if the dimension needs to be extended */ nc_bool_t too_long; /* True if len is too big to fit in local size_t. */ - hid_t hdf_dimscaleid; + hid_t hdf_dimscaleid; /* Non-zero if a DIM_WITHOUT_VARIABLE dataset is in use (no coord var). */ HDF5_OBJID_T hdf5_objid; struct NC_VAR_INFO *coord_var; /* The coord var, if it exists. */ } NC_DIM_INFO_T; @@ -344,6 +350,7 @@ int nc4_convert_type(const void *src, void *dest, /* These functions do HDF5 things. */ int rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid); int rec_reattach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid); +int delete_existing_dimscale_dataset(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T *dim); int nc4_open_var_grp2(NC_GRP_INFO_T *grp, int varid, hid_t *dataset); int nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp, const size_t *countp, nc_type xtype, int is_long, void *op); diff --git a/libsrc4/nc4dim.c b/libsrc4/nc4dim.c index 3037318303..0841de3c80 100644 --- a/libsrc4/nc4dim.c +++ b/libsrc4/nc4dim.c @@ -1,3 +1,6 @@ +/* Copyright 2003-2018, University Corporation for Atmospheric + * Research. See the COPYRIGHT file for copying and redistribution + * conditions. */ /** * @file * @internal This file is part of netcdf-4, a netCDF-like interface @@ -6,9 +9,6 @@ * * This file handles the nc4 dimension functions. * - * Copyright 2003-5, University Corporation for Atmospheric Research. See - * the COPYRIGHT file for copying and redistribution conditions. - * * @author Ed Hartnett */ @@ -103,8 +103,7 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp) /* Find our global metadata structure. */ if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5))) return retval; - - assert(h5 && nc /*& grp*/); + assert(h5 && nc && grp); /* If the file is read-only, return an error. */ if (h5->no_write) @@ -327,9 +326,7 @@ NC4_rename_dim(int ncid, int dimid, const char *name) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5))) return retval; - - assert(nc); - assert(h5 && grp); + assert(nc && h5 && grp); /* Trying to write to a read-only file? No way, Jose! */ if (h5->no_write) @@ -352,33 +349,30 @@ NC4_rename_dim(int ncid, int dimid, const char *name) return NC_EBADDIM; dim = tmp_dim; - /* Check for renaming dimension w/o variable */ + /* Check for renaming dimension w/o variable. */ if (dim->hdf_dimscaleid) { /* Sanity check */ assert(!dim->coord_var); + LOG((3, "dim %s is a dim without variable", dim->name)); - /* Close the HDF5 dataset */ - if (H5Dclose(dim->hdf_dimscaleid) < 0) - return NC_EHDFERR; - dim->hdf_dimscaleid = 0; - - /* Now delete the dataset (it will be recreated later, if necessary) */ - if (H5Gunlink(grp->hdf_grpid, dim->name) < 0) - return NC_EDIMMETA; + /* Delete the dimscale-only dataset. */ + if ((retval = delete_existing_dimscale_dataset(grp, dimid, dim))) + return retval; } /* Give the dimension its new name in metadata. UTF8 normalization * has been done. */ - if(dim->name) - free(dim->name); + assert(dim->name); + free(dim->name); if (!(dim->name = malloc((strlen(norm_name) + 1) * sizeof(char)))) return NC_ENOMEM; strcpy(dim->name, norm_name); - dim->hash = hash_fast(norm_name, strlen(norm_name)); + LOG((3, "dim is now named %s", dim->name)); - /* Check if dimension was a coordinate variable, but names are different now */ + /* Check if dimension was a coordinate variable, but names are + * different now */ if (dim->coord_var && strcmp(dim->name, dim->coord_var->name)) { /* Break up the coordinate variable */ @@ -386,24 +380,24 @@ NC4_rename_dim(int ncid, int dimid, const char *name) return retval; } - /* Check if dimension should become a coordinate variable */ + /* Check if dimension should become a coordinate variable. */ if (!dim->coord_var) { NC_VAR_INFO_T *var; - /* Attempt to find a variable with the same name as the dimension in - * the current group. */ + /* Attempt to find a variable with the same name as the + * dimension in the current group. */ if ((retval = nc4_find_var(grp, dim->name, &var))) return retval; - /* Check if we found a variable and the variable has the dimension in - * index 0. */ + /* Check if we found a variable and the variable has the + * dimension in index 0. */ if (var && var->dim[0] == dim) { /* Sanity check */ assert(var->dimids[0] == dim->dimid); - /* Reform the coordinate variable */ + /* Reform the coordinate variable. */ if ((retval = nc4_reform_coord_var(grp, var, dim))) return retval; } diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index 41d0d7ba3a..d78489b809 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -1526,7 +1526,9 @@ nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp) while (dim) { LOG((4, "%s: deleting dim %s", __func__, dim->name)); - /* Close HDF5 dataset associated with this dim. */ + /* If this is a dim without a coordinate variable, then close + * the HDF5 DIM_WITHOUT_VARIABLE dataset associated with this + * dim. */ if (dim->hdf_dimscaleid && H5Dclose(dim->hdf_dimscaleid) < 0) return NC_EHDFERR; d = dim->l.next; @@ -1620,7 +1622,12 @@ nc4_att_list_del(NC_ATT_INFO_T **list, NC_ATT_INFO_T *att) /** * @internal Break a coordinate variable to separate the dimension and - * the variable. + * the variable. + * + * This is called from nc_rename_dim() and nc_rename_var(). In some + * renames, the coord variable must stay, but it is no longer a coord + * variable. This function changes a coord var into an ordinary + * variable. * * @param grp Pointer to group info struct. * @param coord_var Pointer to variable info struct. @@ -1628,7 +1635,7 @@ nc4_att_list_del(NC_ATT_INFO_T **list, NC_ATT_INFO_T *att) * * @return ::NC_NOERR No error. * @return ::NC_ENOMEM Out of memory. - * @author Quincey Koziol + * @author Quincey Koziol, Ed Hartnett */ int nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T *dim) @@ -1636,10 +1643,11 @@ nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T int retval = NC_NOERR; /* Sanity checks */ - assert(dim->coord_var == coord_var); - assert(coord_var->dim[0] == dim); - assert(coord_var->dimids[0] == dim->dimid); - assert(0 == dim->hdf_dimscaleid); + assert(grp && coord_var && dim && dim->coord_var == coord_var && + coord_var->dim[0] == dim && coord_var->dimids[0] == dim->dimid && + !dim->hdf_dimscaleid); + LOG((3, "%s dim %s was associated with var %s, but now has different name", + __func__, dim->name, coord_var->name)); /* If we're replacing an existing dimscale dataset, go to * every var in the file and detach this dimension scale. */ @@ -1647,17 +1655,23 @@ nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T dim->dimid, coord_var->hdf_datasetid))) return retval; - /* Allow attached dimscales to be tracked on the [former] coordinate variable */ + /* Allow attached dimscales to be tracked on the [former] + * coordinate variable */ if (coord_var->ndims) { - /* Coordinate variables shouldn't have dimscales attached */ - assert(NULL == coord_var->dimscale_attached); + /* Coordinate variables shouldn't have dimscales attached. */ + assert(!coord_var->dimscale_attached); /* Allocate space for tracking them */ - if (NULL == (coord_var->dimscale_attached = calloc(coord_var->ndims, sizeof(nc_bool_t)))) + if (!(coord_var->dimscale_attached = calloc(coord_var->ndims, + sizeof(nc_bool_t)))) return NC_ENOMEM; } + /* Remove the atts that go with being a coordinate var. */ + /* if ((retval = remove_coord_atts(coord_var->hdf_datasetid))) */ + /* return retval; */ + /* Detach dimension from variable */ coord_var->dimscale = NC_FALSE; dim->coord_var = NULL; @@ -1669,9 +1683,54 @@ nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T return NC_NOERR; } +/** + * @internal Delete an existing dimscale-only dataset. + * + * A dimscale-only HDF5 dataset is created when a dim is defined + * without an accompanying coordinate variable. + * + * Sometimes, during renames, or late creation of variables, an + * existing, dimscale-only dataset must be removed. This means + * detatching all variables that use the dataset, then closing and + * unlinking it. + * + * @param grp The grp of the dimscale-only dataset to be deleted, or a + * higher group in the heirarchy (ex. root group). + * @param dim Pointer to the dim with the dimscale-only dataset to be + * deleted. + * + * @return ::NC_NOERR No error. + * @return ::NC_EHDFERR HDF5 error. + * @author Ed Hartnett + */ +int +delete_existing_dimscale_dataset(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T *dim) +{ + int retval; + + assert(grp && dim); + LOG((2, "%s: deleting dimscale dataset %s dimid %d", __func__, dim->name, + dimid)); + + /* Detach dimscale from any variables using it */ + if ((retval = rec_detach_scales(grp, dimid, dim->hdf_dimscaleid)) < 0) + return retval; + + /* Close the HDF5 dataset */ + if (H5Dclose(dim->hdf_dimscaleid) < 0) + return NC_EHDFERR; + dim->hdf_dimscaleid = 0; + + /* Now delete the dataset. */ + if (H5Gunlink(grp->hdf_grpid, dim->name) < 0) + return NC_EHDFERR; + + return NC_NOERR; +} + /** * @internal Reform a coordinate variable from a dimension and a - * variable + * variable. * * @param grp Pointer to group info struct. * @param var Pointer to variable info struct. @@ -1683,8 +1742,12 @@ nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T int nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NC_DIM_INFO_T *dim) { + int need_to_reattach_scales = 0; int retval = NC_NOERR; + assert(grp && var && dim); + LOG((3, "%s: dim->name %s var->name %s", __func__, dim->name, var->name)); + /* Detach dimscales from the [new] coordinate variable */ if(var->dimscale_attached) { @@ -1694,6 +1757,7 @@ nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NC_DIM_INFO_T *dim) /* Loop over all dimensions for variable */ for (d = 0; d < var->ndims && !finished; d++) + { /* Is there a dimscale attached to this axis? */ if(var->dimscale_attached[d]) { @@ -1704,6 +1768,7 @@ nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NC_DIM_INFO_T *dim) NC_DIM_INFO_T *dim1; for (dim1 = g->dim; dim1 && !finished; dim1 = dim1->l.next) + { if (var->dimids[d] == dim1->dimid) { hid_t dim_datasetid; /* Dataset ID for dimension */ @@ -1713,24 +1778,36 @@ nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NC_DIM_INFO_T *dim) dim_datasetid = dim1->coord_var->hdf_datasetid; else dim_datasetid = dim1->hdf_dimscaleid; - assert(dim_datasetid > 0); - if (H5DSdetach_scale(var->hdf_datasetid, dim_datasetid, d) < 0) - BAIL(NC_EHDFERR); + + /* dim_datasetid may be 0 in some cases when + * renames of dims and vars are happening. In + * this case, the scale has already been + * detached. */ + if (dim_datasetid > 0) + { + LOG((3, "detaching scale from %s", var->name)); + if (H5DSdetach_scale(var->hdf_datasetid, dim_datasetid, d) < 0) + BAIL(NC_EHDFERR); + } var->dimscale_attached[d] = NC_FALSE; if (dims_detached++ == var->ndims) finished++; } + } } } + } /* next variable dimension */ /* Release & reset the array tracking attached dimscales */ free(var->dimscale_attached); var->dimscale_attached = NULL; + need_to_reattach_scales++; } - /* Use variable's dataset ID for the dimscale ID */ + /* Use variable's dataset ID for the dimscale ID. */ if (dim->hdf_dimscaleid && grp != NULL) { + LOG((3, "closing and unlinking dimscale dataset %s", dim->name)); if (H5Dclose(dim->hdf_dimscaleid) < 0) BAIL(NC_EHDFERR); dim->hdf_dimscaleid = 0; @@ -1746,7 +1823,7 @@ nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NC_DIM_INFO_T *dim) dim->coord_var = var; /* Check if this variable used to be a coord. var */ - if (var->was_coord_var && grp != NULL) + if (need_to_reattach_scales || (var->was_coord_var && grp != NULL)) { /* Reattach the scale everywhere it is used. */ /* (Recall that netCDF dimscales are always 1-D) */ diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index 36be4e7488..a0347ecab8 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -597,7 +597,7 @@ NC4_def_var(int ncid, const char *name, nc_type xtype, BAIL(NC_EBADTYPE); } - /* Add a new var. */ + /* Create a new var and fill in some HDF5 cache setting values. */ if ((retval = nc4_var_add(&var))) BAIL(retval); @@ -653,19 +653,23 @@ NC4_def_var(int ncid, const char *name, nc_type xtype, { var->dimscale = NC_TRUE; dim->coord_var = var; - - /* Use variable's dataset ID for the dimscale ID */ + + /* Use variable's dataset ID for the dimscale ID. So delete + * the HDF5 DIM_WITHOUT_VARIABLE dataset that was created for + * this dim. */ if (dim->hdf_dimscaleid) { /* Detach dimscale from any variables using it */ if ((retval = rec_detach_scales(grp, dimidsp[d], dim->hdf_dimscaleid)) < 0) BAIL(retval); - + + /* Close the HDF5 DIM_WITHOUT_VARIABLE dataset. */ if (H5Dclose(dim->hdf_dimscaleid) < 0) BAIL(NC_EHDFERR); dim->hdf_dimscaleid = 0; - - /* Now delete the dataset (it will be recreated later, if necessary) */ + + /* Now delete the DIM_WITHOUT_VARIABLE dataset (it will be + * recreated later, if necessary). */ if (H5Gunlink(grp->hdf_grpid, dim->name) < 0) BAIL(NC_EDIMMETA); } @@ -686,7 +690,7 @@ NC4_def_var(int ncid, const char *name, nc_type xtype, } /* Determine default chunksizes for this variable. (Even for - * variables which may be contiguous. */ + * variables which may be contiguous.) */ LOG((4, "allocating array of %d size_t to hold chunksizes for var %s", var->ndims, var->name)); if (var->ndims) @@ -743,8 +747,12 @@ NC4_def_var(int ncid, const char *name, nc_type xtype, } /** - * @internal Get all the information about a variable. Pass NULL for whatever - * you don't care about. + * @internal Get all the information about a variable. Pass NULL for + * whatever you don't care about. This is the internal function called + * by nc_inq_var(), nc_inq_var_deflate(), nc_inq_var_fletcher32(), + * nc_inq_var_chunking(), nc_inq_var_chunking_ints(), + * nc_inq_var_fill(), nc_inq_var_endian(), nc_inq_var_filter(), and + * nc_inq_var_szip(). * * @param ncid File ID. * @param varid Variable ID. @@ -1567,14 +1575,16 @@ NC4_rename_var(int ncid, int varid, const char *name) int retval = NC_NOERR; int i; - LOG((2, "%s: ncid 0x%x varid %d name %s", - __func__, ncid, varid, name)); + if (!name) + return NC_EINVAL; + + LOG((2, "%s: ncid 0x%x varid %d name %s", __func__, ncid, varid, + name)); /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5))) return retval; - - assert(h5); + assert(h5 && grp && h5); /* Is the new name too long? */ if (strlen(name) > NC_MAX_NAME) @@ -1612,9 +1622,19 @@ NC4_rename_var(int ncid, int varid, const char *name) return NC_ENOTINDEFINE; /* Change the HDF5 file, if this var has already been created - there. */ + there. Should we check here to ensure there is not already a + dimscale dataset of name name??? */ if (var->created) { + /* Is there an existing dimscale-only dataset of this name? If + * so, it must be deleted. */ + if (var->ndims && var->dim[0]->hdf_dimscaleid) + { + if ((retval = delete_existing_dimscale_dataset(grp, var->dim[0]->dimid, var->dim[0]))) + return retval; + } + + LOG((3, "Moving dataset %s to %s", var->name, name)); if (H5Gmove(grp->hdf_grpid, var->name, name) < 0) BAIL(NC_EHDFERR); } @@ -1625,6 +1645,7 @@ NC4_rename_var(int ncid, int varid, const char *name) return NC_ENOMEM; strcpy(var->name, name); var->hash = nn_hash; + LOG((3, "var is now %s", var->name)); /* Check if this was a coordinate variable previously, but names are different now */ if (var->dimscale && strcmp(var->name, var->dim[0]->name)) diff --git a/nc_test4/tst_rename.c b/nc_test4/tst_rename.c index 6c12d645d8..87ba17ea35 100644 --- a/nc_test4/tst_rename.c +++ b/nc_test4/tst_rename.c @@ -1,167 +1,398 @@ /* - * Demonstrate netcdf-4 rename bug. + * Test renames of vars and dims. It's a surprisingly tricky business. + * + * Quincey Koziol, Ed Hartnett */ -#include -#include -#include -#include - -/* On error, prints line number and file of test program. */ -#define ERR do { \ -fflush(stdout); \ -fprintf(stderr, "Unexpected result, %s, line: %d\n", \ - __FILE__, __LINE__); \ -return 2; \ -} while (0) - -#define FILE_NAME3 "tst_rnfix3.nc" -#define FILE_NAME4 "tst_rnfix4.nc" -#define ODIM_NAME "lat" /* name for coord dim */ -#define NDIM_NAME "tal" /* new name for coord dim */ -#define OVAR_NAME "lat" /* name for coord var */ -#define NVAR_NAME "tal" /* new name for coord var */ -#define OVAR2_NAME "rh" /* name for non-coord var that uses coord dim */ -#define VAR_RANK 1 /* all vars in this test are of same rank */ -#define DIM_LEN 2 /* all dims in this test are of same len */ +#include "nc_tests.h" +#include "err_macros.h" + +#define FILE_NAME3 "tst_rename_fix3.nc" +#define FILE_NAME4 "tst_rename_fix4.nc" +#define ODIM_NAME "lat" /* name for coord dim */ +#define LAT "lat" +#define TAL "tal" +#define TAL1 "tal1" +#define TAL2 "tal2" +#define RH "rh" +#define NDIM_NAME "tal" /* new name for coord dim */ +#define OVAR_NAME "lat" /* name for coord var */ +#define NVAR_NAME "tal" /* new name for coord var */ +#define OVAR2_NAME "rh" /* name for non-coord var that uses coord dim */ +#define VAR_RANK 1 /* all vars in this test are of same rank */ +#define DIM_LEN 2 /* all dims in this test are of same len */ + +/* Test data. */ +int lats[DIM_LEN] = {-90, 90}; +float rh[DIM_LEN] = {0.25, 0.75}; /* For renaming tests. Create small test file of specified format * with a coordinate dimension, corresponding coordinate variable, and - * a non-coordinate variable that uses the coordinate dimension. - */ + * a non-coordinate variable that uses the coordinate dimension. */ int -create_test_file( - char *path, /* filename */ - int format /* NC_FORMAT_CLASSIC, NC_FORMAT_64BIT, - NC_FORMAT_NETCDF4, or NC_FORMAT_NETCDF4_CLASSIC */ - ) +create_test_file(char *path, int format) { - int ncid, dimid, varid, var2id; - int dims[VAR_RANK]; - int lats[DIM_LEN] = {-90, 90}; - float rh[DIM_LEN] = {0.25, 0.75}; - switch (format) { - case (NC_FORMAT_CLASSIC): - if (nc_create(path, 0, &ncid)) ERR; - break; - case (NC_FORMAT_64BIT_OFFSET): - if (nc_create(path, NC_64BIT_OFFSET, &ncid)) ERR; - break; - case (NC_FORMAT_NETCDF4): - if (nc_create(path, NC_NETCDF4, &ncid)) ERR; - break; - case(NC_FORMAT_NETCDF4_CLASSIC): - if (nc_create(path, NC_NETCDF4 | NC_CLASSIC_MODEL, &ncid)) ERR; - break; - default: - ERR; - return NC_ENOTNC; - } - if (nc_def_dim(ncid, ODIM_NAME, DIM_LEN, &dimid)) ERR; - dims[0] = dimid; - if (nc_def_var(ncid, OVAR_NAME, NC_INT, VAR_RANK, dims, &varid)) ERR; - if (nc_def_var(ncid, OVAR2_NAME, NC_FLOAT, VAR_RANK, dims, &var2id)) ERR; - if (nc_enddef(ncid)) ERR; /* not necessary for netCDF-4 files */ - if (nc_put_var_int(ncid, varid, lats)) ERR; - if (nc_put_var_float(ncid, var2id, rh)) ERR; - if (nc_close(ncid)) ERR; - return 0; + int ncid, varid, var2id; + int dims[VAR_RANK]; + + if (nc_set_default_format(format, NULL)) ERR; + if (nc_create(path, 0, &ncid)) ERR; + if (nc_def_dim(ncid, LAT, DIM_LEN, &dims[0])) ERR; + if (nc_def_var(ncid, LAT, NC_INT, VAR_RANK, dims, &varid)) ERR; + if (nc_def_var(ncid, RH, NC_FLOAT, VAR_RANK, dims, &var2id)) ERR; + if (nc_enddef(ncid)) ERR; /* not necessary for netCDF-4 files */ + if (nc_put_var_int(ncid, varid, lats)) ERR; + if (nc_put_var_float(ncid, var2id, rh)) ERR; + if (nc_close(ncid)) ERR; + return 0; } - + +/* Check the file that was produced by create_test_file(). Only the + * names have been changed... */ +int +check_file(int ncid, char *var0_name, char *var1_name, char *dim_name) +{ + int varid; + int var2id; + int dimid; + int lats_in[DIM_LEN]; + float rh_in[DIM_LEN]; + int ii; + + /* printf("checking for vars %s and %s, dim %s\n", var0_name, var1_name, */ + /* dim_name); */ + + /* Check vars. Ids will change because of rename. */ + if (nc_inq_varid(ncid, var0_name, &varid)) ERR; + if (nc_inq_varid(ncid, var1_name, &var2id)) ERR; + + /* Check dim. */ + if (nc_inq_dimid(ncid, dim_name, &dimid)) ERR; + if (dimid != 0) ERR; + + /* Check the lats. */ + if (nc_get_var_int(ncid, varid, lats_in)) ERR; + for (ii = 0; ii < DIM_LEN; ii++) + if (lats_in[ii] != lats[ii]) + ERR; + + /* Check the RH. */ + if (nc_get_var_float(ncid, var2id, rh_in)) ERR; + for (ii = 0; ii < DIM_LEN; ii++) + if (rh_in[ii] != rh[ii]) + ERR; + + return 0; +} + +/* Check the file created in Charlie Zender's test. See github + * #597. */ +int +check_charlies_file(char *file, char *dim_name, char *var_name) +{ + int ncid; + int varid, dimid; + + if (nc_open(file, 0, &ncid)) ERR; + if (nc_inq_varid(ncid, var_name, &varid)) ERR; + if (nc_inq_dimid(ncid, dim_name, &dimid)) ERR; + if (varid || dimid) ERR; + if (nc_close(ncid)) ERR; + return NC_NOERR; +} + int main(int argc, char **argv) { #define NUM_FORMATS 2 - int formats[NUM_FORMATS] = {NC_FORMAT_NETCDF4, NC_FORMAT_NETCDF4_CLASSIC}; - char *fmt_names[] = {"netCDF-4", "netCDF-4 classic model"}; - char *file_names[] = {FILE_NAME3, FILE_NAME4}; - int format; + int formats[NUM_FORMATS] = {NC_FORMAT_NETCDF4, NC_FORMAT_NETCDF4_CLASSIC}; + char *fmt_names[] = {"netCDF-4", "netCDF-4 classic model"}; + char *file_names[] = {FILE_NAME3, FILE_NAME4}; + int format; - fprintf(stderr,"*** Testing netcdf rename bugs and fixes.\n"); + fprintf(stderr,"*** Testing netcdf rename bugs and fixes.\n"); + nc_set_log_level(5); - for(format = 0; format < NUM_FORMATS; format++) - { + for (format = 0; format < NUM_FORMATS; format++) + /* for (format = 0; format < 1; format++) */ + { int ncid, dimid, varid, var2id; int lats[DIM_LEN] = {-90, 90}; int lats_in[DIM_LEN]; float rh[DIM_LEN] = {0.25, 0.75}; float rh_in[DIM_LEN]; int ii; - - fprintf(stderr,"*** Test renaming coordinate variable and its dimension for %s...\n", - fmt_names[format]); - if (create_test_file(file_names[format], formats[format])) ERR; - if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; - if (nc_inq_dimid(ncid, ODIM_NAME, &dimid)) ERR; - if (nc_inq_varid(ncid, OVAR_NAME, &varid)) ERR; - if (nc_inq_varid(ncid, OVAR2_NAME, &var2id)) ERR; - if (nc_redef(ncid)) ERR; /* omitting this and nc_enddef call eliminates bug */ - if (nc_rename_dim(ncid, dimid, NDIM_NAME)) ERR; - if (nc_rename_var(ncid, varid, NVAR_NAME)) ERR; - if (nc_enddef(ncid)) ERR; - if (nc_get_var_int(ncid, varid, lats_in)) ERR; - for (ii = 0; ii < DIM_LEN; ii++) { - if (lats_in[ii] != lats[ii]) - fprintf(stderr, "\tlats_in[%d] is %d, should be %d\n", ii, lats_in[ii], lats[ii]); + + fprintf(stderr,"*** Test Charlie's test for renaming..."); + { +#define CHARLIE_TEST_FILE "tst_charlie_rename_coord_dim.nc" +#define LON "lon" +#define LONGITUDE "longitude" +#define DIM1_LEN 4 +#define NDIM1 1 + int ncid, dimid, varid; + float data[DIM1_LEN] = {0, 90.0, 180.0, 270.0}; + + /* Create a nice, simple file. This file will contain one + * dataset, "lon", which is a dimscale. */ + if (nc_create(CHARLIE_TEST_FILE, NC_NETCDF4, &ncid)) ERR; + if (nc_def_dim(ncid, LON, DIM1_LEN, &dimid)) ERR; + if (nc_def_var(ncid, LON, NC_FLOAT, NDIM1, &dimid, &varid)) ERR; + if (nc_enddef(ncid)) ERR; + if (nc_put_var_float(ncid, varid, data)) ERR; + if (nc_close(ncid)) ERR; + + /* Check the file. */ + if (check_charlies_file(CHARLIE_TEST_FILE, LON, LON)) ERR; + + /* Open the file and rename the dimension. This will cause + * lon to stop being a coord var and dimscale, and create a + * new dimscale without var dataset "longitude". Dataset + * "lon" will point to "longitude" as its dimscale. */ + if (nc_open(CHARLIE_TEST_FILE, NC_WRITE, &ncid)) ERR; + if (nc_redef(ncid)) ERR; + if (nc_rename_dim(ncid, 0, LONGITUDE)) ERR; + if (nc_enddef(ncid)) ERR; + if (nc_close(ncid)) ERR; + + /* Reopen the file to check. */ + if (check_charlies_file(CHARLIE_TEST_FILE, LONGITUDE, LON)) ERR; + + /* Open the file and rename the variable. This will remove + * the dimscale-only dataset "longitude" and rename the + * extisting dataset "lon" to "longitude". Variable + * "longitude" will become a coordinate var. */ + /* if (nc_open(CHARLIE_TEST_FILE, NC_WRITE, &ncid)) ERR; */ + /* if (nc_redef(ncid)) ERR; */ + /* if (nc_rename_var(ncid, 0, LONGITUDE)) ERR; */ + /* if (nc_enddef(ncid)) ERR; */ + /* if (nc_close(ncid)) ERR; */ + + /* Reopen the file to check. */ + /* if (check_charlies_file(CHARLIE_TEST_FILE, LONGITUDE, LONGITUDE)) ERR; */ } - if (nc_get_var_float(ncid, var2id, rh_in)) ERR; - for (ii = 0; ii < DIM_LEN; ii++) { - if (rh_in[ii] != rh[ii]) - fprintf(stderr, "\trh_in[%d] is %g, should be %g\n", ii, rh_in[ii], rh[ii]); + SUMMARIZE_ERR; + + printf("*** testing renaming before enddef for %s...", fmt_names[format]); + { + int ncid, varid, var2id; + int dimid; + + if (nc_set_default_format(formats[format], NULL)) ERR; + if (nc_create(file_names[format], 0, &ncid)) ERR; + if (nc_def_dim(ncid, LAT, DIM_LEN, &dimid)) ERR; + if (nc_def_var(ncid, LAT, NC_INT, VAR_RANK, &dimid, &varid)) ERR; + if (nc_def_var(ncid, RH, NC_FLOAT, VAR_RANK, &dimid, &var2id)) ERR; + + /* Now rename the dim. */ + if (nc_rename_dim(ncid, dimid, TAL)) ERR; + if (nc_rename_var(ncid, varid, TAL)) ERR; + + if (nc_enddef(ncid)) ERR; /* not necessary for netCDF-4 files */ + if (nc_put_var_int(ncid, varid, lats)) ERR; + if (nc_put_var_float(ncid, var2id, rh)) ERR; + if (nc_close(ncid)) ERR; + + /* Reopen and check. */ + if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; + if (check_file(ncid, TAL, RH, TAL)) ERR; + if (nc_close(ncid)) ERR; } - if (nc_close(ncid)) ERR; - - fprintf(stderr,"*** Test renaming just coordinate variable for %s...\n", - fmt_names[format]); - if (create_test_file(file_names[format], formats[format])) ERR; - if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; - if (nc_inq_dimid(ncid, ODIM_NAME, &dimid)) ERR; - if (nc_inq_varid(ncid, OVAR_NAME, &varid)) ERR; - if (nc_inq_varid(ncid, OVAR2_NAME, &var2id)) ERR; - if (nc_redef(ncid)) ERR; /* omitting this and nc_enddef call eliminates bug */ - /* if (nc_rename_dim(ncid, dimid, NDIM_NAME)) ERR; */ - if (nc_rename_var(ncid, varid, NVAR_NAME)) ERR; - if (nc_enddef(ncid)) ERR; - if (nc_get_var_int(ncid, varid, lats_in)) ERR; - for (ii = 0; ii < DIM_LEN; ii++) { - if (lats_in[ii] != lats[ii]) - fprintf(stderr, "\tlats_in[%d] is %d, should be %d\n", ii, lats_in[ii], lats[ii]); + SUMMARIZE_ERR; + + printf("*** testing renaming after enddef for %s...", fmt_names[format]); + { + int ncid, varid, var2id; + int dimid; + + if (nc_set_default_format(formats[format], NULL)) ERR; + if (nc_create(file_names[format], 0, &ncid)) ERR; + if (nc_def_dim(ncid, LAT, DIM_LEN, &dimid)) ERR; + if (nc_def_var(ncid, TAL1, NC_INT, VAR_RANK, &dimid, &varid)) ERR; + if (nc_def_var(ncid, RH, NC_FLOAT, VAR_RANK, &dimid, &var2id)) ERR; + if (nc_enddef(ncid)) ERR; + if (nc_redef(ncid)) ERR; + + if (nc_rename_var(ncid, varid, TAL2)) ERR; + if (nc_rename_dim(ncid, dimid, TAL)) ERR; + if (nc_enddef(ncid)) ERR; + + if (nc_put_var_int(ncid, varid, lats)) ERR; + if (nc_put_var_float(ncid, var2id, rh)) ERR; + if (nc_close(ncid)) ERR; + + /* Reopen and check. */ + if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; + if (check_file(ncid, TAL2, RH, TAL)) ERR; + if (nc_close(ncid)) ERR; } - if (nc_get_var_float(ncid, var2id, rh_in)) ERR; - for (ii = 0; ii < DIM_LEN; ii++) { - if (rh_in[ii] != rh[ii]) - fprintf(stderr, "\trh_in[%d] is %g, should be %g\n", ii, rh_in[ii], rh[ii]); + SUMMARIZE_ERR; + printf("*** testing more renaming after enddef for %s...", fmt_names[format]); + { + int ncid, varid, var2id; + int dimid; + + /* This will create a HDF5 file with two datasets, RH, and + * LAT. LAT is a dimscale. RH points to dimscale LAT. Life is + * so simple. */ + if (nc_set_default_format(formats[format], NULL)) ERR; + if (nc_create(file_names[format], 0, &ncid)) ERR; + if (nc_def_dim(ncid, LAT, DIM_LEN, &dimid)) ERR; + if (nc_def_var(ncid, LAT, NC_INT, VAR_RANK, &dimid, &varid)) ERR; + if (nc_def_var(ncid, RH, NC_FLOAT, VAR_RANK, &dimid, &var2id)) ERR; + if (nc_enddef(ncid)) ERR; + if (nc_redef(ncid)) ERR; + + /* This will cause dataset LAT to be renamed TAL. It will no + * longer be a dimscale. Dataset LAT will be created as a + * dimscale without a variable. Datasets RH and TAL will + * re-point to (new) dimscale LAT. */ + if (nc_rename_var(ncid, varid, TAL)) ERR; + if (nc_enddef(ncid)) ERR; + + if (nc_redef(ncid)) ERR; + + /* This will cause dimscale-only dataset LAT to be + * deleted. Existing dataset TAL will become the dimscale + * dataset. Dataset RH will re-point to dimscale TAL. */ + if (nc_rename_dim(ncid, dimid, TAL)) ERR; + if (nc_enddef(ncid)) ERR; + + /* Varids have changed, so get them again. */ + if (nc_inq_varid(ncid, TAL, &varid)) ERR; + if (nc_inq_varid(ncid, RH, &var2id)) ERR; + + /* Write some data. */ + if (nc_put_var_int(ncid, varid, lats)) ERR; + if (nc_put_var_float(ncid, var2id, rh)) ERR; + if (nc_close(ncid)) ERR; + + /* Reopen and check. */ + if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; + if (check_file(ncid, TAL, RH, TAL)) ERR; + if (nc_close(ncid)) ERR; } - if (nc_close(ncid)) ERR; + SUMMARIZE_ERR; + + printf("*** testing renaming after enddef for %s...", fmt_names[format]); + { + int ncid, varid, var2id; + int dimid; + + if (nc_set_default_format(formats[format], NULL)) ERR; + if (nc_create(file_names[format], 0, &ncid)) ERR; + if (nc_def_dim(ncid, LAT, DIM_LEN, &dimid)) ERR; + if (nc_def_var(ncid, LAT, NC_INT, VAR_RANK, &dimid, &varid)) ERR; + if (nc_def_var(ncid, RH, NC_FLOAT, VAR_RANK, &dimid, &var2id)) ERR; + if (nc_enddef(ncid)) ERR; /* not necessary for netCDF-4 files */ + if (nc_redef(ncid)) ERR; /* not necessary for netCDF-4 files */ + /* Now rename the dim. */ + if (nc_rename_dim(ncid, dimid, TAL)) ERR; + if (nc_rename_var(ncid, varid, TAL)) ERR; + if (nc_enddef(ncid)) ERR; /* not necessary for netCDF-4 files */ + + if (nc_put_var_int(ncid, varid, lats)) ERR; + if (nc_put_var_float(ncid, var2id, rh)) ERR; + if (nc_close(ncid)) ERR; + + /* Reopen and check. */ + if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; + /* if (check_file(ncid, LAT, RH, TAL)) ERR; */ + /* if (check_file(ncid, TAL, RH, TAL)) ERR; */ + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; - fprintf(stderr,"*** Test renaming just coordinate dimension for %s...\n", - fmt_names[format]); - if (create_test_file(file_names[format], formats[format])) ERR; - if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; - if (nc_inq_dimid(ncid, ODIM_NAME, &dimid)) ERR; - if (nc_inq_varid(ncid, OVAR_NAME, &varid)) ERR; - if (nc_inq_varid(ncid, OVAR2_NAME, &var2id)) ERR; - if (nc_redef(ncid)) ERR; /* omitting this and nc_enddef call eliminates bug */ - if (nc_rename_dim(ncid, dimid, NDIM_NAME)) ERR; - /* if (nc_rename_var(ncid, varid, NVAR_NAME)) ERR; */ - if (nc_enddef(ncid)) ERR; - if (nc_get_var_int(ncid, varid, lats_in)) ERR; - for (ii = 0; ii < DIM_LEN; ii++) { - if (lats_in[ii] != lats[ii]) - fprintf(stderr, "\tlats_in[%d] is %d, should be %d\n", ii, lats_in[ii], lats[ii]); + printf("*** testing renaming after enddef for %s...", fmt_names[format]); + { + /* Create a file with datasets LAT, RH. LAT is a dimscale. RH + * points to LAT. */ + if (create_test_file(file_names[format], formats[format])) ERR; + if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; + if (nc_inq_dimid(ncid, LAT, &dimid)) ERR; + if (nc_inq_varid(ncid, LAT, &varid)) ERR; + if (nc_inq_varid(ncid, RH, &var2id)) ERR; + if (check_file(ncid, LAT, RH, LAT)) ERR; + if (nc_redef(ncid)) ERR; + + /* Rename the dim. This creates new dataset TAL. LAT is no + * longer a dimscale. RH is repointed to TAL. LAT is pointed + * to TAL. */ + if (nc_rename_dim(ncid, dimid, TAL)) ERR; + if (nc_enddef(ncid)) ERR; + if (nc_redef(ncid)) ERR; + + /* Rename the var. This will remove dimscale-only dataset + * TAL. LAT will become a dimscale. RH will point to LAT. */ + if (nc_rename_var(ncid, varid, TAL)) ERR; + if (nc_enddef(ncid)) ERR; + /* if (check_file(ncid, LAT, RH, TAL)) ERR; */ + if (nc_close(ncid)) ERR; + + if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; + /* if (check_file(ncid, LAT, RH, TAL)) ERR; */ + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; + + fprintf(stderr,"*** Test renaming just coordinate variable for %s...", + fmt_names[format]); + { + if (create_test_file(file_names[format], formats[format])) ERR; + if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; + if (nc_inq_dimid(ncid, ODIM_NAME, &dimid)) ERR; + if (nc_inq_varid(ncid, OVAR_NAME, &varid)) ERR; + if (nc_inq_varid(ncid, OVAR2_NAME, &var2id)) ERR; + if (nc_redef(ncid)) ERR; /* omitting this and nc_enddef call eliminates bug */ + /* if (nc_rename_dim(ncid, dimid, NDIM_NAME)) ERR; */ + if (nc_rename_var(ncid, varid, NVAR_NAME)) ERR; + if (nc_enddef(ncid)) ERR; + if (nc_get_var_int(ncid, varid, lats_in)) ERR; + for (ii = 0; ii < DIM_LEN; ii++) { + if (lats_in[ii] != lats[ii]) + fprintf(stderr, "\tlats_in[%d] is %d, should be %d\n", ii, lats_in[ii], lats[ii]); + } + if (nc_get_var_float(ncid, var2id, rh_in)) ERR; + for (ii = 0; ii < DIM_LEN; ii++) { + if (rh_in[ii] != rh[ii]) + fprintf(stderr, "\trh_in[%d] is %g, should be %g\n", ii, rh_in[ii], rh[ii]); + } + if (nc_close(ncid)) ERR; } - if (nc_get_var_float(ncid, var2id, rh_in)) ERR; - for (ii = 0; ii < DIM_LEN; ii++) { - if (rh_in[ii] != rh[ii]) - fprintf(stderr, "\trh_in[%d] is %g, should be %g\n", ii, rh_in[ii], rh[ii]); + SUMMARIZE_ERR; + + fprintf(stderr,"*** Test renaming just coordinate dimension for %s...", + fmt_names[format]); + { + if (create_test_file(file_names[format], formats[format])) ERR; + if (nc_open(file_names[format], NC_WRITE, &ncid)) ERR; + if (nc_inq_dimid(ncid, ODIM_NAME, &dimid)) ERR; + if (nc_inq_varid(ncid, OVAR_NAME, &varid)) ERR; + if (nc_inq_varid(ncid, OVAR2_NAME, &var2id)) ERR; + if (nc_redef(ncid)) ERR; /* omitting this and nc_enddef call eliminates bug */ + if (nc_rename_dim(ncid, dimid, NDIM_NAME)) ERR; + /* if (nc_rename_var(ncid, varid, NVAR_NAME)) ERR; */ + if (nc_enddef(ncid)) ERR; + if (nc_get_var_int(ncid, varid, lats_in)) ERR; + for (ii = 0; ii < DIM_LEN; ii++) { + if (lats_in[ii] != lats[ii]) + fprintf(stderr, "\tlats_in[%d] is %d, should be %d\n", ii, lats_in[ii], lats[ii]); + } + if (nc_get_var_float(ncid, var2id, rh_in)) ERR; + for (ii = 0; ii < DIM_LEN; ii++) { + if (rh_in[ii] != rh[ii]) + fprintf(stderr, "\trh_in[%d] is %g, should be %g\n", ii, rh_in[ii], rh[ii]); + } + if (nc_close(ncid)) ERR; } - if (nc_close(ncid)) ERR; + SUMMARIZE_ERR; - if (formats[format] == NC_FORMAT_NETCDF4) { - printf("*** Test renaming attribute in sub-group for %s...\n", + if (formats[format] == NC_FORMAT_NETCDF4) + { + printf("*** Test renaming attribute in sub-group for %s...", fmt_names[format]); - { + { #define DIMNAME "lon" #define VARNAME "lon" #define G1_VARNAME "lon" @@ -199,16 +430,16 @@ main(int argc, char **argv) if (nc_enddef (ncid)) ERR; /* write variable data */ { - float lon_data[4] = {0, 90, 180, 270}; - size_t start[] = {0}; - size_t count[] = {4}; - if (nc_put_vara(ncid, lon_var, start, count, lon_data)) ERR; + float lon_data[4] = {0, 90, 180, 270}; + size_t start[] = {0}; + size_t count[] = {4}; + if (nc_put_vara(ncid, lon_var, start, count, lon_data)) ERR; } { - float g1_lon_data[4] = {0, 90, 180, 270}; - size_t start[] = {0}; - size_t count[] = {4}; - if (nc_put_vara(g1_grp, g1_lon_var, start, count, g1_lon_data)) ERR; + float g1_lon_data[4] = {0, 90, 180, 270}; + size_t start[] = {0}; + size_t count[] = {4}; + if (nc_put_vara(g1_grp, g1_lon_var, start, count, g1_lon_data)) ERR; } if (nc_close(ncid)) ERR; @@ -223,17 +454,17 @@ main(int argc, char **argv) has expected value */ { - if (nc_open(file_names[format], NC_NOWRITE, &ncid)) ERR; - if (nc_inq_grp_ncid(ncid, GRP_NAME, &g1_grp)) ERR; - if (nc_inq_varid(g1_grp, VARNAME, &g1_lon_var)) ERR; - if (nc_get_att_text(g1_grp, g1_lon_var, NEW_NAME, data_in)) ERR; - if (strncmp(CONTENTS, data_in, strlen(CONTENTS))) ERR; - if (nc_close(ncid)) ERR; + if (nc_open(file_names[format], NC_NOWRITE, &ncid)) ERR; + if (nc_inq_grp_ncid(ncid, GRP_NAME, &g1_grp)) ERR; + if (nc_inq_varid(g1_grp, VARNAME, &g1_lon_var)) ERR; + if (nc_get_att_text(g1_grp, g1_lon_var, NEW_NAME, data_in)) ERR; + if (strncmp(CONTENTS, data_in, strlen(CONTENTS))) ERR; + if (nc_close(ncid)) ERR; } free(data_in); - } + } + SUMMARIZE_ERR; } - } - - return(0); + } /* next format */ + FINAL_RESULTS; } From cdec7074290f55c1c3ef2f94f463daa36021b00e Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Thu, 11 Jan 2018 10:28:18 -0700 Subject: [PATCH 10/36] Eliminate potential buffer overflow I realize strncat is being eliminated, but in case the elimination isn't done prior to release, this patch should be applied. --- libdispatch/dutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdispatch/dutil.c b/libdispatch/dutil.c index bb612c94c1..7ec8625a6e 100644 --- a/libdispatch/dutil.c +++ b/libdispatch/dutil.c @@ -209,7 +209,7 @@ NC_mktmp(const char* base) cvtpath = NCpathcvt(base); strncpy(tmp,cvtpath,sizeof(tmp)); nullfree(cvtpath); - strncat(tmp, "XXXXXX", sizeof(tmp)); + strncat(tmp, "XXXXXX", sizeof(tmp) - strlen(tmp) - 1); #ifdef HAVE_MKSTEMP /* Note Potential problem: old versions of this function From 1b68ca28f79a108b6fe5a514977e4d2f300782ae Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Thu, 11 Jan 2018 10:31:13 -0700 Subject: [PATCH 11/36] Eliminate warning from clang compilers. Eliminate this warning from clang: ``` TPL/netcdf/netcdf-c/libdispatch/ncuri.c:914:31: warning: for loop has empty body [-Wempty-body] for(p=sp,q=sp+1;(*p++=*q++);); ^ TPL/netcdf/netcdf-c/libdispatch/ncuri.c:914:31: note: put the semicolon on a separate line to silence this warning 1 warning generated. ``` --- libdispatch/ncuri.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c index 83a065bb4f..1e7340aab0 100644 --- a/libdispatch/ncuri.c +++ b/libdispatch/ncuri.c @@ -911,7 +911,8 @@ collectprefixparams(char* text, char** nextp) for(;;) { char* p; char* q; /* by construction, here we are at an LBRACKET: compress it out */ - for(p=sp,q=sp+1;(*p++=*q++);); + for(p=sp,q=sp+1;(*p++=*q++);) + ; /* locate the next RRACKET */ ep = nclocate(sp,RBRACKETSTR); if(ep == NULL) break;/* we are done */ From 4d9fb6765b0232d9485d7ab2ad57801fadb1e92b Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Thu, 11 Jan 2018 10:41:53 -0700 Subject: [PATCH 12/36] Make it more clear that limits are not enforced anymore Make it clear that NC_MAX_DIMS, NC_MAX_VARS, and NC_MAX_ATTRS limits are not enforced after netcdf-4.5.0 to avoid confusion --- include/netcdf.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/netcdf.h b/include/netcdf.h index fac6f63d8e..6d9ca157be 100644 --- a/include/netcdf.h +++ b/include/netcdf.h @@ -254,11 +254,14 @@ These maximums are not used for netCDF-4/HDF5 files unless they were created with the ::NC_CLASSIC_MODEL flag. As a rule, NC_MAX_VAR_DIMS <= NC_MAX_DIMS. + +NOTE: The NC_MAX_DIMS, NC_MAX_ATTRS, and NC_MAX_VARS limits + are *not* enforced after version 4.5.0 */ /**@{*/ -#define NC_MAX_DIMS 1024 -#define NC_MAX_ATTRS 8192 -#define NC_MAX_VARS 8192 +#define NC_MAX_DIMS 1024 /* not enforced after 4.5.0 */ +#define NC_MAX_ATTRS 8192 /* not enforced after 4.5.0 */ +#define NC_MAX_VARS 8192 /* not enforced after 4.5.0 */ #define NC_MAX_NAME 256 #define NC_MAX_VAR_DIMS 1024 /**< max per variable dimensions */ /**@}*/ From de150aec4eaf27bd7672d4ea6f98e8f59675f795 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 08:03:15 -0700 Subject: [PATCH 13/36] clean up of test --- nc_test4/run_par_test.sh | 1 + nc_test4/tst_simplerw_coll_r.c | 288 ++++++++++++++++----------------- 2 files changed, 145 insertions(+), 144 deletions(-) diff --git a/nc_test4/run_par_test.sh b/nc_test4/run_par_test.sh index 5c5ab5b759..d1135c44a5 100755 --- a/nc_test4/run_par_test.sh +++ b/nc_test4/run_par_test.sh @@ -36,3 +36,4 @@ echo echo "Parallel I/O test for Collective I/O, contributed by HDF Group." mpiexec -n 1 ./tst_simplerw_coll_r mpiexec -n 2 ./tst_simplerw_coll_r +mpiexec -n 4 ./tst_simplerw_coll_r diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index 098db49c37..b64e90aa30 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -1,10 +1,13 @@ -/* Copyright 2007-2011, UCAR/Unidata. See COPYRIGHT file for copying - and redistribution conditions. - - This is part of the netCDF package. - - This is a benchmarking program for netCDF-4 parallel I/O. -*/ +/* Copyright 2007-2011, UCAR/Unidata. See COPYRIGHT file for copying + * and redistribution conditions. + * + * This is part of the netCDF package. + * + * This test is for parallel IO and the collective access of metadata + * with HDF5. + * + * Ward Fisher, Ed Hartnett + */ /* Defining USE_MPE causes the MPE trace library to be used (and you * must also relink with -llmpe -lmpe). This causes clog2 output to be @@ -30,72 +33,72 @@ #define DIM2_NAME "x" #define DIM3_NAME "y" #define VAR_NAME "Bond_James_Bond" -#define ERR do { \ -fflush(stdout); /* Make sure our stdout is synced with stderr. */ \ -fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \ - __FILE__, __LINE__); \ -return 2; \ -} while (0) +#define ERR do { \ + fflush(stdout); /* Make sure our stdout is synced with stderr. */ \ + fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \ + __FILE__, __LINE__); \ + return 2; \ + } while (0) int main(int argc, char **argv) { - /* MPI stuff. */ - int mpi_namelen; - char mpi_name[MPI_MAX_PROCESSOR_NAME]; - int mpi_size, mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - double start_time = 0, total_time; - - /* Netcdf-4 stuff. */ - int ncid, varid, dimids[NDIMS]; - size_t start[NDIMS] = {0, 0, 0}; - size_t count[NDIMS] = {1, DIMSIZE, DIMSIZE}; - int data[DIMSIZE * DIMSIZE], data_in[DIMSIZE * DIMSIZE]; - int j, i, ret; - - char file_name[NC_MAX_NAME + 1]; - int ndims_in, nvars_in, natts_in, unlimdimid_in; + /* MPI stuff. */ + int mpi_namelen; + char mpi_name[MPI_MAX_PROCESSOR_NAME]; + int mpi_size, mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + double start_time = 0, total_time; + + /* Netcdf-4 stuff. */ + int ncid, varid, dimids[NDIMS]; + size_t start[NDIMS] = {0, 0, 0}; + size_t count[NDIMS] = {1, DIMSIZE, DIMSIZE}; + int data[DIMSIZE * DIMSIZE], data_in[DIMSIZE * DIMSIZE]; + int j, i, ret; + + char file_name[NC_MAX_NAME + 1]; + int ndims_in, nvars_in, natts_in, unlimdimid_in; #ifdef USE_MPE - int s_init, e_init, s_define, e_define, s_write, e_write, s_close, e_close; + int s_init, e_init, s_define, e_define, s_write, e_write, s_close, e_close; #endif /* USE_MPE */ - /* Initialize MPI. */ - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - MPI_Get_processor_name(mpi_name, &mpi_namelen); - /*printf("mpi_name: %s size: %d rank: %d\n", mpi_name, mpi_size, mpi_rank);*/ + /* Initialize MPI. */ + MPI_Init(&argc,&argv); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + MPI_Get_processor_name(mpi_name, &mpi_namelen); + /*printf("mpi_name: %s size: %d rank: %d\n", mpi_name, mpi_size, mpi_rank);*/ //#if 0 - /* Must be able to evenly divide my slabs between processors. */ - if (NUM_SLABS % mpi_size != 0) - { - if (!mpi_rank) printf("NUM_SLABS (%d) is not evenly divisible by mpi_size(%d)\n", - NUM_SLABS, mpi_size); - ERR; - } + /* Must be able to evenly divide my slabs between processors. */ + if (NUM_SLABS % mpi_size != 0) + { + if (!mpi_rank) printf("NUM_SLABS (%d) is not evenly divisible by mpi_size(%d)\n", + NUM_SLABS, mpi_size); + ERR; + } #ifdef USE_MPE - MPE_Init_log(); - s_init = MPE_Log_get_event_number(); - e_init = MPE_Log_get_event_number(); - s_define = MPE_Log_get_event_number(); - e_define = MPE_Log_get_event_number(); - s_write = MPE_Log_get_event_number(); - e_write = MPE_Log_get_event_number(); - s_close = MPE_Log_get_event_number(); - e_close = MPE_Log_get_event_number(); - s_open = MPE_Log_get_event_number(); - e_open = MPE_Log_get_event_number(); - MPE_Describe_state(s_init, e_init, "Init", "red"); - MPE_Describe_state(s_define, e_define, "Define", "yellow"); - MPE_Describe_state(s_write, e_write, "Write", "green"); - MPE_Describe_state(s_close, e_close, "Close", "purple"); - MPE_Describe_state(s_open, e_open, "Open", "blue"); - MPE_Start_log(); - MPE_Log_event(s_init, 0, "start init"); + MPE_Init_log(); + s_init = MPE_Log_get_event_number(); + e_init = MPE_Log_get_event_number(); + s_define = MPE_Log_get_event_number(); + e_define = MPE_Log_get_event_number(); + s_write = MPE_Log_get_event_number(); + e_write = MPE_Log_get_event_number(); + s_close = MPE_Log_get_event_number(); + e_close = MPE_Log_get_event_number(); + s_open = MPE_Log_get_event_number(); + e_open = MPE_Log_get_event_number(); + MPE_Describe_state(s_init, e_init, "Init", "red"); + MPE_Describe_state(s_define, e_define, "Define", "yellow"); + MPE_Describe_state(s_write, e_write, "Write", "green"); + MPE_Describe_state(s_close, e_close, "Close", "purple"); + MPE_Describe_state(s_open, e_open, "Open", "blue"); + MPE_Start_log(); + MPE_Log_event(s_init, 0, "start init"); #endif /* USE_MPE */ /* if (!mpi_rank) */ @@ -105,145 +108,142 @@ main(int argc, char **argv) /* NUM_SLABS, DIMSIZE, DIMSIZE, mpi_size); */ /* } */ - /* We will write the same slab over and over. */ - for (i = 0; i < DIMSIZE * DIMSIZE; i++) - data[i] = mpi_rank; + /* We will write the same slab over and over. */ + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + data[i] = mpi_rank; #ifdef USE_MPE - MPE_Log_event(e_init, 0, "end init"); - MPE_Log_event(s_define, 0, "start define file"); + MPE_Log_event(e_init, 0, "end init"); + MPE_Log_event(s_define, 0, "start define file"); #endif /* USE_MPE */ - /* Create a parallel netcdf-4 file. */ - if (nc_create_par(FILE_NAME, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; + /* Create a parallel netcdf-4 file. */ + if (nc_create_par(FILE_NAME, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; - /* A global attribute holds the number of processors that created - * the file. */ - if (nc_put_att_int(ncid, NC_GLOBAL, "num_processors", NC_INT, 1, &mpi_size)) ERR; + /* A global attribute holds the number of processors that created + * the file. */ + if (nc_put_att_int(ncid, NC_GLOBAL, "num_processors", NC_INT, 1, &mpi_size)) ERR; - /* Create three dimensions. */ - if (nc_def_dim(ncid, DIM1_NAME, NUM_SLABS, dimids)) ERR; - if (nc_def_dim(ncid, DIM2_NAME, DIMSIZE, &dimids[1])) ERR; - if (nc_def_dim(ncid, DIM3_NAME, DIMSIZE, &dimids[2])) ERR; + /* Create three dimensions. */ + if (nc_def_dim(ncid, DIM1_NAME, NUM_SLABS, dimids)) ERR; + if (nc_def_dim(ncid, DIM2_NAME, DIMSIZE, &dimids[1])) ERR; + if (nc_def_dim(ncid, DIM3_NAME, DIMSIZE, &dimids[2])) ERR; - /* Create one var. */ - if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS, dimids, &varid)) ERR; + /* Create one var. */ + if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS, dimids, &varid)) ERR; - /* Write metadata to file. */ - if (nc_enddef(ncid)) ERR; + /* Write metadata to file. */ + if (nc_enddef(ncid)) ERR; #ifdef USE_MPE - MPE_Log_event(e_define, 0, "end define file"); - if (mpi_rank) - sleep(mpi_rank); + MPE_Log_event(e_define, 0, "end define file"); + if (mpi_rank) + sleep(mpi_rank); #endif /* USE_MPE */ /* if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR;*/ /* if (nc_var_par_access(ncid, varid, NC_INDEPENDENT)) ERR;*/ - if (!mpi_rank) - start_time = MPI_Wtime(); + if (!mpi_rank) + start_time = MPI_Wtime(); - /* Write all the slabs this process is responsible for. */ - for (i = 0; i < NUM_SLABS / mpi_size; i++) - { - start[0] = NUM_SLABS / mpi_size * mpi_rank + i; + /* Write all the slabs this process is responsible for. */ + for (i = 0; i < NUM_SLABS / mpi_size; i++) + { + start[0] = NUM_SLABS / mpi_size * mpi_rank + i; #ifdef USE_MPE - MPE_Log_event(s_write, 0, "start write slab"); + MPE_Log_event(s_write, 0, "start write slab"); #endif /* USE_MPE */ /* Write one slab of data. */ - if (nc_put_vara_int(ncid, varid, start, count, data)) ERR; + if (nc_put_vara_int(ncid, varid, start, count, data)) ERR; #ifdef USE_MPE - MPE_Log_event(e_write, 0, "end write file"); + MPE_Log_event(e_write, 0, "end write file"); #endif /* USE_MPE */ - } + } - if (!mpi_rank) - { - total_time = MPI_Wtime() - start_time; + if (!mpi_rank) + { + total_time = MPI_Wtime() - start_time; /* printf("num_proc\ttime(s)\n");*/ - printf("%d\t%g\t%g\n", mpi_size, total_time, DIMSIZE * DIMSIZE * NUM_SLABS * sizeof(int) / total_time); - } + printf("%d\t%g\t%g\n", mpi_size, total_time, DIMSIZE * DIMSIZE * NUM_SLABS * sizeof(int) / total_time); + } #ifdef USE_MPE - MPE_Log_event(s_close, 0, "start close file"); + MPE_Log_event(s_close, 0, "start close file"); #endif /* USE_MPE */ - /* Close the netcdf file. */ - if (nc_close(ncid)) ERR; + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; //#endif #ifdef USE_MPE - MPE_Log_event(e_close, 0, "end close file"); + MPE_Log_event(e_close, 0, "end close file"); #endif /* USE_MPE */ - /* Reopen the file and check it. */ - if ((ret = nc_open_par(FILE_NAME, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) - { - printf("ret = %d\n", ret); - return -1; - } - if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; - if (ndims_in != NDIMS || nvars_in != 1 || natts_in != 1 || - unlimdimid_in != -1) ERR; - - /* Read all the slabs this process is responsible for. */ - for (i = 0; i < NUM_SLABS / mpi_size; i++) - { - start[0] = NUM_SLABS / mpi_size * mpi_rank + i; + /* Reopen the file and check it. */ + if ((ret = nc_open_par(FILE_NAME, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) + { + printf("ret = %d\n", ret); + return -1; + } + if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; + if (ndims_in != NDIMS || nvars_in != 1 || natts_in != 1 || + unlimdimid_in != -1) ERR; + + /* Read all the slabs this process is responsible for. */ + for (i = 0; i < NUM_SLABS / mpi_size; i++) + { + start[0] = NUM_SLABS / mpi_size * mpi_rank + i; #ifdef USE_MPE - MPE_Log_event(s_read, 0, "start read slab"); + MPE_Log_event(s_read, 0, "start read slab"); #endif /* USE_MPE */ if(mpi_rank == 0) { -for(j=0; j<3;j++) -count[j] = 0; + for(j=0; j<3;j++) + count[j] = 0; } - if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; - /* Read one slab of data. */ - if (nc_get_vara_int(ncid, varid, start, count, data_in)) ERR; - -if(mpi_rank != 0) { - /* Check data. */ - for (j = 0; j < DIMSIZE * DIMSIZE; j++) - if (data_in[j] != mpi_rank) - { - ERR; - break; - } -} + if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; + /* Read one slab of data. */ + if (nc_get_vara_int(ncid, varid, start, count, data_in)) ERR; + + if(mpi_rank != 0) { + /* Check data. */ + for (j = 0; j < DIMSIZE * DIMSIZE; j++) + if (data_in[j] != mpi_rank) + { + ERR; + break; + } + } #ifdef USE_MPE - MPE_Log_event(e_read, 0, "end read file"); + MPE_Log_event(e_read, 0, "end read file"); #endif /* USE_MPE */ - } + } #ifdef USE_MPE - MPE_Log_event(s_close, 0, "start close file"); + MPE_Log_event(s_close, 0, "start close file"); #endif /* USE_MPE */ - /* Close the netcdf file. */ - if (nc_close(ncid)) ERR; + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; #ifdef USE_MPE - MPE_Log_event(e_close, 0, "end close file"); + MPE_Log_event(e_close, 0, "end close file"); #endif /* USE_MPE */ - /* Delete this large file. */ - // remove(file_name); - - /* Shut down MPI. */ - MPI_Finalize(); + /* Shut down MPI. */ + MPI_Finalize(); /* if (!mpi_rank) */ /* { */ /* SUMMARIZE_ERR; */ /* FINAL_RESULTS; */ /* } */ - return 0; + return 0; } From 1bd6387e5e6bce0975c447cc2a1c3bf750a08e3f Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 08:04:00 -0700 Subject: [PATCH 14/36] clean up of test --- nc_test4/tst_simplerw_coll_r.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index b64e90aa30..3fee75a8f7 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -15,11 +15,9 @@ * clog2TOslog2) and then used in the analysis program jumpshot. */ /*#define USE_MPE 1*/ -#include -#include -#include -#include -#include +#include "config.h" +#include "nc_tests.h" +#include "err_macros.h" #ifdef USE_MPE #include From f716ac8549d8f48d1d27210a66f6fcf9665520e6 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 08:06:23 -0700 Subject: [PATCH 15/36] more test cleanup --- nc_test4/tst_simplerw_coll_r.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index 3fee75a8f7..68c240e8d5 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -31,12 +31,6 @@ #define DIM2_NAME "x" #define DIM3_NAME "y" #define VAR_NAME "Bond_James_Bond" -#define ERR do { \ - fflush(stdout); /* Make sure our stdout is synced with stderr. */ \ - fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \ - __FILE__, __LINE__); \ - return 2; \ - } while (0) int main(int argc, char **argv) @@ -56,7 +50,6 @@ main(int argc, char **argv) int data[DIMSIZE * DIMSIZE], data_in[DIMSIZE * DIMSIZE]; int j, i, ret; - char file_name[NC_MAX_NAME + 1]; int ndims_in, nvars_in, natts_in, unlimdimid_in; #ifdef USE_MPE @@ -99,12 +92,12 @@ main(int argc, char **argv) MPE_Log_event(s_init, 0, "start init"); #endif /* USE_MPE */ -/* if (!mpi_rank) */ -/* { */ -/* printf("\n*** Testing parallel I/O some more.\n"); */ -/* printf("*** writing a %d x %d x %d file from %d processors...\n", */ -/* NUM_SLABS, DIMSIZE, DIMSIZE, mpi_size); */ -/* } */ + if (!mpi_rank) + { + printf("\n*** Testing parallel I/O some more.\n"); + printf("*** writing a %d x %d x %d file from %d processors...\n", + NUM_SLABS, DIMSIZE, DIMSIZE, mpi_size); + } /* We will write the same slab over and over. */ for (i = 0; i < DIMSIZE * DIMSIZE; i++) @@ -238,10 +231,10 @@ main(int argc, char **argv) /* Shut down MPI. */ MPI_Finalize(); -/* if (!mpi_rank) */ -/* { */ -/* SUMMARIZE_ERR; */ -/* FINAL_RESULTS; */ -/* } */ + if (!mpi_rank) + { + SUMMARIZE_ERR; + FINAL_RESULTS; + } return 0; } From ba518b80a702a5350e3c6371d75a84c22b093033 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 08:09:03 -0700 Subject: [PATCH 16/36] more test cleanup --- nc_test4/tst_simplerw_coll_r.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index 68c240e8d5..04fbecf49b 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -175,11 +175,7 @@ main(int argc, char **argv) #endif /* USE_MPE */ /* Reopen the file and check it. */ - if ((ret = nc_open_par(FILE_NAME, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) - { - printf("ret = %d\n", ret); - return -1; - } + if ((ret = nc_open_par(FILE_NAME, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) ERR; if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; if (ndims_in != NDIMS || nvars_in != 1 || natts_in != 1 || unlimdimid_in != -1) ERR; @@ -193,11 +189,11 @@ main(int argc, char **argv) MPE_Log_event(s_read, 0, "start read slab"); #endif /* USE_MPE */ - if(mpi_rank == 0) { - for(j=0; j<3;j++) + /* Only read data on rank 0. */ + if (mpi_rank == 0) + for(j = 0; j < 3; j++) count[j] = 0; - } if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; /* Read one slab of data. */ if (nc_get_vara_int(ncid, varid, start, count, data_in)) ERR; From f603ab2163569e8d444cb983ab404090dd6e2c76 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 08:09:14 -0700 Subject: [PATCH 17/36] more test cleanup --- nc_test4/tst_simplerw_coll_r.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index 04fbecf49b..b8623d1c4c 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -190,7 +190,7 @@ main(int argc, char **argv) #endif /* USE_MPE */ /* Only read data on rank 0. */ - if (mpi_rank == 0) + if (!mpi_rank) for(j = 0; j < 3; j++) count[j] = 0; From d77ac20af465ee207c4581ed8d37894b20868022 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 08:14:43 -0700 Subject: [PATCH 18/36] more test cleanup --- nc_test4/tst_simplerw_coll_r.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index b8623d1c4c..862b986165 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -62,7 +62,7 @@ main(int argc, char **argv) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Get_processor_name(mpi_name, &mpi_namelen); /*printf("mpi_name: %s size: %d rank: %d\n", mpi_name, mpi_size, mpi_rank);*/ -//#if 0 + /* Must be able to evenly divide my slabs between processors. */ if (NUM_SLABS % mpi_size != 0) { @@ -132,8 +132,9 @@ main(int argc, char **argv) sleep(mpi_rank); #endif /* USE_MPE */ -/* if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR;*/ -/* if (nc_var_par_access(ncid, varid, NC_INDEPENDENT)) ERR;*/ + /* Change access mode to collective, then back to independent. */ + if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; + if (nc_var_par_access(ncid, varid, NC_INDEPENDENT)) ERR; if (!mpi_rank) start_time = MPI_Wtime(); @@ -169,7 +170,6 @@ main(int argc, char **argv) /* Close the netcdf file. */ if (nc_close(ncid)) ERR; -//#endif #ifdef USE_MPE MPE_Log_event(e_close, 0, "end close file"); #endif /* USE_MPE */ @@ -189,24 +189,18 @@ main(int argc, char **argv) MPE_Log_event(s_read, 0, "start read slab"); #endif /* USE_MPE */ - /* Only read data on rank 0. */ + /* Don't read data on rank 0. */ if (!mpi_rank) for(j = 0; j < 3; j++) count[j] = 0; - if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; /* Read one slab of data. */ if (nc_get_vara_int(ncid, varid, start, count, data_in)) ERR; - if(mpi_rank != 0) { - /* Check data. */ + /* Check data on all but rank 0. */ + if (mpi_rank) for (j = 0; j < DIMSIZE * DIMSIZE; j++) - if (data_in[j] != mpi_rank) - { - ERR; - break; - } - } + if (data_in[j] != mpi_rank) ERR; #ifdef USE_MPE MPE_Log_event(e_read, 0, "end read file"); From 0862d6d7ce417b1d38fcc3b70bbab577f3b61490 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 09:23:36 -0700 Subject: [PATCH 19/36] removed MPE calls --- include/nc_tests.h | 22 +-- nc_test4/tst_simplerw_coll_r.c | 284 ++++++++++++++------------------- 2 files changed, 137 insertions(+), 169 deletions(-) diff --git a/include/nc_tests.h b/include/nc_tests.h index 613298e05d..437197667d 100644 --- a/include/nc_tests.h +++ b/include/nc_tests.h @@ -1,11 +1,12 @@ -/** \internal -\file -Common includes, defines, etc., for test code in the libsrc4 and -nc_test4 directories. - -This is part of the netCDF package. Copyright 2005 University -Corporation for Atmospheric Research/Unidata. See \ref copyright file -for conditions of use. +/* This is part of the netCDF package. Copyright 2005 University + * Corporation for Atmospheric Research/Unidata. See \ref copyright + * file for conditions of use. */ +/** @internal @file + * + * Common includes, defines, etc., for test code in the libsrc4 and + * nc_test4 directories. + * + * @author Ed Hartnett, Denis Heimbigner, Ward Fisher */ #ifndef _NC_TESTS_H @@ -22,8 +23,10 @@ for conditions of use. #include "netcdf.h" //#include "err_macros.h" +/** NC_MAX_DIMS for tests. Allows different NC_MAX_DIMS values + * without breaking this test with a heap or stack overflow. */ +#define NC_TESTS_MAX_DIMS 1024 -#define NC_TESTS_MAX_DIMS 1024 /**< NC_MAX_DIMS for tests. Allows different NC_MAX_DIMS values without breaking this test with a heap or stack overflow. */ #define MAX_NUM_FORMATS 5 /**< Max number of available binary formats. */ /** Useful define for tests. */ @@ -38,6 +41,7 @@ for conditions of use. #define ONE_TWENTY_EIGHT_MEG (SIXTEEN_MEG * 8) #define TEST_VAL_42 42 #define BAD_NAME "dd//d/ " +#define NUM_TYPES 12 /** \} */ #ifdef USE_PNETCDF diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index 862b986165..44a9a93d9a 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -9,21 +9,11 @@ * Ward Fisher, Ed Hartnett */ -/* Defining USE_MPE causes the MPE trace library to be used (and you - * must also relink with -llmpe -lmpe). This causes clog2 output to be - * written, which can be converted to slog2 (by the program - * clog2TOslog2) and then used in the analysis program jumpshot. */ -/*#define USE_MPE 1*/ - #include "config.h" #include "nc_tests.h" #include "err_macros.h" -#ifdef USE_MPE -#include -#endif /* USE_MPE */ - -#define FILE_NAME "tst_parallel4_simplerw_coll.nc" +#define TEST_NAME "tst_parallel4_simplerw_coll" #define NDIMS 3 #define DIMSIZE 16 #define NUM_SLABS 16 @@ -47,21 +37,23 @@ main(int argc, char **argv) int ncid, varid, dimids[NDIMS]; size_t start[NDIMS] = {0, 0, 0}; size_t count[NDIMS] = {1, DIMSIZE, DIMSIZE}; - int data[DIMSIZE * DIMSIZE], data_in[DIMSIZE * DIMSIZE]; - int j, i, ret; - + int int_data[DIMSIZE * DIMSIZE], int_data_in[DIMSIZE * DIMSIZE]; + void *data, *data_in; int ndims_in, nvars_in, natts_in, unlimdimid_in; - -#ifdef USE_MPE - int s_init, e_init, s_define, e_define, s_write, e_write, s_close, e_close; -#endif /* USE_MPE */ + int int_fill_value = TEST_VAL_42; + int int_fill_value_in; + int fill_mode_in; + int mpi_size_in; +#define NUM_TEST_TYPES 1 + nc_type test_type[1] = {NC_INT}; + int tt; + int j, i, ret; /* Initialize MPI. */ MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Get_processor_name(mpi_name, &mpi_namelen); - /*printf("mpi_name: %s size: %d rank: %d\n", mpi_name, mpi_size, mpi_rank);*/ /* Must be able to evenly divide my slabs between processors. */ if (NUM_SLABS % mpi_size != 0) @@ -71,153 +63,125 @@ main(int argc, char **argv) ERR; } -#ifdef USE_MPE - MPE_Init_log(); - s_init = MPE_Log_get_event_number(); - e_init = MPE_Log_get_event_number(); - s_define = MPE_Log_get_event_number(); - e_define = MPE_Log_get_event_number(); - s_write = MPE_Log_get_event_number(); - e_write = MPE_Log_get_event_number(); - s_close = MPE_Log_get_event_number(); - e_close = MPE_Log_get_event_number(); - s_open = MPE_Log_get_event_number(); - e_open = MPE_Log_get_event_number(); - MPE_Describe_state(s_init, e_init, "Init", "red"); - MPE_Describe_state(s_define, e_define, "Define", "yellow"); - MPE_Describe_state(s_write, e_write, "Write", "green"); - MPE_Describe_state(s_close, e_close, "Close", "purple"); - MPE_Describe_state(s_open, e_open, "Open", "blue"); - MPE_Start_log(); - MPE_Log_event(s_init, 0, "start init"); -#endif /* USE_MPE */ - if (!mpi_rank) { printf("\n*** Testing parallel I/O some more.\n"); - printf("*** writing a %d x %d x %d file from %d processors...\n", - NUM_SLABS, DIMSIZE, DIMSIZE, mpi_size); - } - - /* We will write the same slab over and over. */ - for (i = 0; i < DIMSIZE * DIMSIZE; i++) - data[i] = mpi_rank; - -#ifdef USE_MPE - MPE_Log_event(e_init, 0, "end init"); - MPE_Log_event(s_define, 0, "start define file"); -#endif /* USE_MPE */ - - /* Create a parallel netcdf-4 file. */ - if (nc_create_par(FILE_NAME, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; - - /* A global attribute holds the number of processors that created - * the file. */ - if (nc_put_att_int(ncid, NC_GLOBAL, "num_processors", NC_INT, 1, &mpi_size)) ERR; - - /* Create three dimensions. */ - if (nc_def_dim(ncid, DIM1_NAME, NUM_SLABS, dimids)) ERR; - if (nc_def_dim(ncid, DIM2_NAME, DIMSIZE, &dimids[1])) ERR; - if (nc_def_dim(ncid, DIM3_NAME, DIMSIZE, &dimids[2])) ERR; - - /* Create one var. */ - if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS, dimids, &varid)) ERR; - - /* Write metadata to file. */ - if (nc_enddef(ncid)) ERR; - -#ifdef USE_MPE - MPE_Log_event(e_define, 0, "end define file"); - if (mpi_rank) - sleep(mpi_rank); -#endif /* USE_MPE */ - - /* Change access mode to collective, then back to independent. */ - if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; - if (nc_var_par_access(ncid, varid, NC_INDEPENDENT)) ERR; - - if (!mpi_rank) - start_time = MPI_Wtime(); - - /* Write all the slabs this process is responsible for. */ - for (i = 0; i < NUM_SLABS / mpi_size; i++) - { - start[0] = NUM_SLABS / mpi_size * mpi_rank + i; - -#ifdef USE_MPE - MPE_Log_event(s_write, 0, "start write slab"); -#endif /* USE_MPE */ - - /* Write one slab of data. */ - if (nc_put_vara_int(ncid, varid, start, count, data)) ERR; - -#ifdef USE_MPE - MPE_Log_event(e_write, 0, "end write file"); -#endif /* USE_MPE */ + printf("*** writing a %d x %d x %d file from %d processors...\n", NUM_SLABS, + DIMSIZE, DIMSIZE, mpi_size); } - if (!mpi_rank) - { - total_time = MPI_Wtime() - start_time; -/* printf("num_proc\ttime(s)\n");*/ - printf("%d\t%g\t%g\n", mpi_size, total_time, DIMSIZE * DIMSIZE * NUM_SLABS * sizeof(int) / total_time); - } - -#ifdef USE_MPE - MPE_Log_event(s_close, 0, "start close file"); -#endif /* USE_MPE */ - - /* Close the netcdf file. */ - if (nc_close(ncid)) ERR; - -#ifdef USE_MPE - MPE_Log_event(e_close, 0, "end close file"); -#endif /* USE_MPE */ - - /* Reopen the file and check it. */ - if ((ret = nc_open_par(FILE_NAME, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) ERR; - if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; - if (ndims_in != NDIMS || nvars_in != 1 || natts_in != 1 || - unlimdimid_in != -1) ERR; - - /* Read all the slabs this process is responsible for. */ - for (i = 0; i < NUM_SLABS / mpi_size; i++) + for (tt = 0; tt < NUM_TEST_TYPES; tt++) { - start[0] = NUM_SLABS / mpi_size * mpi_rank + i; - -#ifdef USE_MPE - MPE_Log_event(s_read, 0, "start read slab"); -#endif /* USE_MPE */ - - /* Don't read data on rank 0. */ - if (!mpi_rank) - for(j = 0; j < 3; j++) - count[j] = 0; - - /* Read one slab of data. */ - if (nc_get_vara_int(ncid, varid, start, count, data_in)) ERR; - - /* Check data on all but rank 0. */ - if (mpi_rank) - for (j = 0; j < DIMSIZE * DIMSIZE; j++) - if (data_in[j] != mpi_rank) ERR; - -#ifdef USE_MPE - MPE_Log_event(e_read, 0, "end read file"); -#endif /* USE_MPE */ - } - -#ifdef USE_MPE - MPE_Log_event(s_close, 0, "start close file"); -#endif /* USE_MPE */ - - /* Close the netcdf file. */ - if (nc_close(ncid)) ERR; - -#ifdef USE_MPE - MPE_Log_event(e_close, 0, "end close file"); -#endif /* USE_MPE */ - + char file_name[NC_MAX_NAME + 1]; + + /* Initialize test data. */ + switch(test_type[tt]) + { + case NC_INT: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + int_data[i] = mpi_rank; + data = int_data; + data_in = int_data_in; + break; + } + + /* Create a file name. */ + sprintf(file_name, "%s_type_%d.nc", TEST_NAME, test_type[tt]); + + /* Create a parallel netcdf-4 file. */ + if (nc_create_par(file_name, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; + + /* A global attribute holds the number of processors that created + * the file. */ + if (nc_put_att_int(ncid, NC_GLOBAL, "num_processors", NC_INT, 1, &mpi_size)) ERR; + + /* Create three dimensions. */ + if (nc_def_dim(ncid, DIM1_NAME, NUM_SLABS, dimids)) ERR; + if (nc_def_dim(ncid, DIM2_NAME, DIMSIZE, &dimids[1])) ERR; + if (nc_def_dim(ncid, DIM3_NAME, DIMSIZE, &dimids[2])) ERR; + + /* Create one var. */ + if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS, dimids, &varid)) ERR; + if (nc_put_att_int(ncid, varid, "var_num_processors", NC_INT, 1, &mpi_size)) ERR; + if (nc_def_var_fill(ncid, varid, NC_FILL, &int_fill_value)) ERR; + if (nc_inq_var_fill(ncid, varid, &fill_mode_in, &int_fill_value_in)) ERR; + if (fill_mode_in != NC_FILL || int_fill_value_in != TEST_VAL_42) ERR; + + /* Write metadata to file. */ + if (nc_enddef(ncid)) ERR; + + /* Change access mode to collective, then back to independent. */ + if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; + if (nc_var_par_access(ncid, varid, NC_INDEPENDENT)) ERR; + + if (!mpi_rank) + start_time = MPI_Wtime(); + + /* Write all the slabs this process is responsible for. */ + for (i = 0; i < NUM_SLABS / mpi_size; i++) + { + start[0] = NUM_SLABS / mpi_size * mpi_rank + i; + + /* Write one slab of data. */ + if (nc_put_vara(ncid, varid, start, count, data)) ERR; + + } + + if (!mpi_rank) + { + total_time = MPI_Wtime() - start_time; + printf("%d\t%g\t%g\n", mpi_size, total_time, DIMSIZE * DIMSIZE * NUM_SLABS * sizeof(int) / total_time); + } + + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; + + /* Reopen the file and check it. */ + if ((ret = nc_open_par(file_name, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) ERR; + if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; + if (ndims_in != NDIMS || nvars_in != 1 || natts_in != 1 || + unlimdimid_in != -1) ERR; + + /* Check the attributes. */ + if (nc_get_att_int(ncid, NC_GLOBAL, "num_processors", &mpi_size_in)) ERR; + if (mpi_size_in != mpi_size) + ERR; + if (nc_get_att_int(ncid, 0, "var_num_processors", &mpi_size_in)) ERR; + if (mpi_size_in != mpi_size) + ERR; + if (nc_inq_var_fill(ncid, varid, &fill_mode_in, &int_fill_value_in)) ERR; + if (fill_mode_in != NC_FILL || int_fill_value_in != TEST_VAL_42) ERR; + + /* Read all the slabs this process is responsible for. */ + for (i = 0; i < NUM_SLABS / mpi_size; i++) + { + start[0] = NUM_SLABS / mpi_size * mpi_rank + i; + + /* Don't read data on rank 0. */ + if (!mpi_rank) + for(j = 0; j < 3; j++) + count[j] = 0; + + /* Read one slab of data. */ + if (nc_get_vara(ncid, varid, start, count, data_in)) ERR; + + /* Check data on all but rank 0. */ + if (mpi_rank) + { + switch (test_type[tt]) + { + case NC_INT: + for (j = 0; j < DIMSIZE * DIMSIZE; j++) + if (int_data_in[j] != mpi_rank) ERR; + break; + } + } + } + + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; + } /* next test type */ + /* Shut down MPI. */ MPI_Finalize(); From 3626c776aefe618141b0b7c6c6585870cec93d56 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 09:43:41 -0700 Subject: [PATCH 20/36] test development --- include/nc_tests.h | 2 +- nc_test4/tst_simplerw_coll_r.c | 46 +++++++++++++--------------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/include/nc_tests.h b/include/nc_tests.h index 437197667d..d89b915d9c 100644 --- a/include/nc_tests.h +++ b/include/nc_tests.h @@ -41,7 +41,7 @@ #define ONE_TWENTY_EIGHT_MEG (SIXTEEN_MEG * 8) #define TEST_VAL_42 42 #define BAD_NAME "dd//d/ " -#define NUM_TYPES 12 +#define NUM_NETCDF_TYPES 12 /** \} */ #ifdef USE_PNETCDF diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index 44a9a93d9a..b8c695c6f0 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -25,15 +25,12 @@ int main(int argc, char **argv) { - /* MPI stuff. */ int mpi_namelen; char mpi_name[MPI_MAX_PROCESSOR_NAME]; int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; double start_time = 0, total_time; - - /* Netcdf-4 stuff. */ int ncid, varid, dimids[NDIMS]; size_t start[NDIMS] = {0, 0, 0}; size_t count[NDIMS] = {1, DIMSIZE, DIMSIZE}; @@ -56,10 +53,11 @@ main(int argc, char **argv) MPI_Get_processor_name(mpi_name, &mpi_namelen); /* Must be able to evenly divide my slabs between processors. */ - if (NUM_SLABS % mpi_size != 0) + if (NUM_SLABS % mpi_size) { - if (!mpi_rank) printf("NUM_SLABS (%d) is not evenly divisible by mpi_size(%d)\n", - NUM_SLABS, mpi_size); + if (!mpi_rank) + printf("NUM_SLABS (%d) is not evenly divisible by mpi_size(%d)\n", + NUM_SLABS, mpi_size); ERR; } @@ -124,17 +122,18 @@ main(int argc, char **argv) /* Write one slab of data. */ if (nc_put_vara(ncid, varid, start, count, data)) ERR; - } + /* On rank 0, keep track of time. */ if (!mpi_rank) { total_time = MPI_Wtime() - start_time; - printf("%d\t%g\t%g\n", mpi_size, total_time, DIMSIZE * DIMSIZE * NUM_SLABS * sizeof(int) / total_time); + printf("%d\t%g\t%g\n", mpi_size, total_time, DIMSIZE * DIMSIZE * NUM_SLABS * + sizeof(int) / total_time); } /* Close the netcdf file. */ - if (nc_close(ncid)) ERR; + if (nc_close(ncid)) ERR; /* Reopen the file and check it. */ if ((ret = nc_open_par(file_name, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) ERR; @@ -144,11 +143,9 @@ main(int argc, char **argv) /* Check the attributes. */ if (nc_get_att_int(ncid, NC_GLOBAL, "num_processors", &mpi_size_in)) ERR; - if (mpi_size_in != mpi_size) - ERR; + if (mpi_size_in != mpi_size) ERR; if (nc_get_att_int(ncid, 0, "var_num_processors", &mpi_size_in)) ERR; - if (mpi_size_in != mpi_size) - ERR; + if (mpi_size_in != mpi_size) ERR; if (nc_inq_var_fill(ncid, varid, &fill_mode_in, &int_fill_value_in)) ERR; if (fill_mode_in != NC_FILL || int_fill_value_in != TEST_VAL_42) ERR; @@ -156,27 +153,20 @@ main(int argc, char **argv) for (i = 0; i < NUM_SLABS / mpi_size; i++) { start[0] = NUM_SLABS / mpi_size * mpi_rank + i; - - /* Don't read data on rank 0. */ - if (!mpi_rank) - for(j = 0; j < 3; j++) - count[j] = 0; + printf("mpi_rank %d i %d start[0] %ld\n", mpi_rank, i, start[0]); /* Read one slab of data. */ if (nc_get_vara(ncid, varid, start, count, data_in)) ERR; - /* Check data on all but rank 0. */ - if (mpi_rank) + /* Check data. */ + switch (test_type[tt]) { - switch (test_type[tt]) - { - case NC_INT: - for (j = 0; j < DIMSIZE * DIMSIZE; j++) - if (int_data_in[j] != mpi_rank) ERR; - break; - } + case NC_INT: + for (j = 0; j < DIMSIZE * DIMSIZE; j++) + if (int_data_in[j] != mpi_rank) ERR; + break; } - } + } /* next slab */ /* Close the netcdf file. */ if (nc_close(ncid)) ERR; From 3a0385da3e4e77be65ea644e6b550c2efb775fe8 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 14:36:47 -0700 Subject: [PATCH 21/36] test development --- nc_test4/tst_simplerw_coll_r.c | 333 ++++++++++++++++++++++----------- 1 file changed, 228 insertions(+), 105 deletions(-) diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index b8c695c6f0..13ae770211 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -21,6 +21,7 @@ #define DIM2_NAME "x" #define DIM3_NAME "y" #define VAR_NAME "Bond_James_Bond" +#define NUM_FILL_TEST_RUNS 3 int main(int argc, char **argv) @@ -31,20 +32,11 @@ main(int argc, char **argv) MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; double start_time = 0, total_time; - int ncid, varid, dimids[NDIMS]; - size_t start[NDIMS] = {0, 0, 0}; - size_t count[NDIMS] = {1, DIMSIZE, DIMSIZE}; - int int_data[DIMSIZE * DIMSIZE], int_data_in[DIMSIZE * DIMSIZE]; - void *data, *data_in; - int ndims_in, nvars_in, natts_in, unlimdimid_in; - int int_fill_value = TEST_VAL_42; - int int_fill_value_in; - int fill_mode_in; int mpi_size_in; -#define NUM_TEST_TYPES 1 - nc_type test_type[1] = {NC_INT}; - int tt; - int j, i, ret; +#define NUM_TEST_TYPES 5 + nc_type test_type[NUM_TEST_TYPES] = {NC_BYTE, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE}; + int tt, fv; + int j, i, k, ret; /* Initialize MPI. */ MPI_Init(&argc,&argv); @@ -62,123 +54,254 @@ main(int argc, char **argv) } if (!mpi_rank) - { printf("\n*** Testing parallel I/O some more.\n"); - printf("*** writing a %d x %d x %d file from %d processors...\n", NUM_SLABS, - DIMSIZE, DIMSIZE, mpi_size); - } - for (tt = 0; tt < NUM_TEST_TYPES; tt++) + /* Test for different fill value settings. */ + for (fv = 0; fv < NUM_FILL_TEST_RUNS; fv++) { - char file_name[NC_MAX_NAME + 1]; - - /* Initialize test data. */ - switch(test_type[tt]) + /* Test for different netCDF types. */ + for (tt = 0; tt < NUM_TEST_TYPES; tt++) { - case NC_INT: - for (i = 0; i < DIMSIZE * DIMSIZE; i++) - int_data[i] = mpi_rank; - data = int_data; - data_in = int_data_in; - break; - } + char file_name[NC_MAX_NAME + 1]; + int fill_mode_in; + void *data, *data_in; + void *fill_value, *fill_value_in; + size_t type_size; + size_t write_start[NDIMS] = {0, 0, 1}; + size_t write_count[NDIMS] = {1, DIMSIZE, DIMSIZE - 1}; + size_t read_start[NDIMS] = {0, 0, 0}; + size_t read_count[NDIMS] = {1, DIMSIZE, DIMSIZE}; + int ncid, varid, dimids[NDIMS]; + int ndims_in, nvars_in, natts_in, unlimdimid_in; + + /* Fill values to be expected. */ + signed char byte_expected_fill_value; + short short_expected_fill_value; + int int_expected_fill_value; + float float_expected_fill_value; + double double_expected_fill_value; + + /* Fill values used when writing. */ + signed char byte_fill_value = -TEST_VAL_42; + short short_fill_value = TEST_VAL_42 * 100; + int int_fill_value = TEST_VAL_42 * 1000; + float float_fill_value = TEST_VAL_42 * 1000; + double double_fill_value = TEST_VAL_42 * 1000; + + /* Fill values read in. */ + signed char byte_fill_value_in; + short short_fill_value_in; + int int_fill_value_in; + float float_fill_value_in; + double double_fill_value_in; + + /* Data to write and read. */ + signed char byte_data[DIMSIZE * DIMSIZE], byte_data_in[DIMSIZE * DIMSIZE]; + short short_data[DIMSIZE * DIMSIZE], short_data_in[DIMSIZE * DIMSIZE]; + int int_data[DIMSIZE * DIMSIZE], int_data_in[DIMSIZE * DIMSIZE]; + float float_data[DIMSIZE * DIMSIZE], float_data_in[DIMSIZE * DIMSIZE]; + double double_data[DIMSIZE * DIMSIZE], double_data_in[DIMSIZE * DIMSIZE]; + + if (!mpi_rank) + printf("*** writing a %d x %d x %d file from %d processors for fill value test %d type %d...\n", + NUM_SLABS, DIMSIZE, DIMSIZE, mpi_size, fv, test_type[tt]); + + /* Initialize test data. */ + switch(test_type[tt]) + { + case NC_BYTE: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + byte_data[i] = mpi_rank; + data = byte_data; + data_in = byte_data_in; + byte_expected_fill_value = fv ? byte_fill_value : NC_FILL_BYTE; + fill_value = &byte_expected_fill_value; + fill_value_in = &byte_fill_value_in; + break; + case NC_SHORT: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + short_data[i] = mpi_rank; + data = short_data; + data_in = short_data_in; + short_expected_fill_value = fv ? short_fill_value : NC_FILL_SHORT; + fill_value = &short_expected_fill_value; + fill_value_in = &short_fill_value_in; + break; + case NC_INT: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + int_data[i] = mpi_rank; + data = int_data; + data_in = int_data_in; + int_expected_fill_value = fv ? int_fill_value : NC_FILL_INT; + fill_value = &int_expected_fill_value; + fill_value_in = &int_fill_value_in; + break; + case NC_FLOAT: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + float_data[i] = mpi_rank; + data = float_data; + data_in = float_data_in; + float_expected_fill_value = fv ? float_fill_value : NC_FILL_FLOAT; + fill_value = &float_expected_fill_value; + fill_value_in = &float_fill_value_in; + break; + case NC_DOUBLE: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + double_data[i] = mpi_rank; + data = double_data; + data_in = double_data_in; + double_expected_fill_value = fv ? double_fill_value : NC_FILL_DOUBLE; + fill_value = &double_expected_fill_value; + fill_value_in = &double_fill_value_in; + break; + } - /* Create a file name. */ - sprintf(file_name, "%s_type_%d.nc", TEST_NAME, test_type[tt]); + /* Create a file name. */ + sprintf(file_name, "%s_type_%d_fv_%d.nc", TEST_NAME, test_type[tt], fv); - /* Create a parallel netcdf-4 file. */ - if (nc_create_par(file_name, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; + /* Create a parallel netcdf-4 file. */ + if (nc_create_par(file_name, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; - /* A global attribute holds the number of processors that created - * the file. */ - if (nc_put_att_int(ncid, NC_GLOBAL, "num_processors", NC_INT, 1, &mpi_size)) ERR; + /* Get the type len. */ + if (nc_inq_type(ncid, test_type[tt], NULL, &type_size)) ERR; - /* Create three dimensions. */ - if (nc_def_dim(ncid, DIM1_NAME, NUM_SLABS, dimids)) ERR; - if (nc_def_dim(ncid, DIM2_NAME, DIMSIZE, &dimids[1])) ERR; - if (nc_def_dim(ncid, DIM3_NAME, DIMSIZE, &dimids[2])) ERR; + /* A global attribute holds the number of processors that created + * the file. */ + if (nc_put_att_int(ncid, NC_GLOBAL, "num_processors", NC_INT, 1, &mpi_size)) ERR; - /* Create one var. */ - if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS, dimids, &varid)) ERR; - if (nc_put_att_int(ncid, varid, "var_num_processors", NC_INT, 1, &mpi_size)) ERR; - if (nc_def_var_fill(ncid, varid, NC_FILL, &int_fill_value)) ERR; - if (nc_inq_var_fill(ncid, varid, &fill_mode_in, &int_fill_value_in)) ERR; - if (fill_mode_in != NC_FILL || int_fill_value_in != TEST_VAL_42) ERR; + /* Create three dimensions. */ + if (nc_def_dim(ncid, DIM1_NAME, NUM_SLABS, dimids)) ERR; + if (nc_def_dim(ncid, DIM2_NAME, DIMSIZE, &dimids[1])) ERR; + if (nc_def_dim(ncid, DIM3_NAME, DIMSIZE, &dimids[2])) ERR; - /* Write metadata to file. */ - if (nc_enddef(ncid)) ERR; + /* Create one var. */ + if (nc_def_var(ncid, VAR_NAME, test_type[tt], NDIMS, dimids, &varid)) ERR; + if (nc_put_att_int(ncid, varid, "var_num_processors", NC_INT, 1, &mpi_size)) ERR; + if (fv == 1) + { + if (nc_def_var_fill(ncid, varid, NC_FILL, fill_value)) ERR; + if (nc_inq_var_fill(ncid, varid, &fill_mode_in, fill_value_in)) ERR; + if (fill_mode_in != NC_FILL) ERR; + if (memcmp(fill_value_in, fill_value, type_size)) ERR; + } + else if (fv == 2) + { + if (nc_def_var_fill(ncid, varid, NC_NOFILL, NULL)) ERR; + if (nc_inq_var_fill(ncid, varid, &fill_mode_in, NULL)) ERR; + if (!fill_mode_in) ERR; /* nofill will be true */ + } - /* Change access mode to collective, then back to independent. */ - if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; - if (nc_var_par_access(ncid, varid, NC_INDEPENDENT)) ERR; + /* Write metadata to file. */ + if (nc_enddef(ncid)) ERR; - if (!mpi_rank) - start_time = MPI_Wtime(); + /* Change access mode to collective, then back to independent. */ + if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; + if (nc_var_par_access(ncid, varid, NC_INDEPENDENT)) ERR; - /* Write all the slabs this process is responsible for. */ - for (i = 0; i < NUM_SLABS / mpi_size; i++) - { - start[0] = NUM_SLABS / mpi_size * mpi_rank + i; + if (!mpi_rank) + start_time = MPI_Wtime(); - /* Write one slab of data. */ - if (nc_put_vara(ncid, varid, start, count, data)) ERR; - } + /* Write all the slabs this process is responsible for. */ + for (i = 0; i < NUM_SLABS / mpi_size; i++) + { + write_start[0] = NUM_SLABS / mpi_size * mpi_rank + i; - /* On rank 0, keep track of time. */ - if (!mpi_rank) - { - total_time = MPI_Wtime() - start_time; - printf("%d\t%g\t%g\n", mpi_size, total_time, DIMSIZE * DIMSIZE * NUM_SLABS * - sizeof(int) / total_time); - } - - /* Close the netcdf file. */ - if (nc_close(ncid)) ERR; - - /* Reopen the file and check it. */ - if ((ret = nc_open_par(file_name, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) ERR; - if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; - if (ndims_in != NDIMS || nvars_in != 1 || natts_in != 1 || - unlimdimid_in != -1) ERR; - - /* Check the attributes. */ - if (nc_get_att_int(ncid, NC_GLOBAL, "num_processors", &mpi_size_in)) ERR; - if (mpi_size_in != mpi_size) ERR; - if (nc_get_att_int(ncid, 0, "var_num_processors", &mpi_size_in)) ERR; - if (mpi_size_in != mpi_size) ERR; - if (nc_inq_var_fill(ncid, varid, &fill_mode_in, &int_fill_value_in)) ERR; - if (fill_mode_in != NC_FILL || int_fill_value_in != TEST_VAL_42) ERR; - - /* Read all the slabs this process is responsible for. */ - for (i = 0; i < NUM_SLABS / mpi_size; i++) - { - start[0] = NUM_SLABS / mpi_size * mpi_rank + i; - printf("mpi_rank %d i %d start[0] %ld\n", mpi_rank, i, start[0]); + /* Write one slab of data. Due to start/count settings, + * every 16th value will be a fill value. */ + if (nc_put_vara(ncid, varid, write_start, write_count, data)) ERR; + } + + /* On rank 0, keep track of time. */ + if (!mpi_rank) + { + total_time = MPI_Wtime() - start_time; + printf("%d\t%g\t%g\n", mpi_size, total_time, DIMSIZE * DIMSIZE * NUM_SLABS * + sizeof(int) / total_time); + } + + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; - /* Read one slab of data. */ - if (nc_get_vara(ncid, varid, start, count, data_in)) ERR; + /* Reopen the file and check it. */ + if ((ret = nc_open_par(file_name, NC_NOWRITE|NC_MPIIO, comm, info, &ncid))) ERR; + if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; + if (ndims_in != NDIMS || nvars_in != 1 || natts_in != 1 || + unlimdimid_in != -1) ERR; - /* Check data. */ - switch (test_type[tt]) + /* Check the attributes. */ + if (nc_get_att_int(ncid, NC_GLOBAL, "num_processors", &mpi_size_in)) ERR; + if (mpi_size_in != mpi_size) ERR; + if (nc_get_att_int(ncid, 0, "var_num_processors", &mpi_size_in)) ERR; + if (mpi_size_in != mpi_size) ERR; + if (fv == 1) { - case NC_INT: - for (j = 0; j < DIMSIZE * DIMSIZE; j++) - if (int_data_in[j] != mpi_rank) ERR; - break; + if (nc_inq_var_fill(ncid, varid, &fill_mode_in, fill_value_in)) ERR; + if (fill_mode_in != NC_FILL) ERR; + if (memcmp(fill_value_in, fill_value, type_size)) ERR; } - } /* next slab */ - /* Close the netcdf file. */ - if (nc_close(ncid)) ERR; - } /* next test type */ + /* Read all the slabs this process is responsible for. */ + for (i = 0; i < NUM_SLABS / mpi_size; i++) + { + read_start[0] = NUM_SLABS / mpi_size * mpi_rank + i; + /* printf("mpi_rank %d i %d read_start[0] %ld\n", mpi_rank, i, read_start[0]); */ + + /* Read one slab of data. */ + if (nc_get_vara(ncid, varid, read_start, read_count, data_in)) ERR; + + /* Check data. For the third fill value test, fill is + * turned off. So don't bother testing the values where k + * is zero. */ + /* printf("mpi_rank %d fv %d i %d j %d k %d int_data_in[j * k] %d int_expected_fill_value %d " */ + /* "expected_value %d\n", mpi_rank, fv, i, j, k, int_data_in[j * k], */ + /* int_expected_fill_value, expected_value); */ + switch (test_type[tt]) + { + case NC_BYTE: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (byte_data_in[j * DIMSIZE + k] != (signed char)(k ? mpi_rank : byte_expected_fill_value)) ERR; + break; + case NC_SHORT: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (short_data_in[j * DIMSIZE + k] != (short)(k ? mpi_rank : short_expected_fill_value)) ERR; + break; + case NC_INT: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (int_data_in[j * DIMSIZE + k] != (int)(k ? mpi_rank : int_expected_fill_value)) ERR; + break; + case NC_FLOAT: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (float_data_in[j * DIMSIZE + k] != (float)(k ? mpi_rank : float_expected_fill_value)) ERR; + break; + case NC_DOUBLE: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (double_data_in[j * DIMSIZE + k] != (double)(k ? mpi_rank : double_expected_fill_value)) ERR; + break; + } + } /* next slab */ + + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; + + if (!mpi_rank) + SUMMARIZE_ERR; + } /* next test type */ + } /* next fill value test run */ /* Shut down MPI. */ MPI_Finalize(); if (!mpi_rank) - { - SUMMARIZE_ERR; FINAL_RESULTS; - } return 0; } From 3af0e84314f947b1356bc9ee4de191595562ebe3 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 14:38:09 -0700 Subject: [PATCH 22/36] test development --- nc_test4/tst_simplerw_coll_r.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index 13ae770211..173548ef20 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -33,8 +33,8 @@ main(int argc, char **argv) MPI_Info info = MPI_INFO_NULL; double start_time = 0, total_time; int mpi_size_in; -#define NUM_TEST_TYPES 5 - nc_type test_type[NUM_TEST_TYPES] = {NC_BYTE, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE}; +#define NUM_TEST_TYPES 6 + nc_type test_type[NUM_TEST_TYPES] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE}; int tt, fv; int j, i, k, ret; @@ -83,6 +83,7 @@ main(int argc, char **argv) /* Fill values used when writing. */ signed char byte_fill_value = -TEST_VAL_42; + unsigned char char_fill_value = 0; short short_fill_value = TEST_VAL_42 * 100; int int_fill_value = TEST_VAL_42 * 1000; float float_fill_value = TEST_VAL_42 * 1000; @@ -90,6 +91,7 @@ main(int argc, char **argv) /* Fill values read in. */ signed char byte_fill_value_in; + unsigned char char_fill_value_in; short short_fill_value_in; int int_fill_value_in; float float_fill_value_in; @@ -97,6 +99,7 @@ main(int argc, char **argv) /* Data to write and read. */ signed char byte_data[DIMSIZE * DIMSIZE], byte_data_in[DIMSIZE * DIMSIZE]; + unsigned char char_data[DIMSIZE * DIMSIZE], char_data_in[DIMSIZE * DIMSIZE]; short short_data[DIMSIZE * DIMSIZE], short_data_in[DIMSIZE * DIMSIZE]; int int_data[DIMSIZE * DIMSIZE], int_data_in[DIMSIZE * DIMSIZE]; float float_data[DIMSIZE * DIMSIZE], float_data_in[DIMSIZE * DIMSIZE]; @@ -118,6 +121,15 @@ main(int argc, char **argv) fill_value = &byte_expected_fill_value; fill_value_in = &byte_fill_value_in; break; + case NC_CHAR: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + char_data[i] = mpi_rank; + data = char_data; + data_in = char_data_in; + char_expected_fill_value = fv ? char_fill_value : NC_FILL_CHAR; + fill_value = &char_expected_fill_value; + fill_value_in = &char_fill_value_in; + break; case NC_SHORT: for (i = 0; i < DIMSIZE * DIMSIZE; i++) short_data[i] = mpi_rank; From e6f82ae397516504036af0a984ce630b57f2573a Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 16 Jan 2018 14:57:40 -0700 Subject: [PATCH 23/36] further test development --- nc_test4/tst_simplerw_coll_r.c | 105 +++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-) diff --git a/nc_test4/tst_simplerw_coll_r.c b/nc_test4/tst_simplerw_coll_r.c index 173548ef20..51d3dbb7a7 100644 --- a/nc_test4/tst_simplerw_coll_r.c +++ b/nc_test4/tst_simplerw_coll_r.c @@ -33,8 +33,9 @@ main(int argc, char **argv) MPI_Info info = MPI_INFO_NULL; double start_time = 0, total_time; int mpi_size_in; -#define NUM_TEST_TYPES 6 - nc_type test_type[NUM_TEST_TYPES] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE}; +#define NUM_TEST_TYPES 11 + nc_type test_type[NUM_TEST_TYPES] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE, + NC_UBYTE, NC_USHORT, NC_UINT, NC_INT64, NC_UINT64}; int tt, fv; int j, i, k, ret; @@ -76,18 +77,29 @@ main(int argc, char **argv) /* Fill values to be expected. */ signed char byte_expected_fill_value; + unsigned char char_expected_fill_value; short short_expected_fill_value; int int_expected_fill_value; float float_expected_fill_value; double double_expected_fill_value; + unsigned char ubyte_expected_fill_value; + unsigned short ushort_expected_fill_value; + unsigned int uint_expected_fill_value; + long long int int64_expected_fill_value; + unsigned long long int uint64_expected_fill_value; /* Fill values used when writing. */ signed char byte_fill_value = -TEST_VAL_42; - unsigned char char_fill_value = 0; + unsigned char char_fill_value = 'x'; short short_fill_value = TEST_VAL_42 * 100; int int_fill_value = TEST_VAL_42 * 1000; float float_fill_value = TEST_VAL_42 * 1000; double double_fill_value = TEST_VAL_42 * 1000; + unsigned char ubyte_fill_value = TEST_VAL_42; + unsigned short ushort_fill_value = TEST_VAL_42 * 100; + unsigned int uint_fill_value = TEST_VAL_42 * 1000; + long long int int64_fill_value = TEST_VAL_42 * 1000; + unsigned long long int uint64_fill_value = TEST_VAL_42 * 1000; /* Fill values read in. */ signed char byte_fill_value_in; @@ -96,7 +108,12 @@ main(int argc, char **argv) int int_fill_value_in; float float_fill_value_in; double double_fill_value_in; - + unsigned char ubyte_fill_value_in; + unsigned short ushort_fill_value_in; + unsigned int uint_fill_value_in; + long long int int64_fill_value_in; + unsigned long long int uint64_fill_value_in; + /* Data to write and read. */ signed char byte_data[DIMSIZE * DIMSIZE], byte_data_in[DIMSIZE * DIMSIZE]; unsigned char char_data[DIMSIZE * DIMSIZE], char_data_in[DIMSIZE * DIMSIZE]; @@ -104,6 +121,11 @@ main(int argc, char **argv) int int_data[DIMSIZE * DIMSIZE], int_data_in[DIMSIZE * DIMSIZE]; float float_data[DIMSIZE * DIMSIZE], float_data_in[DIMSIZE * DIMSIZE]; double double_data[DIMSIZE * DIMSIZE], double_data_in[DIMSIZE * DIMSIZE]; + unsigned char ubyte_data[DIMSIZE * DIMSIZE], ubyte_data_in[DIMSIZE * DIMSIZE]; + unsigned short ushort_data[DIMSIZE * DIMSIZE], ushort_data_in[DIMSIZE * DIMSIZE]; + unsigned int uint_data[DIMSIZE * DIMSIZE], uint_data_in[DIMSIZE * DIMSIZE]; + long long int int64_data[DIMSIZE * DIMSIZE], int64_data_in[DIMSIZE * DIMSIZE]; + unsigned long long int uint64_data[DIMSIZE * DIMSIZE], uint64_data_in[DIMSIZE * DIMSIZE]; if (!mpi_rank) printf("*** writing a %d x %d x %d file from %d processors for fill value test %d type %d...\n", @@ -166,6 +188,51 @@ main(int argc, char **argv) fill_value = &double_expected_fill_value; fill_value_in = &double_fill_value_in; break; + case NC_UBYTE: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + ubyte_data[i] = mpi_rank; + data = ubyte_data; + data_in = ubyte_data_in; + ubyte_expected_fill_value = fv ? ubyte_fill_value : NC_FILL_UBYTE; + fill_value = &ubyte_expected_fill_value; + fill_value_in = &ubyte_fill_value_in; + break; + case NC_USHORT: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + ushort_data[i] = mpi_rank; + data = ushort_data; + data_in = ushort_data_in; + ushort_expected_fill_value = fv ? ushort_fill_value : NC_FILL_USHORT; + fill_value = &ushort_expected_fill_value; + fill_value_in = &ushort_fill_value_in; + break; + case NC_UINT: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + uint_data[i] = mpi_rank; + data = uint_data; + data_in = uint_data_in; + uint_expected_fill_value = fv ? uint_fill_value : NC_FILL_UINT; + fill_value = &uint_expected_fill_value; + fill_value_in = &uint_fill_value_in; + break; + case NC_INT64: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + int64_data[i] = mpi_rank; + data = int64_data; + data_in = int64_data_in; + int64_expected_fill_value = fv ? int64_fill_value : NC_FILL_INT64; + fill_value = &int64_expected_fill_value; + fill_value_in = &int64_fill_value_in; + break; + case NC_UINT64: + for (i = 0; i < DIMSIZE * DIMSIZE; i++) + uint64_data[i] = mpi_rank; + data = uint64_data; + data_in = uint64_data_in; + uint64_expected_fill_value = fv ? uint64_fill_value : NC_FILL_UINT64; + fill_value = &uint64_expected_fill_value; + fill_value_in = &uint64_fill_value_in; + break; } /* Create a file name. */ @@ -299,6 +366,36 @@ main(int argc, char **argv) if (fv < 2 || k) if (double_data_in[j * DIMSIZE + k] != (double)(k ? mpi_rank : double_expected_fill_value)) ERR; break; + case NC_UBYTE: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (ubyte_data_in[j * DIMSIZE + k] != (unsigned char)(k ? mpi_rank : ubyte_expected_fill_value)) ERR; + break; + case NC_USHORT: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (ushort_data_in[j * DIMSIZE + k] != (unsigned short)(k ? mpi_rank : ushort_expected_fill_value)) ERR; + break; + case NC_UINT: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (uint_data_in[j * DIMSIZE + k] != (unsigned int)(k ? mpi_rank : uint_expected_fill_value)) ERR; + break; + case NC_INT64: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (int64_data_in[j * DIMSIZE + k] != (long long int)(k ? mpi_rank : int64_expected_fill_value)) ERR; + break; + case NC_UINT64: + for (j = 0; j < DIMSIZE; j++) + for (k = 0; k < DIMSIZE; k++) + if (fv < 2 || k) + if (uint64_data_in[j * DIMSIZE + k] != (unsigned long long int)(k ? mpi_rank : uint64_expected_fill_value)) ERR; + break; } } /* next slab */ From 001483505f3a4472cfadd1990bcee8724f101104 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 18 Jan 2018 05:34:52 -0700 Subject: [PATCH 24/36] rehabilitated tst_types.c --- nc_test4/CMakeLists.txt | 3 +- nc_test4/Makefile.am | 2 +- nc_test4/tst_types.c | 499 ++++++++++++++++------------------------ 3 files changed, 200 insertions(+), 304 deletions(-) diff --git a/nc_test4/CMakeLists.txt b/nc_test4/CMakeLists.txt index 2a2bf31ef9..94538ad17f 100644 --- a/nc_test4/CMakeLists.txt +++ b/nc_test4/CMakeLists.txt @@ -9,7 +9,8 @@ SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 cdm_sea_soundings tst_vl tst_atts1 tst_atts2 tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite tst_put_vars_two_unlim_dim - tst_hdf5_file_compat tst_fill_attr_vanish tst_rehash tst_filterparser) + tst_hdf5_file_compat tst_fill_attr_vanish tst_rehash tst_filterparser + tst_types) # Note, renamegroup needs to be compiled before run_grp_rename diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 41885b804b..f92d2062f3 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -25,7 +25,7 @@ tst_fillbug tst_xplatform tst_xplatform2 tst_endian_fill tst_atts \ t_type cdm_sea_soundings tst_camrun tst_vl tst_atts1 tst_atts2 \ tst_vars2 tst_files5 tst_files6 tst_sync tst_h_scalar tst_rename \ tst_h5_endians tst_atts_string_rewrite tst_hdf5_file_compat \ -tst_fill_attr_vanish tst_rehash tst_filterparser tst_bug324 +tst_fill_attr_vanish tst_rehash tst_filterparser tst_bug324 tst_types # Temporary I hope if !ISCYGWIN diff --git a/nc_test4/tst_types.c b/nc_test4/tst_types.c index f12f7f2b43..ac587f8d57 100644 --- a/nc_test4/tst_types.c +++ b/nc_test4/tst_types.c @@ -1,333 +1,228 @@ -/* Test program for types. */ -#include -#include - -/* This macro prints an error message and exits. */ -#define BAIL(e) do { \ -fprintf(stderr, "Error in file %s, line %d.\n%s\n", \ -__FILE__, __LINE__, nc_strerror(e)); \ -return 2; \ -} while (0) - -/* This macro keep track of the number of errors and prints an error - * message. */ -#define ERR do { \ -fprintf(stderr, "Error in file %s, line %d.\n", __FILE__, __LINE__); \ -errors++; \ -} while (0) - +/* This is part of the netCDF package. + Copyright 2005 University Corporation for Atmospheric Research/Unidata + See COPYRIGHT file for conditions of use. + + Test netcdf-4 types. + + Ed Hartnett +*/ + +#include "config.h" +#include "nc_tests.h" +#include "err_macros.h" + #define MAX_VARNAME 20 #define NUM_TYPES 6 #define NUM_DIMS 1 #define SIZE 5 #define STRIDE_SIZE 2 -#define FILENAME "test.nc" - -#define CLEAN_INPUT_BUFFERS \ - for (i=0; i Date: Thu, 18 Jan 2018 05:57:33 -0700 Subject: [PATCH 25/36] more test development --- nc_test4/tst_types.c | 243 +++++++++++++++++++++++++++---------------- 1 file changed, 152 insertions(+), 91 deletions(-) diff --git a/nc_test4/tst_types.c b/nc_test4/tst_types.c index ac587f8d57..daa67b574c 100644 --- a/nc_test4/tst_types.c +++ b/nc_test4/tst_types.c @@ -17,9 +17,10 @@ #define SIZE 5 #define STRIDE_SIZE 2 #define FILENAME "tst_types.nc" +#define FILENAME2 "tst_types2.nc" #define CLEAN_INPUT_BUFFERS \ - for (i=0; i Date: Thu, 18 Jan 2018 06:47:50 -0700 Subject: [PATCH 26/36] further test development, added documentation for uncommitted user-defined types, fixed check of return value --- libdispatch/dtype.c | 14 ++++++-- libsrc4/nc4type.c | 6 +++- nc_test4/tst_types.c | 83 ++++++++++++++++++++++++++++++++++++-------- 3 files changed, 85 insertions(+), 18 deletions(-) diff --git a/libdispatch/dtype.c b/libdispatch/dtype.c index 75b71376ba..82fafb475d 100644 --- a/libdispatch/dtype.c +++ b/libdispatch/dtype.c @@ -41,7 +41,12 @@ type). Read attributes of the new type with nc_get_att (see /** \ingroup user_types -Learn if two types are equal +Learn if two types are equal. + +\note User-defined types in netCDF-4/HDF5 files must be committed to +the file before nc_inq_type_equal() will work on the type. For +uncommitted user-defined types, nc_inq_type_equal() will return +::NC_EHDFERR. Commit types to the file with a call to nc_enddef(). \param ncid1 \ref ncid of first typeid. \param typeid1 First typeid. @@ -54,8 +59,11 @@ the two types are equal, a zero if they are not equal. \returns ::NC_EBADID Bad \ref ncid. \returns ::NC_EBADTYPE Bad type id. \returns ::NC_ENOTNC4 Not an netCDF-4 file, or classic model enabled. -\returns ::NC_EHDFERR An error was reported by the HDF5 layer. -\author Dennis Heimbigner, Ward Fisher +\returns ::NC_EHDFERR An error was reported by the HDF5 layer. This +will occur if either of the types have not been committed to the file +(with an nc_enddef()). + +\author Dennis Heimbigner, Ward Fisher, Ed Hartnett */ int nc_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, diff --git a/libsrc4/nc4type.c b/libsrc4/nc4type.c index 186e311dd1..e65de1870a 100644 --- a/libsrc4/nc4type.c +++ b/libsrc4/nc4type.c @@ -104,7 +104,11 @@ NC4_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, /* Are the two types equal? */ if (equalp) - *equalp = (int)H5Tequal(type1->native_hdf_typeid, type2->native_hdf_typeid); + { + if ((retval = H5Tequal(type1->native_hdf_typeid, type2->native_hdf_typeid)) < 0) + return NC_EHDFERR; + *equalp = 1 ? retval : 0; + } return NC_NOERR; } diff --git a/nc_test4/tst_types.c b/nc_test4/tst_types.c index daa67b574c..b049db2216 100644 --- a/nc_test4/tst_types.c +++ b/nc_test4/tst_types.c @@ -35,11 +35,11 @@ create_test_file(char *filename, int *varid, int *ncid) int dimid; int type; char varname[MAX_VARNAME]; - + /* Open a netcdf-4 file, and one dimension. */ if (nc_create(filename, NC_NETCDF4, ncid)) ERR; if (nc_def_dim(*ncid, "dim1", SIZE, &dimid)) ERR; - + /* Create vars of the new types. Take advantage of the fact that * new types are numbered from NC_UBYTE (7) through NC_STRING * (12). */ @@ -79,14 +79,15 @@ int main(int argc, char *argv[]) int i; int type; - printf("\n*** Testing netCDF-4 new atomic types and equality..."); + printf("\n*** Testing netCDF-4 types...\n"); + printf("*** testing netCDF-4 new atomic types and equality..."); { + int ncid1, ncid2; int equal; - int ncid2; - + /* Open a netcdf-4 file, and one dimension. */ - if (nc_create(FILENAME, NC_NETCDF4, &ncid)) ERR; - if (nc_def_dim(ncid, "dim1", SIZE, &dimid)) ERR; + if (nc_create(FILENAME, NC_NETCDF4, &ncid1)) ERR; + if (nc_def_dim(ncid1, "dim1", SIZE, &dimid)) ERR; /* Open another netcdf-4 file. */ if (nc_create(FILENAME2, NC_NETCDF4, &ncid2)) ERR; @@ -98,17 +99,71 @@ int main(int argc, char *argv[]) { /* Create a var... */ sprintf(varname, "var_%d", type); - if (nc_def_var(ncid, varname, type + NC_UBYTE, 1, &dimid, &varid[type])) ERR; - if (nc_inq_type_equal(ncid, type + NC_UBYTE, ncid2, type + NC_UBYTE, &equal)); + if (nc_def_var(ncid1, varname, type + NC_UBYTE, 1, &dimid, &varid[type])) ERR; + if (nc_inq_type_equal(ncid1, type + NC_UBYTE, ncid2, type + NC_UBYTE, &equal)); if (!equal) ERR; } nc_close(ncid2); - nc_close(ncid); + nc_close(ncid1); + } + SUMMARIZE_ERR; + +#define ENUM_TYPE_NAME "enum_type" +#define ENUM_FIELD1_NAME "enum_field_1" +#define ENUM_UNEQUAL_TYPE_NAME_3 "enum_type_3" +#define ENUM_UNEQUAL_TYPE_NAME_4 "enum_type_4" + + printf("*** testing user-defined netCDF-4 enum types and equality..."); + { + int ncid1, ncid2; + int typeid1, typeid2, typeid3; + int enum_value = TEST_VAL_42; + int equal; + + /* Create a netcdf-4 file. */ + if (nc_create(FILENAME, NC_NETCDF4, &ncid1)) ERR; + + /* Create an enum type. */ + if (nc_def_enum(ncid1, NC_INT, ENUM_TYPE_NAME, &typeid1)) ERR; + if (nc_insert_enum(ncid1, typeid1, ENUM_FIELD1_NAME, &enum_value)) ERR; + + /* Create another netcdf-4 file. */ + if (nc_create(FILENAME2, NC_NETCDF4, &ncid2)) ERR; + + /* Create an enum type that will be equal to typeid1. */ + if (nc_def_enum(ncid2, NC_INT, ENUM_TYPE_NAME, &typeid2)) ERR; + if (nc_insert_enum(ncid2, typeid2, ENUM_FIELD1_NAME, &enum_value)) ERR; + + /* These will fail. */ + if (nc_def_enum(ncid2, NC_INT, ENUM_TYPE_NAME, &typeid3) != NC_ENAMEINUSE) ERR; + + /* Create some enum types that will not be equal to typeid1. */ + if (nc_def_enum(ncid2, NC_SHORT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3)) ERR; + if (nc_insert_enum(ncid2, typeid3, ENUM_FIELD1_NAME, &enum_value)) ERR; + + /* This will fail because types are not yet committed. */ + if (nc_inq_type_equal(ncid1, typeid1, ncid2, typeid2, &equal) != NC_EHDFERR) ERR; + + /* Commit the types to the file. */ + if (nc_enddef(ncid1)) ERR; + if (nc_enddef(ncid2)) ERR; + + /* Ensure the two types are equal. */ + if (nc_inq_type_equal(ncid1, typeid1, ncid2, typeid2, &equal)) ERR; + if (!equal) ERR; + + /* Ensure the two types are not equal. */ + if (nc_inq_type_equal(ncid1, typeid1, ncid2, typeid3, &equal)) ERR; + if (equal) ERR; + + /* Close the files. */ + nc_close(ncid2); + nc_close(ncid1); } SUMMARIZE_ERR; /* Test the vara functions. */ - printf("*** testing vara functions..."); + printf("*** testing vara functions with new netCDF-4 atomic types..."); { CLEAN_INPUT_BUFFERS; start[0] = 0; @@ -148,7 +203,7 @@ int main(int argc, char *argv[]) SUMMARIZE_ERR; /* Test the vars functions. */ - printf("*** testing vars functions..."); + printf("*** testing vars functions with new netCDF-4 atomic types..."); { CLEAN_INPUT_BUFFERS; start[0] = 0; @@ -199,7 +254,7 @@ int main(int argc, char *argv[]) SUMMARIZE_ERR; /* Test the var1 functions. */ - printf("*** testing var1 functions..."); + printf("*** testing var1 functions with new netCDF-4 atomic types..."); { CLEAN_INPUT_BUFFERS; index1[0] = 0; @@ -233,7 +288,7 @@ int main(int argc, char *argv[]) SUMMARIZE_ERR; /* Test the varm functions. */ - printf("*** testing varm functions..."); + printf("*** testing varm functions with new netCDF-4 atomic types..."); { int ncid, varid[NUM_TYPES]; CLEAN_INPUT_BUFFERS; From 126d34da1d39ce40a8de239c42b4778191dbb57d Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 18 Jan 2018 07:36:52 -0700 Subject: [PATCH 27/36] more tests, error handling --- libsrc4/nc4internal.c | 7 +++++ libsrc4/nc4type.c | 11 +++----- nc_test4/tst_types.c | 59 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 12 deletions(-) diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index 41d0d7ba3a..f4423f0ac6 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -93,6 +93,7 @@ nc4_hdf5_initialize(void) * * @return ::NC_NOERR No error. * @return ::NC_EMAXNAME Name too long. + * @return ::NC_EINVAL NULL given for name. * @author Dennis Heimbigner */ int @@ -101,6 +102,12 @@ nc4_check_name(const char *name, char *norm_name) char *temp; int retval; + assert(norm_name); + + /* Check for NULL. */ + if (!name) + return NC_EINVAL; + /* Check the length. */ if (strlen(name) > NC_MAX_NAME) return NC_EMAXNAME; diff --git a/libsrc4/nc4type.c b/libsrc4/nc4type.c index e65de1870a..3777f6f159 100644 --- a/libsrc4/nc4type.c +++ b/libsrc4/nc4type.c @@ -137,6 +137,7 @@ NC4_inq_typeid(int ncid, const char *name, nc_type *typeidp) char *norm_name; int i, retval; + /* Handle atomic types. */ for (i = 0; i < NUM_ATOMIC_TYPES; i++) if (!strcmp(name, atomic_name[i])) { @@ -148,10 +149,7 @@ NC4_inq_typeid(int ncid, const char *name, nc_type *typeidp) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; - - /* Must be a netCDF-4 file. */ - if (!h5) - return NC_ENOTNC4; + assert(h5 && grp); /* If the first char is a /, this is a fully-qualified * name. Otherwise, this had better be a local name (i.e. no / in @@ -275,10 +273,7 @@ add_user_type(int ncid, size_t size, const char *name, nc_type base_typeid, /* Find group metadata. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; - - /* Only netcdf-4 files! */ - if (!h5) - return NC_ENOTNC4; + assert(h5 && grp); /* Turn on define mode if it is not on. */ if (!(h5->cmode & NC_INDEF)) diff --git a/nc_test4/tst_types.c b/nc_test4/tst_types.c index b049db2216..def4a0419c 100644 --- a/nc_test4/tst_types.c +++ b/nc_test4/tst_types.c @@ -18,6 +18,8 @@ #define STRIDE_SIZE 2 #define FILENAME "tst_types.nc" #define FILENAME2 "tst_types2.nc" +#define FILENAME3 "tst_types3.nc" +#define FILENAME4 "tst_types4.nc" #define CLEAN_INPUT_BUFFERS \ for (i = 0; i < SIZE; i++) { \ @@ -112,13 +114,19 @@ int main(int argc, char *argv[]) #define ENUM_FIELD1_NAME "enum_field_1" #define ENUM_UNEQUAL_TYPE_NAME_3 "enum_type_3" #define ENUM_UNEQUAL_TYPE_NAME_4 "enum_type_4" +#define NUM_CLASSIC_TYPES 6 +#define NUM_ENHANCED_TYPES 12 printf("*** testing user-defined netCDF-4 enum types and equality..."); { - int ncid1, ncid2; + int ncid1, ncid2, ncid3, ncid4; int typeid1, typeid2, typeid3; int enum_value = TEST_VAL_42; int equal; + int classic_type[NUM_CLASSIC_TYPES] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE}; + int enhanced_type[NUM_ENHANCED_TYPES] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE, + NC_UBYTE, NC_USHORT, NC_UINT, NC_INT64, NC_UINT64, NC_STRING}; + int t; /* Create a netcdf-4 file. */ if (nc_create(FILENAME, NC_NETCDF4, &ncid1)) ERR; @@ -130,12 +138,22 @@ int main(int argc, char *argv[]) /* Create another netcdf-4 file. */ if (nc_create(FILENAME2, NC_NETCDF4, &ncid2)) ERR; + /* Create a netcdf-3 classic file. */ + if (nc_create(FILENAME3, 0, &ncid3)) ERR; + + /* Create a netcdf-4 classic model file. */ + if (nc_create(FILENAME4, NC_NETCDF4|NC_CLASSIC_MODEL, &ncid4)) ERR; + /* Create an enum type that will be equal to typeid1. */ if (nc_def_enum(ncid2, NC_INT, ENUM_TYPE_NAME, &typeid2)) ERR; if (nc_insert_enum(ncid2, typeid2, ENUM_FIELD1_NAME, &enum_value)) ERR; /* These will fail. */ if (nc_def_enum(ncid2, NC_INT, ENUM_TYPE_NAME, &typeid3) != NC_ENAMEINUSE) ERR; + if (nc_def_enum(ncid2 + TEST_VAL_42, NC_INT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3) != NC_EBADID) ERR; + if (nc_def_enum(ncid2, NC_INT, NULL, &typeid3) != NC_EINVAL) ERR; + if (nc_def_enum(ncid3, NC_SHORT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3) != NC_ENOTNC4) ERR; + /* if (nc_def_enum(ncid4, NC_SHORT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3) != NC_ENOTNC4) ERR; */ /* Create some enum types that will not be equal to typeid1. */ if (nc_def_enum(ncid2, NC_SHORT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3)) ERR; @@ -148,17 +166,50 @@ int main(int argc, char *argv[]) if (nc_enddef(ncid1)) ERR; if (nc_enddef(ncid2)) ERR; - /* Ensure the two types are equal. */ + /* This succeeds but does nothing. */ + if (nc_inq_type_equal(ncid1, typeid1, ncid2, typeid2, NULL)) ERR; + + /* These will fail. */ + if (nc_inq_type_equal(ncid1, 0, ncid2, typeid2, &equal) != NC_EINVAL) ERR; + if (nc_inq_type_equal(ncid1, typeid1, ncid2, 0, &equal) != NC_EINVAL) ERR; + if (nc_inq_type_equal(ncid1, -TEST_VAL_42, ncid2, typeid2, &equal) != NC_EINVAL) ERR; + if (nc_inq_type_equal(ncid1, typeid1, ncid2, -TEST_VAL_42, &equal) != NC_EINVAL) ERR; + if (nc_inq_type_equal(ncid1 + TEST_VAL_42, typeid1, ncid2, typeid2, &equal) != NC_EBADID) ERR; + if (nc_inq_type_equal(ncid1, typeid1 + TEST_VAL_42, ncid2, typeid2, &equal) != NC_EBADTYPE) ERR; + if (nc_inq_type_equal(ncid1, typeid1, ncid2 + TEST_VAL_42, typeid2, &equal) != NC_EBADID) ERR; + if (nc_inq_type_equal(ncid1, typeid1, ncid2, typeid2 + TEST_VAL_42, &equal) != NC_EBADTYPE) ERR; + + /* Ensure the two equal types are equal. */ if (nc_inq_type_equal(ncid1, typeid1, ncid2, typeid2, &equal)) ERR; if (!equal) ERR; - /* Ensure the two types are not equal. */ + /* Ensure the two unequal types are not equal. */ if (nc_inq_type_equal(ncid1, typeid1, ncid2, typeid3, &equal)) ERR; if (equal) ERR; + /* Atomic types are not equal to user-defined types, but are + * equal to themselves. */ + for (t = 0; t < NUM_CLASSIC_TYPES; t++) + { + if (nc_inq_type_equal(ncid1, typeid1, ncid3, classic_type[t], &equal)) ERR; + if (equal) ERR; + if (nc_inq_type_equal(ncid1, classic_type[t], ncid3, classic_type[t], &equal)) ERR; + if (!equal) ERR; + } + + for (t = 0; t < NUM_ENHANCED_TYPES; t++) + { + if (nc_inq_type_equal(ncid1, typeid1, ncid2, enhanced_type[t], &equal)) ERR; + if (equal) ERR; + if (nc_inq_type_equal(ncid1, enhanced_type[t], ncid2, enhanced_type[t], &equal)) ERR; + if (!equal) ERR; + } + /* Close the files. */ - nc_close(ncid2); nc_close(ncid1); + nc_close(ncid2); + nc_close(ncid3); + nc_close(ncid4); } SUMMARIZE_ERR; From d350f82889b610d522312a8fbfe85dbe709804d6 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 18 Jan 2018 07:46:31 -0700 Subject: [PATCH 28/36] removed unneeded h5 checks --- libsrc4/nc4type.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libsrc4/nc4type.c b/libsrc4/nc4type.c index 3777f6f159..43dc524f03 100644 --- a/libsrc4/nc4type.c +++ b/libsrc4/nc4type.c @@ -217,9 +217,10 @@ NC4_inq_typeids(int ncid, int *ntypes, int *typeids) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; + assert(h5 && grp); - /* If this is a netCDF-4 file, count types. */ - if (h5 && grp->type) + /* Count types. */ + if (grp->type) for (type = grp->type; type; type = type->l.next) { if (typeids) @@ -631,8 +632,9 @@ find_nc4_file(int ncid, NC **nc) NC_HDF5_FILE_INFO_T* h5; /* Find file metadata. */ - if (!((*nc) = nc4_find_nc_file(ncid,&h5))) + if (!((*nc) = nc4_find_nc_file(ncid, &h5))) return NC_EBADID; + assert(h5); if (h5->cmode & NC_CLASSIC_MODEL) return NC_ESTRICTNC3; From bc1f103c3db8e8985cc19c957b8e5b0fe403291c Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 19 Jan 2018 03:37:49 -0700 Subject: [PATCH 29/36] cleaned up h5 checks in nc4grp.c --- libsrc4/nc4grp.c | 120 +++++++++++++++----------------------------- nc_test4/tst_grps.c | 3 +- 2 files changed, 42 insertions(+), 81 deletions(-) diff --git a/libsrc4/nc4grp.c b/libsrc4/nc4grp.c index 7ea43357d5..080f3bcc31 100644 --- a/libsrc4/nc4grp.c +++ b/libsrc4/nc4grp.c @@ -42,8 +42,7 @@ NC4_def_grp(int parent_ncid, const char *name, int *new_ncid) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(parent_ncid, &grp, &h5))) return retval; - if (!h5) - return NC_ENOTNC4; + assert(h5); /* Check and normalize the name. */ if ((retval = nc4_check_name(name, norm_name))) @@ -103,8 +102,7 @@ NC4_rename_grp(int grpid, const char *name) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(grpid, &grp, &h5))) return retval; - if (!h5) - return NC_ENOTNC4; + assert(h5); if (h5->no_write) return NC_EPERM; /* attempt to write to a read-only file */ @@ -184,10 +182,7 @@ NC4_inq_ncid(int ncid, const char *name, int *grp_ncid) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; - - /* Groups only work with netCDF-4/HDF5 files... */ - if (!h5) - return NC_ENOTNC4; + assert(h5); /* Normalize name. */ if ((retval = nc4_normalize_name(name, norm_name))) @@ -231,14 +226,7 @@ NC4_inq_grps(int ncid, int *numgrps, int *ncids) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; - - /* For netCDF-3 files, just report zero groups. */ - if (!h5) - { - if (numgrps) - *numgrps = 0; - return NC_NOERR; - } + assert(h5); /* Count the number of groups in this group. */ for (g = grp->children; g; g = g->l.next) @@ -283,13 +271,11 @@ NC4_inq_grpname(int ncid, char *name) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; + assert(h5); + + /* Copy the name. */ if (name) - { - if (!h5) - strcpy(name, "/"); - else - strcpy(name, grp->name); - } + strcpy(name, grp->name); return NC_NOERR; } @@ -388,11 +374,8 @@ NC4_inq_grp_parent(int ncid, int *parent_ncid) /* Find info for this file and group. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; - - /* Groups only work with netCDF-4/HDF5 files... */ - if (!h5) - return NC_ENOGRP; - + assert(h5); + /* Set the parent ncid, if there is one. */ if (grp->parent) { @@ -434,6 +417,7 @@ NC4_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid) /* Find info for this file and group, and set pointer to each. */ if ((ret = nc4_find_grp_h5(ncid, &grp, &h5))) return ret; + assert(h5); /* Copy full_name because strtok messes with the value it works * with, and we don't want to mess up full_name. */ @@ -503,29 +487,17 @@ NC4_inq_varids(int ncid, int *nvars, int *varids) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; + assert(h5); - if (!h5) + /* This is a netCDF-4 group. Round up them doggies and count + * 'em. The list is in correct (i.e. creation) order. */ + for (i=0; i < grp->vars.nelems; i++) { - /* If this is a netcdf-3 file, there is only one group, the root - * group, and its vars have ids 0 thru nvars - 1. */ - if ((retval = NC4_inq(ncid, NULL, &num_vars, NULL, NULL))) - return retval; + var = grp->vars.value[i]; + if (!var) continue; if (varids) - for (v = 0; v < num_vars; v++) - varids[v] = v; - } - else - { - /* This is a netCDF-4 group. Round up them doggies and count - * 'em. The list is in correct (i.e. creation) order. */ - for (i=0; i < grp->vars.nelems; i++) - { - var = grp->vars.value[i]; - if (!var) continue; - if (varids) - varids[num_vars] = var->varid; - num_vars++; - } + varids[num_vars] = var->varid; + num_vars++; } /* If the user wants to know how many vars in the group, tell @@ -584,44 +556,32 @@ NC4_inq_dimids(int ncid, int *ndims, int *dimids, int include_parents) /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_grp_h5(ncid, &grp, &h5))) return retval; + assert(h5); - if (!h5) - { - /* If this is a netcdf-3 file, then the dimids are going to be 0 - * thru ndims-1, so just provide them. */ - if ((retval = NC4_inq(ncid, &num, NULL, NULL, NULL))) - return retval; - if (dimids) - for (d = 0; d < num; d++) - dimids[d] = d; - } - else + /* First count them. */ + for (dim = grp->dim; dim; dim = dim->l.next) + num++; + if (include_parents) + for (g = grp->parent; g; g = g->parent) + for (dim = g->dim; dim; dim = dim->l.next) + num++; + + /* If the user wants the dimension ids, get them. */ + if (dimids) { - /* First count them. */ + int n = 0; + + /* Get dimension ids from this group. */ for (dim = grp->dim; dim; dim = dim->l.next) - num++; + dimids[n++] = dim->dimid; + + /* Get dimension ids from parent groups. */ if (include_parents) - for (g = grp->parent; g; g = g->parent) - for (dim = g->dim; dim; dim = dim->l.next) - num++; + for (g = grp->parent; g; g = g->parent) + for (dim = g->dim; dim; dim = dim->l.next) + dimids[n++] = dim->dimid; - /* If the user wants the dimension ids, get them. */ - if (dimids) - { - int n = 0; - - /* Get dimension ids from this group. */ - for (dim = grp->dim; dim; dim = dim->l.next) - dimids[n++] = dim->dimid; - - /* Get dimension ids from parent groups. */ - if (include_parents) - for (g = grp->parent; g; g = g->parent) - for (dim = g->dim; dim; dim = dim->l.next) - dimids[n++] = dim->dimid; - - qsort(dimids, num, sizeof(int), int_cmp); - } + qsort(dimids, num, sizeof(int), int_cmp); } /* If the user wants the number of dims, give it. */ diff --git a/nc_test4/tst_grps.c b/nc_test4/tst_grps.c index 2cadc038d5..216713fa2a 100644 --- a/nc_test4/tst_grps.c +++ b/nc_test4/tst_grps.c @@ -3,7 +3,8 @@ See COPYRIGHT file for conditions of use. Test netcdf-4 group code. - $Id: tst_grps.c,v 1.37 2010/04/07 15:21:28 ed Exp $ + + Ed Hartnett */ #include From 4be1fd82e6385c6520c5f6cd9e1dd8adf240034d Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 19 Jan 2018 04:16:59 -0700 Subject: [PATCH 30/36] further test development --- libsrc4/nc4internal.c | 5 +++ nc_test4/tst_grps.c | 77 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index 41d0d7ba3a..3e0ba89753 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -93,6 +93,7 @@ nc4_hdf5_initialize(void) * * @return ::NC_NOERR No error. * @return ::NC_EMAXNAME Name too long. + * @return ::NC_EINVAL Invalid parameter. * @author Dennis Heimbigner */ int @@ -100,6 +101,10 @@ nc4_check_name(const char *name, char *norm_name) { char *temp; int retval; + + /* Check for NULL. */ + if (!name) + return NC_EINVAL; /* Check the length. */ if (strlen(name) > NC_MAX_NAME) diff --git a/nc_test4/tst_grps.c b/nc_test4/tst_grps.c index 216713fa2a..a9529ad987 100644 --- a/nc_test4/tst_grps.c +++ b/nc_test4/tst_grps.c @@ -12,6 +12,8 @@ #include "netcdf.h" #define FILE_NAME "tst_grps.nc" +#define FILE_NAME_CLASSIC "tst_grps_classic.nc" +#define FILE_NAME_CLASSIC_MODEL "tst_grps_classic_model.nc" #define DIM1_NAME "kingdom" #define DIM1_LEN 3 #define DIM2_NAME "year" @@ -19,6 +21,7 @@ #define VAR1_NAME "Number_of_Beheadings_in_Family" #define DYNASTY "Tudor" #define HENRY_VII "Henry_VII" +#define HENRY_VIII "Henry_VIII" #define MARGARET "Margaret" #define JAMES_V_OF_SCOTLAND "James_V_of_Scotland" #define MARY_I_OF_SCOTLAND "Mary_I_of_Scotland" @@ -32,15 +35,21 @@ main(int argc, char **argv) printf("\n*** Testing netcdf-4 group functions.\n"); printf("*** testing simple group create..."); { - int ncid; + int ncid, ncid2; char name_in[NC_MAX_NAME + 1]; int henry_vii_id; + int henry_viii_id; int grpid_in[MAX_SIBLING_GROUPS], varids_in[MAX_SIBLING_GROUPS]; int dimids_in[MAX_SIBLING_GROUPS], nvars_in, ndims_in, ncid_in; int parent_ncid; char name_out[NC_MAX_NAME + 1]; int num_grps; + /* Create a netCDF classic file. Groups will not be allowed. */ + if (nc_create(FILE_NAME_CLASSIC, 0, &ncid2)) ERR; + if (nc_def_grp(ncid2, name_out, &henry_vii_id) != NC_ENOTNC4) ERR; + if (nc_close(ncid2)) ERR; + /* Create a file with one group, a group to contain data about * Henry VII. */ if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; @@ -48,7 +57,16 @@ main(int argc, char **argv) /* This should also work as simple "is this the root group" test */ if (nc_inq_grp_parent(ncid, NULL) != NC_ENOGRP) ERR; strcpy(name_out, HENRY_VII); + + /* These will not work. */ + if (nc_def_grp(ncid + TEST_VAL_42, name_out, &henry_vii_id) != NC_EBADID) ERR; + if (nc_def_grp(ncid, NULL, &henry_vii_id) != NC_EINVAL) ERR; + if (nc_def_grp(ncid, BAD_NAME, &henry_vii_id) != NC_EBADNAME) ERR; + + /* Define the group. */ if (nc_def_grp(ncid, name_out, &henry_vii_id)) ERR; + + /* Check it out. */ if (nc_inq_grp_parent(henry_vii_id, &parent_ncid)) ERR; if (parent_ncid != ncid) ERR; if (nc_inq_ncid(ncid, HENRY_VII, &ncid_in)) ERR; @@ -74,6 +92,58 @@ main(int argc, char **argv) if (ndims_in != 0) ERR; if (nc_inq_ncid(ncid, HENRY_VII, &ncid_in)) ERR; if (ncid_in != grpid_in[0]) ERR; + + /* These should fail - file is read-only. */ + if (nc_def_grp(ncid, HENRY_VIII, &henry_viii_id) != NC_EPERM) ERR; + if (nc_rename_grp(grpid_in[0], HENRY_VIII) != NC_EPERM) ERR; + + /* Close the file. */ + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; + printf("*** testing simple group rename..."); + { + int ncid, ncid2; + int grpid_in; + char name_in[NC_MAX_NAME + 1]; + int henry_vii_id; + + /* Create a classic model file. No groups will be allowed. */ + if (nc_create(FILE_NAME_CLASSIC_MODEL, NC_NETCDF4|NC_CLASSIC_MODEL, &ncid2)) ERR; + if (nc_def_grp(ncid2, HENRY_VII, &henry_vii_id) != NC_ESTRICTNC3) ERR; + if (nc_close(ncid2)) ERR; + + /* Create a file with one group, a group to contain data about + * Henry VII. */ + if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; + /* Turn off define mode. It will automatically be turned back on + * when nc_def_grp is called. */ + if (nc_enddef(ncid)) ERR; + if (nc_def_grp(ncid, HENRY_VII, &henry_vii_id)) ERR; + + /* Check it out. */ + if (nc_inq_grpname(henry_vii_id, name_in)) ERR; + if (strcmp(name_in, HENRY_VII)) ERR; + + /* Rename the group. */ + if (nc_rename_grp(henry_vii_id, HENRY_VIII)) ERR; + + /* Check it out. */ + if (nc_inq_grpname(henry_vii_id, name_in)) ERR; + if (strcmp(name_in, HENRY_VIII)) ERR; + + /* Close the file. */ + if (nc_close(ncid)) ERR; + + /* Re-open the file. */ + if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; + + /* Check it out. */ + if (nc_inq_grps(ncid, NULL, &grpid_in)) ERR; + if (nc_inq_grpname(grpid_in, name_in)) ERR; + if (strcmp(name_in, HENRY_VIII)) ERR; + + /* Close the file. */ if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; @@ -223,7 +293,6 @@ main(int argc, char **argv) { int ncid, grp_ncid; int henry_vii_id, margaret_id, james_v_of_scotland_id, mary_i_of_scotland_id; - int james_i_of_england_id; char name_in[NC_MAX_NAME + 1]; char full_name[NC_MAX_NAME * 10], full_name_in[NC_MAX_NAME * 10]; int grpid_in[MAX_SIBLING_GROUPS]; @@ -238,7 +307,9 @@ main(int argc, char **argv) if (nc_def_grp(henry_vii_id, MARGARET, &margaret_id)) ERR; if (nc_def_grp(margaret_id, JAMES_V_OF_SCOTLAND, &james_v_of_scotland_id)) ERR; if (nc_def_grp(james_v_of_scotland_id, MARY_I_OF_SCOTLAND, &mary_i_of_scotland_id)) ERR; - if (nc_def_grp(mary_i_of_scotland_id, JAMES_VI_OF_SCOTLAND_AND_I_OF_ENGLAND, &james_i_of_england_id)) ERR; + /* nc_def_grp will accept NULL as ID pointer. Group will be + * created, but ID not returned. */ + if (nc_def_grp(mary_i_of_scotland_id, JAMES_VI_OF_SCOTLAND_AND_I_OF_ENGLAND, NULL)) ERR; strcpy(full_name, "/"); if (nc_inq_grpname_full(ncid, &len, full_name_in)) ERR; From 196a0b574a6adf0f4728ea716cf38be663227eef Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 19 Jan 2018 05:11:07 -0700 Subject: [PATCH 31/36] more test development --- libsrc4/nc4grp.c | 14 ++++----- nc_test4/tst_grps.c | 71 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 12 deletions(-) diff --git a/libsrc4/nc4grp.c b/libsrc4/nc4grp.c index 080f3bcc31..6930bfa7b7 100644 --- a/libsrc4/nc4grp.c +++ b/libsrc4/nc4grp.c @@ -1,3 +1,6 @@ +/* Copyright 2005-2018, University Corporation for Atmospheric + * Research. See COPYRIGHT file for copying and redistribution + * conditions. */ /** * @file * @internal This file is part of netcdf-4, a netCDF-like interface @@ -5,10 +8,6 @@ * view. * * This file handles the nc4 groups. - * - * Copyright 2005, University Corporation for Atmospheric Research. See - * netcdf-4/docs/COPYRIGHT file for copying and redistribution - * conditions. * * @author Ed Hartnett */ @@ -108,15 +107,16 @@ NC4_rename_grp(int grpid, const char *name) return NC_EPERM; /* attempt to write to a read-only file */ /* Do not allow renaming the root group */ - if(grp->parent == NULL) + if (grp->parent == NULL) return NC_EBADGRPID; /* Check and normalize the name. */ if ((retval = nc4_check_name(name, norm_name))) return retval; - /* Check that this name is not in use as a var, grp, or type. */ - if ((retval = nc4_check_dup_name(grp, norm_name))) + /* Check that this name is not in use as a var, grp, or type in the + * parent group (i.e. the group that grp is in). */ + if ((retval = nc4_check_dup_name(grp->parent, norm_name))) return retval; /* If it's not in define mode, switch to define mode. */ diff --git a/nc_test4/tst_grps.c b/nc_test4/tst_grps.c index a9529ad987..5850f7a42f 100644 --- a/nc_test4/tst_grps.c +++ b/nc_test4/tst_grps.c @@ -20,6 +20,7 @@ #define DIM2_LEN 5 #define VAR1_NAME "Number_of_Beheadings_in_Family" #define DYNASTY "Tudor" +#define HENRY_IV "Henry_IV" #define HENRY_VII "Henry_VII" #define HENRY_VIII "Henry_VIII" #define MARGARET "Margaret" @@ -90,6 +91,10 @@ main(int argc, char **argv) if (nvars_in != 0) ERR; if (nc_inq_varids(grpid_in[0], &ndims_in, dimids_in)) ERR; if (ndims_in != 0) ERR; + if (nc_inq_varids(grpid_in[0], NULL, dimids_in)) ERR; + if (nc_inq_varids(grpid_in[0], &ndims_in, NULL)) ERR; + if (nc_inq_varids(grpid_in[0], NULL, NULL)) ERR; + if (nc_inq_ncid(ncid, HENRY_VII, &ncid_in)) ERR; if (ncid_in != grpid_in[0]) ERR; @@ -110,12 +115,15 @@ main(int argc, char **argv) /* Create a classic model file. No groups will be allowed. */ if (nc_create(FILE_NAME_CLASSIC_MODEL, NC_NETCDF4|NC_CLASSIC_MODEL, &ncid2)) ERR; - if (nc_def_grp(ncid2, HENRY_VII, &henry_vii_id) != NC_ESTRICTNC3) ERR; + if (nc_def_grp(ncid2, HENRY_VII, &henry_vii_id) != NC_ESTRICTNC3) ERR; + if (nc_def_var(ncid2, HENRY_IV, NC_INT, 0, NULL, NULL)); if (nc_close(ncid2)) ERR; /* Create a file with one group, a group to contain data about * Henry VII. */ if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; + if (nc_def_var(ncid, HENRY_IV, NC_INT, 0, NULL, NULL)); + /* Turn off define mode. It will automatically be turned back on * when nc_def_grp is called. */ if (nc_enddef(ncid)) ERR; @@ -123,26 +131,36 @@ main(int argc, char **argv) /* Check it out. */ if (nc_inq_grpname(henry_vii_id, name_in)) ERR; - if (strcmp(name_in, HENRY_VII)) ERR; + if (strcmp(name_in, HENRY_VII)) ERR; + + /* These will not work. */ + if (nc_rename_grp(henry_vii_id, BAD_NAME) != NC_EBADNAME) ERR; + if (nc_rename_grp(henry_vii_id, HENRY_IV) != NC_ENAMEINUSE) ERR; + if (nc_rename_grp(ncid, HENRY_IV) != NC_EBADGRPID) ERR; /* Rename the group. */ if (nc_rename_grp(henry_vii_id, HENRY_VIII)) ERR; /* Check it out. */ if (nc_inq_grpname(henry_vii_id, name_in)) ERR; - if (strcmp(name_in, HENRY_VIII)) ERR; + if (strcmp(name_in, HENRY_VIII)) ERR; /* Close the file. */ if (nc_close(ncid)) ERR; /* Re-open the file. */ - if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; + if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; /* Check it out. */ if (nc_inq_grps(ncid, NULL, &grpid_in)) ERR; if (nc_inq_grpname(grpid_in, name_in)) ERR; if (strcmp(name_in, HENRY_VIII)) ERR; + /* Rename it. */ + if (nc_rename_grp(grpid_in, HENRY_VII)) ERR; + if (nc_inq_grpname(grpid_in, name_in)) ERR; + if (strcmp(name_in, HENRY_VII)) ERR; + /* Close the file. */ if (nc_close(ncid)) ERR; } @@ -192,6 +210,9 @@ main(int argc, char **argv) if (nc_def_var(henry_vii_id, VAR_NAME2, NC_INT64, NDIMS_IN_VAR, &dimid1, &varid2)) ERR; if (nc_def_var(henry_vii_id, VAR_NAME3, NC_INT64, NDIMS_IN_VAR, &dimid2, &varid3)) ERR; + /* These won't work. */ + if (nc_inq_ncid(ncid + TEST_VAL_42, HENRY_VII, &grpid_in) != NC_EBADID) ERR; + /* Check it out. Find the group by name. */ if (nc_inq_ncid(ncid, HENRY_VII, &grpid_in)) ERR; @@ -291,14 +312,26 @@ main(int argc, char **argv) printf("*** testing simple nested group creates..."); { + char root_name[] = "/"; int ncid, grp_ncid; int henry_vii_id, margaret_id, james_v_of_scotland_id, mary_i_of_scotland_id; char name_in[NC_MAX_NAME + 1]; char full_name[NC_MAX_NAME * 10], full_name_in[NC_MAX_NAME * 10]; + char full_name_in1[NC_MAX_NAME * 10]; + char wrong_name[NC_MAX_NAME * 10]; int grpid_in[MAX_SIBLING_GROUPS]; int grp_in; + int grp_in2; int num_grps; - size_t len; + size_t len, len1; + + /* This name is wrong. */ + strcpy(wrong_name, "/"); + strcat(wrong_name, HENRY_VII); + strcpy(wrong_name, "/"); + strcat(wrong_name, MARGARET); + strcpy(wrong_name, "/"); + strcat(wrong_name, MARGARET); /* Create a file with some nested groups in it, suitable * to storing information about the Tudor dynasty of England. */ @@ -316,9 +349,28 @@ main(int argc, char **argv) if (len != 1 || strcmp(full_name_in, full_name)) ERR; if (nc_inq_grpname_len(ncid, &len)) ERR; if (len != 1) ERR; + + /* These won't work. */ + if (nc_inq_grp_full_ncid(ncid + TEST_VAL_42, full_name, &grp_in) != NC_EBADID) ERR; + if (nc_inq_grp_full_ncid(ncid, NULL, &grp_in) != NC_EINVAL) ERR; + + /* Get the ncid from the full name. */ if (nc_inq_grp_full_ncid(ncid, full_name, &grp_in)) ERR; if (grp_in != ncid) ERR; + /* Works (pretty pointlessly) with NULL for ID pointer. */ + if (nc_inq_grp_full_ncid(ncid, full_name, NULL)) ERR; + + /* Get the root group ID from '/'. */ + if (nc_inq_grp_full_ncid(ncid, root_name, &grp_in2)) ERR; + if (grp_in2 != ncid) ERR; + + /* But the root group does not exist within another group. */ + if (nc_inq_grp_full_ncid(mary_i_of_scotland_id, root_name, &grp_in2) != NC_ENOGRP) ERR; + + /* This name is wrong. */ + if (nc_inq_grp_full_ncid(ncid, wrong_name, &grp_in2) != NC_ENOGRP) ERR; + if (nc_inq_grp_ncid(ncid, HENRY_VII, NULL)) ERR; if (nc_inq_grp_ncid(ncid, HENRY_VII, &grp_ncid)) ERR; if (nc_inq_grps(ncid, &num_grps, NULL)) ERR; @@ -326,6 +378,7 @@ main(int argc, char **argv) if (nc_inq_grps(ncid, NULL, grpid_in)) ERR; if (nc_inq_grpname(grpid_in[0], name_in)) ERR; if (strcmp(name_in, HENRY_VII)) ERR; + if (nc_inq_grpname(grpid_in[0], NULL)) ERR; if (grpid_in[0] != grp_ncid) ERR; strcat(full_name, HENRY_VII); if (nc_inq_grpname_full(grpid_in[0], &len, full_name_in)) ERR; @@ -333,6 +386,9 @@ main(int argc, char **argv) if (nc_inq_grp_full_ncid(ncid, full_name, &grp_in)) ERR; if (grp_in != grpid_in[0]) ERR; + /* Also works with NULL last param. */ + if (nc_inq_grp_full_ncid(ncid, full_name, NULL)) ERR; + if (nc_inq_grp_ncid(grpid_in[0], MARGARET, &grp_ncid)) ERR; if (nc_inq_grps(grpid_in[0], &num_grps, grpid_in)) ERR; if (num_grps != 1) ERR; @@ -384,6 +440,11 @@ main(int argc, char **argv) if (len != strlen(full_name) || strcmp(full_name_in, full_name)) ERR; if (nc_inq_grp_full_ncid(ncid, full_name, &grp_in)) ERR; if (grp_in != grpid_in[0]) ERR; + if (nc_inq_grpname_full(grpid_in[0], NULL, NULL)) ERR; + if (nc_inq_grpname_full(grpid_in[0], &len1, NULL)) ERR; + if (len1 != strlen(full_name)) ERR; + if (nc_inq_grpname_full(grpid_in[0], &len, full_name_in1)) ERR; + if (strcmp(full_name_in1, full_name)) ERR; if (nc_close(ncid)) ERR; From 2f7625d19ab12b77f2375c95a76d9f90e31bd558 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 19 Jan 2018 05:19:15 -0700 Subject: [PATCH 32/36] more test development --- nc_test4/tst_grps.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nc_test4/tst_grps.c b/nc_test4/tst_grps.c index 5850f7a42f..a404214ad4 100644 --- a/nc_test4/tst_grps.c +++ b/nc_test4/tst_grps.c @@ -89,10 +89,8 @@ main(int argc, char **argv) if (strcmp(name_in, HENRY_VII)) ERR; if (nc_inq_varids(grpid_in[0], &nvars_in, varids_in)) ERR; if (nvars_in != 0) ERR; - if (nc_inq_varids(grpid_in[0], &ndims_in, dimids_in)) ERR; - if (ndims_in != 0) ERR; - if (nc_inq_varids(grpid_in[0], NULL, dimids_in)) ERR; - if (nc_inq_varids(grpid_in[0], &ndims_in, NULL)) ERR; + if (nc_inq_varids(grpid_in[0], NULL, varids_in)) ERR; + if (nc_inq_varids(grpid_in[0], &nvars_in, NULL)) ERR; if (nc_inq_varids(grpid_in[0], NULL, NULL)) ERR; if (nc_inq_ncid(ncid, HENRY_VII, &ncid_in)) ERR; From ea3874c5676f02390cc7886c51aaa945e856e83e Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 19 Jan 2018 05:40:48 -0700 Subject: [PATCH 33/36] more test development --- libsrc4/nc4grp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc4/nc4grp.c b/libsrc4/nc4grp.c index 6930bfa7b7..c11167c5cd 100644 --- a/libsrc4/nc4grp.c +++ b/libsrc4/nc4grp.c @@ -7,7 +7,7 @@ * for HDF5, or a HDF5 backend for netCDF, depending on your point of * view. * - * This file handles the nc4 groups. + * This file handles groups. * * @author Ed Hartnett */ From cc4eb3cd96a9df7ea5db7f108257862a2ee602be Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 19 Jan 2018 05:41:05 -0700 Subject: [PATCH 34/36] more test development --- libsrc4/nc4grp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc4/nc4grp.c b/libsrc4/nc4grp.c index c11167c5cd..a422fd729c 100644 --- a/libsrc4/nc4grp.c +++ b/libsrc4/nc4grp.c @@ -15,7 +15,7 @@ #include "nc4dispatch.h" /** - * @internal Create a group. It's ncid is returned in the new_ncid + * @internal Create a group. Its ncid is returned in the new_ncid * pointer. * * @param parent_ncid Parent group. From 986673ff49ddb82663b4ba470035e4079aa05b83 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 19 Jan 2018 06:53:04 -0700 Subject: [PATCH 35/36] attempted to fix parallel build issue --- nc_test4/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 3bcb00d6ca..882990deae 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -97,6 +97,7 @@ check_PROGRAMS += tst_interops2 tst_chunk_hdf4 tst_h4_lendian if BUILD_UTILITIES # This test script depends on ncdump. TESTS += tst_interops2 tst_formatx_hdf4.sh +tst_formatx_hdf4.log: tst_interops2.log endif # BUILD_UTILITIES TESTS += run_chunk_hdf4.sh tst_h4_lendian From c5b962f654a5a2b6bd3d32f8ff53beb63782feeb Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 19 Jan 2018 16:16:21 -0700 Subject: [PATCH 36/36] fixed release notes --- RELEASE_NOTES.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 004343c994..dd58e56774 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -11,11 +11,8 @@ reading and writing. See the file docs/filters.md. ## 4.5.1 - TBD -<<<<<<< HEAD * [Enhancement] Added an option to enable strict null-byte padding for headers; this padding was specified in the spec but was not enforced. Enabling this option will allow you to check your files, as it will return an E_NULLPAD error. It is possible for these files to have been written by older versions of libnetcdf. There is no effective problem caused by this lack of null padding, so enabling these options is informational only. The options for `configure` and `cmake` are `--enable-strict-null-byte-header-padding` and `-DENABLE_STRICT_NULL_BYTE_HEADER_PADDING`, respectively. See [Github #657](https://github.com/Unidata/netcdf-c/issues/657) for more information. -======= * Corrected a number of memory issues identified in `ncgen`. See [GitHub #558 for more information](https://github.com/Unidata/netcdf-c/pull/558). ->>>>>>> 53e2517e022c41f60ea0fab72dd5c9109a0230c6 * [Enhancement] Reverted behavior/handling of out-of-range attribute values to pre-4.5.0 default. See [Github #512](https://github.com/Unidata/netcdf-c/issues/512) for more information. * [Bug] Fixed error in tst_parallel2.c. See [Github #545](https://github.com/Unidata/netcdf-c/issues/545) for more information. * [Bug] Fixed handling of corrupt files + proper offset handling for hdf5 files. See [Github #552](https://github.com/Unidata/netcdf-c/issues/552) for more information.