From f9ed1d035de8c2098ca4360b4d6c5f4756b69e7f Mon Sep 17 00:00:00 2001 From: "C. Piker" Date: Sun, 3 Mar 2024 14:51:15 -0600 Subject: [PATCH] Passes unittests on older gcc --- das2/codec.c | 2 ++ das2/property.c | 19 ++++++++++++++----- das2/value.c | 12 +++++++----- das2/variable.c | 2 +- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/das2/codec.c b/das2/codec.c index 78e3fcb..3dee3bf 100644 --- a/das2/codec.c +++ b/das2/codec.c @@ -839,9 +839,11 @@ int DasCodec_decode( /* or search of the end, parse, then run in the data */ case DASENC_TEXT|DASENC_VARSZ: case DASENC_TEXT|DASENC_PARSE|DASENC_VARSZ: + { int nValsDidRead = 0; nBytesRead = _var_text_read(pThis, pBuf, nBufLen, nValsToRead, &nValsDidRead); nValsToRead = nValsDidRead; + } if(nBytesRead < 0 ) return nBytesRead; diff --git a/das2/property.c b/das2/property.c index c253dd7..f010fc7 100644 --- a/das2/property.c +++ b/das2/property.c @@ -120,11 +120,14 @@ DasErrCode DasProp_init( if((units == NULL) && (nStandard == DASPROP_DAS2) && (sType != NULL)){ int nUnitWord = 0; - if(strcasecmp(sType, "datum") == 0) + if((strcasecmp(sType, "datum") == 0)||(strcasecmp(sType, "time") == 0) + ||(strcasecmp(sType, "datetime") == 0) + ) nUnitWord = 1; else - if (strcasecmp(sType, "datumrange") == 0) - nUnitWord = 4; + if( (strcasecmp(sType, "datumrange") == 0)||(strcasecmp(sType, "timerange") == 0) + ||(strcasecmp(sType, "datetimerange") == 0)) + nUnitWord = 3; if(nUnitWord > 0){ const char* pRead = sValue; @@ -214,8 +217,14 @@ DasErrCode DasProp_init( uFlags |= (DASPROP_DATETIME | DASPROP_RANGE); else if( (strcasecmp(sType, "datum") == 0) && (sValue[0] != '\0')) uFlags |= (DASPROP_REAL | DASPROP_SINGLE); - else if((strcasecmp(sType, "datumrange") == 0) && (sValue[0] != '\0')) - uFlags |= (DASPROP_REAL | DASPROP_RANGE); + else if((strcasecmp(sType, "datumrange") == 0) && (sValue[0] != '\0')){ + /* Some time ranges have been listed as datum ranges, if you + * see units of 'UTC', make this a time range instead */ + if(Units_haveCalRep(units)) + uFlags |= (DASPROP_DATETIME | DASPROP_RANGE); + else + uFlags |= (DASPROP_REAL | DASPROP_RANGE); + } else return das_error(DASERR_PROP, "Invalid property type '%s' for value '%s'", sName, sValue diff --git a/das2/value.c b/das2/value.c index 81049fc..2ddf3e5 100644 --- a/das2/value.c +++ b/das2/value.c @@ -535,11 +535,13 @@ DasErrCode das_value_fromStr( case vtUnknown: return das_error(DASERR_VALUE, "Cannot determine fill values for unknown types"); - case vtText: - size_t nLen = strlen(sStr); - if(nLen <= nBufLen){ - strncpy((char*)pBuf, sStr, nLen); - return DAS_OKAY; + case vtText: + { + size_t nLen = strlen(sStr); + if(nLen <= nBufLen){ + strncpy((char*)pBuf, sStr, nLen); + return DAS_OKAY; + } } daslog_error_v( "string value '%s' can't fit into %d byte buffer", sStr, nBufLen diff --git a/das2/variable.c b/das2/variable.c index adc0826..29a6277 100644 --- a/das2/variable.c +++ b/das2/variable.c @@ -629,7 +629,7 @@ DasAry* DasConstant_subset( return pAry; } -bool DasConstant_degenerate(const DasVar* pBase, int) +bool DasConstant_degenerate(const DasVar* pBase, int iIdx) { return true; }