Commit 4060bb3c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Renamed str_is_equal() to strIsEqual().

parent 5a9e834c
......@@ -16,7 +16,7 @@ char *strToLower(char *str)
}
bool str_is_equal(const char *vstr, const char *cstr)
bool strIsEqual(const char *vstr, const char *cstr)
{
bool is_equal = false;
size_t clen = (cstr != NULL) ? strlen(cstr) : 0;
......@@ -34,13 +34,13 @@ int get_timeunit(size_t len, const char *ptu)
if ( len > 2 )
{
if ( str_is_equal(ptu, "sec") ) timeunit = TUNIT_SECOND;
else if ( str_is_equal(ptu, "minute") ) timeunit = TUNIT_MINUTE;
else if ( str_is_equal(ptu, "hour") ) timeunit = TUNIT_HOUR;
else if ( str_is_equal(ptu, "day") ) timeunit = TUNIT_DAY;
else if ( str_is_equal(ptu, "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;
if ( strIsEqual(ptu, "sec") ) timeunit = TUNIT_SECOND;
else if ( strIsEqual(ptu, "minute") ) timeunit = TUNIT_MINUTE;
else if ( strIsEqual(ptu, "hour") ) timeunit = TUNIT_HOUR;
else if ( strIsEqual(ptu, "day") ) timeunit = TUNIT_DAY;
else if ( strIsEqual(ptu, "month") ) timeunit = TUNIT_MONTH;
else if ( strIsEqual(ptu, "calendar_month") ) timeunit = TUNIT_MONTH;
else if ( strIsEqual(ptu, "year") ) timeunit = TUNIT_YEAR;
}
else if ( len == 1 && ptu[0] == 's' ) timeunit = TUNIT_SECOND;
......@@ -52,13 +52,13 @@ 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")
|| str_is_equal(timeunits, "day")
|| str_is_equal(timeunits, "month")
|| str_is_equal(timeunits, "calendar_month")
|| str_is_equal(timeunits, "year");
bool status = strIsEqual(timeunits, "sec")
|| strIsEqual(timeunits, "minute")
|| strIsEqual(timeunits, "hour")
|| strIsEqual(timeunits, "day")
|| strIsEqual(timeunits, "month")
|| strIsEqual(timeunits, "calendar_month")
|| strIsEqual(timeunits, "year");
return status;
}
......@@ -83,8 +83,8 @@ bool is_timeaxis_units(const char *timeunits)
{
while ( isspace(*ptu) ) ptu++;
int timetype = str_is_equal(ptu, "as") ? TAXIS_ABSOLUTE :
str_is_equal(ptu, "since") ? TAXIS_RELATIVE : -1;
int timetype = strIsEqual(ptu, "as") ? TAXIS_ABSOLUTE :
strIsEqual(ptu, "since") ? TAXIS_RELATIVE : -1;
status = timetype != -1;
}
......@@ -192,14 +192,14 @@ bool is_lon_axis(const char *units, const char *stdname)
lc_units[15] = 0;
strToLower(lc_units);
if ( (str_is_equal(lc_units, "degree") || str_is_equal(lc_units, "radian")) &&
(str_is_equal(stdname, "grid_longitude") || str_is_equal(stdname, "longitude")) )
if ( (strIsEqual(lc_units, "degree") || strIsEqual(lc_units, "radian")) &&
(strIsEqual(stdname, "grid_longitude") || strIsEqual(stdname, "longitude")) )
{
status = true;
}
else if ( str_is_equal(lc_units, "degree")
&& !str_is_equal(stdname, "grid_latitude")
&& !str_is_equal(stdname, "latitude") )
else if ( strIsEqual(lc_units, "degree")
&& !strIsEqual(stdname, "grid_latitude")
&& !strIsEqual(stdname, "latitude") )
{
int ioff = 6;
if ( lc_units[ioff] == 's' ) ioff++;
......@@ -221,14 +221,14 @@ bool is_lat_axis(const char *units, const char *stdname)
lc_units[15] = 0;
strToLower(lc_units);
if ( (str_is_equal(lc_units, "degree") || str_is_equal(lc_units, "radian")) &&
(str_is_equal(stdname, "grid_latitude") || str_is_equal(stdname, "latitude")) )
if ( (strIsEqual(lc_units, "degree") || strIsEqual(lc_units, "radian")) &&
(strIsEqual(stdname, "grid_latitude") || strIsEqual(stdname, "latitude")) )
{
status = true;
}
else if ( str_is_equal(lc_units, "degree")
&& !str_is_equal(stdname, "grid_longitude")
&& !str_is_equal(stdname, "longitude") )
else if ( strIsEqual(lc_units, "degree")
&& !strIsEqual(stdname, "grid_longitude")
&& !strIsEqual(stdname, "longitude") )
{
int ioff = 6;
if ( lc_units[ioff] == 's' ) ioff++;
......@@ -324,21 +324,21 @@ void set_zaxistype(const char *attstring, int *zaxistype)
void set_calendar(const char *attstring, int *calendar)
{
if ( str_is_equal(attstring, "standard") )
if ( strIsEqual(attstring, "standard") )
*calendar = CALENDAR_STANDARD;
else if ( str_is_equal(attstring, "gregorian") )
else if ( strIsEqual(attstring, "gregorian") )
*calendar = CALENDAR_GREGORIAN;
else if ( str_is_equal(attstring, "none") )
else if ( strIsEqual(attstring, "none") )
*calendar = CALENDAR_NONE;
else if ( str_is_equal(attstring, "proleptic") )
else if ( strIsEqual(attstring, "proleptic") )
*calendar = CALENDAR_PROLEPTIC;
else if ( str_is_equal(attstring, "360") )
else if ( strIsEqual(attstring, "360") )
*calendar = CALENDAR_360DAYS;
else if ( str_is_equal(attstring, "365") ||
str_is_equal(attstring, "noleap") )
else if ( strIsEqual(attstring, "365") ||
strIsEqual(attstring, "noleap") )
*calendar = CALENDAR_365DAYS;
else if ( str_is_equal(attstring, "366") ||
str_is_equal(attstring, "all_leap") )
else if ( strIsEqual(attstring, "366") ||
strIsEqual(attstring, "all_leap") )
*calendar = CALENDAR_366DAYS;
else
Warning("calendar >%s< unsupported!", attstring);
......
......@@ -39,7 +39,7 @@ char *strdup(const char *s);
#endif
char *strToLower(char *str);
bool str_is_equal(const char *vstr, const char *cstr);
bool strIsEqual(const char *vstr, const char *cstr);
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
......
......@@ -222,7 +222,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
{
while ( isspace(tu[pos]) ) ++pos;
if ( str_is_equal(tu+pos, "since") )
if ( strIsEqual(tu+pos, "since") )
taxistype = TAXIS_RELATIVE;
while ( pos < len && !isspace(tu[pos]) ) ++pos;
......@@ -234,7 +234,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
{
if ( timeunit == TUNIT_DAY )
{
if ( !str_is_equal(tu+pos, "%y%m%d.%f") )
if ( !strIsEqual(tu+pos, "%y%m%d.%f") )
{
Message("Unsupported format %s for TIMEUNIT day!", tu+pos);
timeunit = -1;
......@@ -242,7 +242,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
}
else if ( timeunit == TUNIT_MONTH )
{
if ( !str_is_equal(tu+pos, "%y%m.%f") )
if ( !strIsEqual(tu+pos, "%y%m.%f") )
{
Message("Unsupported format %s for TIMEUNIT month!", tu+pos);
timeunit = -1;
......@@ -584,7 +584,7 @@ int cdf_time_dimid(int fileID, int ndims, int nvars, ncdim_t *ncdims)
{
dimname[0] = 0;
cdf_inq_dimname(fileID, ncdims[dimid].dimid, dimname);
if ( str_is_equal(dimname, "time") || str_is_equal(dimname, "Time") ) return dimid;
if ( strIsEqual(dimname, "time") || strIsEqual(dimname, "Time") ) return dimid;
}
for ( int varid = 0; varid < nvars; ++varid )
......@@ -1070,7 +1070,7 @@ int cdf_get_cell_varid(char *attstring, int ncid)
printf("cell_measures >%s<\n", cell_measures);
printf("cell_var >%s<\n", cell_var);
*/
if ( str_is_equal(cell_measures, "area") )
if ( strIsEqual(cell_measures, "area") )
{
int nc_var_id;
int status = nc_inq_varid(ncid, cell_var, &nc_var_id);
......@@ -1245,7 +1245,7 @@ void cdfScanVarAttr(int nvars, ncvar_t *ncvars, int ndims, ncdim_t *ncdims, int
}
else if ( isText && strcmp(attname, "trunc_type") == 0 )
{
if ( str_is_equal(attstring, "Triangular") )
if ( strIsEqual(attstring, "Triangular") )
ncvars[ncvarid].gridtype = GRID_SPECTRAL;
}
else if ( isText && (strcmp(attname, "grid_type") == 0 || strcmp(attname, "CDI_grid_type") == 0) )
......@@ -1449,8 +1449,8 @@ void cdfScanVarAttr(int nvars, ncvar_t *ncvars, int ndims, ncdim_t *ncdims, int
{
strToLower(attstring);
if ( str_is_equal(attstring, "down") ) ncvars[ncvarid].positive = POSITIVE_DOWN;
else if ( str_is_equal(attstring, "up") ) ncvars[ncvarid].positive = POSITIVE_UP;
if ( strIsEqual(attstring, "down") ) ncvars[ncvarid].positive = POSITIVE_DOWN;
else if ( strIsEqual(attstring, "up") ) ncvars[ncvarid].positive = POSITIVE_UP;
if ( ncvars[ncvarid].ndims == 1 )
{
......@@ -1525,7 +1525,7 @@ void cdfScanVarAttr(int nvars, ncvar_t *ncvars, int ndims, ncdim_t *ncdims, int
{
strToLower(attstring);
if ( str_is_equal(attstring, "true") )
if ( strIsEqual(attstring, "true") )
{
ncvars[ncvarid].lunsigned = true;
/*
......@@ -1540,7 +1540,7 @@ void cdfScanVarAttr(int nvars, ncvar_t *ncvars, int ndims, ncdim_t *ncdims, int
{
strToLower(attstring);
if ( str_is_equal(attstring, "ignore") )
if ( strIsEqual(attstring, "ignore") )
{
ncvars[ncvarid].ignore = true;
cdf_set_var(ncvars, ncvarid, FALSE);
......@@ -1901,14 +1901,14 @@ void verify_coordinate_vars_1(int ncid, int ndims, ncdim_t *ncdims, ncvar_t *ncv
strcmp(ncvars[ncvarid].longname, "generalized height") == 0) &&
strcmp(ncvars[ncvarid].stdname, "height") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_REFERENCE;
else if ( str_is_equal(ncvars[ncvarid].stdname, "air_pressure") )
else if ( strIsEqual(ncvars[ncvarid].stdname, "air_pressure") )
ncvars[ncvarid].zaxistype = ZAXIS_PRESSURE;
}
if ( !ncvars[ncvarid].islon && ncvars[ncvarid].longname[0] != 0 &&
!ncvars[ncvarid].islat && ncvars[ncvarid].longname[1] != 0 )
{
if ( str_is_equal(ncvars[ncvarid].longname+1, "ongitude") )
if ( strIsEqual(ncvars[ncvarid].longname+1, "ongitude") )
{
ncvars[ncvarid].islon = true;
cdf_set_var(ncvars, ncvarid, FALSE);
......@@ -1916,7 +1916,7 @@ void verify_coordinate_vars_1(int ncid, int ndims, ncdim_t *ncdims, ncvar_t *ncv
ncdims[ncdimid].dimtype = X_AXIS;
continue;
}
else if ( str_is_equal(ncvars[ncvarid].longname+1, "atitude") )
else if ( strIsEqual(ncvars[ncvarid].longname+1, "atitude") )
{
ncvars[ncvarid].islat = true;
cdf_set_var(ncvars, ncvarid, FALSE);
......@@ -2007,19 +2007,19 @@ void verify_coordinate_vars_2(int nvars, ncvar_t *ncvars)
{
ncvars[ncvarid].isc = true;
}
else if ( str_is_equal(ncvars[ncvarid].stdname, "air_pressure") )
else if ( strIsEqual(ncvars[ncvarid].stdname, "air_pressure") )
ncvars[ncvarid].zaxistype = ZAXIS_PRESSURE;
/* not needed anymore for rotated grids */
if ( !ncvars[ncvarid].islon && ncvars[ncvarid].longname[0] != 0 &&
!ncvars[ncvarid].islat && ncvars[ncvarid].longname[1] != 0 )
{
if ( str_is_equal(ncvars[ncvarid].longname+1, "ongitude") )
if ( strIsEqual(ncvars[ncvarid].longname+1, "ongitude") )
{
ncvars[ncvarid].islon = true;
continue;
}
else if ( str_is_equal(ncvars[ncvarid].longname+1, "atitude") )
else if ( strIsEqual(ncvars[ncvarid].longname+1, "atitude") )
{
ncvars[ncvarid].islat = true;
continue;
......@@ -3292,7 +3292,7 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
size_t len = strlen(name);
if ( len > 3 && isdigit((int) name[3]) )
{
if ( str_is_equal(name, "var") )
if ( strIsEqual(name, "var") )
{
vlistDefVarCode(vlistID, varID, atoi(name+3));
// vlistDestroyVarName(vlistID, varID);
......@@ -3300,7 +3300,7 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
}
else if ( len > 4 && isdigit((int) name[4]) )
{
if ( str_is_equal(name, "code") )
if ( strIsEqual(name, "code") )
{
vlistDefVarCode(vlistID, varID, atoi(name+4));
// vlistDestroyVarName(vlistID, varID);
......@@ -3308,7 +3308,7 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
}
else if ( len > 5 && isdigit((int) name[5]) )
{
if ( str_is_equal(name, "param") )
if ( strIsEqual(name, "param") )
{
int pnum = -1, pcat = 255, pdis = 255;
sscanf(name+5, "%d.%d.%d", &pnum, &pcat, &pdis);
......
......@@ -3269,7 +3269,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
gribapiGetString(gh, "shortName", grb_name, sizeof(grb_name));
strToLower(cdi_name);
strToLower(grb_name);
if ( (strlen(cdi_name) != strlen(grb_name)) || !str_is_equal(cdi_name, grb_name) )
if ( (strlen(cdi_name) != strlen(grb_name)) || !strIsEqual(cdi_name, grb_name) )
Message("*** GRIB2 shortName does not correspond to chosen variable name: \"%s\" (\"%s\").",
grb_name[0]?grb_name:"unknown", cdi_name);
}
......
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