More accurate e-mail cheching

This commit is contained in:
Alexander S. Aganichev 2001-11-02 10:06:13 +00:00
parent 01da006468
commit d2a2e75859

View File

@ -149,8 +149,9 @@ void Container::StyleCodeHighlight(const char* text, int row, int col, bool dohi
txptr = end; txptr = end;
ptr = end-1; ptr = end-1;
} }
else if(((ptr == text) or not in_ftn_domained_address(ptr, text)) else if(((ptr == text) or not in_ftn_domained_address(ptr, text)) and
and (isascii(*ptr) and not isspace(*ptr) and not ispunct(*ptr))) { (isascii(*ptr) and not isspace(*ptr) and not ispunct(*ptr) and
((ptr == text) or (not isxalnum(ptr[-1]) and (ptr[-1] != '@'))))) {
// try to guess e-mail address... // try to guess e-mail address...
const char *commerce_at = NULL; const char *commerce_at = NULL;
@ -163,19 +164,24 @@ void Container::StyleCodeHighlight(const char* text, int row, int col, bool dohi
else { else {
commerce_at = strpbrk(ptr, " \t:/@"); commerce_at = strpbrk(ptr, " \t:/@");
} }
if ((commerce_at != NULL) and (*commerce_at == '@')) { if((commerce_at != NULL) and (*commerce_at == '@')) {
bool dot_found = false;
++commerce_at; ++commerce_at;
while((*commerce_at != NUL) and (isalnum(*commerce_at) or (*commerce_at == '.') or (*commerce_at == '-'))) { while((*commerce_at != NUL) and (isalnum(*commerce_at) or (*commerce_at == '.') or (*commerce_at == '-'))) {
if(*commerce_at == '.')
dot_found = true;
++commerce_at; ++commerce_at;
} }
strxcpy(buf, txptr, (uint)(ptr-txptr)+1); if(dot_found) {
prints(row, col+sclen, color, buf); strxcpy(buf, txptr, (uint)(ptr-txptr)+1);
sclen += strlen(buf); prints(row, col+sclen, color, buf);
strxcpy(buf, ptr, (uint)(commerce_at-ptr)+1); sclen += strlen(buf);
prints(row, col+sclen, C_READU, buf); strxcpy(buf, ptr, (uint)(commerce_at-ptr)+1);
sclen += strlen(buf); prints(row, col+sclen, C_READU, buf);
txptr = commerce_at; sclen += strlen(buf);
ptr = commerce_at-1; txptr = commerce_at;
ptr = commerce_at-1;
}
} }
} }
} }