diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 145cdfb91..adf7e8d36 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -1047,7 +1047,7 @@ int grib_f_open_file_(int* fid, char* name , char* op, int lname, int lop) { while (*p != '\0') { *p=tolower(*p);p++;} trimmed = cast_char_no_cut(fname,name,lname); /* ECC-1392 */ - rtrim( trimmed ); + string_rtrim( trimmed ); f = fopen(trimmed, oper); if(!f) { ioerr=errno; @@ -2891,7 +2891,7 @@ int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int val /* ECC-1316 */ cast_char_no_cut(bufval,val,vallen); - rtrim( bufval ); + string_rtrim( bufval ); return grib_index_select_string(h, cast_char(buf,key,len), bufval); } @@ -3257,7 +3257,7 @@ int grib_f_set_string_array_(int* gid, char* key, char* val,int* nvals,int* slen for (i=0;iident, pTemp, IDENT_LEN - 1); } diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 4acbbcb0f..4844843bc 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -1457,13 +1457,13 @@ int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err); /* string_util.c */ int strcmp_nocase(const char* s1, const char* s2); -void rtrim(char* s); -void lrtrim(char** x, int do_left, int do_right); +void string_rtrim(char* s); +void string_lrtrim(char** x, int do_left, int do_right); const char* extract_filename(const char* filepath); char** string_split(char* inputString, const char* delimiter); int string_to_long(const char* input, long* output); int string_ends_with(const char* str1, const char* str2); -int count_char_in_string(const char* str, char c); +int string_count_char(const char* str, char c); const char* codes_get_product_name(ProductKind product); const char* grib_get_type_name(int type); char* string_replace_char(char *str, char oldc, char newc); diff --git a/src/grib_accessor_class_codetable.c b/src/grib_accessor_class_codetable.c index 7c33c898e..245b0156d 100644 --- a/src/grib_accessor_class_codetable.c +++ b/src/grib_accessor_class_codetable.c @@ -506,7 +506,7 @@ static int grib_load_codetable(grib_context* c, const char* filename, Assert(*abbreviation); Assert(*title); - rtrim(title); /* ECC-1315 */ + string_rtrim(title); /* ECC-1315 */ if (t->entries[code].abbreviation != NULL) { grib_context_log(c, GRIB_LOG_WARNING, "code_table_entry: duplicate code in %s: %d (table size=%ld)", filename, code, size); diff --git a/src/grib_accessor_class_trim.c b/src/grib_accessor_class_trim.c index 646547836..07f5252c8 100644 --- a/src/grib_accessor_class_trim.c +++ b/src/grib_accessor_class_trim.c @@ -161,7 +161,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) err = grib_get_string(h, self->input, input, &size); if (err) return err; - lrtrim(&pInput, self->trim_left, self->trim_right); + string_lrtrim(&pInput, self->trim_left, self->trim_right); sprintf(val, "%s", pInput); size = strlen(val); *len = size + 1; @@ -189,7 +189,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) sprintf(buf, "%s", val); pBuf = buf; - lrtrim(&pBuf, self->trim_left, self->trim_right); + string_lrtrim(&pBuf, self->trim_left, self->trim_right); return grib_pack_string(inputAccesstor, pBuf, len); } diff --git a/src/string_util.c b/src/string_util.c index b2262fde8..f42845ff9 100644 --- a/src/string_util.c +++ b/src/string_util.c @@ -27,7 +27,7 @@ int strcmp_nocase(const char* s1, const char* s2) } /* Strip whitespace from the end of a string */ -void rtrim(char* s) +void string_rtrim(char* s) { size_t len = 0; if (!s) @@ -38,7 +38,7 @@ void rtrim(char* s) s[len] = '\0'; } -void lrtrim(char** x, int do_left, int do_right) +void string_lrtrim(char** x, int do_left, int do_right) { DebugAssert(do_left || do_right); if (do_left) { @@ -161,7 +161,7 @@ int string_ends_with(const char* s, const char* suffix) return 0; } -int count_char_in_string(const char* str, char c) +int string_count_char(const char* str, char c) { int i = 0, count = 0; DebugAssert(str); diff --git a/tests/unit_tests.c b/tests/unit_tests.c index 79ef61793..7d15a9437 100644 --- a/tests/unit_tests.c +++ b/tests/unit_tests.c @@ -1511,19 +1511,19 @@ static void test_trimming() printf("Testing: test_trimming...\n"); - lrtrim(&pA, 0, 1); /*right only*/ + string_lrtrim(&pA, 0, 1); /*right only*/ assert( strcmp(pA, " Standing")==0 ); - lrtrim(&pB, 1, 0); /*left only*/ + string_lrtrim(&pB, 1, 0); /*left only*/ assert( strcmp(pB, "Weeping ")==0 ); - lrtrim(&pC, 1, 1); /*both ends*/ + string_lrtrim(&pC, 1, 1); /*both ends*/ assert( strcmp(pC, "Silhouette")==0 ); - lrtrim(&pD, 1, 1); /*make sure other spaces are not removed*/ + string_lrtrim(&pD, 1, 1); /*make sure other spaces are not removed*/ assert( strcmp(pD, "The Forest Of October")==0 ); - lrtrim(&pE, 1, 1); /* Other chars */ + string_lrtrim(&pE, 1, 1); /* Other chars */ assert( strcmp(pE, "Apostle In Triumph")==0 ); } diff --git a/tools/grib_get_data.c b/tools/grib_get_data.c index 69f409649..b5aadd581 100644 --- a/tools/grib_get_data.c +++ b/tools/grib_get_data.c @@ -135,7 +135,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) if (grib_options_on("L:")) { /* Do a very basic sanity check */ const char* str = grib_options_get_option("L:"); - if (count_char_in_string(str, '%') != 2) { + if (string_count_char(str, '%') != 2) { fprintf(stderr, "ERROR: Invalid lats/lons format option \"%s\".\nThe default is: \"%s\"\n", str, default_format_latlons); exit(1);