Mercurial > pidgin
diff src/util.c @ 1100:f168625b63fe
[gaim-migrate @ 1110]
some perl updates, and indication of which account got warned
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 16 Nov 2000 08:48:01 +0000 |
parents | 56c7ceb986a8 |
children | f3e0f41beddb |
line wrap: on
line diff
--- a/src/util.c Thu Nov 16 07:35:58 2000 +0000 +++ b/src/util.c Thu Nov 16 08:48:01 2000 +0000 @@ -1258,3 +1258,52 @@ return 0; } + +GSList *message_split(char *message, int limit) { + static GSList *ret = NULL; + int lastgood = 0, curgood = 0, curpos = 0, len = strlen(message); + gboolean intag = FALSE; + + if (ret) { + GSList *tmp = ret; + while (tmp) { + g_free(tmp->data); + tmp = g_slist_remove(tmp, tmp->data); + } + ret = NULL; + } + + while (TRUE) { + if (lastgood >= len) + return ret; + + if (len - lastgood < limit) { + ret = g_slist_append(ret, g_strdup(&message[lastgood])); + return ret; + } + + curgood = curpos = 0; + intag = FALSE; + while (curpos <= limit) { + if (isspace(message[curpos + lastgood]) && !intag) + curgood = curpos; + if (message[curpos + lastgood] == '<') + intag = TRUE; + if (message[curpos + lastgood] == '>') + intag = FALSE; + curpos++; + } + + if (curgood) { + ret = g_slist_append(ret, g_strndup(&message[lastgood], curgood)); + if (isspace(message[curgood + lastgood])) + lastgood += curgood + 1; + else + lastgood += curgood; + } else { + /* whoops, guess we have to fudge it here */ + ret = g_slist_append(ret, g_strndup(&message[lastgood], limit)); + lastgood += limit; + } + } +}