- detecting empty array size even when containing spaces
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
* @date 27.02.2017
|
* @date 27.02.2017
|
||||||
* @author SESA354004
|
* @author SESA354004
|
||||||
*/
|
*/
|
||||||
|
#include "xtypes.h"
|
||||||
#include "xstring.h"
|
#include "xstring.h"
|
||||||
#include "ctype.h"
|
#include "ctype.h"
|
||||||
|
|
||||||
@@ -24,6 +25,29 @@ char* gnu_basename(char *path)
|
|||||||
return base ? base + 1 : 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
|
* @brief Trim leading and trailing whitespaces
|
||||||
* @param [in] *str Input string
|
* @param [in] *str Input string
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
char* gnu_basename(char *path);
|
char* gnu_basename(char *path);
|
||||||
|
uint32_t xStrCount(char *aStr, char aC);
|
||||||
char* strntrimStatic(char *aStr, size_t aMaxLength);
|
char* strntrimStatic(char *aStr, size_t aMaxLength);
|
||||||
void xStringTrim(char *aStr, size_t aMaxLength);
|
void xStringTrim(char *aStr, size_t aMaxLength);
|
||||||
|
|
||||||
|
@@ -648,7 +648,7 @@ STATIC int8_t cfile_parser_evaluateExpression(char *aExpression, cfile_t *aCfile
|
|||||||
xStringTrim(tempChar, strlen(tempChar));
|
xStringTrim(tempChar, strlen(tempChar));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (2 == strlen(tempChar))
|
if (2 == strlen(tempChar) - xStrCount(tempChar, ' '))
|
||||||
{
|
{
|
||||||
// array without size definition
|
// array without size definition
|
||||||
xmallocStrlcat(&variable->dataType, "*", 1);
|
xmallocStrlcat(&variable->dataType, "*", 1);
|
||||||
|
Reference in New Issue
Block a user