mirror of
https://github.com/irssi/irssi.git
synced 2026-08-20 00:52:30 +02:00
strsplit_len: use strlen() directly instead of a remaining_len variable
This commit is contained in:
parent
ed28483e75
commit
8736c12fc9
1 changed files with 2 additions and 4 deletions
|
|
@ -996,11 +996,10 @@ char **strsplit_len(const char *str, int len, gboolean onspace)
|
||||||
char **ret = g_new(char *, 1);
|
char **ret = g_new(char *, 1);
|
||||||
int n;
|
int n;
|
||||||
int split_offset = 0;
|
int split_offset = 0;
|
||||||
size_t remaining_len = strlen(str);
|
|
||||||
|
|
||||||
for (n = 0; *str != '\0'; n++) {
|
for (n = 0; *str != '\0'; n++) {
|
||||||
split_offset = MIN(len, remaining_len);
|
split_offset = MIN(len, strlen(str));
|
||||||
if (onspace && remaining_len > len) {
|
if (onspace && strlen(str) > len) {
|
||||||
/*
|
/*
|
||||||
* Try to find a space to split on and leave
|
* Try to find a space to split on and leave
|
||||||
* the space on the previous line.
|
* 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);
|
ret = g_renew(char *, ret, n + 2);
|
||||||
|
|
||||||
str += split_offset;
|
str += split_offset;
|
||||||
remaining_len -= split_offset;
|
|
||||||
}
|
}
|
||||||
ret[n] = NULL;
|
ret[n] = NULL;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue