fix bug 99081 [ExtractPortFrom sometimes finds ports that are not there] ExtractPortFrom trys to parse the portnumber from url-strings and sometimes it found ports that are none like messageids of news urls, r=dougt@netscape.com, sr=darin@netscape.com

This commit is contained in:
andreas.otte%primus-online.de 2001-09-14 05:38:51 +00:00
Родитель 25856c9451
Коммит 511821a823
1 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -39,11 +39,26 @@ nsAppendURLEscapedString(nsCString& originalStr, const char* str, PRInt16 mask)
return rv;
}
/* extract portnumber from string */
/* extracts first number from a string and assumes that this is the port number*/
NS_NET PRInt32
ExtractPortFrom(const char* src)
{
// search for digits up to a slash or the string ends
const char* port = src;
PRInt32 returnValue = -1;
// skip leading white space
while (nsCRT::IsAsciiSpace(*port))
port++;
char c;
while ((c = *port++) != '\0') {
// stop if slash reached
if (c == '/')
break;
else if (!nsCRT::IsAsciiDigit(c))
return returnValue;
}
return (0 < PR_sscanf(src, "%d", &returnValue)) ? returnValue : -1;
}