Skip to content

Commit

Permalink
Fix for github issue #310.
Browse files Browse the repository at this point in the history
The problem was that for opendap, it is possible to use keywords
as identifiers
 when there is no ambiguity. However, the DAP2
parser lost the case of the identifier used the lower case version.
Fix is to use the actual text of the symbol when it is used as an identifier.
Also added a test case for this (kwcase.*).

Additionally cleaned up some misc. dap2 testing problems.
1. ncdap_test/tst_ncdap3.sh was using an empty test set.
   restored the testing of datasets.
2. as a consequence of #1, some tests needed to be updated with minor
   tweeks.
3. fix dapmerge to handle multiple DODS_EXTRAS attributes.
4. modify buildattribute to suppress nul characters and terminate
   the name at the first nul.
5. clean up various test scripts to remove residual, unused
   references to obsolete netcdf-4 translation.
6. export e.g. NCDUMP from test_common.in so that non-top-level
   shell scripts can access it.
  • Loading branch information
DennisHeimbigner committed Jun 28, 2017
1 parent 8ee484b commit dc9e31d
Show file tree
Hide file tree
Showing 39 changed files with 869 additions and 198 deletions.
42 changes: 29 additions & 13 deletions libdap2/dapattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,20 @@ fprintf(stderr,"%s.dimname=%s\n",node->ocname,node->dodsspecial.dimname);
} else node->dodsspecial.dimname = NULL;
} else if(strcmp(ocname,"DODS.Unlimited_Dimension")==0
|| strcmp(ocname,"DODS_EXTRA.Unlimited_Dimension")==0) {
if(values != NULL) {
if(nccomm->cdf.recorddimname != NULL)
char* val0 = NULL;
if(values != NULL)
val0 = values[0];
if(val0 != NULL) {
if(nccomm->cdf.recorddimname != NULL) {
if(strcmp(nccomm->cdf.recorddimname,val0)!=0)
nclog(NCLOGWARN,"Duplicate DODS_EXTRA:Unlimited_Dimension specifications");
else
} else {
nccomm->cdf.recorddimname = nulldup(values[0]);
#ifdef DEBUG
fprintf(stderr,"%s.Unlimited_Dimension=%s\n",node->ocname,nccomm->cdf.recorddimname);
#endif
}
}

}
}
/* clean up */
Expand All @@ -115,7 +119,13 @@ fprintf(stderr,"%s.Unlimited_Dimension=%s\n",node->ocname,nccomm->cdf.recorddimn
return THROW(ncstat);
}

