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 @@
* using CGRIBEX library version 1.8.1
* Version 1.9.0 released
2017-07-06 Uwe Schulzweida
* removed leading space from time units (bug fix)
2017-07-01 Uwe Schulzweida
* Added function tableInqEntry().
......
......@@ -13,6 +13,7 @@ void str_tolower(char *str)
str[i] = (char)tolower((int)str[i]);
}
bool str_is_equal(const char *vstr, const char *cstr)
{
bool is_equal = false;
......@@ -27,6 +28,8 @@ int get_timeunit(size_t len, const char *ptu)
{
int timeunit = -1;
while ( isspace(*ptu) && len ) { ptu++; len--; }
if ( len > 2 )
{
if ( str_is_equal(ptu, "sec") ) timeunit = TUNIT_SECOND;
......@@ -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, "year") ) timeunit = TUNIT_YEAR;
}
else if ( len == 1 && ptu[0] == 's' )
timeunit = TUNIT_SECOND;
else if ( len == 1 && ptu[0] == 's' ) timeunit = TUNIT_SECOND;
return timeunit;
}
......@@ -46,6 +48,8 @@ int get_timeunit(size_t len, const char *ptu)
bool is_time_units(const char *timeunits)
{
while ( isspace(*timeunits) ) timeunits++;
bool status = str_is_equal(timeunits, "sec")
|| str_is_equal(timeunits, "minute")
|| str_is_equal(timeunits, "hour")
......
......@@ -199,6 +199,8 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
int rdate = -1, rtime = -1;
size_t len = strlen(timeunits);
while ( isspace(*timeunits) && len ) { timeunits++; len--; }
char *restrict tu = (char *)Malloc((len+1) * sizeof(char));
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