[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:42:30 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=115ba5a
The following commit has been merged in the master branch:
commit 115ba5a04e441e992ea35fef37c53f0a1f572b1f
Author: vog <vog at notjusthosting.com>
Date: Wed Jun 29 12:16:34 2011 +0000
Improved epsimage.cpp and preview.cpp to avoid unnecessary type casts, also make some implicit type casts explicit for clarity
---
src/epsimage.cpp | 24 ++++++++++++------------
src/preview.cpp | 43 ++++++++++++++++++++++---------------------
src/types.cpp | 3 +--
src/types.hpp | 2 +-
4 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/src/epsimage.cpp b/src/epsimage.cpp
index d33c3d7..9e455aa 100644
--- a/src/epsimage.cpp
+++ b/src/epsimage.cpp
@@ -143,7 +143,7 @@ namespace {
}
//! Get the current write position of temp file, taking care of errors
- static size_t posTemp(BasicIo& tempIo)
+ static uint32_t posTemp(BasicIo& tempIo)
{
const long pos = tempIo.tell();
if (pos == -1) {
@@ -152,7 +152,7 @@ namespace {
#endif
throw Error(21);
}
- return pos;
+ return static_cast<uint32_t>(pos);
}
//! Check whether a string has a certain beginning
@@ -415,13 +415,13 @@ namespace {
const byte *data = io.mmap();
// default positions and sizes
- const size_t size = io.size();
+ const size_t size = static_cast<size_t>(io.size());
size_t posEps = 0;
size_t posEndEps = size;
- size_t posWmf = 0;
- size_t sizeWmf = 0;
- size_t posTiff = 0;
- size_t sizeTiff = 0;
+ uint32_t posWmf = 0;
+ uint32_t sizeWmf = 0;
+ uint32_t posTiff = 0;
+ uint32_t sizeTiff = 0;
// check for DOS EPS
const bool dosEps = (size >= dosEpsSignature.size() && memcmp(data, dosEpsSignature.data(), dosEpsSignature.size()) == 0);
@@ -727,7 +727,7 @@ namespace {
if (sizeWmf != 0) {
NativePreview nativePreview;
nativePreview.position_ = static_cast<long>(posWmf);
- nativePreview.size_ = (uint32_t) sizeWmf;
+ nativePreview.size_ = sizeWmf;
nativePreview.width_ = 0;
nativePreview.height_ = 0;
nativePreview.mimeType_ = "image/x-wmf";
@@ -736,7 +736,7 @@ namespace {
if (sizeTiff != 0) {
NativePreview nativePreview;
nativePreview.position_ = static_cast<long>(posTiff);
- nativePreview.size_ = (uint32_t) sizeTiff;
+ nativePreview.size_ = sizeTiff;
nativePreview.width_ = 0;
nativePreview.height_ = 0;
nativePreview.mimeType_ = "image/tiff";
@@ -793,7 +793,7 @@ namespace {
// DOS EPS header will be written afterwards
writeTemp(*tempIo, std::string(30, '\x00'));
}
- const size_t posEpsNew = posTemp(*tempIo);
+ const uint32_t posEpsNew = posTemp(*tempIo);
size_t prevPos = posEps;
size_t prevSkipPos = prevPos;
for (std::vector<size_t>::const_iterator i = positions.begin(); i != positions.end(); i++) {
@@ -942,7 +942,7 @@ namespace {
prevPos = pos;
prevSkipPos = skipPos;
}
- const size_t posEndEpsNew = posTemp(*tempIo);
+ const uint32_t posEndEpsNew = posTemp(*tempIo);
#ifdef DEBUG
EXV_DEBUG << "readWriteEpsMetadata: New EPS size: " << (posEndEpsNew - posEpsNew) << "
";
#endif
@@ -1073,7 +1073,7 @@ namespace Exiv2
bool isEpsType(BasicIo& iIo, bool advance)
{
// read as many bytes as needed for the longest (DOS) EPS signature
- long bufSize = (long) dosEpsSignature.size();
+ long bufSize = static_cast<long>(dosEpsSignature.size());
for (size_t i = 0; i < (sizeof epsFirstLine) / (sizeof *epsFirstLine); i++) {
if (bufSize < static_cast<long>(epsFirstLine[i].size())) {
bufSize = static_cast<long>(epsFirstLine[i].size());
diff --git a/src/preview.cpp b/src/preview.cpp
index f532eb4..4e04cf3 100644
--- a/src/preview.cpp
+++ b/src/preview.cpp
@@ -70,7 +70,7 @@ namespace {
/*!
@brief Decode a Base64 string.
*/
- std::string decodeBase64(const std::string &src);
+ DataBuf decodeBase64(const std::string &src);
/*!
Base class for image loaders. Provides virtual methods for reading properties
@@ -282,7 +282,7 @@ namespace {
protected:
//! Preview image data
- std::string preview_;
+ DataBuf preview_;
};
//! Function to create new LoaderXmpJpeg
@@ -445,7 +445,7 @@ namespace {
throw Error(9, io.path(), strError());
}
IoCloser closer(io);
- const Exiv2::byte* data = io.mmap();
+ const byte* data = io.mmap();
if (io.size() < nativePreview_.position_ + static_cast<long>(nativePreview_.size_)) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Invalid native preview position or size.
";
@@ -805,7 +805,7 @@ namespace {
{
(void)parIdx;
- const Exiv2::XmpData &xmpData = image_.xmpData();
+ const XmpData &xmpData = image_.xmpData();
std::string prefix = "xmpGImg";
if (xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/xapGImg:image")) != xmpData.end()) {
@@ -826,7 +826,7 @@ namespace {
width_ = widthDatum->toLong();
height_ = heightDatum->toLong();
preview_ = decodeBase64(imageDatum->toString());
- size_ = (uint32_t)preview_.size();
+ size_ = static_cast<uint32_t>(preview_.size_);
valid_ = true;
}
@@ -849,7 +849,7 @@ namespace {
DataBuf LoaderXmpJpeg::getData() const
{
if (!valid()) return DataBuf();
- return DataBuf(reinterpret_cast<const Exiv2::byte*>(preview_.data()), (long)preview_.size());
+ return DataBuf(preview_.pData_, preview_.size_);
}
bool LoaderXmpJpeg::readDimensions()
@@ -859,38 +859,39 @@ namespace {
static const char encodeBase64Table[64 + 1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- std::string decodeBase64(const std::string& src)
+ DataBuf decodeBase64(const std::string& src)
{
- const unsigned int srcSize = (const unsigned int) src.size();
+ const unsigned long srcSize = static_cast<const unsigned long>(src.size());
// create decoding table
- unsigned int invalid = 64;
- unsigned int decodeBase64Table[256];
- for (unsigned int i = 0; i < 256; i++) decodeBase64Table[i] = invalid;
- for (unsigned int i = 0; i < 64; i++) decodeBase64Table[(unsigned char)encodeBase64Table[i]] = i;
+ unsigned long invalid = 64;
+ unsigned long decodeBase64Table[256];
+ for (unsigned long i = 0; i < 256; i++) decodeBase64Table[i] = invalid;
+ for (unsigned long i = 0; i < 64; i++) decodeBase64Table[(unsigned char)encodeBase64Table[i]] = i;
// calculate dest size
- unsigned int validSrcSize = 0;
- for (unsigned int srcPos = 0; srcPos < srcSize; srcPos++) {
+ unsigned long validSrcSize = 0;
+ for (unsigned long srcPos = 0; srcPos < srcSize; srcPos++) {
if (decodeBase64Table[(unsigned char)src[srcPos]] != invalid) validSrcSize++;
}
- if (validSrcSize > UINT_MAX / 3) return std::string(); // avoid integer overflow
- const unsigned int destSize = (validSrcSize * 3) / 4;
+ if (validSrcSize > ULONG_MAX / 3) return DataBuf(); // avoid integer overflow
+ const unsigned long destSize = (validSrcSize * 3) / 4;
// allocate dest buffer
- std::string dest(destSize, 0);
+ if (destSize > LONG_MAX) return DataBuf(); // avoid integer overflow
+ DataBuf dest(static_cast<long>(destSize));
// decode
- for (unsigned int srcPos = 0, destPos = 0; destPos < destSize;) {
- unsigned int buffer = 0;
+ for (unsigned long srcPos = 0, destPos = 0; destPos < destSize;) {
+ unsigned long buffer = 0;
for (int bufferPos = 3; bufferPos >= 0 && srcPos < srcSize; srcPos++) {
- unsigned int srcValue = decodeBase64Table[(unsigned char)src[srcPos]];
+ unsigned long srcValue = decodeBase64Table[(unsigned char)src[srcPos]];
if (srcValue == invalid) continue;
buffer |= srcValue << (bufferPos * 6);
bufferPos--;
}
for (int bufferPos = 2; bufferPos >= 0 && destPos < destSize; bufferPos--, destPos++) {
- dest[destPos] = buffer >> (bufferPos * 8);
+ dest.pData_[destPos] = (buffer >> (bufferPos * 8)) & 0xFF;
}
}
return dest;
diff --git a/src/types.cpp b/src/types.cpp
index 2016b81..d254353 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -330,9 +330,8 @@ namespace Exiv2 {
return 2;
}
- long ul2Data(byte* buf, size_t s, ByteOrder byteOrder)
+ long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder)
{
- uint32_t l = (uint32_t) s; // downcast for 64 bit architecture
if (byteOrder == littleEndian) {
buf[0] = (byte) (l & 0x000000ff);
buf[1] = (byte)((l & 0x0000ff00) >> 8);
diff --git a/src/types.hpp b/src/types.hpp
index 2ece2ab..0ed6ca5 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -293,7 +293,7 @@ namespace Exiv2 {
@brief Convert an unsigned long to data, write the data to the buffer,
return number of bytes written.
*/
- EXIV2API long ul2Data(byte* buf, size_t s, ByteOrder byteOrder);
+ EXIV2API long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder);
/*!
@brief Convert an unsigned rational to data, write the data to the buffer,
return number of bytes written.
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list