1
0
mirror of https://github.com/irssi/irssi.git synced 2024-07-21 03:14:16 -04:00

strsplit_len: use strlen() directly instead of a remaining_len variable

This commit is contained in:
dequis 2015-11-09 06:33:08 -03:00
parent ed28483e75
commit 8736c12fc9

View File

@ -996,11 +996,10 @@ char **strsplit_len(const char *str, int len, gboolean onspace)
char **ret = g_new(char *, 1);
int n;
int split_offset = 0;
size_t remaining_len = strlen(str);
for (n = 0; *str != '\0'; n++) {
split_offset = MIN(len, remaining_len);
if (onspace && remaining_len > len) {
split_offset = MIN(len, strlen(str));
if (onspace && strlen(str) > len) {
/*
* Try to find a space to split on and leave
* the space on the previous line.
@ -1017,7 +1016,6 @@ char **strsplit_len(const char *str, int len, gboolean onspace)
ret = g_renew(char *, ret, n + 2);
str += split_offset;
remaining_len -= split_offset;
}
ret[n] = NULL;