mirror of https://github.com/ecmwf/eccodes.git
Check the value passed to the grib_set -d option
This commit is contained in:
parent
8881d760df
commit
efe074293d
|
@ -240,7 +240,13 @@ int grib_process_runtime_options(grib_context* context,int argc,char** argv,grib
|
||||||
options->gts=grib_options_on("g");
|
options->gts=grib_options_on("g");
|
||||||
|
|
||||||
if (grib_options_on("d:")) {
|
if (grib_options_on("d:")) {
|
||||||
options->constant=atof(grib_options_get_option("d:"));
|
char* endPtr = NULL; /* for error handling */
|
||||||
|
const char* optionStr = grib_options_get_option("d:");
|
||||||
|
options->constant=strtod(optionStr, &endPtr);
|
||||||
|
if(*endPtr) {
|
||||||
|
fprintf(stderr, "Invalid number for -d option: '%s'\n", optionStr);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
options->repack=1;
|
options->repack=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue