Bug 1485343 - Avoid locale-dependent C standard library functions in FTP code. r=valentin

MozReview-Commit-ID: CXcluPKLwIv

Differential Revision: https://phabricator.services.mozilla.com/D4315

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henri Sivonen 2018-08-27 09:11:30 +00:00
Родитель 2be0158cae
Коммит cbab098175
4 изменённых файлов: 126 добавлений и 88 удалений

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

@ -86,6 +86,33 @@ ToLowerCaseASCII(char32_t aChar)
return aChar;
}
char
ToUpperCaseASCII(char aChar)
{
if (aChar >= 'a' && aChar <= 'z') {
return aChar - 0x20;
}
return aChar;
}
char16_t
ToUpperCaseASCII(char16_t aChar)
{
if (aChar >= 'a' && aChar <= 'z') {
return aChar - 0x20;
}
return aChar;
}
char32_t
ToUpperCaseASCII(char32_t aChar)
{
if (aChar >= 'a' && aChar <= 'z') {
return aChar - 0x20;
}
return aChar;
}
void
ToLowerCase(const nsAString& aSource,
nsAString& aDest)

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

@ -44,6 +44,10 @@ char ToLowerCaseASCII(const char aChar);
char16_t ToLowerCaseASCII(const char16_t aChar);
char32_t ToLowerCaseASCII(const char32_t aChar);
char ToUpperCaseASCII(const char aChar);
char16_t ToUpperCaseASCII(const char16_t aChar);
char32_t ToUpperCaseASCII(const char32_t aChar);
inline bool IsUpperCase(uint32_t c) {
return ToLowerCase(c) != c;
}

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

