mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Merge branch 'master' into ejh_func_cleanup3
This commit is contained in:
commit
5f89204bdb
2
cf
2
cf
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#NB=1
|
#NB=1
|
||||||
#DB=1
|
DB=1
|
||||||
#X=-x
|
#X=-x
|
||||||
|
|
||||||
#FAST=1
|
#FAST=1
|
||||||
|
@ -567,7 +567,8 @@ getlimitnumber(const char* limit)
|
|||||||
case 'K': case 'k': multiplier = KILOBYTE; break;
|
case 'K': case 'k': multiplier = KILOBYTE; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
sscanf(limit,"%lu",&lu);
|
if(sscanf(limit,"%lu",&lu) != 1)
|
||||||
|
return 0;
|
||||||
return (lu*multiplier);
|
return (lu*multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,14 +128,17 @@ range(DCEparsestate* state, Object sfirst, Object sstride, Object slast)
|
|||||||
|
|
||||||
/* Note: that incoming arguments are strings; we must convert to size_t;
|
/* Note: that incoming arguments are strings; we must convert to size_t;
|
||||||
but we do know they are legal integers or NULL */
|
but we do know they are legal integers or NULL */
|
||||||
sscanf((char*)sfirst,"%lu",&first); /* always defined */
|
if(sscanf((char*)sfirst,"%lu",&first) != 1) /* always defined */
|
||||||
if(slast != NULL)
|
return NULL;
|
||||||
sscanf((char*)slast,"%lu",&last);
|
if(slast != NULL) {
|
||||||
else
|
if(sscanf((char*)slast,"%lu",&last) != 1)
|
||||||
|
return NULL;
|
||||||
|
} else
|
||||||
last = first;
|
last = first;
|
||||||
if(sstride != NULL)
|
if(sstride != NULL) {
|
||||||
sscanf((char*)sstride,"%lu",&stride);
|
if(sscanf((char*)sstride,"%lu",&stride) != 1)
|
||||||
else
|
return NULL;
|
||||||
|
} else
|
||||||
stride = 1; /* default */
|
stride = 1; /* default */
|
||||||
|
|
||||||
if(stride == 0)
|
if(stride == 0)
|
||||||
@ -158,7 +161,8 @@ Object
|
|||||||
range1(DCEparsestate* state, Object rangenumber)
|
range1(DCEparsestate* state, Object rangenumber)
|
||||||
{
|
{
|
||||||
int range = -1;
|
int range = -1;
|
||||||
sscanf((char*)rangenumber,"%u",&range);
|
if(sscanf((char*)rangenumber,"%u",&range) != 1)
|
||||||
|
range = -1;
|
||||||
if(range < 0) {
|
if(range < 0) {
|
||||||
dceerror(state,"Illegal range index");
|
dceerror(state,"Illegal range index");
|
||||||
}
|
}
|
||||||
@ -199,7 +203,8 @@ array_indices(DCEparsestate* state, Object list0, Object indexno)
|
|||||||
long long start = -1;
|
long long start = -1;
|
||||||
NClist* list = (NClist*)list0;
|
NClist* list = (NClist*)list0;
|
||||||
if(list == NULL) list = nclistnew();
|
if(list == NULL) list = nclistnew();
|
||||||
sscanf((char*)indexno,"%lld",&start);
|
if(sscanf((char*)indexno,"%lld",&start) != 1)
|
||||||
|
start = -1;
|
||||||
if(start < 0) {
|
if(start < 0) {
|
||||||
dceerror(state,"Illegal array index");
|
dceerror(state,"Illegal array index");
|
||||||
start = 1;
|
start = 1;
|
||||||
|
@ -2090,7 +2090,7 @@ printhashmap(NC_hashmap* hm)
|
|||||||
NC_hentry e = hm->table[i];
|
NC_hentry e = hm->table[i];
|
||||||
if(e.flags == ACTIVE) {
|
if(e.flags == ACTIVE) {
|
||||||
fprintf(stderr,"[%ld] flags=ACTIVE hashkey=%lu data=%p keysize=%u key=(%llu)|%s|\n",
|
fprintf(stderr,"[%ld] flags=ACTIVE hashkey=%lu data=%p keysize=%u key=(%llu)|%s|\n",
|
||||||
(unsigned long)i,(unsigned long)e.hashkey,(void*)e.data,(unsigned)e.keysize,(unsigned long long)e.key,e.key);
|
(unsigned long)i,(unsigned long)e.hashkey,(void*)e.data,(unsigned)e.keysize,(unsigned long long)(uintptr_t)e.key,e.key);
|
||||||
running = 0;
|
running = 0;
|
||||||
} else if(e.flags == DELETED) {
|
} else if(e.flags == DELETED) {
|
||||||
fprintf(stderr,"[%ld] flags=DELETED hashkey=%lu\n",
|
fprintf(stderr,"[%ld] flags=DELETED hashkey=%lu\n",
|
||||||
|
@ -226,7 +226,9 @@ nc4_close_netcdf4_file(NC_FILE_INFO_T *h5, int abort, int extractmem)
|
|||||||
exit:
|
exit:
|
||||||
/* Free the nc4_info struct; above code should have reclaimed
|
/* Free the nc4_info struct; above code should have reclaimed
|
||||||
everything else */
|
everything else */
|
||||||
|
|
||||||
if (!retval)
|
if (!retval)
|
||||||
|
|
||||||
free(h5);
|
free(h5);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ echo "*** Testing dynamic filters using nccopy"
|
|||||||
rm -f ./unfiltered.nc ./filtered.nc ./tmp.nc ./filtered.dump ./tst_filter.txt
|
rm -f ./unfiltered.nc ./filtered.nc ./tmp.nc ./filtered.dump ./tst_filter.txt
|
||||||
${NCGEN} -4 -lb -o unfiltered.nc ${srcdir}/unfiltered.cdl
|
${NCGEN} -4 -lb -o unfiltered.nc ${srcdir}/unfiltered.cdl
|
||||||
echo " *** Testing simple filter application"
|
echo " *** Testing simple filter application"
|
||||||
${NCCOPY} -F "/g/var,307,9,4" unfiltered.nc filtered.nc
|
${NCCOPY} -M0 -F "/g/var,307,9,4" unfiltered.nc filtered.nc
|
||||||
${NCDUMP} -s filtered.nc > ./tst_filter.txt
|
${NCDUMP} -s filtered.nc > ./tst_filter.txt
|
||||||
# Remove irrelevant -s output
|
# Remove irrelevant -s output
|
||||||
sclean ./tst_filter.txt ./filtered.dump
|
sclean ./tst_filter.txt ./filtered.dump
|
||||||
@ -119,7 +119,7 @@ echo " *** Pass: pass-thru of filters"
|
|||||||
|
|
||||||
echo " *** Testing -F none"
|
echo " *** Testing -F none"
|
||||||
rm -f ./tst_filter.txt ./tst_filter2.txt ./tst_filter.nc
|
rm -f ./tst_filter.txt ./tst_filter2.txt ./tst_filter.nc
|
||||||
${NCCOPY} -F none ./filtered.nc ./tst_filter.nc
|
${NCCOPY} -M0 -F none ./filtered.nc ./tst_filter.nc
|
||||||
${NCDUMP} -s tst_filter.nc > ./tst_filter.txt
|
${NCDUMP} -s tst_filter.nc > ./tst_filter.txt
|
||||||
sed -e '/_Filter/p' -e d < ./tst_filter.txt >./tst_filter2.txt
|
sed -e '/_Filter/p' -e d < ./tst_filter.txt >./tst_filter2.txt
|
||||||
test ! -s tst_filter2.txt
|
test ! -s tst_filter2.txt
|
||||||
@ -127,7 +127,7 @@ echo " *** Pass: -F none"
|
|||||||
|
|
||||||
echo " *** Testing -F var,none "
|
echo " *** Testing -F var,none "
|
||||||
rm -f ./tst_filter.txt ./tst_filter.nc
|
rm -f ./tst_filter.txt ./tst_filter.nc
|
||||||
${NCCOPY} -F "/g/var,none" ./filtered.nc ./tst_filter.nc
|
${NCCOPY} -M0 -F "/g/var,none" ./filtered.nc ./tst_filter.nc
|
||||||
${NCDUMP} -s tst_filter.nc > ./tst_filter.txt
|
${NCDUMP} -s tst_filter.nc > ./tst_filter.txt
|
||||||
sed -e '/_Filter/p' -e d < ./tst_filter.txt >tst_filter2.txt
|
sed -e '/_Filter/p' -e d < ./tst_filter.txt >tst_filter2.txt
|
||||||
test ! -s tst_filter2.txt
|
test ! -s tst_filter2.txt
|
||||||
|
@ -2133,6 +2133,8 @@ main(int argc, char**argv)
|
|||||||
if(level >= 0)
|
if(level >= 0)
|
||||||
nc_set_log_level(level);
|
nc_set_log_level(level);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
error("-L specified, but logging support not enabled");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'F': /* optional filter spec for a specified variable */
|
case 'F': /* optional filter spec for a specified variable */
|
||||||
@ -2154,9 +2156,13 @@ main(int argc, char**argv)
|
|||||||
#else
|
#else
|
||||||
error("-F requires netcdf-4");
|
error("-F requires netcdf-4");
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
case 'M': /* set min chunk size */
|
case 'M': /* set min chunk size */
|
||||||
#ifdef USE_NETCDF4
|
#ifdef USE_NETCDF4
|
||||||
option_min_chunk_bytes = atol(optarg);
|
if(optarg == NULL)
|
||||||
|
option_min_chunk_bytes = -1;
|
||||||
|
else
|
||||||
|
option_min_chunk_bytes = atol(optarg);
|
||||||
if(option_min_chunk_bytes < 0)
|
if(option_min_chunk_bytes < 0)
|
||||||
error("-M value must be non-negative integer");
|
error("-M value must be non-negative integer");
|
||||||
break;
|
break;
|
||||||
|
@ -217,7 +217,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'D': {
|
case 'D': {
|
||||||
int c0;
|
int c0;
|
||||||
if(strlen(optarg) == 0) usage("missing -D argument");
|
if(optarg == NULL || strlen(optarg) == 0) usage("missing -D argument");
|
||||||
c0 = optarg[0];
|
c0 = optarg[0];
|
||||||
if(c0 >= '0' && c0 <= '9') {/* debug level */
|
if(c0 >= '0' && c0 <= '9') {/* debug level */
|
||||||
ocopt.debug.debuglevel = atoi(optarg); break;
|
ocopt.debug.debuglevel = atoi(optarg); break;
|
||||||
@ -245,6 +245,8 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
if(ocopt.output != NULL) fclose(ocopt.output);
|
if(ocopt.output != NULL) fclose(ocopt.output);
|
||||||
|
if(optarg == NULL)
|
||||||
|
usage("-o does not specify a file name");
|
||||||
ocopt.output = fopen(optarg,"w");
|
ocopt.output = fopen(optarg,"w");
|
||||||
if(ocopt.output == NULL)
|
if(ocopt.output == NULL)
|
||||||
usage("-o file not writeable");
|
usage("-o file not writeable");
|
||||||
@ -255,6 +257,8 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
|
if(optarg == NULL)
|
||||||
|
usage("-p does not specify an argument");
|
||||||
if(strcasecmp(optarg,"das")==0) ocopt.optdas=1;
|
if(strcasecmp(optarg,"das")==0) ocopt.optdas=1;
|
||||||
else if(strcasecmp(optarg,"dds")==0) ocopt.optdds=1;
|
else if(strcasecmp(optarg,"dds")==0) ocopt.optdds=1;
|
||||||
else if(strcasecmp(optarg,"data")==0) ocopt.optdatadds=1;
|
else if(strcasecmp(optarg,"data")==0) ocopt.optdatadds=1;
|
||||||
@ -280,7 +284,8 @@ main(int argc, char **argv)
|
|||||||
if(ocopt.logging) {
|
if(ocopt.logging) {
|
||||||
ncloginit();
|
ncloginit();
|
||||||
ncsetlogging(1);
|
ncsetlogging(1);
|
||||||
nclogopen(NULL);
|
if(!nclogopen(NULL))
|
||||||
|
fprintf(stderr,"Failed to open logging output\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
@ -479,10 +484,7 @@ processdata(OCflags flags)
|
|||||||
if(ocopt.optdatadds) {
|
if(ocopt.optdatadds) {
|
||||||
ocstat = oc_fetch(link,ocopt.url->query,OCDATADDS,flags,&dataddsroot);
|
ocstat = oc_fetch(link,ocopt.url->query,OCDATADDS,flags,&dataddsroot);
|
||||||
if(ocstat) {
|
if(ocstat) {
|
||||||
if(ocopt.url->query)
|
fprintf(stderr,"Cannot read DATADDS: %s\n",ocopt.surl);
|
||||||
fprintf(stderr,"Cannot read DATADDS: %s\n",ocopt.surl);
|
|
||||||
else
|
|
||||||
fprintf(stderr,"Cannot read DATADDS: %s\n",ocopt.surl);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if(ocopt.debug.dumpdds)
|
if(ocopt.debug.dumpdds)
|
||||||
@ -556,8 +558,8 @@ printdata_container(OClink link, OCdatanode datanode, NCbytes* buffer, int istop
|
|||||||
pushstack(field);
|
pushstack(field);
|
||||||
FAIL(printdata_indices(link,field,buffer,istoplevel));
|
FAIL(printdata_indices(link,field,buffer,istoplevel));
|
||||||
popstack();
|
popstack();
|
||||||
oc_data_free(link,field);
|
if(oc_data_free(link,field) != OC_NOERR)
|
||||||
if(stat != OC_NOERR) break;
|
break;
|
||||||
}
|
}
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
@ -997,7 +999,7 @@ dumpdatanode(OClink link, OCdatanode datanode, size_t count, void* memory, NCbyt
|
|||||||
OCtype atomtype;
|
OCtype atomtype;
|
||||||
OCtype octype;
|
OCtype octype;
|
||||||
NCbytes* path = NULL;
|
NCbytes* path = NULL;
|
||||||
char* name;
|
char* name = NULL;
|
||||||
char id[1024];
|
char id[1024];
|
||||||
char tmp[1024];
|
char tmp[1024];
|
||||||
struct DUMPPATH* entry = NULL;
|
struct DUMPPATH* entry = NULL;
|
||||||
|
@ -103,7 +103,7 @@ dap_unrecognizedresponse(DAPparsestate* state)
|
|||||||
unsigned int httperr = 0;
|
unsigned int httperr = 0;
|
||||||
int i;
|
int i;
|
||||||
char iv[32];
|
char iv[32];
|
||||||
sscanf(state->lexstate->input,"%u ",&httperr);
|
(void)sscanf(state->lexstate->input,"%u ",&httperr);
|
||||||
sprintf(iv,"%u",httperr);
|
sprintf(iv,"%u",httperr);
|
||||||
state->lexstate->next = state->lexstate->input;
|
state->lexstate->next = state->lexstate->input;
|
||||||
/* Limit the amount of input to prevent runaway */
|
/* Limit the amount of input to prevent runaway */
|
||||||
|
Loading…
Reference in New Issue
Block a user