diff --git a/ncgen/bindata.c b/ncgen/bindata.c index 741cb601e..7dd2d57c2 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 fd68dc630..d4ba1d3da 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 45a8eb764..95a78043c 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 c564ab416..6420f7679 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 468986f7b..b20bd0665 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 60ec1e4e8..bf183aae6 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 3211728b3..a5e66bcc2 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 17682246d..7a96ff069 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 9c2449ea6..73f234d4e 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 a47558656..7cc391069 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 98e845bb1..ff27dd7b7 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 9450b0dc8..70110e397 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 710a553c3..c98ef0a2c 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 dbc4ce6fe..73672b8ca 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 42ff6dca1..7afc90f44 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 48bacb065..c595da725 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 0680ecc41..a30553730 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 9e21e44f1..4ad4f9c78 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 @@ yyreduce: 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 @@ yyreduce: 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 @@ yyreduce: (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 @@ yyreduce: } 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 @@ yyreduce: } 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 @@ yyreduce: (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 @@ yyreduce: (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 @@ yyreduce: (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 @@ yyreduce: } 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 @@ yyreduce: 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 @@ yyreduce: 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 a70994c6c..4d09af569 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 2f628fedf..1e5a95fbe 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 9b2dd7023..7ea714f23 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