Remove all references to __FILE__ in ncgen

re: issue https://github.com/Unidata/netcdf-c/issues/1323
    and PR https://github.com/Unidata/netcdf-c/pull/1326

Replace the uses of the __FILE__ macro in ncgen with the
constant string "ncgen" in order to keep external package
builders (like Debian) happy.

Note that __FILE__ will still appear in ncgen generated C code
files, but this should be ok since it is not part of the distro
per-se.
This commit is contained in:
Dennis Heimbigner 2019-02-17 14:22:30 -07:00
parent 05dadede2b
commit ad3e3bd48e
2 changed files with 36 additions and 36 deletions

View File

@ -60,7 +60,7 @@ genbin_netcdf(void)
#endif
stat = nc_create(filename, cmode_modifier, &ncid);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
/* ncid created above is also root group*/
rootgroup->nc_id = ncid;
@ -72,7 +72,7 @@ genbin_netcdf(void)
Symbol* gsym = (Symbol*)listget(grpdefs,igrp);
if(gsym == rootgroup) continue; /* ignore root group*/
stat = nc_def_grp(gsym->container->nc_id,gsym->name,&gsym->nc_id);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
#endif
@ -95,7 +95,7 @@ genbin_netcdf(void)
dsym->name,
(dsym->dim.isunlimited?NC_UNLIMITED:dsym->dim.declsize),
&dsym->nc_id);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
}
@ -122,7 +122,7 @@ genbin_netcdf(void)
NULL,
&vsym->nc_id);
}
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
}
@ -154,12 +154,12 @@ genbin_netcdf(void)
if (nofill_flag) {
stat = nc_set_fill(rootgroup->nc_id, NC_NOFILL, 0);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
/* leave define mode */
stat = nc_enddef(rootgroup->nc_id);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
if(!header_only) {
/* Load values into those variables with defined data */
@ -189,7 +189,7 @@ genbin_defineglobalspecials(void)
/* Watch out, this is a global Attribute */
format = kind_string(/*Main.*/format_flag);
stat = nc_put_att_text(rootgroup->nc_id,NC_GLOBAL,"_Format",strlen(format),format);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
#endif /*0*/
@ -206,13 +206,13 @@ genbin_definespecialattributes(Symbol* var)
derror("NC_CHUNKED requested, but no chunksizes specified");
stat = nc_def_var_chunking(var->container->nc_id, var->nc_id, NC_CHUNKED, special->_ChunkSizes);
}
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
if(special->flags & _FLETCHER32_FLAG) {
stat = nc_def_var_fletcher32(var->container->nc_id,
var->nc_id,
special->_Fletcher32);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
if(special->flags & (_DEFLATE_FLAG | _SHUFFLE_FLAG)) {
stat = nc_def_var_deflate(var->container->nc_id,
@ -221,7 +221,7 @@ genbin_definespecialattributes(Symbol* var)
(special->_DeflateLevel >= 0?1:0),
(special->_DeflateLevel >= 0?special->_DeflateLevel
:0));
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
if(special->flags & _ENDIAN_FLAG) {
stat = nc_def_var_endian(var->container->nc_id,
@ -229,14 +229,14 @@ genbin_definespecialattributes(Symbol* var)
(special->_Endianness == NC_ENDIAN_LITTLE?
NC_ENDIAN_LITTLE
:NC_ENDIAN_BIG));
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
if(special->flags & _NOFILL_FLAG) {
stat = nc_def_var_fill(var->container->nc_id,
var->nc_id,
(special->_Fill?NC_FILL:NC_NOFILL),
NULL);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
if(special->flags & _FILTER_FLAG) {
/* Special check for alternate way to specify _Deflate */
@ -263,7 +263,7 @@ genbin_definespecialattributes(Symbol* var)
special->_FilterParams
);
}
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
return stat;
}
@ -275,7 +275,7 @@ genbin_close(void)
{
int stat;
stat = nc_close(rootgroup->nc_id);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
#ifdef USE_NETCDF4
@ -296,7 +296,7 @@ genbin_deftype(Symbol* tsym)
tsym->typ.size,
tsym->name,
&tsym->nc_id);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
break;
case NC_ENUM:
{
@ -305,7 +305,7 @@ genbin_deftype(Symbol* tsym)
tsym->typ.basetype->nc_id,
tsym->name,
&tsym->nc_id);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
datum = bbNew();
for(i=0;i<listlength(tsym->subnodes);i++) {
Symbol* econst = (Symbol*)listget(tsym->subnodes,i);
@ -317,7 +317,7 @@ genbin_deftype(Symbol* tsym)
tsym->nc_id,
econst->name,
bbContents(datum));
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
bbFree(datum);
}
@ -327,14 +327,14 @@ genbin_deftype(Symbol* tsym)
tsym->name,
tsym->typ.basetype->nc_id,
&tsym->nc_id);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
break;
case NC_COMPOUND:
stat = nc_def_compound(tsym->container->nc_id,
tsym->typ.size,
tsym->name,
&tsym->nc_id);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
for(i=0;i<listlength(tsym->subnodes);i++) {
Symbol* efield = (Symbol*)listget(tsym->subnodes,i);
ASSERT(efield->subclass == NC_FIELD);
@ -362,7 +362,7 @@ genbin_deftype(Symbol* tsym)
efield->typ.dimset.ndims,
dimsizes);
}
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
break;
default: panic("definectype: unexpected type subclass");
@ -448,11 +448,11 @@ genbin_writevar(Generator* generator, Symbol* vsym, Bytebuffer* memory,
} else {
stat = nc_put_vara(vsym->container->nc_id, vsym->nc_id, start, count, data);
}
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
#if 0
/* Reclaim the data */
stat = ncaux_reclaim_data(vsym->container->nc_id, vsym->typ.basetype->nc_id, data, nelems);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
bbClear(memory); /* reclaim top-level memory */
#endif
return stat;
@ -481,7 +481,7 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
case NC_BYTE: {
signed char* data = (signed char*)bbContents(databuf);
stat = nc_put_att_schar(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_CHAR: {
char* data = (char*)bbContents(databuf);
@ -495,27 +495,27 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
slen++;
}
stat = nc_put_att_text(grpid,varid,asym->name,slen,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_SHORT: {
short* data = (short*)bbContents(databuf);
stat = nc_put_att_short(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_INT: {
int* data = (int*)bbContents(databuf);
stat = nc_put_att_int(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_FLOAT: {
float* data = (float*)bbContents(databuf);
stat = nc_put_att_float(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_DOUBLE: {
double* data = (double*)bbContents(databuf);
stat = nc_put_att_double(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_STRING: {
const char** data;
@ -527,27 +527,27 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
case NC_UBYTE: {
unsigned char* data = (unsigned char*)bbContents(databuf);
stat = nc_put_att_uchar(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_USHORT: {
unsigned short* data = (unsigned short*)bbContents(databuf);
stat = nc_put_att_ushort(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_UINT: {
unsigned int* data = (unsigned int*)bbContents(databuf);
stat = nc_put_att_uint(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
case NC_INT64: {
long long* data = (long long*)bbContents(databuf);
stat = nc_put_att_longlong(grpid,varid,asym->name,typid,len,data);
check_err2(stat,asym->lineno,__LINE__,__FILE__);
check_err2(stat,asym->lineno,__LINE__,"ncgen");
} break;
case NC_UINT64: {
unsigned long long* data = (unsigned long long*)bbContents(databuf);
stat = nc_put_att_ulonglong(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
} break;
default: PANIC1("genbin_defineattr: unexpected basetype: %d",basetype->typ.typecode);
}
@ -556,13 +556,13 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
data = (const char*)bbContents(databuf);
stat = nc_put_att(grpid,varid,asym->name,typid,
len,(void*)data);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
#ifdef GENDEBUG
{
char out[4096];
memset(out,0x77,sizeof(out));
stat = nc_get_att(grpid,varid,asym->name,&out);
check_err(stat,__LINE__,__FILE__);
check_err(stat,__LINE__,"ncgen");
}
#endif
}

View File

@ -14,7 +14,7 @@ It has diverged slightly over time.
#include "nc_iter.h"
#define CHECK(stat,f) if(stat != NC_NOERR) {check(stat,#f,__FILE__,__LINE__);} else {}
#define CHECK(stat,f) if(stat != NC_NOERR) {check(stat,#f,"ncgen",__LINE__);} else {}
/* forward declarations */
static int nc_blkio_init(size_t bufsize, size_t value_size, int rank,