diff --git a/src/grib_templates.c b/src/grib_templates.c index f847c7409..850f5858f 100644 --- a/src/grib_templates.c +++ b/src/grib_templates.c @@ -55,7 +55,10 @@ static grib_handle* try_template(grib_context* c, const char* dir, const char* n grib_handle* g = NULL; int err = 0; - sprintf(path, "%s/%s.tmpl", dir, name); + if (string_ends_with(name, ".tmpl")) + sprintf(path, "%s/%s", dir, name); + else + sprintf(path, "%s/%s.tmpl", dir, name); if (c->debug) { fprintf(stderr, "ECCODES DEBUG try_template path='%s'\n", path); @@ -83,7 +86,10 @@ static grib_handle* try_bufr_template(grib_context* c, const char* dir, const ch grib_handle* g = NULL; int err = 0; - sprintf(path, "%s/%s.tmpl", dir, name); + if (string_ends_with(name, ".tmpl")) + sprintf(path, "%s/%s", dir, name); + else + sprintf(path, "%s/%s.tmpl", dir, name); if (c->debug) { fprintf(stderr, "ECCODES DEBUG try_template path='%s'\n", path); @@ -108,8 +114,10 @@ static grib_handle* try_bufr_template(grib_context* c, const char* dir, const ch static char* try_template_path(grib_context* c, const char* dir, const char* name) { char path[2048]; - - sprintf(path, "%s/%s.tmpl", dir, name); + if (string_ends_with(name, ".tmpl")) + sprintf(path, "%s/%s", dir, name); + else + sprintf(path, "%s/%s.tmpl", dir, name); if (codes_access(path, F_OK) == 0) { return grib_context_strdup(c, path); diff --git a/tests/grib_sh_ieee64.c b/tests/grib_sh_ieee64.c index 57b98c626..e9f32e2ce 100644 --- a/tests/grib_sh_ieee64.c +++ b/tests/grib_sh_ieee64.c @@ -31,7 +31,7 @@ int main(int argc, char* argv[]) double zval[ILCHAM]; int m, n, k; - GRIB_CHECK(((h = grib_handle_new_from_samples(NULL, "sh_ml_grib2")) == NULL), 0); + GRIB_CHECK(((h = grib_handle_new_from_samples(NULL, "sh_ml_grib2.tmpl")) == NULL), 0); /* Meteo-France settings */ GRIB_CHECK(grib_set_long(h, "centre", 85), 0); diff --git a/tools/codes_export_resource.c b/tools/codes_export_resource.c index ad00c2671..d54ee9db2 100644 --- a/tools/codes_export_resource.c +++ b/tools/codes_export_resource.c @@ -58,10 +58,6 @@ int main(int argc, char* argv[]) } if (resource_type == SAMPLE) { - char* t = strstr(resource_path, ".tmpl"); - if (t) { - *t = '\0'; /* get rid of sample file extension (if there) */ - } full_path = grib_external_template_path(c, resource_path); } else if (resource_type == DEFINITION) { @@ -101,7 +97,7 @@ int main(int argc, char* argv[]) grib_context_free(c, full_path); - printf("Resource written out to file '%s'.\n", out_file); + printf("Resource exported to file '%s'.\n", out_file); return 0; }