Remove duplicated macro

This commit is contained in:
Shahram Najm 2023-02-17 15:44:46 +00:00
parent 1db0f4fc6f
commit 2432c1d029
6 changed files with 27 additions and 33 deletions

View File

@ -86,44 +86,44 @@ char* codes_getenv(const char* name)
const char* old_name = name;
/* Test the most commonly used variables first */
if (STR_EQ(name, "ECCODES_SAMPLES_PATH"))
if (STR_EQUAL(name, "ECCODES_SAMPLES_PATH"))
old_name = "GRIB_SAMPLES_PATH";
else if (STR_EQ(name, "ECCODES_DEFINITION_PATH"))
else if (STR_EQUAL(name, "ECCODES_DEFINITION_PATH"))
old_name = "GRIB_DEFINITION_PATH";
else if (STR_EQ(name, "ECCODES_DEBUG"))
else if (STR_EQUAL(name, "ECCODES_DEBUG"))
old_name = "GRIB_API_DEBUG";
else if (STR_EQ(name, "ECCODES_FAIL_IF_LOG_MESSAGE"))
else if (STR_EQUAL(name, "ECCODES_FAIL_IF_LOG_MESSAGE"))
old_name = "GRIB_API_FAIL_IF_LOG_MESSAGE";
else if (STR_EQ(name, "ECCODES_GRIB_WRITE_ON_FAIL"))
else if (STR_EQUAL(name, "ECCODES_GRIB_WRITE_ON_FAIL"))
old_name = "GRIB_API_WRITE_ON_FAIL";
else if (STR_EQ(name, "ECCODES_GRIB_LARGE_CONSTANT_FIELDS"))
else if (STR_EQUAL(name, "ECCODES_GRIB_LARGE_CONSTANT_FIELDS"))
old_name = "GRIB_API_LARGE_CONSTANT_FIELDS";
else if (STR_EQ(name, "ECCODES_NO_ABORT"))
else if (STR_EQUAL(name, "ECCODES_NO_ABORT"))
old_name = "GRIB_API_NO_ABORT";
else if (STR_EQ(name, "ECCODES_GRIBEX_MODE_ON"))
else if (STR_EQUAL(name, "ECCODES_GRIBEX_MODE_ON"))
old_name = "GRIB_GRIBEX_MODE_ON";
else if (STR_EQ(name, "ECCODES_GRIB_IEEE_PACKING"))
else if (STR_EQUAL(name, "ECCODES_GRIB_IEEE_PACKING"))
old_name = "GRIB_IEEE_PACKING";
else if (STR_EQ(name, "ECCODES_IO_BUFFER_SIZE"))
else if (STR_EQUAL(name, "ECCODES_IO_BUFFER_SIZE"))
old_name = "GRIB_API_IO_BUFFER_SIZE";
else if (STR_EQ(name, "ECCODES_LOG_STREAM"))
else if (STR_EQUAL(name, "ECCODES_LOG_STREAM"))
old_name = "GRIB_API_LOG_STREAM";
else if (STR_EQ(name, "ECCODES_GRIB_NO_BIG_GROUP_SPLIT"))
else if (STR_EQUAL(name, "ECCODES_GRIB_NO_BIG_GROUP_SPLIT"))
old_name = "GRIB_API_NO_BIG_GROUP_SPLIT";
else if (STR_EQ(name, "ECCODES_GRIB_NO_SPD"))
else if (STR_EQUAL(name, "ECCODES_GRIB_NO_SPD"))
old_name = "GRIB_API_NO_SPD";
else if (STR_EQ(name, "ECCODES_GRIB_KEEP_MATRIX"))
else if (STR_EQUAL(name, "ECCODES_GRIB_KEEP_MATRIX"))
old_name = "GRIB_API_KEEP_MATRIX";
else if (STR_EQ(name, "_ECCODES_ECMWF_TEST_DEFINITION_PATH"))
else if (STR_EQUAL(name, "_ECCODES_ECMWF_TEST_DEFINITION_PATH"))
old_name = "_GRIB_API_ECMWF_TEST_DEFINITION_PATH";
else if (STR_EQ(name, "_ECCODES_ECMWF_TEST_SAMPLES_PATH"))
else if (STR_EQUAL(name, "_ECCODES_ECMWF_TEST_SAMPLES_PATH"))
old_name = "_GRIB_API_ECMWF_TEST_SAMPLES_PATH";
else if (STR_EQ(name, "ECCODES_GRIB_JPEG"))
else if (STR_EQUAL(name, "ECCODES_GRIB_JPEG"))
old_name = "GRIB_JPEG";
else if (STR_EQ(name, "ECCODES_GRIB_DUMP_JPG_FILE"))
else if (STR_EQUAL(name, "ECCODES_GRIB_DUMP_JPG_FILE"))
old_name = "GRIB_DUMP_JPG_FILE";
else if (STR_EQ(name, "ECCODES_PRINT_MISSING"))
else if (STR_EQUAL(name, "ECCODES_PRINT_MISSING"))
old_name = "GRIB_PRINT_MISSING";
result = getenv(old_name);

