mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
s390-tools: Move function util_strstrip
This patch - moves function util_strstrip to libutil/util_libc.c and deletes the extra files util_strstip.[ch] - adds doxygen comments for util_strstrip() - provides an example on how to use util_strstrip(). Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
08bc0a947a
commit
427dff3450
@@ -198,3 +198,33 @@ int __util_vsprintf(const char *func, const char *file, int line,
|
||||
rc != -1, "Could not format string\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip leading and trailing spaces from string
|
||||
*
|
||||
* Remove string \a s leading and trailing spaces
|
||||
*
|
||||
* @param[in,out] s String to manipulate
|
||||
*
|
||||
* @returns Pointer to first non-space character in string \a s
|
||||
*/
|
||||
char *util_strstrip(char *s)
|
||||
{
|
||||
size_t size;
|
||||
char *end;
|
||||
|
||||
size = strlen(s);
|
||||
|
||||
if (!size)
|
||||
return s;
|
||||
|
||||
end = s + size - 1;
|
||||
while (end >= s && isspace(*end))
|
||||
end--;
|
||||
*(end + 1) = '\0';
|
||||
|
||||
while (*s && isspace(*s))
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user