From ab5022256d90fb9612e0432a63ecc34065391f8c Mon Sep 17 00:00:00 2001 From: dmh Date: Sat, 16 May 2015 15:46:39 -0600 Subject: [PATCH] need to set -e many of the .sh programs --- cf | 2 +- libdap2/dapdebug.h | 2 +- libdap2/env | 6 +- libsrc/attr.c | 2691 ++++++++++++++++++++---------------- ncdap_test/tst_ncdap.sh | 1 + ncdap_test/tst_ncdap3.sh | 2 + ncdap_test/tst_ncdap4.sh | 2 + ncdap_test/tst_nocache3.sh | 2 + ncdap_test/tst_nocache4.sh | 2 + ncdap_test/tst_remote.sh | 13 +- ncdap_test/tst_remote3.sh | 4 +- ncdap_test/tst_remote4.sh | 2 + ncdap_test/tst_special.sh | 2 + ncdap_test/tst_tds.sh | 2 + 14 files changed, 1543 insertions(+), 1190 deletions(-) diff --git a/cf b/cf index 3736feac2..dda3508e4 100644 --- a/cf +++ b/cf @@ -123,7 +123,7 @@ FLAGS="$FLAGS --disable-examples" #FLAGS="$FLAGS --disable-testsets" #FLAGS="$FLAGS --disable-dap-remote-tests" #FLAGS="$FLAGS --enable-dap-auth-tests" -FLAGS="$FLAGS --enable-doxygen" +#FLAGS="$FLAGS --enable-doxygen" #FLAGS="$FLAGS --enable-logging" #FLAGS="$FLAGS --disable-diskless" #FLAGS="$FLAGS --enable-mmap" diff --git a/libdap2/dapdebug.h b/libdap2/dapdebug.h index e2fd32c8a..f593a1848 100644 --- a/libdap2/dapdebug.h +++ b/libdap2/dapdebug.h @@ -5,7 +5,7 @@ #ifndef DEBUG_H #define DEBUG_H -#if 0 +#if 1 #define DAPDEBUG 1 #define OCDEBUG 1 #endif diff --git a/libdap2/env b/libdap2/env index b1aa564c5..fd751e0e4 100644 --- a/libdap2/env +++ b/libdap2/env @@ -1,12 +1,12 @@ -TOP="/home/dmh/git/netcdf-c" -#TOP="/cygdrive/f/git/netcdf-c" +#TOP="/home/dmh/git/netcdf-c" +TOP="/cygdrive/f/git/netcdf-c" alias xx="cd ..;make; cd libdap2" PARMS=""; ARGS=""; CON="" ; CE=""; OCON="" ; VAR=""; SHARP='#' alias q0=;alias qq=;alias qv=;alias q=;alias qh=;alias qqh=;alias qall=;alias qv=;alias qo=; -F="file://${TOP}/ncdap_test/testdata3/test.02" +F="file://${TOP}/ncdap_test/testdata3/synth9" if test -f ./ncd ; then PROG=./ncd diff --git a/libsrc/attr.c b/libsrc/attr.c index 9819dbd3e..22a961d43 100644 --- a/libsrc/attr.c +++ b/libsrc/attr.c @@ -1,1176 +1,1515 @@ -/* Do not edit this file. It is produced from the corresponding .m4 source */ -/* - * Copyright 1996, University Corporation for Atmospheric Research - * See netcdf/COPYRIGHT file for copying and redistribution conditions. - */ -/* $Id: attr.m4,v 2.39 2010/05/26 18:11:08 dmh Exp $ */ - -#include "nc3internal.h" -#include "ncdispatch.h" -#include "nc3dispatch.h" -#include -#include -#include -#include "ncx.h" -#include "fbits.h" -#include "rnd.h" -#include "utf8proc.h" - - -/* - * Free attr - * Formerly -NC_free_attr() - */ -void -free_NC_attr(NC_attr *attrp) -{ - - if(attrp == NULL) - return; - free_NC_string(attrp->name); - free(attrp); -} - - -/* - * How much space will 'nelems' of 'type' take in - * external representation (as the values of an attribute)? - */ -static size_t -ncx_len_NC_attrV(nc_type type, size_t nelems) -{ - switch(type) { - case NC_BYTE: - case NC_CHAR: - return ncx_len_char(nelems); - case NC_SHORT: - return ncx_len_short(nelems); - case NC_INT: - return ncx_len_int(nelems); - case NC_FLOAT: - return ncx_len_float(nelems); - case NC_DOUBLE: - return ncx_len_double(nelems); - default: - assert("ncx_len_NC_attr bad type" == 0); - } - return 0; -} - - -NC_attr * -new_x_NC_attr( - NC_string *strp, - nc_type type, - size_t nelems) -{ - NC_attr *attrp; - const size_t xsz = ncx_len_NC_attrV(type, nelems); - size_t sz = M_RNDUP(sizeof(NC_attr)); - - assert(!(xsz == 0 && nelems != 0)); - - sz += xsz; - - attrp = (NC_attr *) malloc(sz); - if(attrp == NULL ) - return NULL; - - attrp->xsz = xsz; - - attrp->name = strp; - attrp->type = type; - attrp->nelems = nelems; - if(xsz != 0) - attrp->xvalue = (char *)attrp + M_RNDUP(sizeof(NC_attr)); - else - attrp->xvalue = NULL; - - return(attrp); -} - - -/* - * Formerly -NC_new_attr(name,type,count,value) - */ -static NC_attr * -new_NC_attr( - const char *uname, - nc_type type, - size_t nelems) -{ - NC_string *strp; - NC_attr *attrp; - - char *name = (char *)utf8proc_NFC((const unsigned char *)uname); - if(name == NULL) - return NULL; - assert(name != NULL && *name != 0); - - strp = new_NC_string(strlen(name), name); - free(name); - if(strp == NULL) - return NULL; - - attrp = new_x_NC_attr(strp, type, nelems); - if(attrp == NULL) - { - free_NC_string(strp); - return NULL; - } - - return(attrp); -} - - -static NC_attr * -dup_NC_attr(const NC_attr *rattrp) -{ - NC_attr *attrp = new_NC_attr(rattrp->name->cp, - rattrp->type, rattrp->nelems); - if(attrp == NULL) - return NULL; - if(attrp->xvalue != NULL && rattrp->xvalue != NULL) - (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); - return attrp; -} - -/* attrarray */ - -/* - * Free the stuff "in" (referred to by) an NC_attrarray. - * Leaves the array itself allocated. - */ -void -free_NC_attrarrayV0(NC_attrarray *ncap) -{ - assert(ncap != NULL); - - if(ncap->nelems == 0) - return; - - assert(ncap->value != NULL); - - { - NC_attr **app = ncap->value; - NC_attr *const *const end = &app[ncap->nelems]; - for( /*NADA*/; app < end; app++) - { - free_NC_attr(*app); - *app = NULL; - } - } - ncap->nelems = 0; -} - - -/* - * Free NC_attrarray values. - * formerly -NC_free_array() - */ -void -free_NC_attrarrayV(NC_attrarray *ncap) -{ - assert(ncap != NULL); - - if(ncap->nalloc == 0) - return; - - assert(ncap->value != NULL); - - free_NC_attrarrayV0(ncap); - - free(ncap->value); - ncap->value = NULL; - ncap->nalloc = 0; -} - - -int -dup_NC_attrarrayV(NC_attrarray *ncap, const NC_attrarray *ref) -{ - int status = NC_NOERR; - - assert(ref != NULL); - assert(ncap != NULL); - - if(ref->nelems != 0) - { - const size_t sz = ref->nelems * sizeof(NC_attr *); - ncap->value = (NC_attr **) malloc(sz); - if(ncap->value == NULL) - return NC_ENOMEM; - - (void) memset(ncap->value, 0, sz); - ncap->nalloc = ref->nelems; - } - - ncap->nelems = 0; - { - NC_attr **app = ncap->value; - const NC_attr **drpp = (const NC_attr **)ref->value; - NC_attr *const *const end = &app[ref->nelems]; - for( /*NADA*/; app < end; drpp++, app++, ncap->nelems++) - { - *app = dup_NC_attr(*drpp); - if(*app == NULL) - { - status = NC_ENOMEM; - break; - } - } - } - - if(status != NC_NOERR) - { - free_NC_attrarrayV(ncap); - return status; - } - - assert(ncap->nelems == ref->nelems); - - return NC_NOERR; -} - - -/* - * Add a new handle on the end of an array of handles - * Formerly -NC_incr_array(array, tail) - */ -static int -incr_NC_attrarray(NC_attrarray *ncap, NC_attr *newelemp) -{ - NC_attr **vp; - - assert(ncap != NULL); - - if(ncap->nalloc == 0) - { - assert(ncap->nelems == 0); - vp = (NC_attr **) malloc(NC_ARRAY_GROWBY * sizeof(NC_attr *)); - if(vp == NULL) - return NC_ENOMEM; - - ncap->value = vp; - ncap->nalloc = NC_ARRAY_GROWBY; - } - else if(ncap->nelems +1 > ncap->nalloc) - { - vp = (NC_attr **) realloc(ncap->value, - (ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_attr *)); - if(vp == NULL) - return NC_ENOMEM; - - ncap->value = vp; - ncap->nalloc += NC_ARRAY_GROWBY; - } - - if(newelemp != NULL) - { - ncap->value[ncap->nelems] = newelemp; - ncap->nelems++; - } - return NC_NOERR; -} - - -NC_attr * -elem_NC_attrarray(const NC_attrarray *ncap, size_t elem) -{ - assert(ncap != NULL); - /* cast needed for braindead systems with signed size_t */ - if(ncap->nelems == 0 || (unsigned long) elem >= ncap->nelems) - return NULL; - - assert(ncap->value != NULL); - - return ncap->value[elem]; -} - -/* End attarray per se */ - -/* - * Given ncp and varid, return ptr to array of attributes - * else NULL on error - */ -static NC_attrarray * -NC_attrarray0(NC3_INFO* ncp, int varid) -{ - NC_attrarray *ap; - - if(varid == NC_GLOBAL) /* Global attribute, attach to cdf */ - { - ap = &ncp->attrs; - } - else if(varid >= 0 && (size_t) varid < ncp->vars.nelems) - { - NC_var **vpp; - vpp = (NC_var **)ncp->vars.value; - vpp += varid; - ap = &(*vpp)->attrs; - } else { - ap = NULL; - } - return(ap); -} - - -/* - * Step thru NC_ATTRIBUTE array, seeking match on name. - * return match or NULL if Not Found or out of memory. - */ -NC_attr ** -NC_findattr(const NC_attrarray *ncap, const char *uname) -{ - NC_attr **attrpp; - size_t attrid; - size_t slen; - char *name; - - assert(ncap != NULL); - - if(ncap->nelems == 0) - return NULL; - - attrpp = (NC_attr **) ncap->value; - - /* normalized version of uname */ - name = (char *)utf8proc_NFC((const unsigned char *)uname); - if(name == NULL) - return NULL; /* TODO: need better way to indicate no memory */ - slen = strlen(name); - - for(attrid = 0; attrid < ncap->nelems; attrid++, attrpp++) - { - if(strlen((*attrpp)->name->cp) == slen && - strncmp((*attrpp)->name->cp, name, slen) == 0) - { - free(name); - return(attrpp); /* Normal return */ - } - } - free(name); - return(NULL); -} - - -/* - * Look up by ncid, varid and name, return NULL if not found - */ -static int -NC_lookupattr(int ncid, - int varid, - const char *name, /* attribute name */ - NC_attr **attrpp) /* modified on return */ -{ - int status; - NC* nc; - NC3_INFO *ncp; - NC_attrarray *ncap; - NC_attr **tmp; - - status = NC_check_id(ncid, &nc); - if(status != NC_NOERR) - return status; - ncp = NC3_DATA(nc); - - ncap = NC_attrarray0(ncp, varid); - if(ncap == NULL) - return NC_ENOTVAR; - - tmp = NC_findattr(ncap, name); - if(tmp == NULL) - return NC_ENOTATT; - - if(attrpp != NULL) - *attrpp = *tmp; - - return ENOERR; -} - -/* Public */ - -int -NC3_inq_attname(int ncid, int varid, int attnum, char *name) -{ - int status; - NC* nc; - NC3_INFO *ncp; - NC_attrarray *ncap; - NC_attr *attrp; - - status = NC_check_id(ncid, &nc); - if(status != NC_NOERR) - return status; - ncp = NC3_DATA(nc); - - ncap = NC_attrarray0(ncp, varid); - if(ncap == NULL) - return NC_ENOTVAR; - - attrp = elem_NC_attrarray(ncap, (size_t)attnum); - if(attrp == NULL) - return NC_ENOTATT; - - (void) strncpy(name, attrp->name->cp, attrp->name->nchars); - name[attrp->name->nchars] = 0; - - return NC_NOERR; -} - - -int -NC3_inq_attid(int ncid, int varid, const char *name, int *attnump) -{ - int status; - NC *nc; - NC3_INFO* ncp; - NC_attrarray *ncap; - NC_attr **attrpp; - - status = NC_check_id(ncid, &nc); - if(status != NC_NOERR) - return status; - ncp = NC3_DATA(nc); - - ncap = NC_attrarray0(ncp, varid); - if(ncap == NULL) - return NC_ENOTVAR; - - - attrpp = NC_findattr(ncap, name); - if(attrpp == NULL) - return NC_ENOTATT; - - if(attnump != NULL) - *attnump = (int)(attrpp - ncap->value); - - return NC_NOERR; -} - -int -NC3_inq_att(int ncid, - int varid, - const char *name, /* input, attribute name */ - nc_type *datatypep, - size_t *lenp) -{ - int status; - NC_attr *attrp; - - status = NC_lookupattr(ncid, varid, name, &attrp); - if(status != NC_NOERR) - return status; - - if(datatypep != NULL) - *datatypep = attrp->type; - if(lenp != NULL) - *lenp = attrp->nelems; - - return NC_NOERR; -} - - -int -NC3_rename_att( int ncid, int varid, const char *name, const char *unewname) -{ - int status; - NC *nc; - NC3_INFO* ncp; - NC_attrarray *ncap; - NC_attr **tmp; - NC_attr *attrp; - NC_string *newStr, *old; - char *newname; /* normalized version */ - - /* sortof inline clone of NC_lookupattr() */ - status = NC_check_id(ncid, &nc); - if(status != NC_NOERR) - return status; - ncp = NC3_DATA(nc); - - if(NC_readonly(ncp)) - return NC_EPERM; - - ncap = NC_attrarray0(ncp, varid); - if(ncap == NULL) - return NC_ENOTVAR; - - status = NC_check_name(unewname); - if(status != NC_NOERR) - return status; - - tmp = NC_findattr(ncap, name); - if(tmp == NULL) - return NC_ENOTATT; - attrp = *tmp; - /* end inline clone NC_lookupattr() */ - - if(NC_findattr(ncap, unewname) != NULL) - { - /* name in use */ - return NC_ENAMEINUSE; - } - - old = attrp->name; - newname = (char *)utf8proc_NFC((const unsigned char *)unewname); - if(newname == NULL) - return NC_EBADNAME; - if(NC_indef(ncp)) - { - newStr = new_NC_string(strlen(newname), newname); - free(newname); - if( newStr == NULL) - return NC_ENOMEM; - attrp->name = newStr; - free_NC_string(old); - return NC_NOERR; - } - /* else */ - status = set_NC_string(old, newname); - free(newname); - if( status != NC_NOERR) - return status; - - set_NC_hdirty(ncp); - - if(NC_doHsync(ncp)) - { - status = NC_sync(ncp); - if(status != NC_NOERR) - return status; - } - - return NC_NOERR; -} - -int -NC3_del_att(int ncid, int varid, const char *uname) -{ - int status; - NC *nc; - NC3_INFO* ncp; - NC_attrarray *ncap; - NC_attr **attrpp; - NC_attr *old = NULL; - int attrid; - size_t slen; - - status = NC_check_id(ncid, &nc); - if(status != NC_NOERR) - return status; - ncp = NC3_DATA(nc); - - if(!NC_indef(ncp)) - return NC_ENOTINDEFINE; - - ncap = NC_attrarray0(ncp, varid); - if(ncap == NULL) - return NC_ENOTVAR; - - { - char *name = (char *)utf8proc_NFC((const unsigned char *)uname); - if(name == NULL) - return NC_ENOMEM; - - /* sortof inline NC_findattr() */ - slen = strlen(name); - - attrpp = (NC_attr **) ncap->value; - for(attrid = 0; (size_t) attrid < ncap->nelems; attrid++, attrpp++) - { - if( slen == (*attrpp)->name->nchars && - strncmp(name, (*attrpp)->name->cp, slen) == 0) - { - old = *attrpp; - break; - } - } - free(name); - } - if( (size_t) attrid == ncap->nelems ) - return NC_ENOTATT; - /* end inline NC_findattr() */ - - /* shuffle down */ - for(attrid++; (size_t) attrid < ncap->nelems; attrid++) - { - *attrpp = *(attrpp + 1); - attrpp++; - } - *attrpp = NULL; - /* decrement count */ - ncap->nelems--; - - free_NC_attr(old); - - return NC_NOERR; -} - - -static int -ncx_pad_putn_Iuchar(void **xpp, size_t nelems, const uchar *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_putn_schar_uchar(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_putn_short_uchar(xpp, nelems, tp); - case NC_INT: - return ncx_putn_int_uchar(xpp, nelems, tp); - case NC_FLOAT: - return ncx_putn_float_uchar(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_putn_double_uchar(xpp, nelems, tp); - default: - assert("ncx_pad_putn_Iuchar invalid type" == 0); - } - return NC_EBADTYPE; -} - -static int -ncx_pad_getn_Iuchar(const void **xpp, size_t nelems, uchar *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_getn_schar_uchar(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_getn_short_uchar(xpp, nelems, tp); - case NC_INT: - return ncx_getn_int_uchar(xpp, nelems, tp); - case NC_FLOAT: - return ncx_getn_float_uchar(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_getn_double_uchar(xpp, nelems, tp); - default: - assert("ncx_pad_getn_Iuchar invalid type" == 0); - } - return NC_EBADTYPE; -} - - -static int -ncx_pad_putn_Ischar(void **xpp, size_t nelems, const schar *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_putn_schar_schar(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_putn_short_schar(xpp, nelems, tp); - case NC_INT: - return ncx_putn_int_schar(xpp, nelems, tp); - case NC_FLOAT: - return ncx_putn_float_schar(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_putn_double_schar(xpp, nelems, tp); - default: - assert("ncx_pad_putn_Ischar invalid type" == 0); - } - return NC_EBADTYPE; -} - -static int -ncx_pad_getn_Ischar(const void **xpp, size_t nelems, schar *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_getn_schar_schar(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_getn_short_schar(xpp, nelems, tp); - case NC_INT: - return ncx_getn_int_schar(xpp, nelems, tp); - case NC_FLOAT: - return ncx_getn_float_schar(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_getn_double_schar(xpp, nelems, tp); - default: - assert("ncx_pad_getn_Ischar invalid type" == 0); - } - return NC_EBADTYPE; -} - - -static int -ncx_pad_putn_Ishort(void **xpp, size_t nelems, const short *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_putn_schar_short(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_putn_short_short(xpp, nelems, tp); - case NC_INT: - return ncx_putn_int_short(xpp, nelems, tp); - case NC_FLOAT: - return ncx_putn_float_short(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_putn_double_short(xpp, nelems, tp); - default: - assert("ncx_pad_putn_Ishort invalid type" == 0); - } - return NC_EBADTYPE; -} - -static int -ncx_pad_getn_Ishort(const void **xpp, size_t nelems, short *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_getn_schar_short(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_getn_short_short(xpp, nelems, tp); - case NC_INT: - return ncx_getn_int_short(xpp, nelems, tp); - case NC_FLOAT: - return ncx_getn_float_short(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_getn_double_short(xpp, nelems, tp); - default: - assert("ncx_pad_getn_Ishort invalid type" == 0); - } - return NC_EBADTYPE; -} - - -static int -ncx_pad_putn_Iint(void **xpp, size_t nelems, const int *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_putn_schar_int(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_putn_short_int(xpp, nelems, tp); - case NC_INT: - return ncx_putn_int_int(xpp, nelems, tp); - case NC_FLOAT: - return ncx_putn_float_int(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_putn_double_int(xpp, nelems, tp); - default: - assert("ncx_pad_putn_Iint invalid type" == 0); - } - return NC_EBADTYPE; -} - -static int -ncx_pad_getn_Iint(const void **xpp, size_t nelems, int *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_getn_schar_int(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_getn_short_int(xpp, nelems, tp); - case NC_INT: - return ncx_getn_int_int(xpp, nelems, tp); - case NC_FLOAT: - return ncx_getn_float_int(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_getn_double_int(xpp, nelems, tp); - default: - assert("ncx_pad_getn_Iint invalid type" == 0); - } - return NC_EBADTYPE; -} - - -static int -ncx_pad_putn_Ifloat(void **xpp, size_t nelems, const float *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_putn_schar_float(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_putn_short_float(xpp, nelems, tp); - case NC_INT: - return ncx_putn_int_float(xpp, nelems, tp); - case NC_FLOAT: - return ncx_putn_float_float(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_putn_double_float(xpp, nelems, tp); - default: - assert("ncx_pad_putn_Ifloat invalid type" == 0); - } - return NC_EBADTYPE; -} - -static int -ncx_pad_getn_Ifloat(const void **xpp, size_t nelems, float *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_getn_schar_float(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_getn_short_float(xpp, nelems, tp); - case NC_INT: - return ncx_getn_int_float(xpp, nelems, tp); - case NC_FLOAT: - return ncx_getn_float_float(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_getn_double_float(xpp, nelems, tp); - default: - assert("ncx_pad_getn_Ifloat invalid type" == 0); - } - return NC_EBADTYPE; -} - - -static int -ncx_pad_putn_Idouble(void **xpp, size_t nelems, const double *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_putn_schar_double(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_putn_short_double(xpp, nelems, tp); - case NC_INT: - return ncx_putn_int_double(xpp, nelems, tp); - case NC_FLOAT: - return ncx_putn_float_double(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_putn_double_double(xpp, nelems, tp); - default: - assert("ncx_pad_putn_Idouble invalid type" == 0); - } - return NC_EBADTYPE; -} - -static int -ncx_pad_getn_Idouble(const void **xpp, size_t nelems, double *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_getn_schar_double(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_getn_short_double(xpp, nelems, tp); - case NC_INT: - return ncx_getn_int_double(xpp, nelems, tp); - case NC_FLOAT: - return ncx_getn_float_double(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_getn_double_double(xpp, nelems, tp); - default: - assert("ncx_pad_getn_Idouble invalid type" == 0); - } - return NC_EBADTYPE; -} - - -#ifdef IGNORE -static int -ncx_pad_putn_Ilong(void **xpp, size_t nelems, const long *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_putn_schar_long(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_putn_short_long(xpp, nelems, tp); - case NC_INT: - return ncx_putn_int_long(xpp, nelems, tp); - case NC_FLOAT: - return ncx_putn_float_long(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_putn_double_long(xpp, nelems, tp); - default: - assert("ncx_pad_putn_Ilong invalid type" == 0); - } - return NC_EBADTYPE; -} - -static int -ncx_pad_getn_Ilong(const void **xpp, size_t nelems, long *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_getn_schar_long(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_getn_short_long(xpp, nelems, tp); - case NC_INT: - return ncx_getn_int_long(xpp, nelems, tp); - case NC_FLOAT: - return ncx_getn_float_long(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_getn_double_long(xpp, nelems, tp); - default: - assert("ncx_pad_getn_Ilong invalid type" == 0); - } - return NC_EBADTYPE; -} - -#endif - -static int -ncx_pad_putn_Ilonglong(void **xpp, size_t nelems, const longlong *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_putn_schar_longlong(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_putn_short_longlong(xpp, nelems, tp); - case NC_INT: - return ncx_putn_int_longlong(xpp, nelems, tp); - case NC_FLOAT: - return ncx_putn_float_longlong(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_putn_double_longlong(xpp, nelems, tp); - default: - assert("ncx_pad_putn_Ilonglong invalid type" == 0); - } - return NC_EBADTYPE; -} - -static int -ncx_pad_getn_Ilonglong(const void **xpp, size_t nelems, longlong *tp, nc_type type) -{ - switch(type) { - case NC_CHAR: - return NC_ECHAR; - case NC_BYTE: - return ncx_pad_getn_schar_longlong(xpp, nelems, tp); - case NC_SHORT: - return ncx_pad_getn_short_longlong(xpp, nelems, tp); - case NC_INT: - return ncx_getn_int_longlong(xpp, nelems, tp); - case NC_FLOAT: - return ncx_getn_float_longlong(xpp, nelems, tp); - case NC_DOUBLE: - return ncx_getn_double_longlong(xpp, nelems, tp); - default: - assert("ncx_pad_getn_Ilonglong invalid type" == 0); - } - return NC_EBADTYPE; -} - - - -/* Common dispatcher for put cases */ -static int -dispatchput(void **xpp, size_t nelems, const void* tp, - nc_type atype, nc_type memtype) -{ - switch (memtype) { - case NC_CHAR: - return ncx_pad_putn_text(xpp,nelems, (char *)tp); - case NC_BYTE: - return ncx_pad_putn_Ischar(xpp, nelems, (schar*)tp, atype); - case NC_SHORT: - return ncx_pad_putn_Ishort(xpp, nelems, (short*)tp, atype); - case NC_INT: - return ncx_pad_putn_Iint(xpp, nelems, (int*)tp, atype); - case NC_FLOAT: - return ncx_pad_putn_Ifloat(xpp, nelems, (float*)tp, atype); - case NC_DOUBLE: - return ncx_pad_putn_Idouble(xpp, nelems, (double*)tp, atype); - case NC_UBYTE: /*Synthetic*/ - return ncx_pad_putn_Iuchar(xpp,nelems, (uchar *)tp, atype); - case NC_INT64: - return ncx_pad_putn_Ilonglong(xpp, nelems, (longlong*)tp, atype); - case NC_NAT: - return NC_EBADTYPE; - default: - break; - } - return NC_EBADTYPE; -} - -int -NC3_put_att( - int ncid, - int varid, - const char *name, - nc_type type, - size_t nelems, - const void *value, - nc_type memtype) -{ - int status; - NC *nc; - NC3_INFO* ncp; - NC_attrarray *ncap; - NC_attr **attrpp; - NC_attr *old = NULL; - NC_attr *attrp; - - status = NC_check_id(ncid, &nc); - if(status != NC_NOERR) - return status; - ncp = NC3_DATA(nc); - - if(NC_readonly(ncp)) - return NC_EPERM; - - ncap = NC_attrarray0(ncp, varid); - if(ncap == NULL) - return NC_ENOTVAR; - - status = nc_cktype(type); - if(status != NC_NOERR) - return status; - - if(memtype == NC_NAT) memtype = type; - - if(memtype != NC_CHAR && type == NC_CHAR) - return NC_ECHAR; - if(memtype == NC_CHAR && type != NC_CHAR) - return NC_ECHAR; - - /* cast needed for braindead systems with signed size_t */ - if((unsigned long) nelems > X_INT_MAX) /* backward compat */ - return NC_EINVAL; /* Invalid nelems */ - - if(nelems != 0 && value == NULL) - return NC_EINVAL; /* Null arg */ - - attrpp = NC_findattr(ncap, name); - - /* 4 cases: exists X indef */ - - if(attrpp != NULL) { /* name in use */ - if(!NC_indef(ncp)) { - const size_t xsz = ncx_len_NC_attrV(type, nelems); - attrp = *attrpp; /* convenience */ - - if(xsz > attrp->xsz) return NC_ENOTINDEFINE; - /* else, we can reuse existing without redef */ - - attrp->xsz = xsz; - attrp->type = type; - attrp->nelems = nelems; - - if(nelems != 0) { - void *xp = attrp->xvalue; - status = dispatchput(&xp, nelems, (const void*)value, type, memtype); - } - - set_NC_hdirty(ncp); - - if(NC_doHsync(ncp)) { - const int lstatus = NC_sync(ncp); - /* - * N.B.: potentially overrides NC_ERANGE - * set by ncx_pad_putn_I$1 - */ - if(lstatus != ENOERR) return lstatus; - } - - return status; - } - /* else, redefine using existing array slot */ - old = *attrpp; - } else { - if(!NC_indef(ncp)) return NC_ENOTINDEFINE; - - if(ncap->nelems >= NC_MAX_ATTRS) return NC_EMAXATTS; - } - - status = NC_check_name(name); - if(status != NC_NOERR) return status; - - attrp = new_NC_attr(name, type, nelems); - if(attrp == NULL) return NC_ENOMEM; - - if(nelems != 0) { - void *xp = attrp->xvalue; - status = dispatchput(&xp, nelems, (const void*)value, type, memtype); - } - - if(attrpp != NULL) { - *attrpp = attrp; - if(old != NULL) - free_NC_attr(old); - } else { - const int lstatus = incr_NC_attrarray(ncap, attrp); - /* - * N.B.: potentially overrides NC_ERANGE - * set by ncx_pad_putn_I$1 - */ - if(lstatus != NC_NOERR) { - free_NC_attr(attrp); - return lstatus; - } - } - return status; -} - -int -NC3_get_att( - int ncid, - int varid, - const char *name, - void *value, - nc_type memtype) -{ - int status; - NC_attr *attrp; - const void *xp; - - status = NC_lookupattr(ncid, varid, name, &attrp); - if(status != NC_NOERR) return status; - - if(attrp->nelems == 0) return NC_NOERR; - - if(memtype == NC_NAT) memtype = attrp->type; - - if(memtype != NC_CHAR && attrp->type == NC_CHAR) - return NC_ECHAR; - if(memtype == NC_CHAR && attrp->type != NC_CHAR) - return NC_ECHAR; - - xp = attrp->xvalue; - switch (memtype) { - case NC_CHAR: - return ncx_pad_getn_text(&xp, attrp->nelems , (char *)value); - case NC_BYTE: - return ncx_pad_getn_Ischar(&xp,attrp->nelems,(schar*)value,attrp->type); - case NC_SHORT: - return ncx_pad_getn_Ishort(&xp,attrp->nelems,(short*)value,attrp->type); - case NC_INT: - return ncx_pad_getn_Iint(&xp,attrp->nelems,(int*)value,attrp->type); - case NC_FLOAT: - return ncx_pad_getn_Ifloat(&xp,attrp->nelems,(float*)value,attrp->type); - case NC_DOUBLE: - return ncx_pad_getn_Idouble(&xp,attrp->nelems,(double*)value,attrp->type); - case NC_INT64: - return ncx_pad_getn_Ilonglong(&xp,attrp->nelems,(longlong*)value,attrp->type); - case NC_UBYTE: /* Synthetic */ - return ncx_pad_getn_Iuchar(&xp, attrp->nelems , (uchar *)value, attrp->type); - case NC_NAT: - return NC_EBADTYPE; - default: - break; - } - status = NC_EBADTYPE; - return status; -} +#line 5 "attr.m4" +/* Do not edit this file. It is produced from the corresponding .m4 source */ +#line 7 +/* + * Copyright 1996, University Corporation for Atmospheric Research + * See netcdf/COPYRIGHT file for copying and redistribution conditions. + */ +/* $Id: attr.m4,v 2.39 2010/05/26 18:11:08 dmh Exp $ */ + +#include "nc3internal.h" +#include "ncdispatch.h" +#include "nc3dispatch.h" +#include +#include +#include +#include "ncx.h" +#include "fbits.h" +#include "rnd.h" +#include "utf8proc.h" + + +/* + * Free attr + * Formerly +NC_free_attr() + */ +void +free_NC_attr(NC_attr *attrp) +{ + + if(attrp == NULL) + return; + free_NC_string(attrp->name); + free(attrp); +} + + +/* + * How much space will 'nelems' of 'type' take in + * external representation (as the values of an attribute)? + */ +static size_t +ncx_len_NC_attrV(nc_type type, size_t nelems) +{ + switch(type) { + case NC_BYTE: + case NC_CHAR: + return ncx_len_char(nelems); + case NC_SHORT: + return ncx_len_short(nelems); + case NC_INT: + return ncx_len_int(nelems); + case NC_FLOAT: + return ncx_len_float(nelems); + case NC_DOUBLE: + return ncx_len_double(nelems); + default: + assert("ncx_len_NC_attr bad type" == 0); + } + return 0; +} + + +NC_attr * +new_x_NC_attr( + NC_string *strp, + nc_type type, + size_t nelems) +{ + NC_attr *attrp; + const size_t xsz = ncx_len_NC_attrV(type, nelems); + size_t sz = M_RNDUP(sizeof(NC_attr)); + + assert(!(xsz == 0 && nelems != 0)); + + sz += xsz; + + attrp = (NC_attr *) malloc(sz); + if(attrp == NULL ) + return NULL; + + attrp->xsz = xsz; + + attrp->name = strp; + attrp->type = type; + attrp->nelems = nelems; + if(xsz != 0) + attrp->xvalue = (char *)attrp + M_RNDUP(sizeof(NC_attr)); + else + attrp->xvalue = NULL; + + return(attrp); +} + + +/* + * Formerly +NC_new_attr(name,type,count,value) + */ +static NC_attr * +new_NC_attr( + const char *uname, + nc_type type, + size_t nelems) +{ + NC_string *strp; + NC_attr *attrp; + + char *name = (char *)utf8proc_NFC((const unsigned char *)uname); + if(name == NULL) + return NULL; + assert(name != NULL && *name != 0); + + strp = new_NC_string(strlen(name), name); + free(name); + if(strp == NULL) + return NULL; + + attrp = new_x_NC_attr(strp, type, nelems); + if(attrp == NULL) + { + free_NC_string(strp); + return NULL; + } + + return(attrp); +} + + +static NC_attr * +dup_NC_attr(const NC_attr *rattrp) +{ + NC_attr *attrp = new_NC_attr(rattrp->name->cp, + rattrp->type, rattrp->nelems); + if(attrp == NULL) + return NULL; + if(attrp->xvalue != NULL && rattrp->xvalue != NULL) + (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); + return attrp; +} + +/* attrarray */ + +/* + * Free the stuff "in" (referred to by) an NC_attrarray. + * Leaves the array itself allocated. + */ +void +free_NC_attrarrayV0(NC_attrarray *ncap) +{ + assert(ncap != NULL); + + if(ncap->nelems == 0) + return; + + assert(ncap->value != NULL); + + { + NC_attr **app = ncap->value; + NC_attr *const *const end = &app[ncap->nelems]; + for( /*NADA*/; app < end; app++) + { + free_NC_attr(*app); + *app = NULL; + } + } + ncap->nelems = 0; +} + + +/* + * Free NC_attrarray values. + * formerly +NC_free_array() + */ +void +free_NC_attrarrayV(NC_attrarray *ncap) +{ + assert(ncap != NULL); + + if(ncap->nalloc == 0) + return; + + assert(ncap->value != NULL); + + free_NC_attrarrayV0(ncap); + + free(ncap->value); + ncap->value = NULL; + ncap->nalloc = 0; +} + + +int +dup_NC_attrarrayV(NC_attrarray *ncap, const NC_attrarray *ref) +{ + int status = NC_NOERR; + + assert(ref != NULL); + assert(ncap != NULL); + + if(ref->nelems != 0) + { + const size_t sz = ref->nelems * sizeof(NC_attr *); + ncap->value = (NC_attr **) malloc(sz); + if(ncap->value == NULL) + return NC_ENOMEM; + + (void) memset(ncap->value, 0, sz); + ncap->nalloc = ref->nelems; + } + + ncap->nelems = 0; + { + NC_attr **app = ncap->value; + const NC_attr **drpp = (const NC_attr **)ref->value; + NC_attr *const *const end = &app[ref->nelems]; + for( /*NADA*/; app < end; drpp++, app++, ncap->nelems++) + { + *app = dup_NC_attr(*drpp); + if(*app == NULL) + { + status = NC_ENOMEM; + break; + } + } + } + + if(status != NC_NOERR) + { + free_NC_attrarrayV(ncap); + return status; + } + + assert(ncap->nelems == ref->nelems); + + return NC_NOERR; +} + + +/* + * Add a new handle on the end of an array of handles + * Formerly +NC_incr_array(array, tail) + */ +static int +incr_NC_attrarray(NC_attrarray *ncap, NC_attr *newelemp) +{ + NC_attr **vp; + + assert(ncap != NULL); + + if(ncap->nalloc == 0) + { + assert(ncap->nelems == 0); + vp = (NC_attr **) malloc(NC_ARRAY_GROWBY * sizeof(NC_attr *)); + if(vp == NULL) + return NC_ENOMEM; + + ncap->value = vp; + ncap->nalloc = NC_ARRAY_GROWBY; + } + else if(ncap->nelems +1 > ncap->nalloc) + { + vp = (NC_attr **) realloc(ncap->value, + (ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_attr *)); + if(vp == NULL) + return NC_ENOMEM; + + ncap->value = vp; + ncap->nalloc += NC_ARRAY_GROWBY; + } + + if(newelemp != NULL) + { + ncap->value[ncap->nelems] = newelemp; + ncap->nelems++; + } + return NC_NOERR; +} + + +NC_attr * +elem_NC_attrarray(const NC_attrarray *ncap, size_t elem) +{ + assert(ncap != NULL); + /* cast needed for braindead systems with signed size_t */ + if(ncap->nelems == 0 || (unsigned long) elem >= ncap->nelems) + return NULL; + + assert(ncap->value != NULL); + + return ncap->value[elem]; +} + +/* End attarray per se */ + +/* + * Given ncp and varid, return ptr to array of attributes + * else NULL on error + */ +static NC_attrarray * +NC_attrarray0(NC3_INFO* ncp, int varid) +{ + NC_attrarray *ap; + + if(varid == NC_GLOBAL) /* Global attribute, attach to cdf */ + { + ap = &ncp->attrs; + } + else if(varid >= 0 && (size_t) varid < ncp->vars.nelems) + { + NC_var **vpp; + vpp = (NC_var **)ncp->vars.value; + vpp += varid; + ap = &(*vpp)->attrs; + } else { + ap = NULL; + } + return(ap); +} + + +/* + * Step thru NC_ATTRIBUTE array, seeking match on name. + * return match or NULL if Not Found or out of memory. + */ +NC_attr ** +NC_findattr(const NC_attrarray *ncap, const char *uname) +{ + NC_attr **attrpp; + size_t attrid; + size_t slen; + char *name; + + assert(ncap != NULL); + + if(ncap->nelems == 0) + return NULL; + + attrpp = (NC_attr **) ncap->value; + + /* normalized version of uname */ + name = (char *)utf8proc_NFC((const unsigned char *)uname); + if(name == NULL) + return NULL; /* TODO: need better way to indicate no memory */ + slen = strlen(name); + + for(attrid = 0; attrid < ncap->nelems; attrid++, attrpp++) + { + if(strlen((*attrpp)->name->cp) == slen && + strncmp((*attrpp)->name->cp, name, slen) == 0) + { + free(name); + return(attrpp); /* Normal return */ + } + } + free(name); + return(NULL); +} + + +/* + * Look up by ncid, varid and name, return NULL if not found + */ +static int +NC_lookupattr(int ncid, + int varid, + const char *name, /* attribute name */ + NC_attr **attrpp) /* modified on return */ +{ + int status; + NC* nc; + NC3_INFO *ncp; + NC_attrarray *ncap; + NC_attr **tmp; + + status = NC_check_id(ncid, &nc); + if(status != NC_NOERR) + return status; + ncp = NC3_DATA(nc); + + ncap = NC_attrarray0(ncp, varid); + if(ncap == NULL) + return NC_ENOTVAR; + + tmp = NC_findattr(ncap, name); + if(tmp == NULL) + return NC_ENOTATT; + + if(attrpp != NULL) + *attrpp = *tmp; + + return ENOERR; +} + +/* Public */ + +int +NC3_inq_attname(int ncid, int varid, int attnum, char *name) +{ + int status; + NC* nc; + NC3_INFO *ncp; + NC_attrarray *ncap; + NC_attr *attrp; + + status = NC_check_id(ncid, &nc); + if(status != NC_NOERR) + return status; + ncp = NC3_DATA(nc); + + ncap = NC_attrarray0(ncp, varid); + if(ncap == NULL) + return NC_ENOTVAR; + + attrp = elem_NC_attrarray(ncap, (size_t)attnum); + if(attrp == NULL) + return NC_ENOTATT; + + (void) strncpy(name, attrp->name->cp, attrp->name->nchars); + name[attrp->name->nchars] = 0; + + return NC_NOERR; +} + + +int +NC3_inq_attid(int ncid, int varid, const char *name, int *attnump) +{ + int status; + NC *nc; + NC3_INFO* ncp; + NC_attrarray *ncap; + NC_attr **attrpp; + + status = NC_check_id(ncid, &nc); + if(status != NC_NOERR) + return status; + ncp = NC3_DATA(nc); + + ncap = NC_attrarray0(ncp, varid); + if(ncap == NULL) + return NC_ENOTVAR; + + + attrpp = NC_findattr(ncap, name); + if(attrpp == NULL) + return NC_ENOTATT; + + if(attnump != NULL) + *attnump = (int)(attrpp - ncap->value); + + return NC_NOERR; +} + +int +NC3_inq_att(int ncid, + int varid, + const char *name, /* input, attribute name */ + nc_type *datatypep, + size_t *lenp) +{ + int status; + NC_attr *attrp; + + status = NC_lookupattr(ncid, varid, name, &attrp); + if(status != NC_NOERR) + return status; + + if(datatypep != NULL) + *datatypep = attrp->type; + if(lenp != NULL) + *lenp = attrp->nelems; + + return NC_NOERR; +} + + +int +NC3_rename_att( int ncid, int varid, const char *name, const char *unewname) +{ + int status; + NC *nc; + NC3_INFO* ncp; + NC_attrarray *ncap; + NC_attr **tmp; + NC_attr *attrp; + NC_string *newStr, *old; + char *newname; /* normalized version */ + + /* sortof inline clone of NC_lookupattr() */ + status = NC_check_id(ncid, &nc); + if(status != NC_NOERR) + return status; + ncp = NC3_DATA(nc); + + if(NC_readonly(ncp)) + return NC_EPERM; + + ncap = NC_attrarray0(ncp, varid); + if(ncap == NULL) + return NC_ENOTVAR; + + status = NC_check_name(unewname); + if(status != NC_NOERR) + return status; + + tmp = NC_findattr(ncap, name); + if(tmp == NULL) + return NC_ENOTATT; + attrp = *tmp; + /* end inline clone NC_lookupattr() */ + + if(NC_findattr(ncap, unewname) != NULL) + { + /* name in use */ + return NC_ENAMEINUSE; + } + + old = attrp->name; + newname = (char *)utf8proc_NFC((const unsigned char *)unewname); + if(newname == NULL) + return NC_EBADNAME; + if(NC_indef(ncp)) + { + newStr = new_NC_string(strlen(newname), newname); + free(newname); + if( newStr == NULL) + return NC_ENOMEM; + attrp->name = newStr; + free_NC_string(old); + return NC_NOERR; + } + /* else */ + status = set_NC_string(old, newname); + free(newname); + if( status != NC_NOERR) + return status; + + set_NC_hdirty(ncp); + + if(NC_doHsync(ncp)) + { + status = NC_sync(ncp); + if(status != NC_NOERR) + return status; + } + + return NC_NOERR; +} + +int +NC3_del_att(int ncid, int varid, const char *uname) +{ + int status; + NC *nc; + NC3_INFO* ncp; + NC_attrarray *ncap; + NC_attr **attrpp; + NC_attr *old = NULL; + int attrid; + size_t slen; + + status = NC_check_id(ncid, &nc); + if(status != NC_NOERR) + return status; + ncp = NC3_DATA(nc); + + if(!NC_indef(ncp)) + return NC_ENOTINDEFINE; + + ncap = NC_attrarray0(ncp, varid); + if(ncap == NULL) + return NC_ENOTVAR; + + { + char *name = (char *)utf8proc_NFC((const unsigned char *)uname); + if(name == NULL) + return NC_ENOMEM; + + /* sortof inline NC_findattr() */ + slen = strlen(name); + + attrpp = (NC_attr **) ncap->value; + for(attrid = 0; (size_t) attrid < ncap->nelems; attrid++, attrpp++) + { + if( slen == (*attrpp)->name->nchars && + strncmp(name, (*attrpp)->name->cp, slen) == 0) + { + old = *attrpp; + break; + } + } + free(name); + } + if( (size_t) attrid == ncap->nelems ) + return NC_ENOTATT; + /* end inline NC_findattr() */ + + /* shuffle down */ + for(attrid++; (size_t) attrid < ncap->nelems; attrid++) + { + *attrpp = *(attrpp + 1); + attrpp++; + } + *attrpp = NULL; + /* decrement count */ + ncap->nelems--; + + free_NC_attr(old); + + return NC_NOERR; +} + +#line 674 + +static int +#line 675 +ncx_pad_putn_Iuchar(void **xpp, size_t nelems, const uchar *tp, nc_type type) +#line 675 +{ +#line 675 + switch(type) { +#line 675 + case NC_CHAR: +#line 675 + return NC_ECHAR; +#line 675 + case NC_BYTE: +#line 675 + return ncx_pad_putn_schar_uchar(xpp, nelems, tp); +#line 675 + case NC_SHORT: +#line 675 + return ncx_pad_putn_short_uchar(xpp, nelems, tp); +#line 675 + case NC_INT: +#line 675 + return ncx_putn_int_uchar(xpp, nelems, tp); +#line 675 + case NC_FLOAT: +#line 675 + return ncx_putn_float_uchar(xpp, nelems, tp); +#line 675 + case NC_DOUBLE: +#line 675 + return ncx_putn_double_uchar(xpp, nelems, tp); +#line 675 + default: +#line 675 + assert("ncx_pad_putn_Iuchar invalid type" == 0); +#line 675 + } +#line 675 + return NC_EBADTYPE; +#line 675 +} +#line 675 + +static int +#line 676 +ncx_pad_getn_Iuchar(const void **xpp, size_t nelems, uchar *tp, nc_type type) +#line 676 +{ +#line 676 + switch(type) { +#line 676 + case NC_CHAR: +#line 676 + return NC_ECHAR; +#line 676 + case NC_BYTE: +#line 676 + return ncx_pad_getn_schar_uchar(xpp, nelems, tp); +#line 676 + case NC_SHORT: +#line 676 + return ncx_pad_getn_short_uchar(xpp, nelems, tp); +#line 676 + case NC_INT: +#line 676 + return ncx_getn_int_uchar(xpp, nelems, tp); +#line 676 + case NC_FLOAT: +#line 676 + return ncx_getn_float_uchar(xpp, nelems, tp); +#line 676 + case NC_DOUBLE: +#line 676 + return ncx_getn_double_uchar(xpp, nelems, tp); +#line 676 + default: +#line 676 + assert("ncx_pad_getn_Iuchar invalid type" == 0); +#line 676 + } +#line 676 + return NC_EBADTYPE; +#line 676 +} +#line 676 + + +static int +#line 678 +ncx_pad_putn_Ischar(void **xpp, size_t nelems, const schar *tp, nc_type type) +#line 678 +{ +#line 678 + switch(type) { +#line 678 + case NC_CHAR: +#line 678 + return NC_ECHAR; +#line 678 + case NC_BYTE: +#line 678 + return ncx_pad_putn_schar_schar(xpp, nelems, tp); +#line 678 + case NC_SHORT: +#line 678 + return ncx_pad_putn_short_schar(xpp, nelems, tp); +#line 678 + case NC_INT: +#line 678 + return ncx_putn_int_schar(xpp, nelems, tp); +#line 678 + case NC_FLOAT: +#line 678 + return ncx_putn_float_schar(xpp, nelems, tp); +#line 678 + case NC_DOUBLE: +#line 678 + return ncx_putn_double_schar(xpp, nelems, tp); +#line 678 + default: +#line 678 + assert("ncx_pad_putn_Ischar invalid type" == 0); +#line 678 + } +#line 678 + return NC_EBADTYPE; +#line 678 +} +#line 678 + +static int +#line 679 +ncx_pad_getn_Ischar(const void **xpp, size_t nelems, schar *tp, nc_type type) +#line 679 +{ +#line 679 + switch(type) { +#line 679 + case NC_CHAR: +#line 679 + return NC_ECHAR; +#line 679 + case NC_BYTE: +#line 679 + return ncx_pad_getn_schar_schar(xpp, nelems, tp); +#line 679 + case NC_SHORT: +#line 679 + return ncx_pad_getn_short_schar(xpp, nelems, tp); +#line 679 + case NC_INT: +#line 679 + return ncx_getn_int_schar(xpp, nelems, tp); +#line 679 + case NC_FLOAT: +#line 679 + return ncx_getn_float_schar(xpp, nelems, tp); +#line 679 + case NC_DOUBLE: +#line 679 + return ncx_getn_double_schar(xpp, nelems, tp); +#line 679 + default: +#line 679 + assert("ncx_pad_getn_Ischar invalid type" == 0); +#line 679 + } +#line 679 + return NC_EBADTYPE; +#line 679 +} +#line 679 + + +static int +#line 681 +ncx_pad_putn_Ishort(void **xpp, size_t nelems, const short *tp, nc_type type) +#line 681 +{ +#line 681 + switch(type) { +#line 681 + case NC_CHAR: +#line 681 + return NC_ECHAR; +#line 681 + case NC_BYTE: +#line 681 + return ncx_pad_putn_schar_short(xpp, nelems, tp); +#line 681 + case NC_SHORT: +#line 681 + return ncx_pad_putn_short_short(xpp, nelems, tp); +#line 681 + case NC_INT: +#line 681 + return ncx_putn_int_short(xpp, nelems, tp); +#line 681 + case NC_FLOAT: +#line 681 + return ncx_putn_float_short(xpp, nelems, tp); +#line 681 + case NC_DOUBLE: +#line 681 + return ncx_putn_double_short(xpp, nelems, tp); +#line 681 + default: +#line 681 + assert("ncx_pad_putn_Ishort invalid type" == 0); +#line 681 + } +#line 681 + return NC_EBADTYPE; +#line 681 +} +#line 681 + +static int +#line 682 +ncx_pad_getn_Ishort(const void **xpp, size_t nelems, short *tp, nc_type type) +#line 682 +{ +#line 682 + switch(type) { +#line 682 + case NC_CHAR: +#line 682 + return NC_ECHAR; +#line 682 + case NC_BYTE: +#line 682 + return ncx_pad_getn_schar_short(xpp, nelems, tp); +#line 682 + case NC_SHORT: +#line 682 + return ncx_pad_getn_short_short(xpp, nelems, tp); +#line 682 + case NC_INT: +#line 682 + return ncx_getn_int_short(xpp, nelems, tp); +#line 682 + case NC_FLOAT: +#line 682 + return ncx_getn_float_short(xpp, nelems, tp); +#line 682 + case NC_DOUBLE: +#line 682 + return ncx_getn_double_short(xpp, nelems, tp); +#line 682 + default: +#line 682 + assert("ncx_pad_getn_Ishort invalid type" == 0); +#line 682 + } +#line 682 + return NC_EBADTYPE; +#line 682 +} +#line 682 + + +static int +#line 684 +ncx_pad_putn_Iint(void **xpp, size_t nelems, const int *tp, nc_type type) +#line 684 +{ +#line 684 + switch(type) { +#line 684 + case NC_CHAR: +#line 684 + return NC_ECHAR; +#line 684 + case NC_BYTE: +#line 684 + return ncx_pad_putn_schar_int(xpp, nelems, tp); +#line 684 + case NC_SHORT: +#line 684 + return ncx_pad_putn_short_int(xpp, nelems, tp); +#line 684 + case NC_INT: +#line 684 + return ncx_putn_int_int(xpp, nelems, tp); +#line 684 + case NC_FLOAT: +#line 684 + return ncx_putn_float_int(xpp, nelems, tp); +#line 684 + case NC_DOUBLE: +#line 684 + return ncx_putn_double_int(xpp, nelems, tp); +#line 684 + default: +#line 684 + assert("ncx_pad_putn_Iint invalid type" == 0); +#line 684 + } +#line 684 + return NC_EBADTYPE; +#line 684 +} +#line 684 + +static int +#line 685 +ncx_pad_getn_Iint(const void **xpp, size_t nelems, int *tp, nc_type type) +#line 685 +{ +#line 685 + switch(type) { +#line 685 + case NC_CHAR: +#line 685 + return NC_ECHAR; +#line 685 + case NC_BYTE: +#line 685 + return ncx_pad_getn_schar_int(xpp, nelems, tp); +#line 685 + case NC_SHORT: +#line 685 + return ncx_pad_getn_short_int(xpp, nelems, tp); +#line 685 + case NC_INT: +#line 685 + return ncx_getn_int_int(xpp, nelems, tp); +#line 685 + case NC_FLOAT: +#line 685 + return ncx_getn_float_int(xpp, nelems, tp); +#line 685 + case NC_DOUBLE: +#line 685 + return ncx_getn_double_int(xpp, nelems, tp); +#line 685 + default: +#line 685 + assert("ncx_pad_getn_Iint invalid type" == 0); +#line 685 + } +#line 685 + return NC_EBADTYPE; +#line 685 +} +#line 685 + + +static int +#line 687 +ncx_pad_putn_Ifloat(void **xpp, size_t nelems, const float *tp, nc_type type) +#line 687 +{ +#line 687 + switch(type) { +#line 687 + case NC_CHAR: +#line 687 + return NC_ECHAR; +#line 687 + case NC_BYTE: +#line 687 + return ncx_pad_putn_schar_float(xpp, nelems, tp); +#line 687 + case NC_SHORT: +#line 687 + return ncx_pad_putn_short_float(xpp, nelems, tp); +#line 687 + case NC_INT: +#line 687 + return ncx_putn_int_float(xpp, nelems, tp); +#line 687 + case NC_FLOAT: +#line 687 + return ncx_putn_float_float(xpp, nelems, tp); +#line 687 + case NC_DOUBLE: +#line 687 + return ncx_putn_double_float(xpp, nelems, tp); +#line 687 + default: +#line 687 + assert("ncx_pad_putn_Ifloat invalid type" == 0); +#line 687 + } +#line 687 + return NC_EBADTYPE; +#line 687 +} +#line 687 + +static int +#line 688 +ncx_pad_getn_Ifloat(const void **xpp, size_t nelems, float *tp, nc_type type) +#line 688 +{ +#line 688 + switch(type) { +#line 688 + case NC_CHAR: +#line 688 + return NC_ECHAR; +#line 688 + case NC_BYTE: +#line 688 + return ncx_pad_getn_schar_float(xpp, nelems, tp); +#line 688 + case NC_SHORT: +#line 688 + return ncx_pad_getn_short_float(xpp, nelems, tp); +#line 688 + case NC_INT: +#line 688 + return ncx_getn_int_float(xpp, nelems, tp); +#line 688 + case NC_FLOAT: +#line 688 + return ncx_getn_float_float(xpp, nelems, tp); +#line 688 + case NC_DOUBLE: +#line 688 + return ncx_getn_double_float(xpp, nelems, tp); +#line 688 + default: +#line 688 + assert("ncx_pad_getn_Ifloat invalid type" == 0); +#line 688 + } +#line 688 + return NC_EBADTYPE; +#line 688 +} +#line 688 + + +static int +#line 690 +ncx_pad_putn_Idouble(void **xpp, size_t nelems, const double *tp, nc_type type) +#line 690 +{ +#line 690 + switch(type) { +#line 690 + case NC_CHAR: +#line 690 + return NC_ECHAR; +#line 690 + case NC_BYTE: +#line 690 + return ncx_pad_putn_schar_double(xpp, nelems, tp); +#line 690 + case NC_SHORT: +#line 690 + return ncx_pad_putn_short_double(xpp, nelems, tp); +#line 690 + case NC_INT: +#line 690 + return ncx_putn_int_double(xpp, nelems, tp); +#line 690 + case NC_FLOAT: +#line 690 + return ncx_putn_float_double(xpp, nelems, tp); +#line 690 + case NC_DOUBLE: +#line 690 + return ncx_putn_double_double(xpp, nelems, tp); +#line 690 + default: +#line 690 + assert("ncx_pad_putn_Idouble invalid type" == 0); +#line 690 + } +#line 690 + return NC_EBADTYPE; +#line 690 +} +#line 690 + +static int +#line 691 +ncx_pad_getn_Idouble(const void **xpp, size_t nelems, double *tp, nc_type type) +#line 691 +{ +#line 691 + switch(type) { +#line 691 + case NC_CHAR: +#line 691 + return NC_ECHAR; +#line 691 + case NC_BYTE: +#line 691 + return ncx_pad_getn_schar_double(xpp, nelems, tp); +#line 691 + case NC_SHORT: +#line 691 + return ncx_pad_getn_short_double(xpp, nelems, tp); +#line 691 + case NC_INT: +#line 691 + return ncx_getn_int_double(xpp, nelems, tp); +#line 691 + case NC_FLOAT: +#line 691 + return ncx_getn_float_double(xpp, nelems, tp); +#line 691 + case NC_DOUBLE: +#line 691 + return ncx_getn_double_double(xpp, nelems, tp); +#line 691 + default: +#line 691 + assert("ncx_pad_getn_Idouble invalid type" == 0); +#line 691 + } +#line 691 + return NC_EBADTYPE; +#line 691 +} +#line 691 + + +#ifdef IGNORE +static int +#line 694 +ncx_pad_putn_Ilong(void **xpp, size_t nelems, const long *tp, nc_type type) +#line 694 +{ +#line 694 + switch(type) { +#line 694 + case NC_CHAR: +#line 694 + return NC_ECHAR; +#line 694 + case NC_BYTE: +#line 694 + return ncx_pad_putn_schar_long(xpp, nelems, tp); +#line 694 + case NC_SHORT: +#line 694 + return ncx_pad_putn_short_long(xpp, nelems, tp); +#line 694 + case NC_INT: +#line 694 + return ncx_putn_int_long(xpp, nelems, tp); +#line 694 + case NC_FLOAT: +#line 694 + return ncx_putn_float_long(xpp, nelems, tp); +#line 694 + case NC_DOUBLE: +#line 694 + return ncx_putn_double_long(xpp, nelems, tp); +#line 694 + default: +#line 694 + assert("ncx_pad_putn_Ilong invalid type" == 0); +#line 694 + } +#line 694 + return NC_EBADTYPE; +#line 694 +} +#line 694 + +static int +#line 695 +ncx_pad_getn_Ilong(const void **xpp, size_t nelems, long *tp, nc_type type) +#line 695 +{ +#line 695 + switch(type) { +#line 695 + case NC_CHAR: +#line 695 + return NC_ECHAR; +#line 695 + case NC_BYTE: +#line 695 + return ncx_pad_getn_schar_long(xpp, nelems, tp); +#line 695 + case NC_SHORT: +#line 695 + return ncx_pad_getn_short_long(xpp, nelems, tp); +#line 695 + case NC_INT: +#line 695 + return ncx_getn_int_long(xpp, nelems, tp); +#line 695 + case NC_FLOAT: +#line 695 + return ncx_getn_float_long(xpp, nelems, tp); +#line 695 + case NC_DOUBLE: +#line 695 + return ncx_getn_double_long(xpp, nelems, tp); +#line 695 + default: +#line 695 + assert("ncx_pad_getn_Ilong invalid type" == 0); +#line 695 + } +#line 695 + return NC_EBADTYPE; +#line 695 +} +#line 695 + +#endif + +static int +#line 698 +ncx_pad_putn_Ilonglong(void **xpp, size_t nelems, const longlong *tp, nc_type type) +#line 698 +{ +#line 698 + switch(type) { +#line 698 + case NC_CHAR: +#line 698 + return NC_ECHAR; +#line 698 + case NC_BYTE: +#line 698 + return ncx_pad_putn_schar_longlong(xpp, nelems, tp); +#line 698 + case NC_SHORT: +#line 698 + return ncx_pad_putn_short_longlong(xpp, nelems, tp); +#line 698 + case NC_INT: +#line 698 + return ncx_putn_int_longlong(xpp, nelems, tp); +#line 698 + case NC_FLOAT: +#line 698 + return ncx_putn_float_longlong(xpp, nelems, tp); +#line 698 + case NC_DOUBLE: +#line 698 + return ncx_putn_double_longlong(xpp, nelems, tp); +#line 698 + default: +#line 698 + assert("ncx_pad_putn_Ilonglong invalid type" == 0); +#line 698 + } +#line 698 + return NC_EBADTYPE; +#line 698 +} +#line 698 + +static int +#line 699 +ncx_pad_getn_Ilonglong(const void **xpp, size_t nelems, longlong *tp, nc_type type) +#line 699 +{ +#line 699 + switch(type) { +#line 699 + case NC_CHAR: +#line 699 + return NC_ECHAR; +#line 699 + case NC_BYTE: +#line 699 + return ncx_pad_getn_schar_longlong(xpp, nelems, tp); +#line 699 + case NC_SHORT: +#line 699 + return ncx_pad_getn_short_longlong(xpp, nelems, tp); +#line 699 + case NC_INT: +#line 699 + return ncx_getn_int_longlong(xpp, nelems, tp); +#line 699 + case NC_FLOAT: +#line 699 + return ncx_getn_float_longlong(xpp, nelems, tp); +#line 699 + case NC_DOUBLE: +#line 699 + return ncx_getn_double_longlong(xpp, nelems, tp); +#line 699 + default: +#line 699 + assert("ncx_pad_getn_Ilonglong invalid type" == 0); +#line 699 + } +#line 699 + return NC_EBADTYPE; +#line 699 +} +#line 699 + + + +/* Common dispatcher for put cases */ +static int +dispatchput(void **xpp, size_t nelems, const void* tp, + nc_type atype, nc_type memtype) +{ + switch (memtype) { + case NC_CHAR: + return ncx_pad_putn_text(xpp,nelems, (char *)tp); + case NC_BYTE: + return ncx_pad_putn_Ischar(xpp, nelems, (schar*)tp, atype); + case NC_SHORT: + return ncx_pad_putn_Ishort(xpp, nelems, (short*)tp, atype); + case NC_INT: + return ncx_pad_putn_Iint(xpp, nelems, (int*)tp, atype); + case NC_FLOAT: + return ncx_pad_putn_Ifloat(xpp, nelems, (float*)tp, atype); + case NC_DOUBLE: + return ncx_pad_putn_Idouble(xpp, nelems, (double*)tp, atype); + case NC_UBYTE: /*Synthetic*/ + return ncx_pad_putn_Iuchar(xpp,nelems, (uchar *)tp, atype); + case NC_INT64: + return ncx_pad_putn_Ilonglong(xpp, nelems, (longlong*)tp, atype); + case NC_NAT: + return NC_EBADTYPE; + default: + break; + } + return NC_EBADTYPE; +} + +int +NC3_put_att( + int ncid, + int varid, + const char *name, + nc_type type, + size_t nelems, + const void *value, + nc_type memtype) +{ + int status; + NC *nc; + NC3_INFO* ncp; + NC_attrarray *ncap; + NC_attr **attrpp; + NC_attr *old = NULL; + NC_attr *attrp; + + status = NC_check_id(ncid, &nc); + if(status != NC_NOERR) + return status; + ncp = NC3_DATA(nc); + + if(NC_readonly(ncp)) + return NC_EPERM; + + ncap = NC_attrarray0(ncp, varid); + if(ncap == NULL) + return NC_ENOTVAR; + + status = nc_cktype(type); + if(status != NC_NOERR) + return status; + + if(memtype == NC_NAT) memtype = type; + + if(memtype != NC_CHAR && type == NC_CHAR) + return NC_ECHAR; + if(memtype == NC_CHAR && type != NC_CHAR) + return NC_ECHAR; + + /* cast needed for braindead systems with signed size_t */ + if((unsigned long) nelems > X_INT_MAX) /* backward compat */ + return NC_EINVAL; /* Invalid nelems */ + + if(nelems != 0 && value == NULL) + return NC_EINVAL; /* Null arg */ + + attrpp = NC_findattr(ncap, name); + + /* 4 cases: exists X indef */ + + if(attrpp != NULL) { /* name in use */ + if(!NC_indef(ncp)) { + const size_t xsz = ncx_len_NC_attrV(type, nelems); + attrp = *attrpp; /* convenience */ + + if(xsz > attrp->xsz) return NC_ENOTINDEFINE; + /* else, we can reuse existing without redef */ + + attrp->xsz = xsz; + attrp->type = type; + attrp->nelems = nelems; + + if(nelems != 0) { + void *xp = attrp->xvalue; + status = dispatchput(&xp, nelems, (const void*)value, type, memtype); + } + + set_NC_hdirty(ncp); + + if(NC_doHsync(ncp)) { + const int lstatus = NC_sync(ncp); + /* + * N.B.: potentially overrides NC_ERANGE + * set by ncx_pad_putn_I$1 + */ + if(lstatus != ENOERR) return lstatus; + } + + return status; + } + /* else, redefine using existing array slot */ + old = *attrpp; + } else { + if(!NC_indef(ncp)) return NC_ENOTINDEFINE; + + if(ncap->nelems >= NC_MAX_ATTRS) return NC_EMAXATTS; + } + + status = NC_check_name(name); + if(status != NC_NOERR) return status; + + attrp = new_NC_attr(name, type, nelems); + if(attrp == NULL) return NC_ENOMEM; + + if(nelems != 0) { + void *xp = attrp->xvalue; + status = dispatchput(&xp, nelems, (const void*)value, type, memtype); + } + + if(attrpp != NULL) { + *attrpp = attrp; + if(old != NULL) + free_NC_attr(old); + } else { + const int lstatus = incr_NC_attrarray(ncap, attrp); + /* + * N.B.: potentially overrides NC_ERANGE + * set by ncx_pad_putn_I$1 + */ + if(lstatus != NC_NOERR) { + free_NC_attr(attrp); + return lstatus; + } + } + return status; +} + +int +NC3_get_att( + int ncid, + int varid, + const char *name, + void *value, + nc_type memtype) +{ + int status; + NC_attr *attrp; + const void *xp; + + status = NC_lookupattr(ncid, varid, name, &attrp); + if(status != NC_NOERR) return status; + + if(attrp->nelems == 0) return NC_NOERR; + + if(memtype == NC_NAT) memtype = attrp->type; + + if(memtype != NC_CHAR && attrp->type == NC_CHAR) + return NC_ECHAR; + if(memtype == NC_CHAR && attrp->type != NC_CHAR) + return NC_ECHAR; + + xp = attrp->xvalue; + switch (memtype) { + case NC_CHAR: + return ncx_pad_getn_text(&xp, attrp->nelems , (char *)value); + case NC_BYTE: + return ncx_pad_getn_Ischar(&xp,attrp->nelems,(schar*)value,attrp->type); + case NC_SHORT: + return ncx_pad_getn_Ishort(&xp,attrp->nelems,(short*)value,attrp->type); + case NC_INT: + return ncx_pad_getn_Iint(&xp,attrp->nelems,(int*)value,attrp->type); + case NC_FLOAT: + return ncx_pad_getn_Ifloat(&xp,attrp->nelems,(float*)value,attrp->type); + case NC_DOUBLE: + return ncx_pad_getn_Idouble(&xp,attrp->nelems,(double*)value,attrp->type); + case NC_INT64: + return ncx_pad_getn_Ilonglong(&xp,attrp->nelems,(longlong*)value,attrp->type); + case NC_UBYTE: /* Synthetic */ + return ncx_pad_getn_Iuchar(&xp, attrp->nelems , (uchar *)value, attrp->type); + case NC_NAT: + return NC_EBADTYPE; + default: + break; + } + status = NC_EBADTYPE; + return status; +} diff --git a/ncdap_test/tst_ncdap.sh b/ncdap_test/tst_ncdap.sh index 7669db597..42ba0e775 100755 --- a/ncdap_test/tst_ncdap.sh +++ b/ncdap_test/tst_ncdap.sh @@ -1,5 +1,6 @@ #!/bin/sh +set -e #set -x quiet=0 leakcheck=0 diff --git a/ncdap_test/tst_ncdap3.sh b/ncdap_test/tst_ncdap3.sh index b73bee131..3b0f3b19f 100755 --- a/ncdap_test/tst_ncdap3.sh +++ b/ncdap_test/tst_ncdap3.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + #X="-x" #grind="checkleaks" diff --git a/ncdap_test/tst_ncdap4.sh b/ncdap_test/tst_ncdap4.sh index 76cfe58ec..c421e3ab3 100755 --- a/ncdap_test/tst_ncdap4.sh +++ b/ncdap_test/tst_ncdap4.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + #X="-x" #grind="checkleaks" diff --git a/ncdap_test/tst_nocache3.sh b/ncdap_test/tst_nocache3.sh index fddda9754..238edebd3 100755 --- a/ncdap_test/tst_nocache3.sh +++ b/ncdap_test/tst_nocache3.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + # if this is part of a distcheck action, then this script # will be executed in a different directory # than the one containing it; so capture the path to this script diff --git a/ncdap_test/tst_nocache4.sh b/ncdap_test/tst_nocache4.sh index 8f80ef841..6d02f0f73 100755 --- a/ncdap_test/tst_nocache4.sh +++ b/ncdap_test/tst_nocache4.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + # if this is part of a distcheck action, then this script # will be executed in a different directory # than the one containing it; so capture the path to this script diff --git a/ncdap_test/tst_remote.sh b/ncdap_test/tst_remote.sh index 18406264d..7034bf6c8 100755 --- a/ncdap_test/tst_remote.sh +++ b/ncdap_test/tst_remote.sh @@ -1,6 +1,7 @@ #!/bin/sh -#set -x +set -e + quiet=0 leakcheck=0 timing=0 @@ -244,7 +245,7 @@ for i in $WHICHTESTS ; do *) echo "Unknown which test: $i" ;; esac -rm -f ./.dodsrc ./.ocrc +rm -f ./.dodsrc ./.ocrc ./.daprc cd ${RESULTSDIR} for t in ${TESTSET} ; do @@ -252,24 +253,20 @@ for t in ${TESTSET} ; do #index=`expr index "${t}" ";"` #echo index: $index - if [ "$myplatform" = "Darwin" ]; then - index=`echo "${t}" | sed -n "s/;.*//p" | wc -c` + index=`echo "${t}" | sed -n "s/;.*//p" | wc -c` if (( $index == 0 )) ; then constrained=0 else constrained=1 fi - else - index=`expr index "${t}" ";"` - + if index=`expr index "${t}" ";"` ; then ignore=1; fi # avoid set -e if test "x$index" = "x0" ; then constrained=0 else constrained=1 fi - fi if test "x$constrained" = "x0" ; then # No constraint diff --git a/ncdap_test/tst_remote3.sh b/ncdap_test/tst_remote3.sh index 10620ad01..2ad269373 100755 --- a/ncdap_test/tst_remote3.sh +++ b/ncdap_test/tst_remote3.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + # if this is part of a distcheck action, then this script # will be executed in a different directory # than the one containing it; so capture the path to this script @@ -17,5 +19,5 @@ if [ `uname | cut -d "_" -f 1` = "MINGW32" ]; then fi cd ${builddir}/ncdap_test -sh ${srcdir}/tst_remote.sh "$srcdir" "$builddir" "3" "" "" +sh ${srcdir}/tst_remote.sh "$srcdir" "$builddir" "3" "" "" exit diff --git a/ncdap_test/tst_remote4.sh b/ncdap_test/tst_remote4.sh index ec8d97e3f..6aba70b33 100755 --- a/ncdap_test/tst_remote4.sh +++ b/ncdap_test/tst_remote4.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + # if this is part of a distcheck action, then this script # will be executed in a different directory # than the one containing it; so capture the path to this script diff --git a/ncdap_test/tst_special.sh b/ncdap_test/tst_special.sh index aa6f8941c..0bd59e79a 100755 --- a/ncdap_test/tst_special.sh +++ b/ncdap_test/tst_special.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + # if this is part of a distcheck action, then this script # will be executed in a different directory # than the one containing it; so capture the path to this script diff --git a/ncdap_test/tst_tds.sh b/ncdap_test/tst_tds.sh index b81a253af..f83dc21f9 100755 --- a/ncdap_test/tst_tds.sh +++ b/ncdap_test/tst_tds.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + # if this is part of a distcheck action, then this script # will be executed in a different directory # than the one containing it; so capture the path to this script