- detecting empty array size even when containing spaces

This commit is contained in:
2017-03-15 13:14:52 +00:00
parent 6291fa4b78
commit f392bb586d
3 changed files with 26 additions and 1 deletions

View File

@@ -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

View File

@@ -16,6 +16,7 @@
#include <string.h>
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);

View File

@@ -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);