summaryrefslogtreecommitdiff
path: root/src/core/misc.c
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-11-09 06:46:40 -0300
committerdequis <dx@dxzone.com.ar>2015-11-09 06:46:40 -0300
commitb054ade4b90a05d778a64c63c0c834a126884aaa (patch)
tree0666e3201c484d72b4c858d8ba6dd0eb8587502b /src/core/misc.c
parent8736c12fc95ca977f4fc4a947c760bac651cd3af (diff)
downloadirssi-b054ade4b90a05d778a64c63c0c834a126884aaa.zip
strsplit_len: make it look more like the original version
Diffstat (limited to 'src/core/misc.c')
-rw-r--r--src/core/misc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 4e8322fa..490b5a8f 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -995,10 +995,10 @@ char **strsplit_len(const char *str, int len, gboolean onspace)
{
char **ret = g_new(char *, 1);
int n;
- int split_offset = 0;
+ int offset;
- for (n = 0; *str != '\0'; n++) {
- split_offset = MIN(len, strlen(str));
+ for (n = 0; *str != '\0'; n++, str += offset) {
+ offset = MIN(len, strlen(str));
if (onspace && strlen(str) > len) {
/*
* Try to find a space to split on and leave
@@ -1007,15 +1007,13 @@ char **strsplit_len(const char *str, int len, gboolean onspace)
int i;
for (i = len - 1; i > 0; i--) {
if (str[i] == ' ') {
- split_offset = i;
+ offset = i;
break;
}
}
}
- ret[n] = g_strndup(str, split_offset);
+ ret[n] = g_strndup(str, offset);
ret = g_renew(char *, ret, n + 2);
-
- str += split_offset;
}
ret[n] = NULL;