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:
Thomas Richter
2018-02-21 12:25:09 +00:00
committed by Jan Höppner
parent 08bc0a947a
commit 427dff3450
7 changed files with 51 additions and 67 deletions
-39
View File
@@ -1,39 +0,0 @@
/*
* util - Utility function library
*
* Strip leading and trailing blanks.
*
* Copyright IBM Corp. 2018
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <string.h>
#include <ctype.h>
#include "lib/util_str.h"
/*
* strip leading and trailing blanks
*/
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;
}