- tokens = g_strsplit_set ((const gchar*) address, "<>()", 3);
-
- /* Note that if any of the delimiters is the first character
- then g_strsplit_set will return "" as the first string */
- while (tokens[i] != NULL) {
- if (strlen ((char *) (tokens[i])) != 0)
- break;
- i++;
+ /* should not be needed, and otherwise, we probably won't screw up the address
+ * more than it already is :)
+ * g_return_val_if_fail (g_utf8_validate (address, -1, NULL), NULL);
+ * */
+
+ /* remove leading whitespace */
+ if (address[0] == ' ')
+ g_strchug (address);
+
+ for (i = 0; address[i]; ++i) {
+ if (address[i] == '<') {
+ if (G_UNLIKELY(i == 0))
+ return; /* there's nothing else, leave it */
+ else {
+ address[i] = '\0'; /* terminate the string here */
+ return;
+ }
+ }