@ -9,6 +9,7 @@
#include "prprf.h"
#include "mozilla/Logging.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/TextUtils.h"
#include "prtime.h"
#include "nsIOService.h"
@ -186,9 +187,9 @@ nsFtpState::OnControlDataAvailable(const char *aData, uint32_t aDataLen)
// Does this start with a response code?
bool startNum = (line.Length() >= 3 &&
isdigit(line[0]) &&
isdigit(line[1]) &&
isdigit(line[2]));
IsAsciiDigit(line[0]) &&
IsAsciiDigit(line[1]) &&
IsAsciiDigit(line[2]));
if (mResponseMsg.IsEmpty()) {
// If we get here, then we know that we have a complete line, and

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

@ -11,13 +11,19 @@
#include "plstr.h"
#include "nsDebug.h"
#include "prprf.h"
#include "nsUnicharUtils.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/TextUtils.h"
#include "mozilla/Sprintf.h"
/* ==================================================================== */
using mozilla::CheckedInt;
using mozilla::IsAsciiDigit;
using mozilla::IsAsciiAlpha;
using mozilla::IsAsciiLowercaseAlpha;
using mozilla::IsAsciiAlphanumeric;
static const int kMaxFTPListLen = 32768;
@ -147,9 +153,9 @@ int ParseFTPList(const char *line, struct list_state *state,
result->fe_type = 'f'; /* its a file */
else if (*p == 'm')
{
if (isdigit(line[pos]))
if (IsAsciiDigit(line[pos]))
{
while (pos < linelen && isdigit(line[pos]))
while (pos < linelen && IsAsciiDigit(line[pos]))
pos++;
if (pos < linelen && line[pos] == ',')
{
@ -163,9 +169,9 @@ int ParseFTPList(const char *line, struct list_state *state,
}
else if (*p == 's')
{
if (isdigit(line[pos]))
if (IsAsciiDigit(line[pos]))
{
while (pos < linelen && isdigit(line[pos]))
while (pos < linelen && IsAsciiDigit(line[pos]))
pos++;
if (pos < linelen && line[pos] == ',' &&
((&line[pos]) - (p+1)) < int(sizeof(result->fe_size)-1) )
@ -175,7 +181,7 @@ int ParseFTPList(const char *line, struct list_state *state,
}
}
}
else if (isalpha(*p)) /* 'i'/'up' or unknown "fact" (property) */
else if (IsAsciiAlpha(*p)) /* 'i'/'up' or unknown "fact" (property) */
{
while (pos < linelen && *++p != ',')
pos++;
@ -253,9 +259,9 @@ int ParseFTPList(const char *line, struct list_state *state,
break;
}
else if (p[pos] != '.' && p[pos] != '~' &&
!isdigit(p[pos]) && !isalpha(p[pos]))
!IsAsciiAlphanumeric(p[pos]))
break;
else if (isalpha(p[pos]) && p[pos] != toupper(p[pos]))
else if (IsAsciiLowercaseAlpha(p[pos]))
break;
}
if (pos > 0)
@ -271,9 +277,9 @@ int ParseFTPList(const char *line, struct list_state *state,
{
pos--;
if (p[pos] != '$' && p[pos] != '_' && p[pos] != '-' &&
p[pos] != '~' && !isdigit(p[pos]) && !isalpha(p[pos]))
p[pos] != '~' && !IsAsciiAlphanumeric(p[pos]))
break;
else if (isalpha(p[pos]) && p[pos] != toupper(p[pos]))
else if (IsAsciiLowercaseAlpha(p[pos]))
break;
}
if (pos == 0)
@ -309,9 +315,9 @@ int ParseFTPList(const char *line, struct list_state *state,
((toklen[3]==10 || toklen[3]==11 ) &&
(tokens[3][toklen[3]-3]) == '.' )
) && /* time in [H]H:MM[:SS[.CC]] format */
isdigit(*tokens[1]) && /* size */
isdigit(*tokens[2]) && /* date */
isdigit(*tokens[3]) /* time */
IsAsciiDigit(*tokens[1]) && /* size */
IsAsciiDigit(*tokens[2]) && /* date */
IsAsciiDigit(*tokens[3]) /* time */
)
{
lstyle = 'V';
@ -348,7 +354,7 @@ int ParseFTPList(const char *line, struct list_state *state,
while (lstyle && pos < toklen[0] && *p != ']')
{
if (*p != '$' && *p != '.' && *p != '_' && *p != '-' &&
*p != '~' && !isdigit(*p) && !isalpha(*p))
*p != '~' && !IsAsciiAlphanumeric(*p))
lstyle = 0;
pos++;
p++;
@ -368,9 +374,9 @@ int ParseFTPList(const char *line, struct list_state *state,
while (lstyle && pos < toklen[0] && *p != ';')
{
if (*p != '$' && *p != '.' && *p != '_' && *p != '-' &&
*p != '~' && !isdigit(*p) && !isalpha(*p))
*p != '~' && !IsAsciiAlphanumeric(*p))
lstyle = 0;
else if (isalpha(*p) && *p != toupper(*p))
else if (IsAsciiLowercaseAlpha(*p))
lstyle = 0;
p++;
pos++;
@ -381,7 +387,7 @@ int ParseFTPList(const char *line, struct list_state *state,
lstyle = 0;
for (pos++;lstyle && pos < toklen[0];pos++)
{
if (!isdigit(tokens[0][pos]))
if (!IsAsciiDigit(tokens[0][pos]))
lstyle = 0;
}
}
@ -404,11 +410,11 @@ int ParseFTPList(const char *line, struct list_state *state,
state->carry_buf_len = pos;
return '?'; /* tell caller to treat as junk */
}
else if (isdigit(*tokens[1])) /* not no-privs message */
else if (IsAsciiDigit(*tokens[1])) /* not no-privs message */
{
for (pos = 0; lstyle && pos < (toklen[1]); pos++)
{
if (!isdigit((tokens[1][pos])) && (tokens[1][pos]) != '/')
if (!IsAsciiDigit((tokens[1][pos])) && (tokens[1][pos]) != '/')
lstyle = 0;
}
if (lstyle && numtoks > 4) /* Multinet or UCX but not CMU */
@ -429,7 +435,7 @@ int ParseFTPList(const char *line, struct list_state *state,
state->parsed_one = 1;
state->lstyle = lstyle;
if (isdigit(*tokens[1])) /* not permission denied etc */
if (IsAsciiDigit(*tokens[1])) /* not permission denied etc */
{
/* strip leading directory name */
if (*tokens[0] == '[') /* CMU server */
@ -491,8 +497,8 @@ int ParseFTPList(const char *line, struct list_state *state,
if (*p == '-')
p++;
tbuf[0] = p[0];
tbuf[1] = tolower(p[1]);
tbuf[2] = tolower(p[2]);
tbuf[1] = ToLowerCaseASCII(p[1]);
tbuf[2] = ToLowerCaseASCII(p[2]);
month_num = 0;
for (pos = 0; pos < (12*3); pos+=3)
{
@ -518,7 +524,7 @@ int ParseFTPList(const char *line, struct list_state *state,
return result->fe_type;
} /* if (isdigit(*tokens[1])) */
} /* if (IsAsciiDigit(*tokens[1])) */
return '?'; /* junk */
@ -575,9 +581,9 @@ int ParseFTPList(const char *line, struct list_state *state,
if ( (*tokens[pos+1] == '-' &&
*tokens[pos+2] == '-' &&
*tokens[pos+3] == '-') ||
(isdigit(*tokens[pos+1]) &&
isdigit(*tokens[pos+2]) &&
isdigit(*tokens[pos+3])) )
(IsAsciiDigit(*tokens[pos+1]) &&
IsAsciiDigit(*tokens[pos+2]) &&
IsAsciiDigit(*tokens[pos+3])) )
{
lstyle = 'C';
tokmarker = pos;
@ -593,7 +599,7 @@ int ParseFTPList(const char *line, struct list_state *state,
{
for (pos = 0, p = tokens[0]; lstyle && pos < toklen[0]; pos++, p++)
{
if (isalpha(*p) && toupper(*p) != *p)
if (IsAsciiLowercaseAlpha(*p))
lstyle = 0;
}
for (pos = tokmarker+1; pos <= tokmarker+3; pos++)
@ -602,7 +608,7 @@ int ParseFTPList(const char *line, struct list_state *state,
{
for (p = tokens[pos]; lstyle && p<(tokens[pos]+toklen[pos]); p++)
{
if (!isdigit(*p))
if (!IsAsciiDigit(*p))
lstyle = 0;
}
}
@ -623,7 +629,7 @@ int ParseFTPList(const char *line, struct list_state *state,
else if (pos != 2 && pos != 5)
lstyle = 0;
}
else if (*p != '-' && !isdigit(*p))
else if (*p != '-' && !IsAsciiDigit(*p))
lstyle = 0;
else if (*p == '-' && pos != 4 && pos != 7)
lstyle = 0;
@ -631,7 +637,7 @@ int ParseFTPList(const char *line, struct list_state *state,
for (pos = 0, p = tokens[tokmarker+5];
lstyle && pos < toklen[tokmarker+5]; pos++, p++)
{
if (*p != ':' && !isdigit(*p))
if (*p != ':' && !IsAsciiDigit(*p))
lstyle = 0;
else if (*p == ':' && pos != (toklen[tokmarker+5]-3)
&& pos != (toklen[tokmarker+5]-6))
@ -723,16 +729,16 @@ int ParseFTPList(const char *line, struct list_state *state,
// "05-03-13 22:01 <DIR> APPS"
if ((numtoks >= 4) && (toklen[0] == 8 || toklen[0] == 10) &&
(toklen[1] == 5 || toklen[1] == 7) &&
(*tokens[2] == '<' || isdigit(*tokens[2])) )
(*tokens[2] == '<' || IsAsciiDigit(*tokens[2])) )
{
p = tokens[0];
if ( isdigit(p[0]) && isdigit(p[1]) && p[2]=='-' &&
isdigit(p[3]) && isdigit(p[4]) && p[5]=='-' &&
isdigit(p[6]) && isdigit(p[7]) )
if ( IsAsciiDigit(p[0]) && IsAsciiDigit(p[1]) && p[2]=='-' &&
IsAsciiDigit(p[3]) && IsAsciiDigit(p[4]) && p[5]=='-' &&
IsAsciiDigit(p[6]) && IsAsciiDigit(p[7]) )
{
p = tokens[1];
if ( isdigit(p[0]) && isdigit(p[1]) && p[2]==':' &&
isdigit(p[3]) && isdigit(p[4]) &&
if ( IsAsciiDigit(p[0]) && IsAsciiDigit(p[1]) && p[2]==':' &&
IsAsciiDigit(p[3]) && IsAsciiDigit(p[4]) &&
(toklen[1] == 5 || (toklen[1] == 7 &&
(p[5]=='A' || p[5]=='P') && p[6]=='M')))
{
@ -745,7 +751,7 @@ int ParseFTPList(const char *line, struct list_state *state,
{
for (pos = 1; (lstyle && pos < toklen[2]); pos++)
{
if (!isdigit(*++p))
if (!IsAsciiDigit(*++p))
lstyle = 0;
}
}
@ -873,16 +879,16 @@ int ParseFTPList(const char *line, struct list_state *state,
*/
p = &(line[toklen[0]]);
/* \s(\d\d-\d\d-\d\d)\s+(\d\d:\d\d)\s */
if (numtoks >= 4 && toklen[0] <= 18 && isdigit(*tokens[0]) &&
if (numtoks >= 4 && toklen[0] <= 18 && IsAsciiDigit(*tokens[0]) &&
(linelen - toklen[0]) >= (53-18) &&
p[18-18] == ' ' && p[34-18] == ' ' &&
p[37-18] == '-' && p[40-18] == '-' && p[43-18] == ' ' &&
p[45-18] == ' ' && p[48-18] == ':' && p[51-18] == ' ' &&
isdigit(p[35-18]) && isdigit(p[36-18]) &&
isdigit(p[38-18]) && isdigit(p[39-18]) &&
isdigit(p[41-18]) && isdigit(p[42-18]) &&
isdigit(p[46-18]) && isdigit(p[47-18]) &&
isdigit(p[49-18]) && isdigit(p[50-18])
IsAsciiDigit(p[35-18]) && IsAsciiDigit(p[36-18]) &&
IsAsciiDigit(p[38-18]) && IsAsciiDigit(p[39-18]) &&
IsAsciiDigit(p[41-18]) && IsAsciiDigit(p[42-18]) &&
IsAsciiDigit(p[46-18]) && IsAsciiDigit(p[47-18]) &&
IsAsciiDigit(p[49-18]) && IsAsciiDigit(p[50-18])
)
{
lstyle = 'O'; /* OS/2 */
@ -890,7 +896,7 @@ int ParseFTPList(const char *line, struct list_state *state,
{
for (pos = 1; lstyle && pos < toklen[0]; pos++)
{
if (!isdigit(tokens[0][pos]))
if (!IsAsciiDigit(tokens[0][pos]))
lstyle = 0;
}
}
@ -1036,34 +1042,34 @@ int ParseFTPList(const char *line, struct list_state *state,
* (\d\d\d\d|\d\:\d\d|\d\d\:\d\d|\d\:\d\d\:\d\d|\d\d\:\d\d\:\d\d)
* \s+(.+)$
*/
if (isdigit(*tokens[pos]) /* size */
if (IsAsciiDigit(*tokens[pos]) /* size */
/* (\w\w\w) */
&& toklen[pos+1] == 3 && isalpha(*tokens[pos+1]) &&
isalpha(tokens[pos+1][1]) && isalpha(tokens[pos+1][2])
&& toklen[pos+1] == 3 && IsAsciiAlpha(*tokens[pos+1]) &&
IsAsciiAlpha(tokens[pos+1][1]) && IsAsciiAlpha(tokens[pos+1][2])
/* (\d|\d\d) */
&& isdigit(*tokens[pos+2]) &&
&& IsAsciiDigit(*tokens[pos+2]) &&
(toklen[pos+2] == 1 ||
(toklen[pos+2] == 2 && isdigit(tokens[pos+2][1])))
&& toklen[pos+3] >= 4 && isdigit(*tokens[pos+3])
(toklen[pos+2] == 2 && IsAsciiDigit(tokens[pos+2][1])))
&& toklen[pos+3] >= 4 && IsAsciiDigit(*tokens[pos+3])
/* (\d\:\d\d\:\d\d|\d\d\:\d\d\:\d\d) */
&& (toklen[pos+3] <= 5 || (
(toklen[pos+3] == 7 || toklen[pos+3] == 8) &&
(tokens[pos+3][toklen[pos+3]-3]) == ':'))
&& isdigit(tokens[pos+3][toklen[pos+3]-2])
&& isdigit(tokens[pos+3][toklen[pos+3]-1])
&& IsAsciiDigit(tokens[pos+3][toklen[pos+3]-2])
&& IsAsciiDigit(tokens[pos+3][toklen[pos+3]-1])
&& (
/* (\d\d\d\d) */
((toklen[pos+3] == 4 || toklen[pos+3] == 5) &&
isdigit(tokens[pos+3][1]) &&
isdigit(tokens[pos+3][2]) )
IsAsciiDigit(tokens[pos+3][1]) &&
IsAsciiDigit(tokens[pos+3][2]) )
/* (\d\:\d\d|\d\:\d\d\:\d\d) */
|| ((toklen[pos+3] == 4 || toklen[pos+3] == 7) &&
(tokens[pos+3][1]) == ':' &&
isdigit(tokens[pos+3][2]) && isdigit(tokens[pos+3][3]))
IsAsciiDigit(tokens[pos+3][2]) && IsAsciiDigit(tokens[pos+3][3]))
/* (\d\d\:\d\d|\d\d\:\d\d\:\d\d) */
|| ((toklen[pos+3] == 5 || toklen[pos+3] == 8) &&
isdigit(tokens[pos+3][1]) && (tokens[pos+3][2]) == ':' &&
isdigit(tokens[pos+3][3]) && isdigit(tokens[pos+3][4]))
IsAsciiDigit(tokens[pos+3][1]) && (tokens[pos+3][2]) == ':' &&
IsAsciiDigit(tokens[pos+3][3]) && IsAsciiDigit(tokens[pos+3][4]))
)
)
{
@ -1075,7 +1081,7 @@ int ParseFTPList(const char *line, struct list_state *state,
unsigned int i;
for (i = 0; i < toklen[tokmarker]; i++)
{
if (!isdigit(*p++))
if (!IsAsciiDigit(*p++))
{
lstyle = 0;
break;
@ -1274,7 +1280,7 @@ int ParseFTPList(const char *line, struct list_state *state,
* CMT.CSV 0 Jul 06 1995 14:56 RHA
*/
if (numtoks >= 4 && toklen[0] < 13 &&
((toklen[1] == 5 && *tokens[1] == '<') || isdigit(*tokens[1])) )
((toklen[1] == 5 && *tokens[1] == '<') || IsAsciiDigit(*tokens[1])) )
{
if (numtoks == 4
&& (toklen[2] == 8 || toklen[2] == 9)
@ -1282,12 +1288,12 @@ int ParseFTPList(const char *line, struct list_state *state,
((tokens[2][2]) == '-' && (tokens[2][5]) == '-'))
&& (toklen[3] == 4 || toklen[3] == 5)
&& (tokens[3][toklen[3]-3]) == ':'
&& isdigit(tokens[2][0]) && isdigit(tokens[2][1])
&& isdigit(tokens[2][3]) && isdigit(tokens[2][4])
&& isdigit(tokens[2][6]) && isdigit(tokens[2][7])
&& (toklen[2] < 9 || isdigit(tokens[2][8]))
&& isdigit(tokens[3][toklen[3]-1]) && isdigit(tokens[3][toklen[3]-2])
&& isdigit(tokens[3][toklen[3]-4]) && isdigit(*tokens[3])
&& IsAsciiDigit(tokens[2][0]) && IsAsciiDigit(tokens[2][1])
&& IsAsciiDigit(tokens[2][3]) && IsAsciiDigit(tokens[2][4])
&& IsAsciiDigit(tokens[2][6]) && IsAsciiDigit(tokens[2][7])
&& (toklen[2] < 9 || IsAsciiDigit(tokens[2][8]))
&& IsAsciiDigit(tokens[3][toklen[3]-1]) && IsAsciiDigit(tokens[3][toklen[3]-2])
&& IsAsciiDigit(tokens[3][toklen[3]-4]) && IsAsciiDigit(*tokens[3])
)
{
lstyle = 'w';
@ -1296,13 +1302,13 @@ int ParseFTPList(const char *line, struct list_state *state,
&& toklen[2] == 3 && toklen[3] == 2
&& toklen[4] == 4 && toklen[5] == 5
&& (tokens[5][2]) == ':'
&& isalpha(tokens[2][0]) && isalpha(tokens[2][1])
&& isalpha(tokens[2][2])
&& isdigit(tokens[3][0]) && isdigit(tokens[3][1])
&& isdigit(tokens[4][0]) && isdigit(tokens[4][1])
&& isdigit(tokens[4][2]) && isdigit(tokens[4][3])
&& isdigit(tokens[5][0]) && isdigit(tokens[5][1])
&& isdigit(tokens[5][3]) && isdigit(tokens[5][4])
&& IsAsciiAlpha(tokens[2][0]) && IsAsciiAlpha(tokens[2][1])
&& IsAsciiAlpha(tokens[2][2])
&& IsAsciiDigit(tokens[3][0]) && IsAsciiDigit(tokens[3][1])
&& IsAsciiDigit(tokens[4][0]) && IsAsciiDigit(tokens[4][1])
&& IsAsciiDigit(tokens[4][2]) && IsAsciiDigit(tokens[4][3])
&& IsAsciiDigit(tokens[5][0]) && IsAsciiDigit(tokens[5][1])
&& IsAsciiDigit(tokens[5][3]) && IsAsciiDigit(tokens[5][4])
/* could also check that (&(tokens[5][5]) - tokens[2]) == 17 */
)
{
@ -1316,7 +1322,7 @@ int ParseFTPList(const char *line, struct list_state *state,
{
for (pos = 0; lstyle && pos < toklen[1]; pos++)
{
if (!isdigit(*p++))
if (!IsAsciiDigit(*p++))
lstyle = 0;
}
} /* not <DIR> */
@ -1334,7 +1340,7 @@ int ParseFTPList(const char *line, struct list_state *state,
result->fe_type = 'd';
p = tokens[1];
if (isdigit(*p))
if (IsAsciiDigit(*p))
{
result->fe_type = 'f';
pos = toklen[1];
@ -1347,9 +1353,9 @@ int ParseFTPList(const char *line, struct list_state *state,
p = tokens[2];
if (toklen[2] == 3) /* Chameleon */
{
tbuf[0] = toupper(p[0]);
tbuf[1] = tolower(p[1]);
tbuf[2] = tolower(p[2]);
tbuf[0] = ToUpperCaseASCII(p[0]);
tbuf[1] = ToLowerCaseASCII(p[1]);
tbuf[2] = ToLowerCaseASCII(p[2]);
for (pos = 0; pos < (12*3); pos+=3)
{
if (tbuf[0] == month_names[pos+0] &&
@ -1467,7 +1473,7 @@ int ParseFTPList(const char *line, struct list_state *state,
if (linelen > pos)
{
p = &line[pos];
if ((*p == '-' || *p == '=' || isdigit(*p)) &&
if ((*p == '-' || *p == '=' || IsAsciiDigit(*p)) &&
((linelen == (pos+1)) ||
(linelen >= (pos+3) && p[1] == ' ' && p[2] == ' ')) )
{
@ -1494,7 +1500,7 @@ int ParseFTPList(const char *line, struct list_state *state,
{
for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++)
{
if (!isdigit(tokens[tokmarker][pos]))
if (!IsAsciiDigit(tokens[tokmarker][pos]))
lstyle = 0;
}
}
@ -1551,7 +1557,7 @@ int ParseFTPList(const char *line, struct list_state *state,
result->fe_type = 'd';
}
}
else if (isdigit(*tokens[tokmarker]))
else if (IsAsciiDigit(*tokens[tokmarker]))
{
pos = toklen[tokmarker];
if (pos > (sizeof(result->fe_size)-1))
@ -1569,24 +1575,24 @@ int ParseFTPList(const char *line, struct list_state *state,
pos = toklen[pos];
if ((pos == 4 || pos == 5)
&& isdigit(*p) && isdigit(p[pos-1]) && isdigit(p[pos-2])
&& IsAsciiDigit(*p) && IsAsciiDigit(p[pos-1]) && IsAsciiDigit(p[pos-2])
&& ((pos == 5 && p[2] == ':') ||
(pos == 4 && (isdigit(p[1]) || p[1] == ':')))
(pos == 4 && (IsAsciiDigit(p[1]) || p[1] == ':')))
)
{
month_num = tokmarker+1; /* assumed position of month field */
pos = tokmarker+2; /* assumed position of mday field */
if (isdigit(*tokens[month_num])) /* positions are reversed */
if (IsAsciiDigit(*tokens[month_num])) /* positions are reversed */
{
month_num++;
pos--;
}
p = tokens[month_num];
if (isdigit(*tokens[pos])
if (IsAsciiDigit(*tokens[pos])
&& (toklen[pos] == 1 ||
(toklen[pos] == 2 && isdigit(tokens[pos][1])))
(toklen[pos] == 2 && IsAsciiDigit(tokens[pos][1])))
&& toklen[month_num] == 3
&& isalpha(*p) && isalpha(p[1]) && isalpha(p[2]) )
&& IsAsciiAlpha(*p) && IsAsciiAlpha(p[1]) && IsAsciiAlpha(p[2]) )
{
pos = atoi(tokens[pos]);
if (pos > 0 && pos <= 31)