diff --git a/src/ext/xstring.c b/src/ext/xstring.c index db96d1b..c4454d9 100644 --- a/src/ext/xstring.c +++ b/src/ext/xstring.c @@ -10,6 +10,7 @@ * @date 27.02.2017 * @author SESA354004 */ +#include "xtypes.h" #include "xstring.h" #include "ctype.h" @@ -24,6 +25,29 @@ char* gnu_basename(char *path) return base ? base + 1 : path; } +uint32_t xStrCount(char *aStr, char aC) +{ + uint32_t count = 0; + char *temp = NULL; + + if (NULL == aStr) + { + return 0; + } + temp = aStr; + + while (*temp) + { + if (aC == *temp) + { + ++count; + } + temp++; + } + + return count; +} + /*! * @brief Trim leading and trailing whitespaces * @param [in] *str Input string diff --git a/src/ext/xstring.h b/src/ext/xstring.h index 324bb76..49c0d7a 100644 --- a/src/ext/xstring.h +++ b/src/ext/xstring.h @@ -16,6 +16,7 @@ #include char* gnu_basename(char *path); +uint32_t xStrCount(char *aStr, char aC); char* strntrimStatic(char *aStr, size_t aMaxLength); void xStringTrim(char *aStr, size_t aMaxLength); diff --git a/src/stubser/cfile_parser.c b/src/stubser/cfile_parser.c index c159485..f01a8fc 100644 --- a/src/stubser/cfile_parser.c +++ b/src/stubser/cfile_parser.c @@ -648,7 +648,7 @@ STATIC int8_t cfile_parser_evaluateExpression(char *aExpression, cfile_t *aCfile xStringTrim(tempChar, strlen(tempChar)); } - if (2 == strlen(tempChar)) + if (2 == strlen(tempChar) - xStrCount(tempChar, ' ')) { // array without size definition xmallocStrlcat(&variable->dataType, "*", 1);