Skip to content
Snippets Groups Projects
Commit f7fdc765 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdo_cmpstr: changed parameter type to std::string_view

parent 184fe6e2
No related branches found
No related tags found
1 merge request!337cdo_cmpstr: changed parameter type to std::string_view
Pipeline #98309 failed
......@@ -6,6 +6,7 @@
*/
#include <cmath>
#include <cstring>
#include "cdo_options.h"
#include "cdo_omp.h"
......
......@@ -2,8 +2,7 @@
#define COMPARE_H
#include <cmath>
#include <cstring>
#include <string>
#include <string_view>
// compare
// clang-format off
......@@ -15,13 +14,7 @@ const auto fp_is_equal = [](auto a, auto b) noexcept { return ((std::isnan(
// clang-format on
static inline bool
cdo_cmpstr(const char *x, const char *y)
{
return (strcmp(x, y) == 0);
}
static inline bool
cdo_cmpstr(std::string_view lhs, const std::string &rhs)
cdo_cmpstr(std::string_view lhs, std::string_view rhs)
{
return (lhs.compare(rhs) == 0);
}
......
......@@ -533,15 +533,15 @@ generate_grid_gaussian(GridDesciption &grid, std::string gridname)
if (gridname.size())
{
int intVal = 0;
int intValue = 0;
std::vector<char> typeString(gridname.size(), 0);
auto numVals = sscanf(gridname.c_str(), "%d%s", &intVal, typeString.data());
auto numValues = sscanf(gridname.c_str(), "%d%s", &intValue, typeString.data());
// printf("%s: %d %d%s\n", gridname.c_str(), numVals, intVal, typeString.data());
if (numVals <= 0 || numVals > 2) return;
if (intVal < 0) return;
if (numValues <= 0 || numValues > 2) return;
if (intValue < 0) return;
grid.ntr = intVal;
grid.ntr = intValue;
// clang-format off
if (cdo_cmpstr(typeString.data(), "grid")) grid.type = GRID_GAUSSIAN;
else if (cdo_cmpstr(typeString.data(), "zon")) grid.type = GRID_GAUSSIAN;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment