Fixed bug for chars with ASCII value > 127, explicitly casting to an unsigned char (Sebastian Gottschalk)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52490 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2008-03-14 14:16:28 +00:00
parent 2e4dc1ddb1
commit da62ad4c09
2 changed files with 18 additions and 18 deletions

View File

@@ -238,7 +238,7 @@ wxPluralFormsScanner::wxPluralFormsScanner(const char* s) : m_s(s)
bool wxPluralFormsScanner::nextToken() bool wxPluralFormsScanner::nextToken()
{ {
wxPluralFormsToken::Type type = wxPluralFormsToken::T_ERROR; wxPluralFormsToken::Type type = wxPluralFormsToken::T_ERROR;
while (isspace(*m_s)) while (isspace((unsigned char) *m_s))
{ {
++m_s; ++m_s;
} }
@@ -246,20 +246,20 @@ bool wxPluralFormsScanner::nextToken()
{ {
type = wxPluralFormsToken::T_EOF; type = wxPluralFormsToken::T_EOF;
} }
else if (isdigit(*m_s)) else if (isdigit((unsigned char) *m_s))
{ {
wxPluralFormsToken::Number number = *m_s++ - '0'; wxPluralFormsToken::Number number = *m_s++ - '0';
while (isdigit(*m_s)) while (isdigit((unsigned char) *m_s))
{ {
number = number * 10 + (*m_s++ - '0'); number = number * 10 + (*m_s++ - '0');
} }
m_token.setNumber(number); m_token.setNumber(number);
type = wxPluralFormsToken::T_NUMBER; type = wxPluralFormsToken::T_NUMBER;
} }
else if (isalpha(*m_s)) else if (isalpha((unsigned char) *m_s))
{ {
const char* begin = m_s++; const char* begin = m_s++;
while (isalnum(*m_s)) while (isalnum((unsigned char) *m_s))
{ {
++m_s; ++m_s;
} }

View File

@@ -230,7 +230,7 @@ wxUint32 wxTarHeaderBlock::SumField(int id)
} }
bool wxTarHeaderBlock::Read(wxInputStream& in) bool wxTarHeaderBlock::Read(wxInputStream& in)
{ {
bool ok = true; bool ok = true;
for (int id = 0; id < TAR_NUMFIELDS && ok; id++) for (int id = 0; id < TAR_NUMFIELDS && ok; id++)
@@ -268,7 +268,7 @@ wxTarNumber wxTarHeaderBlock::GetOctal(int id)
bool wxTarHeaderBlock::SetOctal(int id, wxTarNumber n) bool wxTarHeaderBlock::SetOctal(int id, wxTarNumber n)
{ {
// set an octal field, return true if the number fits // set an octal field, return true if the number fits
char *field = Get(id); char *field = Get(id);
char *p = field + Len(id); char *p = field + Len(id);
*--p = 0; *--p = 0;
while (p > field) { while (p > field) {
@@ -311,7 +311,7 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv)
for (;;) { for (;;) {
fits = i < maxprefix && len - i <= maxname; fits = i < maxprefix && len - i <= maxname;
if (!fits) { if (!fits) {
const char *p = strchr(mbName + i, '/'); const char *p = strchr(mbName + i, '/');
if (p) if (p)
@@ -333,7 +333,7 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv)
return fits && !badconv; return fits && !badconv;
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Some helpers // Some helpers
@@ -624,7 +624,7 @@ int wxTarEntry::GetMode() const
return m_Mode; return m_Mode;
else else
return m_Mode | 0111; return m_Mode | 0111;
} }
void wxTarEntry::SetMode(int mode) void wxTarEntry::SetMode(int mode)
@@ -946,7 +946,7 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
// read the record size (byte count in ascii decimal) // read the record size (byte count in ascii decimal)
recSize = 0; recSize = 0;
while (isdigit(*p)) while (isdigit((unsigned char) *p))
recSize = recSize * 10 + *p++ - '0'; recSize = recSize * 10 + *p++ - '0';
// validity checks // validity checks
@@ -980,7 +980,7 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
if (value.empty()) if (value.empty())
recs->erase(key); recs->erase(key);
else else
(*recs)[key] = value; (*recs)[key] = value;
} }
if (!ok || recPos < len || size != lastread) { if (!ok || recPos < len || size != lastread) {
@@ -1029,7 +1029,7 @@ size_t wxTarInputStream::OnSysRead(void *buffer, size_t size)
size_t lastread = m_parent_i_stream->Read(buffer, size).LastRead(); size_t lastread = m_parent_i_stream->Read(buffer, size).LastRead();
m_pos += lastread; m_pos += lastread;
if (m_pos >= m_size) { if (m_pos >= m_size) {
m_lasterror = wxSTREAM_EOF; m_lasterror = wxSTREAM_EOF;
} else if (!m_parent_i_stream->IsOk()) { } else if (!m_parent_i_stream->IsOk()) {
@@ -1242,7 +1242,7 @@ bool wxTarOutputStream::WriteHeaders(wxTarEntry& entry)
*m_hdr->Get(TAR_TYPEFLAG) = char(entry.GetTypeFlag()); *m_hdr->Get(TAR_TYPEFLAG) = char(entry.GetTypeFlag());
strcpy(m_hdr->Get(TAR_MAGIC), USTAR_MAGIC); strcpy(m_hdr->Get(TAR_MAGIC), USTAR_MAGIC);
strcpy(m_hdr->Get(TAR_VERSION), USTAR_VERSION); strcpy(m_hdr->Get(TAR_VERSION), USTAR_VERSION);
SetHeaderString(TAR_LINKNAME, entry.GetLinkName()); SetHeaderString(TAR_LINKNAME, entry.GetLinkName());
SetHeaderString(TAR_UNAME, entry.GetUserName()); SetHeaderString(TAR_UNAME, entry.GetUserName());
@@ -1251,7 +1251,7 @@ bool wxTarOutputStream::WriteHeaders(wxTarEntry& entry)
if (~entry.GetDevMajor()) if (~entry.GetDevMajor())
SetHeaderNumber(TAR_DEVMAJOR, entry.GetDevMajor()); SetHeaderNumber(TAR_DEVMAJOR, entry.GetDevMajor());
if (~entry.GetDevMinor()) if (~entry.GetDevMinor())
SetHeaderNumber(TAR_DEVMINOR, entry.GetDevMinor()); SetHeaderNumber(TAR_DEVMINOR, entry.GetDevMinor());
m_chksum = m_hdr->Sum(); m_chksum = m_hdr->Sum();
m_hdr->SetOctal(TAR_CHKSUM, m_chksum); m_hdr->SetOctal(TAR_CHKSUM, m_chksum);
@@ -1282,7 +1282,7 @@ bool wxTarOutputStream::WriteHeaders(wxTarEntry& entry)
strcpy(m_hdr2->Get(TAR_MTIME), m_hdr->Get(TAR_MTIME)); strcpy(m_hdr2->Get(TAR_MTIME), m_hdr->Get(TAR_MTIME));
*m_hdr2->Get(TAR_TYPEFLAG) = 'x'; *m_hdr2->Get(TAR_TYPEFLAG) = 'x';
strcpy(m_hdr2->Get(TAR_MAGIC), USTAR_MAGIC); strcpy(m_hdr2->Get(TAR_MAGIC), USTAR_MAGIC);
strcpy(m_hdr2->Get(TAR_VERSION), USTAR_VERSION); strcpy(m_hdr2->Get(TAR_VERSION), USTAR_VERSION);
strcpy(m_hdr2->Get(TAR_UNAME), m_hdr->Get(TAR_UNAME)); strcpy(m_hdr2->Get(TAR_UNAME), m_hdr->Get(TAR_UNAME));
strcpy(m_hdr2->Get(TAR_GNAME), m_hdr->Get(TAR_GNAME)); strcpy(m_hdr2->Get(TAR_GNAME), m_hdr->Get(TAR_GNAME));
@@ -1306,7 +1306,7 @@ bool wxTarOutputStream::WriteHeaders(wxTarEntry& entry)
m_badfit.c_str(), entry.GetName().c_str()); m_badfit.c_str(), entry.GetName().c_str());
m_badfit.clear(); m_badfit.clear();
} }
m_hdr->Write(*m_parent_o_stream); m_hdr->Write(*m_parent_o_stream);
m_tarsize += TAR_BLOCKSIZE; m_tarsize += TAR_BLOCKSIZE;
m_lasterror = m_parent_o_stream->GetLastError(); m_lasterror = m_parent_o_stream->GetLastError();
@@ -1320,7 +1320,7 @@ wxString wxTarOutputStream::PaxHeaderPath(const wxString& format,
wxString d = path.BeforeLast(_T('/')); wxString d = path.BeforeLast(_T('/'));
wxString f = path.AfterLast(_T('/')); wxString f = path.AfterLast(_T('/'));
wxString ret; wxString ret;
if (d.empty()) if (d.empty())
d = _T("."); d = _T(".");