Skip to content

Commit

Permalink
test1
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHeimbigner committed Feb 11, 2025
1 parent aa66703 commit 8b57718
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main-cmake.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: NetCDF-C CMake CI - Windows

on: [ pull_request, workflow_dispatch]
on: [push, pull_request, workflow_dispatch]

env:
REMOTETESTDOWN: ${{ vars.REMOTETESTDOWN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

name: Run macOS-based netCDF Tests

on: [pull_request,workflow_dispatch]
on: [push,pull_request,workflow_dispatch]

concurrency:
group: ${{ github.workflow}}-${{ github.head_ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: Run Ubuntu/Linux netCDF Tests

on: [pull_request,workflow_dispatch]
on: [push,pull_request,workflow_dispatch]

env:
REMOTETESTDOWN: ${{ vars.REMOTETESTDOWN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_win_cygwin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run Cygwin-based tests

on: [pull_request,workflow_dispatch]
on: [push,pull_request,workflow_dispatch]

concurrency:
group: ${{ github.workflow}}-${{ github.head_ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_win_mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
CPPFLAGS: "-D_BSD_SOURCE"
REMOTETESTDOWN: ${{ vars.REMOTETESTDOWN }}

on: [pull_request,workflow_dispatch]
on: [push,pull_request,workflow_dispatch]

concurrency:
group: ${{ github.workflow}}-${{ github.head_ref }}
Expand Down
2 changes: 1 addition & 1 deletion libdap2/ncd2dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ fprintf(stderr,"\n");
NCattribute* att = (NCattribute*)nclistget(var->attributes,j);
char* val = NULL;
/* Check for _FillValue/Variable mismatch */
if(strcmp(att->name,"_FillValue")==0) {
if(strcmp(att->name,NC_FillValue)==0) {
/* Special case var is byte, fillvalue is int16 and
unsignedattr == 0;
This exception is needed because DAP2 byte type
Expand Down
7 changes: 5 additions & 2 deletions libdap4/d4http.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
nclog(NCLOGWARN,"WriteMemoryCallback: zero sized chunk");
/* Optimize for reading potentially large dods datasets */
while(!ncbytesavail(buf,realsize)) {
/* double the size of the packet */
ncbytessetalloc(buf,2*ncbytesalloc(buf));
/* double the size of the packet (unless the buf is empty) */
if(ncbytesalloc(buf) == 0)
ncbytessetalloc(buf,1024);
else
ncbytessetalloc(buf,2*ncbytesalloc(buf));
}
ncbytesappendn(buf, ptr, realsize);
#ifdef PROGRESS
Expand Down
2 changes: 1 addition & 1 deletion libdap4/d4meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ compileAttrValues(NCD4meta* builder, NCD4node* attr, void** memoryp, NClist* blo
memset((void*)&converter,0,sizeof(converter));

/* Deal with _FillValue */
if(container->sort == NCD4_VAR && strcmp(attr->name,"_FillValue")==0) {
if(container->sort == NCD4_VAR && strcmp(attr->name,NC_FillValue)==0) {
/* Verify or fix or ignore or fail on type mismatch */
if(container->basetype != basetype) {/* _FillValue/Variable type mismatch */
int compatible = isfilltypecompatible(container->basetype, basetype);
Expand Down
68 changes: 40 additions & 28 deletions libdap4/d4parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ static const struct KEYWORDINFO {
};
typedef struct KEYWORDINFO KEYWORDINFO;

static const struct ATOMICTYPEINFO {
/* Warning do not make const because sort will modify */
static struct ATOMICTYPEINFO {
char* name; nc_type type; size_t size;
} atomictypeinfo[] = {
/* Keep in sorted order for binary search */
/* Will be sorted on first use */
/* Use lower case for canonical comparison, but keep proper name here */
{"Byte",NC_BYTE,sizeof(char)},
{"Char",NC_CHAR,sizeof(char)},
Expand All @@ -85,8 +86,9 @@ static const struct ATOMICTYPEINFO {
{"UInt64",NC_UINT64,sizeof(unsigned long long)},
{"UInt8",NC_UBYTE,sizeof(unsigned char)},
{"Url",NC_STRING,sizeof(char*)},
{NULL,NC_NAT,0}
};
#define NCD4_NATOMICTYPES (sizeof(atomictypeinfo)/sizeof(struct ATOMICTYPEINFO))
static int atomictypessorted = 0;

/***************************************************/

Expand Down Expand Up @@ -116,7 +118,7 @@ static NCD4node* getOpaque(NCD4parser*, ncxml_t varxml, NCD4node* group);
static int getValueStrings(NCD4parser*, NCD4node*, ncxml_t xattr, NClist*);
static int isReserved(const char* name);
static const KEYWORDINFO* keyword(const char* name);
static NCD4node* lookupAtomicType(NClist*, const char* name);
static NCD4node* lookupAtomicType(NClist*,const char* name);
static NCD4node* lookFor(NClist* elems, const char* name, NCD4sort sort);
static NCD4node* lookupFQN(NCD4parser*, const char* sfqn, NCD4sort);
static int lookupFQNList(NCD4parser*, NClist* fqn, NCD4sort sort, NCD4node** result);
Expand Down Expand Up @@ -764,6 +766,7 @@ parseMaps(NCD4parser* parser, NCD4node* var, ncxml_t xml)
int ret = NC_NOERR;
ncxml_t x;

NC_UNUSED(parser);
for(x=ncxml_child(xml, "Map");x!= NULL;x=ncxml_next(x,"Map")) {
char* fqn;
fqn = ncxml_attr(x,"name");
Expand Down Expand Up @@ -937,6 +940,8 @@ static int
getValueStrings(NCD4parser* parser, NCD4node* type, ncxml_t xattr, NClist* svalues)
{
char* s;
NC_UNUSED(parser);
NC_UNUSED(type);
/* See first if we have a "value" xml attribute */
s = ncxml_attr(xattr,"value");
if(s != NULL)
Expand Down Expand Up @@ -1249,7 +1254,7 @@ defineBytestringType(NCD4parser* parser)
if(ret != NC_NOERR) goto done;
SETNAME(bstring,"_bytestring");
bstring->opaque.size = 0;
bstring->basetype = lookupAtomicType(parser,"UInt8");
bstring->basetype = lookupAtomicType(parser->meta->atomictypes,"UInt8");
PUSH(parser->metadata->root->types,bstring);
parser->metadata->_bytestring = bstring;
} else
Expand All @@ -1259,16 +1264,25 @@ defineBytestringType(NCD4parser* parser)
}
#endif

static int atisort(const void* a, const void* b)
{
return strcasecmp(((struct ATOMICTYPEINFO*)a)->name,((struct ATOMICTYPEINFO*)b)->name);
}

static int
defineAtomicTypes(NCD4meta* meta, NClist* list)
{
int ret = NC_NOERR;
NCD4node* node;
const struct ATOMICTYPEINFO* ati;
size_t i;

if(list == NULL)
return THROW(NC_EINTERNAL);
for(ati=atomictypeinfo;ati->name;ati++) {
if(list == NULL) return THROW(NC_EINTERNAL);
if(!atomictypessorted) {
qsort((void*)atomictypeinfo, NCD4_NATOMICTYPES,sizeof(struct ATOMICTYPEINFO),atisort);
atomictypessorted = 1;
}
for(i=0;i<NCD4_NATOMICTYPES;i++) {
const struct ATOMICTYPEINFO* ati = &atomictypeinfo[i];
if((ret=makeNodeStatic(meta,NULL,NCD4_TYPE,ati->type,&node))) goto done;
SETNAME(node,ati->name);
PUSH(list,node);
Expand All @@ -1277,29 +1291,26 @@ defineAtomicTypes(NCD4meta* meta, NClist* list)
return THROW(ret);
}

static int
aticmp(const void* a, const void* b)
{
const char* name = (const char*)a;
NCD4node** nodebp = (NCD4node**)b;
return strcasecmp(name,(*nodebp)->name);
}

/* Binary search the set of set of atomictypes */
static NCD4node*
lookupAtomicType(NClist* atomictypes, const char* name)
{
size_t n = nclistlength(atomictypes);
if (n == 0) return NULL;
size_t L = 0;
size_t R = n - 1;
NCD4node* p;

for(;;) {
if(L > R) break;
size_t m = (L + R) / 2;
p = (NCD4node*)nclistget(atomictypes,m);
int cmp = strcasecmp(p->name,name);
if(cmp == 0)
return p;
if(cmp < 0)
L = (m + 1);
else /*cmp > 0*/
R = (m - 1);
}
return NULL;
void* match = NULL;
size_t ntypes = 0;
NCD4node** types = NULL;
assert(atomictypessorted && nclistlength(atomictypes) > 0);
ntypes = nclistlength(atomictypes);
types = (NCD4node**)atomictypes->content;
match = bsearch((void*)name,(void*)types,ntypes,sizeof(NCD4node*),aticmp);
return (match==NULL?NULL:*(NCD4node**)match);
}

/**************************************************/
Expand Down Expand Up @@ -1650,6 +1661,7 @@ parseForwards(NCD4parser* parser, NCD4node* root)
int ret = NC_NOERR;
size_t i,j;

NC_UNUSED(root);
/* process all vars */
for(i=0;i<nclistlength(parser->vars);i++) {
NCD4node* var = (NCD4node*)nclistget(parser->vars,i);
Expand Down

0 comments on commit 8b57718

Please sign in to comment.