mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-12 15:45:21 +08:00
fix bug in opaque parsing
This commit is contained in:
parent
766b45b459
commit
e42d7d7f61
3
cf
3
cf
@ -125,7 +125,8 @@ FLAGS="$FLAGS --disable-pnetcdf"
|
||||
#FLAGS="$FLAGS --enable-dap-long-tests"
|
||||
#FLAGS="$FLAGS --enable-ffio"
|
||||
#FLAGS="$FLAGS --enable-benchmarks"
|
||||
#FLAGS="$FLAGS --enable-extra-tests"
|
||||
FLAGS="$FLAGS --enable-extra-tests"
|
||||
FLAGS="$FLAGS --enable-logging"
|
||||
#FLAGS="$FLAGS --enable-large-file-tests"
|
||||
#FLAGS="$FLAGS --disable-testsets"
|
||||
#FLAGS="$FLAGS --enable-mmap"
|
||||
|
@ -2967,19 +2967,21 @@ close_netcdf4_file(NC_HDF5_FILE_INFO_T *h5, int abort)
|
||||
{
|
||||
if (H5Fclose(h5->hdfid) < 0)
|
||||
{
|
||||
int nobjs;
|
||||
nobjs = H5Fget_obj_count(h5->hdfid, H5F_OBJ_ALL);
|
||||
/* Apparently we can get an error even when nobjs == 0 */
|
||||
if(nobjs < 0) {
|
||||
return NC_EHDFERR;
|
||||
} else if(nobjs > 0) {
|
||||
#ifdef LOGGING
|
||||
/* If the close doesn't work, probably there are still some HDF5
|
||||
* objects open, which means there's a bug in the library. So
|
||||
* print out some info on to help the poor programmer figure it
|
||||
* out. */
|
||||
{
|
||||
int nobjs;
|
||||
if ((nobjs = H5Fget_obj_count(h5->hdfid, H5F_OBJ_ALL) < 0))
|
||||
return NC_EHDFERR;
|
||||
LOG((0, "There are %d HDF5 objects open!", nobjs));
|
||||
}
|
||||
LOG((0, "There are %d HDF5 objects open!", nobjs));
|
||||
#endif
|
||||
return NC_EHDFERR;
|
||||
}
|
||||
}
|
||||
/* if (H5garbage_collect() < 0)
|
||||
return NC_EHDFERR; */
|
||||
|
@ -13,6 +13,7 @@
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
nc_set_log_level(0);
|
||||
printf("\n*** Testing netcdf-4 dimensions even more.\n");
|
||||
printf("*** testing netcdf-4 dimension inheritance...");
|
||||
{
|
||||
@ -78,7 +79,7 @@ main(int argc, char **argv)
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** testing a scalar coordinate dimension...");
|
||||
{
|
||||
int ncid, dimid, varid;
|
||||
int ncid, dimid, varid, stat;
|
||||
float data = 42.5;
|
||||
|
||||
/* Create a scalar coordinate dimension. The only reason that
|
||||
@ -92,7 +93,8 @@ main(int argc, char **argv)
|
||||
if (nc_def_dim(ncid, "scalar", 0, &dimid)) ERR_RET;
|
||||
if (nc_def_var(ncid, "scalar", NC_FLOAT, 0, &dimid, &varid)) ERR_RET;
|
||||
if (nc_put_var_float(ncid, varid, &data)) ERR_RET;
|
||||
if (nc_close(ncid)) ERR_RET;
|
||||
if (nc_close(ncid))
|
||||
ERR_RET;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
FINAL_RESULTS;
|
||||
|
@ -526,6 +526,7 @@ case CASE(NC_OPAQUE,NC_OPAQUE):
|
||||
tmp.opaquev.stringv = (char*)malloc(src->value.opaquev.len);
|
||||
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';
|
||||
break;
|
||||
|
||||
/* We are missing all CASE(X,NC_ECONST) cases*/
|
||||
|
@ -190,10 +190,9 @@ yytext[MAXTRST-1] = '\0';
|
||||
{OPAQUESTRING} { /* drop leading 0x; pad to even number of chars */
|
||||
char* p = yytext+2;
|
||||
int len = yyleng - 2;
|
||||
int padlen = len;
|
||||
if((padlen % 2) == 1) padlen++;
|
||||
bbClear(lextext);
|
||||
bbAppendn(lextext,p,len);
|
||||
if((len % 2) == 1) bbAppend(lextext,'0');
|
||||
bbNull(lextext);
|
||||
/* convert all chars to lower case */
|
||||
for(p=bbContents(lextext);*p;p++) *p = tolower(*p);
|
||||
|
@ -1033,17 +1033,13 @@ makeconstdata(nc_type nctype)
|
||||
#ifdef USE_NETCDF4
|
||||
case NC_OPAQUE: {
|
||||
char* s;
|
||||
int len,padlen;
|
||||
int len;
|
||||
len = bbLength(lextext);
|
||||
padlen = len;
|
||||
if(padlen < 16) padlen = 16;
|
||||
if((padlen % 2) == 1) padlen++;
|
||||
s = (char*)emalloc(padlen+1);
|
||||
memset((void*)s,'0',padlen);
|
||||
s[padlen]='\0';
|
||||
s = (char*)emalloc(len+1);
|
||||
strncpy(s,bbContents(lextext),len);
|
||||
s[len] = '\0';
|
||||
con.value.opaquev.stringv = s;
|
||||
con.value.opaquev.len = padlen;
|
||||
con.value.opaquev.len = len;
|
||||
} break;
|
||||
#endif
|
||||
|
||||
|
935
ncgen/ncgentab.c
935
ncgen/ncgentab.c
File diff suppressed because it is too large
Load Diff
1720
ncgen/ncgenyy.c
1720
ncgen/ncgenyy.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user