View File

@ -201,7 +201,7 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
#endif
/* Return true if two strings are equal */
#define STR_EQ(a, b) (strcmp((a), (b)) == 0)
#define STR_EQUAL(a, b) (strcmp((a), (b)) == 0)
#include "grib_api.h"

View File

@ -11,8 +11,6 @@
#include "grib_api_internal.h"
#include <float.h>
#define STR_EQUAL(s1, s2) (strcmp((s1), (s2)) == 0)
typedef enum
{
eROUND_ANGLE_UP,

View File

@ -11,8 +11,6 @@
#include "grib_api_internal.h"
#include "eccodes.h"
#define STR_EQUAL(s1, s2) (strcmp((s1), (s2)) == 0)
static int get_packing_type_code(const char* packingType)
{
int result = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE;

View File

@ -10,7 +10,6 @@
#include "grib_api_internal.h"
#define STR_EQUAL(s1, s2) (strcmp((s1), (s2)) == 0)
#define NUMBER(x) (sizeof(x) / sizeof(x[0]))
int assertion_caught = 0;
@ -1404,10 +1403,10 @@ static void test_string_splitting()
if (!list) { Assert(!"List is NULL"); return; }
for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */
Assert(i == 4);
if (!list[0] || !STR_EQ(list[0], "Born")) Assert(0);
if (!list[1] || !STR_EQ(list[1], "To")) Assert(0);
if (!list[2] || !STR_EQ(list[2], "Be")) Assert(0);
if (!list[3] || !STR_EQ(list[3], "Wild")) Assert(0);
if (!list[0] || !STR_EQUAL(list[0], "Born")) Assert(0);
if (!list[1] || !STR_EQUAL(list[1], "To")) Assert(0);
if (!list[2] || !STR_EQUAL(list[2], "Be")) Assert(0);
if (!list[3] || !STR_EQUAL(list[3], "Wild")) Assert(0);
Assert(list[4] == NULL);
for (i = 0; list[i] != NULL; ++i) free(list[i]);
free(list);
@ -1417,8 +1416,8 @@ static void test_string_splitting()
if (!list) { Assert(0); return; }
for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */
Assert(i == 2);
if (!list[0] || !STR_EQ(list[0], "12345")) Assert(0);
if (!list[1] || !STR_EQ(list[1], "a gap")) Assert(0);
if (!list[0] || !STR_EQUAL(list[0], "12345")) Assert(0);
if (!list[1] || !STR_EQUAL(list[1], "a gap")) Assert(0);
Assert(list[2] == NULL);
for (i = 0; list[i] != NULL; ++i) free(list[i]);
free(list);
@ -1428,7 +1427,7 @@ static void test_string_splitting()
if (!list) { Assert(0); return; }
for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */
Assert(i == 1);
if (!list[0] || !STR_EQ(list[0], "Steppenwolf")) Assert(0);
if (!list[0] || !STR_EQUAL(list[0], "Steppenwolf")) Assert(0);
Assert(list[1] == NULL);
for (i = 0; list[i] != NULL; ++i) free(list[i]);
free(list);

View File

@ -22,7 +22,6 @@
#include "grib_api_internal.h"
#define STR_EQUAL(s1, s2) (strcmp((s1), (s2)) == 0)
int exit_on_error = 1; /* By default exit if any check fails */
int verbose = 0; /* By default quiet unless errors */