/* Build an NCattribute */
/*
Build an NCattribute
from a DAP attribute.
As of Jun 27, 2017, we modify
to suppress nul characters and terminate
the name at the first nul.
*/
static NCerror
buildattribute(char* name, nc_type ptype,
size_t nvalues, char** values, NCattribute** attp)
Expand All @@ -130,9 +140,10 @@ buildattribute(char* name, nc_type ptype,
att->etype = ptype;

att->values = nclistnew();
for(i=0;i<nvalues;i++)
nclistpush(att->values,(void*)nulldup(values[i]));

for(i=0;i<nvalues;i++) {
char* copy = nulldup(values[i]);
nclistpush(att->values,(void*)copy);
}
if(attp) *attp = att;
else
free(att);
Expand Down Expand Up @@ -399,14 +410,19 @@ fprintf(stderr,"%s.dimname=%s\n",dds->ocname,dds->dodsspecial.dimname);
#endif
} else dds->dodsspecial.dimname = NULL;
} else if(strcmp(dodsname,"Unlimited_Dimension")==0) {
if(nccomm->cdf.recorddimname != NULL) {
nclog(NCLOGWARN,"Duplicate DODS_EXTRA:Unlimited_Dimension specifications");
} else if(nclistlength(stringvalues) > 0) {
char* stringval = (char*)nclistget(stringvalues,0);
nccomm->cdf.recorddimname = nulldup(stringval);
char* stringval = NULL;
if(nclistlength(stringvalues) > 0)
stringval = (char*)nclistget(stringvalues,0);
if(stringval != NULL) {
if(nccomm->cdf.recorddimname != NULL) {
if(strcmp(stringval,nccomm->cdf.recorddimname) != 0)
nclog(NCLOGWARN,"Duplicate DODS_EXTRA:Unlimited_Dimension specifications");
} else {
nccomm->cdf.recorddimname = nulldup(stringval);
#ifdef DEBUG
fprintf(stderr,"%s.Unlimited_Dimension=%s\n",dds->ocname,nccomm->cdf.recorddimname);
#endif
}
}
} /* else ignore */
nullfree(dodsname);
Expand Down
5 changes: 4 additions & 1 deletion libdap2/dapdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ int ncdap3debug = 0;
#ifdef CATCHERROR
/* Place breakpoint here to catch errors close to where they occur*/
int
dapbreakpoint(int err) {return err;}
dapbreakpoint(int err)
{
return err;
}

int
dapthrow(int err)
Expand Down
1 change: 1 addition & 0 deletions libdap2/nccommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ typedef struct NCCDF {
size_t smallsizelimit; /* what constitutes a small object? */
size_t totalestimatedsize;
const char* separator; /* constant; do not free */
/* Following fields should be set from the unconstrained dds only */
/* global string dimension */
struct CDFnode* globalstringdim;
char* recorddimname; /* From DODS_EXTRA */
Expand Down
8 changes: 5 additions & 3 deletions libdap2/ncd2dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "dapincludes.h"
#include "ncd2dispatch.h"
#include "ncoffsets.h"
#ifdef DEBUG2
#include "dapdump.h"
#endif

#ifdef _MSC_VER
#include <crtdbg.h>
Expand Down Expand Up @@ -2020,7 +2023,7 @@ fetchpatternmetadata(NCDAPCOMMON* dapcomm)
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
}

#ifdef DEBUG
#ifdef DEBUG2
fprintf(stderr,"full pattern:\n%s",dumptree(dapcomm->cdf.fullddsroot));
#endif

Expand Down Expand Up @@ -2061,7 +2064,7 @@ fetchconstrainedmetadata(NCDAPCOMMON* dapcomm)
if(ncstat) goto fail;
}

#ifdef DEBUG
#ifdef DEBUG2
fprintf(stderr,"constrained:\n%s",dumptree(dapcomm->cdf.ddsroot));
#endif

Expand All @@ -2071,7 +2074,6 @@ fprintf(stderr,"constrained:\n%s",dumptree(dapcomm->cdf.ddsroot));
dapcomm->oc.ocdasroot);
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
}

/* map the constrained DDS to the unconstrained DDS */
ncstat = mapnodes(dapcomm->cdf.ddsroot,dapcomm->cdf.fullddsroot);
if(ncstat) goto fail;
Expand Down
7 changes: 2 additions & 5 deletions ncdap_test/expected3/123.nc.dmp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ dimensions:
variables:
short l(l) ;
char bears(i, j, maxStrlen64) ;
bears:act = "text string\n",
"\t123" ;
bears:act = "text string\\012\\011123" ;
bears:acs = -40s ;
bears:acl = 17000 ;
bears:acf = -2.f, 1.f, 0.f ;
Expand All @@ -20,9 +19,7 @@ variables:
double cross(i, j) ;

// global attributes:
:history = "This is an example of a multi-line global\n",
"attribute. It could be used for representing the\n",
"processing history of the data, for example." ;
:history = "This is an example of a multi-line global\\012attribute. It could be used for representing the\\012processing history of the data, for example." ;
:DODS_EXTRA.Unlimited_Dimension = "k" ;
data:

Expand Down
7 changes: 2 additions & 5 deletions ncdap_test/expected3/123bears.nc.dmp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ dimensions:
variables:
short l(l) ;
char bears(i, j, maxStrlen64) ;
bears:act = "text string\n",
"\t123" ;
bears:act = "text string\\012\\011123" ;
bears:acs = -40s ;
bears:acl = 17000 ;
bears:acf = -2.f, 1.f, 0.f ;
Expand All @@ -20,9 +19,7 @@ variables:
double cross(i, j) ;

// global attributes:
:history = "This is an example of a multi-line global\n",
"attribute. It could be used for representing the\n",
"processing history of the data, for example." ;
:history = "This is an example of a multi-line global\\012attribute. It could be used for representing the\\012processing history of the data, for example." ;
:DODS_EXTRA.Unlimited_Dimension = "k" ;
data:

Expand Down
Loading

0 comments on commit dc9e31d

Please sign in to comment.