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/trunk@52491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2008-03-14 14:16:39 +00:00
parent eb61203f6e
commit 2eb37f730d
2 changed files with 19 additions and 19 deletions

View File

@@ -236,7 +236,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;
} }
@@ -244,20 +244,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) {
@@ -314,7 +314,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)
@@ -336,7 +336,7 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv)
return fits && !badconv; return fits && !badconv;
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Some helpers // Some helpers
@@ -627,7 +627,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)
@@ -949,7 +949,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
@@ -983,7 +983,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) {
@@ -1032,7 +1032,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()) {
@@ -1209,7 +1209,7 @@ bool wxTarOutputStream::Close()
{ {
if (!CloseEntry() || (m_tarsize == 0 && m_endrecWritten)) if (!CloseEntry() || (m_tarsize == 0 && m_endrecWritten))
return false; return false;
memset(m_hdr, 0, sizeof(*m_hdr)); memset(m_hdr, 0, sizeof(*m_hdr));
int count = (RoundUpSize(m_tarsize + 2 * TAR_BLOCKSIZE, m_BlockingFactor) int count = (RoundUpSize(m_tarsize + 2 * TAR_BLOCKSIZE, m_BlockingFactor)
- m_tarsize) / TAR_BLOCKSIZE; - m_tarsize) / TAR_BLOCKSIZE;
@@ -1246,7 +1246,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());
@@ -1255,7 +1255,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);
@@ -1286,7 +1286,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));
@@ -1310,7 +1310,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();
@@ -1324,7 +1324,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(".");