Commit 45672ae9 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

removed leading space from time units (bug fix).

parent 1698f3b0
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
* using CGRIBEX library version 1.8.1 * using CGRIBEX library version 1.8.1
* Version 1.9.0 released * Version 1.9.0 released
2017-07-06 Uwe Schulzweida
* removed leading space from time units (bug fix)
2017-07-01 Uwe Schulzweida 2017-07-01 Uwe Schulzweida
* Added function tableInqEntry(). * Added function tableInqEntry().
......
...@@ -13,6 +13,7 @@ void str_tolower(char *str) ...@@ -13,6 +13,7 @@ void str_tolower(char *str)
str[i] = (char)tolower((int)str[i]); str[i] = (char)tolower((int)str[i]);
} }
bool str_is_equal(const char *vstr, const char *cstr) bool str_is_equal(const char *vstr, const char *cstr)
{ {
bool is_equal = false; bool is_equal = false;
...@@ -27,6 +28,8 @@ int get_timeunit(size_t len, const char *ptu) ...@@ -27,6 +28,8 @@ int get_timeunit(size_t len, const char *ptu)
{ {
int timeunit = -1; int timeunit = -1;
while ( isspace(*ptu) && len ) { ptu++; len--; }
if ( len > 2 ) if ( len > 2 )
{ {
if ( str_is_equal(ptu, "sec") ) timeunit = TUNIT_SECOND; if ( str_is_equal(ptu, "sec") ) timeunit = TUNIT_SECOND;
...@@ -37,8 +40,7 @@ int get_timeunit(size_t len, const char *ptu) ...@@ -37,8 +40,7 @@ int get_timeunit(size_t len, const char *ptu)
else if ( str_is_equal(ptu, "calendar_month") ) timeunit = TUNIT_MONTH; else if ( str_is_equal(ptu, "calendar_month") ) timeunit = TUNIT_MONTH;
else if ( str_is_equal(ptu, "year") ) timeunit = TUNIT_YEAR; else if ( str_is_equal(ptu, "year") ) timeunit = TUNIT_YEAR;
} }
else if ( len == 1 && ptu[0] == 's' ) else if ( len == 1 && ptu[0] == 's' ) timeunit = TUNIT_SECOND;
timeunit = TUNIT_SECOND;
return timeunit; return timeunit;
} }
...@@ -46,6 +48,8 @@ int get_timeunit(size_t len, const char *ptu) ...@@ -46,6 +48,8 @@ int get_timeunit(size_t len, const char *ptu)
bool is_time_units(const char *timeunits) bool is_time_units(const char *timeunits)
{ {
while ( isspace(*timeunits) ) timeunits++;
bool status = str_is_equal(timeunits, "sec") bool status = str_is_equal(timeunits, "sec")
|| str_is_equal(timeunits, "minute") || str_is_equal(timeunits, "minute")
|| str_is_equal(timeunits, "hour") || str_is_equal(timeunits, "hour")
......
...@@ -199,6 +199,8 @@ int setBaseTime(const char *timeunits, taxis_t *taxis) ...@@ -199,6 +199,8 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
int rdate = -1, rtime = -1; int rdate = -1, rtime = -1;
size_t len = strlen(timeunits); size_t len = strlen(timeunits);
while ( isspace(*timeunits) && len ) { timeunits++; len--; }
char *restrict tu = (char *)Malloc((len+1) * sizeof(char)); char *restrict tu = (char *)Malloc((len+1) * sizeof(char));
for ( size_t i = 0; i < len; i++ ) tu[i] = (char)tolower((int)timeunits[i]); for ( size_t i = 0; i < len; i++ ) tu[i] = (char)tolower((int)timeunits[i]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment