- processing of function parameter added (first tests successful)

- next stage -> constructing stub files (.c and .h)
This commit is contained in:
2017-03-03 14:07:38 +00:00
parent 444b9fb078
commit 9557e97bab
8 changed files with 167 additions and 37 deletions

View File

@@ -1,13 +1,13 @@
/*!
* @file xstring.c
* @brief
* @brief
* @details
* Project: \n
* Subsystem: \n
* Module: \n
* Code: GNU-C\n
*
* @date 27.02.2017
*
* @date 27.02.2017
* @author SESA354004
*/
#include "xstring.h"
@@ -60,7 +60,7 @@ char* strntrimStatic(char *aStr, size_t aMaxLength)
end = aStr + strlen(aStr) - 1;
}
while (end > aStr && isspace((unsigned char)*end))
while (end > aStr && isspace((unsigned char )*end))
{
end--;
}
@@ -73,3 +73,53 @@ char* strntrimStatic(char *aStr, size_t aMaxLength)
return aStr;
}
void xStringTrim(char *aStr, size_t aMaxLength)
{
char *start;
char *end;
if (NULL == aStr)
{
return;
}
start = aStr;
// Trim leading space
while (isspace((unsigned char)*aStr) && 0 < aMaxLength)
{
if (--aMaxLength > 0)
{
++aStr;
}
}
// All spaces at termination or end of max length
if (*aStr == '\0' || 0 == aMaxLength)
{
start = '\0';
return;
}
(void) strlcpy(start, aStr, strlen(aStr) + 1);
// Trim trailing space
if (strlen(start) >= aMaxLength)
{
end = start + aMaxLength - 1;
}
else
{
end = start + strlen(start) - 1;
}
while (end > start && isspace((unsigned char )*end))
{
end--;
}
// Write new null terminator (if length is enough)
if (end < (start + aMaxLength - 1))
{
*(end + 1) = '\0';
}
}