- if (p[-1] == '}') p--;
- while (isdigit(*--p)) ;
- p += 1 + sprintf(CS p+1, "%s%d,%d}", *p == ',' ? "" : "{",
- i2->port, ipa->port);
+ for (p = i2->log; *p; ) p++; /* end of existing string */
+ if (*--p == '}') *p = '\0'; /* drop EOL */
+ while (isdigit(*--p)) ; /* char before port */
+
+ i2->log = *p == ':' /* no list yet? */
+ ? string_sprintf("%.*s{%s,%d}",
+ (int)(p - i2->log + 1), i2->log, p+1, ipa->port)
+ : string_sprintf("%s,%d}", i2->log, ipa->port);
+ ipa->log = NULL;