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:
parent
9e22e75fa1
commit
947dfda515
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user