Commit 688cbf84 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

season_to_months: convert user string to upper case.

parent 0ffcdd29
......@@ -50,8 +50,10 @@ void season_to_months(const char *season, int *imonths)
else
{
if ( len > 12 ) cdoAbort("Too many months %d (limit=12)!", (int)len);
// char *sstr = strcasestr(smons, season); // nonstandard extension
const char *sstr = strstr(smons, season);
char *season_u = strdup(season);
strtoupper(season_u);
const char *sstr = strstr(smons, season_u);
free(season_u);
if ( sstr == NULL ) cdoAbort("Season %s not available!", season);
size_t ks = (size_t)(sstr-smons);
size_t ke = ks + len;
......
......@@ -55,14 +55,14 @@ int download_gridfile(const char *restrict uri, const char *restrict basename)
#endif
CURLcode ret = curl_global_init(curlflags);
if(ret != 0)
if ( ret != 0 )
{
fprintf(stderr, "ERROR: %s!\n", curl_easy_strerror(ret));
return -1;
}
CURL *hd = curl_easy_init();
if (hd == NULL)
if ( hd == NULL )
{
fprintf(stderr, "ERROR: could not get curl handler.\n");
return -1;
......@@ -70,7 +70,7 @@ int download_gridfile(const char *restrict uri, const char *restrict basename)
else
{
FILE *fp = fopen(basename, "w");
if (fp == NULL)
if ( fp == NULL )
{
fprintf(stderr, "ERROR: could not open local output file %s. %s.\n", basename, strerror(errno));
return -1;
......@@ -109,7 +109,7 @@ int download_gridfile(const char *restrict uri, const char *restrict basename)
else
{
int status = remove(basename);
if (status == -1) perror(basename);
if ( status == -1 ) perror(basename);
fprintf(stderr, "ERROR: %s. Download %s failed.\n\n", curl_easy_strerror(ret), basename);
}
......@@ -197,7 +197,7 @@ int referenceToGrid(int gridID1)
strcpy(gridpath, cdoGridSearchDir);
strcat(gridpath, basename);
if ( cdoVerbose ) cdoPrint("Search for horizontal grid file \"%s\"", gridpath);
/* scan directory given by environment variable */
status = search_file(cdoGridSearchDir, gridpath);
}
......
......@@ -390,6 +390,13 @@ void strtolower(char *str)
str[i] = (char)tolower((int)str[i]);
}
void strtoupper(char *str)
{
if ( str )
for ( size_t i = 0; str[i]; ++i )
str[i] = (char)toupper((int)str[i]);
}
const char *parameter2word(const char *string)
{
......
Supports Markdown
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