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