More fixes for accurate URL detection

This commit is contained in:
Alexander S. Aganichev 2001-10-28 20:16:00 +00:00
parent 9379ef4226
commit d509dcf0f1

View File

@ -133,10 +133,13 @@ void Container::StyleCodeHighlight(const char* text, int row, int col, bool dohi
} }
else { else {
if(not strnicmp(ptr, "http://", 7) or not strnicmp(ptr, "ftp://", 6) or if(not strnicmp(ptr, "http://", 7) or not strnicmp(ptr, "ftp://", 6) or
not strnicmp(ptr, "www.", 4) or not strnicmp(ptr, "ftp.", 4) or (not strnicmp(ptr, "www.", 4) and not isspace(ptr[4])) or
(not strnicmp(ptr, "ftp.", 4) and not isspace(ptr[4])) or
not strnicmp(ptr, "mailto:", 7)) { not strnicmp(ptr, "mailto:", 7)) {
const char *end = ptr+4+strcspn(ptr+4, " \t\"\'<>()[]"); const char *end = ptr+4+strcspn(ptr+4, " \t\"\'<>()[]");
if(ispunct(end[-1]) and (end[-1] != '/'))
--end;
strxcpy(buf, txptr, (uint)(ptr-txptr)+1); strxcpy(buf, txptr, (uint)(ptr-txptr)+1);
prints(row, col+sclen, color, buf); prints(row, col+sclen, color, buf);
sclen += strlen(buf); sclen += strlen(buf);