1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-21 23:38:49 -05:00

Refactor strtrim function

Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Silvan Jegen 2015-11-09 18:43:40 +01:00 committed by Allan McRae
parent 9e22e75fa1
commit 947dfda515

View File

@ -144,17 +144,13 @@ size_t strtrim(char *str)
}
if(pch != str) {
size_t len = strlen(pch);
if(len) {
memmove(str, pch, len + 1);
pch = str;
} else {
/* check if there wasn't anything but whitespace in the string. */
if(len == 0) {
*str = '\0';
return 0;
}
}
/* check if there wasn't anything but whitespace in the string. */
if(*str == '\0') {
return 0;
memmove(str, pch, len + 1);
pch = str;
}
end = (str + strlen(str) - 1);