Skip to content

Commit

Permalink
Replace DEBUG with EXIV2_DEBUG_MESSAGES
Browse files Browse the repository at this point in the history
Fixes #926
  • Loading branch information
piponazo committed Jul 11, 2019
1 parent b7a9785 commit 02facf9
Show file tree
Hide file tree
Showing 31 changed files with 187 additions and 188 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,22 +424,22 @@ $

[TOC](#TOC)

2) About preprocessor symbols **NDEBUG** and **DEBUG**
2) About preprocessor symbols `NDEBUG` and `EXIV2_DEBUG_MESSAGES`

In accordance with current practice, exiv2 respects the symbol *NDEBUG* which is set for Release builds. There are sequences of code which are defined within:
Exiv2 respects the symbol `NDEBUG` which is set only for Release builds. There are sequences of code which are defined within:

```C++
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
....
#endif
```

Those blocks of code are not compiled for debug builds. They are provided for additional debugging information. For example, if you are interested in additonal output from webpimage.cpp, you can update your build as follows:
Those blocks of code are not compiled unless you define `EXIV2_DEBUG_MESSAGES` by yourself. They are provided for additional debugging information. For example, if you are interested in additional output from webpimage.cpp, you can update your build as follows:

```bash
$ cd <exiv2dir>
$ touch src/webpimage.cpp
$ make CXXFLAGS=-DDEBUG
$ make CXXFLAGS=-DEXIV2_DEBUG_MESSAGESDEBUG
$ bin/exiv2 ...
-- or --
$ sudo make install
Expand Down
2 changes: 1 addition & 1 deletion samples/geotag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ int timeZoneAdjust()
struct tm local = *localtime(&now) ;
offset = local.tm_gmtoff ;

#if DEBUG
#if EXIV2_DEBUG_MESSAGES
struct tm utc = *gmtime(&now);
printf("utc : offset = %6d dst = %d time = %s", 0 ,utc .tm_isdst, asctime(&utc ));
printf("local: offset = %6d dst = %d time = %s", offset,local.tm_isdst, asctime(&local));
Expand Down
2 changes: 1 addition & 1 deletion src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ namespace {
int targetType,
bool preserve)
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "actions.cpp::metacopy" << " source = " << source << " target = " << tgt << std::endl;
#endif

Expand Down
14 changes: 7 additions & 7 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ namespace Exiv2 {
}
// #906. Mountain Lion 'sandbox' terminates the app when we call setxattr
#ifndef __APPLE__
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
EXV_DEBUG << "Copying xattr \"" << name << "\" with value size " << valueSize << "\n";
#endif
if (::setxattr(path_.c_str(), name, value, valueSize, 0, 0) != 0) {
Expand Down Expand Up @@ -337,19 +337,19 @@ namespace Exiv2 {
if (pfcn_GetFileInformationByHandle(hFd, &fi)) {
nlink = fi.nNumberOfLinks;
}
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
else EXV_DEBUG << "GetFileInformationByHandle failed\n";
#endif
}
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
else EXV_DEBUG << "GetProcAddress(hKernel, \"GetFileInformationByHandle\") failed\n";
#endif
}
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
else EXV_DEBUG << "GetModuleHandleA(\"kernel32.dll\") failed\n";
#endif
}
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
else EXV_DEBUG << "_get_osfhandle failed: INVALID_HANDLE_VALUE\n";
#endif

Expand Down Expand Up @@ -1730,7 +1730,7 @@ namespace Exiv2 {
p_->eof_ = false;
p_->idx_ = 0;
}
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "RemoteIo::close totalRead_ = " << p_->totalRead_ << std::endl;
#endif
if ( bigBlock_ ) {
Expand Down Expand Up @@ -1950,7 +1950,7 @@ namespace Exiv2 {
memcpy(bigBlock_+(block*blockSize),p,blockSize);
}
}
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "RemoteIo::mmap nRealData = " << nRealData << std::endl;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/bmpimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace Exiv2

void BmpImage::readMetadata()
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Exiv2::BmpImage::readMetadata: Reading Windows bitmap file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
Expand Down
12 changes: 6 additions & 6 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ namespace {
{
// Naive byte-swapping, I'm sure this can be done more efficiently
if (str.size() & 1) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
EXV_DEBUG << "swapBytes: Size " << str.size() << " of input string is not even.\n";
#endif
return false;
Expand All @@ -1392,7 +1392,7 @@ namespace {
if (str.empty()) return true;
int len = MultiByteToWideChar(cp, 0, str.c_str(), (int)str.size(), 0, 0);
if (len == 0) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
EXV_DEBUG << "mb2wc: Failed to determine required size of output buffer.\n";
#endif
return false;
Expand All @@ -1401,7 +1401,7 @@ namespace {
out.resize(len * 2);
int ret = MultiByteToWideChar(cp, 0, str.c_str(), (int)str.size(), (LPWSTR)&out[0], len * 2);
if (ret == 0) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
EXV_DEBUG << "mb2wc: Failed to convert the input string to a wide character string.\n";
#endif
return false;
Expand All @@ -1414,14 +1414,14 @@ namespace {
{
if (str.empty()) return true;
if (str.size() & 1) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
EXV_DEBUG << "wc2mb: Size " << str.size() << " of input string is not even.\n";
#endif
return false;
}
int len = WideCharToMultiByte(cp, 0, (LPCWSTR)str.data(), (int)str.size() / 2, 0, 0, 0, 0);
if (len == 0) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
EXV_DEBUG << "wc2mb: Failed to determine required size of output buffer.\n";
#endif
return false;
Expand All @@ -1430,7 +1430,7 @@ namespace {
out.resize(len);
int ret = WideCharToMultiByte(cp, 0, (LPCWSTR)str.data(), (int)str.size() / 2, (LPSTR)&out[0], len, 0, 0);
if (ret == 0) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
EXV_DEBUG << "wc2mb: Failed to convert the input string to a multi byte string.\n";
#endif
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/cr2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace Exiv2 {

void Cr2Image::readMetadata()
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Reading CR2 file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
Expand All @@ -112,7 +112,7 @@ namespace Exiv2 {

void Cr2Image::writeMetadata()
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Writing CR2 file " << io_->path() << "\n";
#endif
ByteOrder bo = byteOrder();
Expand Down Expand Up @@ -174,7 +174,7 @@ namespace Exiv2 {
panaRawId
};
for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfds); ++i) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: Exif IFD " << filteredIfds[i] << " not encoded\n";
#endif
ed.erase(std::remove_if(ed.begin(),
Expand Down
6 changes: 3 additions & 3 deletions src/crwimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace Exiv2 {

void CrwImage::readMetadata()
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Reading CRW file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
Expand All @@ -110,7 +110,7 @@ namespace Exiv2 {

void CrwImage::writeMetadata()
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Writing CRW file " << io_->path() << "\n";
#endif
// Read existing image
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace Exiv2 {
// Parse the image, starting with a CIFF header component
CiffHeader::AutoPtr head(new CiffHeader);
head->read(pData, size);
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
head->print(std::cerr);
#endif
head->decode(*pCrwImage);
Expand Down
16 changes: 8 additions & 8 deletions src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace Exiv2 {
offset_ = start + 2;
}
pData_ = pData + offset_;
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << " Entry for tag 0x"
<< std::hex << tagId() << " (0x" << tag()
<< "), " << std::dec << size_
Expand All @@ -265,11 +265,11 @@ namespace Exiv2 {
ByteOrder byteOrder)
{
CiffComponent::doRead(pData, size, start, byteOrder);
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Reading directory 0x" << std::hex << tag() << "\n";
#endif
readDirectory(pData + offset(), this->size(), byteOrder);
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "<---- 0x" << std::hex << tag() << "\n";
#endif
} // CiffDirectory::doRead
Expand All @@ -284,7 +284,7 @@ namespace Exiv2 {
if ( o > size-2 )
throw Error(kerCorruptedMetadata);
uint16_t count = getUShort(pData + o, byteOrder);
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Directory at offset " << std::dec << o
<<", " << count << " entries \n";
#endif
Expand Down Expand Up @@ -383,7 +383,7 @@ namespace Exiv2 {
uint32_t CiffComponent::writeValueData(Blob& blob, uint32_t offset)
{
if (dataLocation() == valueData) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << " Data for tag 0x" << std::hex << tagId()
<< ", " << std::dec << size_ << " Bytes\n";
#endif
Expand All @@ -403,7 +403,7 @@ namespace Exiv2 {
ByteOrder byteOrder,
uint32_t offset)
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Writing directory 0x" << std::hex << tag() << "---->\n";
#endif
// Ciff offsets are relative to the start of the directory
Expand Down Expand Up @@ -438,7 +438,7 @@ namespace Exiv2 {
setOffset(offset);
setSize(dirOffset);

#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Directory is at offset " << std::dec << dirStart
<< ", " << components_.size() << " entries\n"
<< "<---- 0x" << std::hex << tag() << "\n";
Expand All @@ -448,7 +448,7 @@ namespace Exiv2 {

void CiffComponent::writeDirEntry(Blob& blob, ByteOrder byteOrder) const
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << " Directory entry for tag 0x"
<< std::hex << tagId() << " (0x" << tag()
<< "), " << std::dec << size_
Expand Down
6 changes: 3 additions & 3 deletions src/exif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ namespace Exiv2 {
for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfd0Tags); ++i) {
ExifData::iterator pos = ed.findKey(ExifKey(filteredIfd0Tags[i]));
if (pos != ed.end()) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: Exif tag " << pos->key() << " not encoded\n";
#endif
ed.erase(pos);
Expand All @@ -689,7 +689,7 @@ namespace Exiv2 {
ifd3Id
};
for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfds); ++i) {
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: Exif IFD " << filteredIfds[i] << " not encoded\n";
#endif
eraseIfd(ed, filteredIfds[i]);
Expand Down Expand Up @@ -816,7 +816,7 @@ namespace Exiv2 {
header.get(),
0);
append(blob, mio2.mmap(), (uint32_t) mio2.size());
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
if (wm == wmIntrusive) {
std::cerr << "SIZE OF EXIF DATA IS " << std::dec << mio2.size() << " BYTES\n";
}
Expand Down
2 changes: 1 addition & 1 deletion src/gifimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace Exiv2 {

void GifImage::readMetadata()
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Exiv2::GifImage::readMetadata: Reading GIF file " << io_->path() << "\n";
#endif
if (io_->open() != 0)
Expand Down
2 changes: 1 addition & 1 deletion src/iptc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ namespace Exiv2 {
uint32_t size
)
{
#ifdef DEBUG
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "IptcParser::decode, size = " << size << "\n";
#endif
const byte* pRead = pData;
Expand Down
Loading

0 comments on commit 02facf9

Please sign in to comment.