Suppress "Assignement in logical expression" type warnings for compilers that compain about this sort of thing.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,7 +43,7 @@ extern "C"
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxTIFFHandler,wxImageHandler)
|
IMPLEMENT_DYNAMIC_CLASS(wxTIFFHandler,wxImageHandler)
|
||||||
|
|
||||||
static tsize_t
|
static tsize_t LINKAGEMODE
|
||||||
_tiffNullProc(thandle_t WXUNUSED(handle),
|
_tiffNullProc(thandle_t WXUNUSED(handle),
|
||||||
tdata_t WXUNUSED(buf),
|
tdata_t WXUNUSED(buf),
|
||||||
tsize_t WXUNUSED(size))
|
tsize_t WXUNUSED(size))
|
||||||
@@ -51,7 +51,7 @@ _tiffNullProc(thandle_t WXUNUSED(handle),
|
|||||||
return (tsize_t) -1;
|
return (tsize_t) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static tsize_t
|
static tsize_t LINKAGEMODE
|
||||||
_tiffReadProc(thandle_t handle, tdata_t buf, tsize_t size)
|
_tiffReadProc(thandle_t handle, tdata_t buf, tsize_t size)
|
||||||
{
|
{
|
||||||
wxInputStream *stream = (wxInputStream*) handle;
|
wxInputStream *stream = (wxInputStream*) handle;
|
||||||
@@ -59,7 +59,7 @@ _tiffReadProc(thandle_t handle, tdata_t buf, tsize_t size)
|
|||||||
return stream->LastRead();
|
return stream->LastRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
static tsize_t
|
static tsize_t LINKAGEMODE
|
||||||
_tiffWriteProc(thandle_t handle, tdata_t buf, tsize_t size)
|
_tiffWriteProc(thandle_t handle, tdata_t buf, tsize_t size)
|
||||||
{
|
{
|
||||||
wxOutputStream *stream = (wxOutputStream*) handle;
|
wxOutputStream *stream = (wxOutputStream*) handle;
|
||||||
@@ -67,7 +67,7 @@ _tiffWriteProc(thandle_t handle, tdata_t buf, tsize_t size)
|
|||||||
return stream->LastWrite();
|
return stream->LastWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
static toff_t
|
static toff_t LINKAGEMODE
|
||||||
_tiffSeekIProc(thandle_t handle, toff_t off, int whence)
|
_tiffSeekIProc(thandle_t handle, toff_t off, int whence)
|
||||||
{
|
{
|
||||||
wxInputStream *stream = (wxInputStream*) handle;
|
wxInputStream *stream = (wxInputStream*) handle;
|
||||||
@@ -83,7 +83,7 @@ _tiffSeekIProc(thandle_t handle, toff_t off, int whence)
|
|||||||
return (toff_t)stream->SeekI( (off_t)off, mode );
|
return (toff_t)stream->SeekI( (off_t)off, mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
static toff_t
|
static toff_t LINKAGEMODE
|
||||||
_tiffSeekOProc(thandle_t handle, toff_t off, int whence)
|
_tiffSeekOProc(thandle_t handle, toff_t off, int whence)
|
||||||
{
|
{
|
||||||
wxOutputStream *stream = (wxOutputStream*) handle;
|
wxOutputStream *stream = (wxOutputStream*) handle;
|
||||||
@@ -99,20 +99,20 @@ _tiffSeekOProc(thandle_t handle, toff_t off, int whence)
|
|||||||
return (toff_t)stream->SeekO( (off_t)off, mode );
|
return (toff_t)stream->SeekO( (off_t)off, mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int LINKAGEMODE
|
||||||
_tiffCloseProc(thandle_t WXUNUSED(handle))
|
_tiffCloseProc(thandle_t WXUNUSED(handle))
|
||||||
{
|
{
|
||||||
return 0; // ?
|
return 0; // ?
|
||||||
}
|
}
|
||||||
|
|
||||||
static toff_t
|
static toff_t LINKAGEMODE
|
||||||
_tiffSizeProc(thandle_t handle)
|
_tiffSizeProc(thandle_t handle)
|
||||||
{
|
{
|
||||||
wxStreamBase *stream = (wxStreamBase*) handle;
|
wxStreamBase *stream = (wxStreamBase*) handle;
|
||||||
return (toff_t) stream->GetSize();
|
return (toff_t) stream->GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int LINKAGEMODE
|
||||||
_tiffMapProc(thandle_t WXUNUSED(handle),
|
_tiffMapProc(thandle_t WXUNUSED(handle),
|
||||||
tdata_t* WXUNUSED(pbase),
|
tdata_t* WXUNUSED(pbase),
|
||||||
toff_t* WXUNUSED(psize))
|
toff_t* WXUNUSED(psize))
|
||||||
@@ -120,7 +120,7 @@ _tiffMapProc(thandle_t WXUNUSED(handle),
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LINKAGEMODE
|
||||||
_tiffUnmapProc(thandle_t WXUNUSED(handle),
|
_tiffUnmapProc(thandle_t WXUNUSED(handle),
|
||||||
tdata_t WXUNUSED(base),
|
tdata_t WXUNUSED(base),
|
||||||
toff_t WXUNUSED(size))
|
toff_t WXUNUSED(size))
|
||||||
@@ -190,7 +190,7 @@ bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbos
|
|||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
wxLogError( _("TIFF: Couldn't allocate memory.") );
|
wxLogError( _("TIFF: Couldn't allocate memory.") );
|
||||||
|
|
||||||
TIFFClose( tif );
|
TIFFClose( tif );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -301,11 +301,11 @@ bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
|
|||||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
||||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
|
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
|
||||||
|
|
||||||
tsize_t linebytes = (tsize_t)image->GetWidth() * 3;
|
tsize_t linebytes = (tsize_t)image->GetWidth() * 3;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
if (TIFFScanlineSize(tif) > linebytes)
|
if (TIFFScanlineSize(tif) > linebytes)
|
||||||
{
|
{
|
||||||
buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif));
|
buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif));
|
||||||
if (!buf)
|
if (!buf)
|
||||||
@@ -317,30 +317,30 @@ bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
|
|||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
|
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
|
||||||
TIFFDefaultStripSize(tif, (uint32) -1));
|
TIFFDefaultStripSize(tif, (uint32) -1));
|
||||||
|
|
||||||
unsigned char *ptr = image->GetData();
|
unsigned char *ptr = image->GetData();
|
||||||
for (int row = 0; row < image->GetHeight(); row++)
|
for (int row = 0; row < image->GetHeight(); row++)
|
||||||
{
|
{
|
||||||
if (buf)
|
if (buf)
|
||||||
memcpy(buf, ptr, image->GetWidth());
|
memcpy(buf, ptr, image->GetWidth());
|
||||||
|
|
||||||
if (TIFFWriteScanline(tif, buf ? buf : ptr, (uint32)row, 0) < 0)
|
if (TIFFWriteScanline(tif, buf ? buf : ptr, (uint32)row, 0) < 0)
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
wxLogError( _("TIFF: Error writing image.") );
|
wxLogError( _("TIFF: Error writing image.") );
|
||||||
|
|
||||||
TIFFClose( tif );
|
TIFFClose( tif );
|
||||||
if (buf)
|
if (buf)
|
||||||
_TIFFfree(buf);
|
_TIFFfree(buf);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ptr += image->GetWidth()*3;
|
ptr += image->GetWidth()*3;
|
||||||
|
|||||||
@@ -131,14 +131,14 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream)
|
|||||||
{
|
{
|
||||||
size_t length = stream.GetSize();
|
size_t length = stream.GetSize();
|
||||||
wxCHECK_MSG(length != 0, wxNullImage, wxT("Cannot read XPM from stream of unknown size"));
|
wxCHECK_MSG(length != 0, wxNullImage, wxT("Cannot read XPM from stream of unknown size"));
|
||||||
|
|
||||||
char *xpm_buffer = new char[length];
|
char *xpm_buffer = new char[length];
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if ( stream.Read(xpm_buffer, length).LastError() != wxSTREAM_NO_ERROR )
|
if ( stream.Read(xpm_buffer, length).LastError() != wxSTREAM_NO_ERROR )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove comments from the file:
|
* Remove comments from the file:
|
||||||
*/
|
*/
|
||||||
@@ -178,7 +178,7 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream)
|
|||||||
i = 0;
|
i = 0;
|
||||||
for (p = xpm_buffer; *p != '\0'; p++)
|
for (p = xpm_buffer; *p != '\0'; p++)
|
||||||
{
|
{
|
||||||
if ( *p != '"' )
|
if ( *p != '"' )
|
||||||
continue;
|
continue;
|
||||||
for (q = p + 1; *q != '\0'; q++)
|
for (q = p + 1; *q != '\0'; q++)
|
||||||
if (*q == '"')
|
if (*q == '"')
|
||||||
@@ -189,38 +189,38 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream)
|
|||||||
p = q + 1;
|
p = q + 1;
|
||||||
}
|
}
|
||||||
xpm_buffer[i] = '\0';
|
xpm_buffer[i] = '\0';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create array of lines and convert \n's to \0's:
|
* Create array of lines and convert \n's to \0's:
|
||||||
*/
|
*/
|
||||||
const char **xpm_lines;
|
const char **xpm_lines;
|
||||||
size_t lines_cnt = 0;
|
size_t lines_cnt = 0;
|
||||||
size_t line;
|
size_t line;
|
||||||
|
|
||||||
for (p = xpm_buffer; *p != '\0'; p++)
|
for (p = xpm_buffer; *p != '\0'; p++)
|
||||||
{
|
{
|
||||||
if ( *p == '\n' )
|
if ( *p == '\n' )
|
||||||
lines_cnt++;
|
lines_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
xpm_lines = new const char*[lines_cnt];
|
xpm_lines = new const char*[lines_cnt];
|
||||||
xpm_lines[0] = xpm_buffer;
|
xpm_lines[0] = xpm_buffer;
|
||||||
line = 1;
|
line = 1;
|
||||||
for (p = xpm_buffer; (*p != '\0') && (line < lines_cnt); p++)
|
for (p = xpm_buffer; (*p != '\0') && (line < lines_cnt); p++)
|
||||||
{
|
{
|
||||||
if ( *p == '\n' )
|
if ( *p == '\n' )
|
||||||
{
|
{
|
||||||
xpm_lines[line] = p + 1;
|
xpm_lines[line] = p + 1;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the image:
|
* Read the image:
|
||||||
*/
|
*/
|
||||||
wxImage img = ReadData(xpm_lines);
|
wxImage img = ReadData(xpm_lines);
|
||||||
|
|
||||||
delete[] xpm_buffer;
|
delete[] xpm_buffer;
|
||||||
delete[] xpm_lines;
|
delete[] xpm_lines;
|
||||||
return img;
|
return img;
|
||||||
@@ -243,7 +243,7 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream)
|
|||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
wxUint32 rgb;
|
wxUint32 rgb;
|
||||||
@@ -512,7 +512,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
|
|||||||
buf[0] = inname[5]; buf[1] = inname[6];
|
buf[0] = inname[5]; buf[1] = inname[6];
|
||||||
*b = (unsigned char) wxHexToDec(buf);
|
*b = (unsigned char) wxHexToDec(buf);
|
||||||
*isNone = FALSE;
|
*isNone = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,7 +522,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
|
|||||||
// lot of gray...
|
// lot of gray...
|
||||||
|
|
||||||
// so first extract ' '
|
// so first extract ' '
|
||||||
while ((p = strchr(name, ' ')))
|
while ((p = strchr(name, ' ')) != NULL)
|
||||||
{
|
{
|
||||||
while (*(p)) // till eof of string
|
while (*(p)) // till eof of string
|
||||||
{
|
{
|
||||||
@@ -532,7 +532,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
|
|||||||
}
|
}
|
||||||
// fold to lower case
|
// fold to lower case
|
||||||
p = name;
|
p = name;
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
*p = tolower(*p);
|
*p = tolower(*p);
|
||||||
p++;
|
p++;
|
||||||
@@ -540,7 +540,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
|
|||||||
|
|
||||||
// substitute Grey with Gray, else rgbtab.h would have more than 100
|
// substitute Grey with Gray, else rgbtab.h would have more than 100
|
||||||
// 'duplicate' entries
|
// 'duplicate' entries
|
||||||
if ( (grey = strstr(name, "grey")) )
|
if ( (grey = strstr(name, "grey")) != NULL )
|
||||||
grey[2] = 'a';
|
grey[2] = 'a';
|
||||||
|
|
||||||
// check for special 'none' colour:
|
// check for special 'none' colour:
|
||||||
@@ -553,7 +553,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
|
|||||||
// binary search:
|
// binary search:
|
||||||
left = 0;
|
left = 0;
|
||||||
right = numTheRGBRecords - 1;
|
right = numTheRGBRecords - 1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
middle = (left + right) / 2;
|
middle = (left + right) / 2;
|
||||||
cmp = strcmp(name, theRGBRecords[middle].name);
|
cmp = strcmp(name, theRGBRecords[middle].name);
|
||||||
@@ -566,12 +566,12 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
|
|||||||
*isNone = FALSE;
|
*isNone = FALSE;
|
||||||
free(name);
|
free(name);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if ( cmp < 0 )
|
else if ( cmp < 0 )
|
||||||
{
|
{
|
||||||
right = middle - 1;
|
right = middle - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // > 0
|
{ // > 0
|
||||||
left = middle + 1;
|
left = middle + 1;
|
||||||
}
|
}
|
||||||
@@ -583,7 +583,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
|
|||||||
|
|
||||||
static const char *ParseColor(const char *data)
|
static const char *ParseColor(const char *data)
|
||||||
{
|
{
|
||||||
static const char *targets[] =
|
static const char *targets[] =
|
||||||
{"c ", "g ", "g4 ", "m ", "b ", "s ", NULL};
|
{"c ", "g ", "g4 ", "m ", "b ", "s ", NULL};
|
||||||
|
|
||||||
const char *p, *r;
|
const char *p, *r;
|
||||||
@@ -630,11 +630,11 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
|
|||||||
bool hasMask;
|
bool hasMask;
|
||||||
wxXPMColourMapData *clr_data;
|
wxXPMColourMapData *clr_data;
|
||||||
wxHashTable clr_tbl(wxKEY_STRING);
|
wxHashTable clr_tbl(wxKEY_STRING);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read hints and initialize structures:
|
* Read hints and initialize structures:
|
||||||
*/
|
*/
|
||||||
count = sscanf(xpm_data[0], "%u %u %u %u",
|
count = sscanf(xpm_data[0], "%u %u %u %u",
|
||||||
&width, &height, &colors_cnt, &chars_per_pixel);
|
&width, &height, &colors_cnt, &chars_per_pixel);
|
||||||
if ( count != 4 || width * height * colors_cnt == 0 )
|
if ( count != 4 || width * height * colors_cnt == 0 )
|
||||||
{
|
{
|
||||||
@@ -646,7 +646,7 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
|
|||||||
// 92 possible values on each position, 92^64 is *way* larger space than
|
// 92 possible values on each position, 92^64 is *way* larger space than
|
||||||
// 8bit RGB...
|
// 8bit RGB...
|
||||||
wxCHECK_MSG(chars_per_pixel < 64, wxNullImage, wxT("XPM colormaps this large not supported."));
|
wxCHECK_MSG(chars_per_pixel < 64, wxNullImage, wxT("XPM colormaps this large not supported."));
|
||||||
|
|
||||||
img.Create(width, height);
|
img.Create(width, height);
|
||||||
if ( !img.Ok() ) return img;
|
if ( !img.Ok() ) return img;
|
||||||
|
|
||||||
@@ -654,7 +654,7 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
|
|||||||
key[chars_per_pixel] = '\0';
|
key[chars_per_pixel] = '\0';
|
||||||
hasMask = FALSE;
|
hasMask = FALSE;
|
||||||
clr_tbl.DeleteContents(TRUE);
|
clr_tbl.DeleteContents(TRUE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create colour map:
|
* Create colour map:
|
||||||
*/
|
*/
|
||||||
@@ -672,7 +672,7 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool isNone;
|
bool isNone;
|
||||||
if ( !GetRGBFromName(clr_def, &isNone,
|
if ( !GetRGBFromName(clr_def, &isNone,
|
||||||
&clr_data->R, &clr_data->G, &clr_data->B) )
|
&clr_data->R, &clr_data->G, &clr_data->B) )
|
||||||
{
|
{
|
||||||
wxLogError(_("XPM: malformed colour definition '%s'!"), xpm_data[1+i]);
|
wxLogError(_("XPM: malformed colour definition '%s'!"), xpm_data[1+i]);
|
||||||
@@ -689,7 +689,7 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( hasMask && clr_data->R == 255 &&
|
if ( hasMask && clr_data->R == 255 &&
|
||||||
clr_data->G == 0 && clr_data->B == 255 )
|
clr_data->G == 0 && clr_data->B == 255 )
|
||||||
clr_data->B = 254;
|
clr_data->B = 254;
|
||||||
}
|
}
|
||||||
@@ -701,13 +701,13 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
|
|||||||
/*
|
/*
|
||||||
* Parse image data:
|
* Parse image data:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned char *img_data = img.GetData();
|
unsigned char *img_data = img.GetData();
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < width; i++, img_data += 3)
|
for (i = 0; i < width; i++, img_data += 3)
|
||||||
{
|
{
|
||||||
memcpy(key,
|
memcpy(key,
|
||||||
xpm_data[1 + colors_cnt + j] + chars_per_pixel * i,
|
xpm_data[1 + colors_cnt + j] + chars_per_pixel * i,
|
||||||
chars_per_pixel);
|
chars_per_pixel);
|
||||||
clr_data = (wxXPMColourMapData*) clr_tbl.Get(key);
|
clr_data = (wxXPMColourMapData*) clr_tbl.Get(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user