Skip to content

Commit

Permalink
clang-format adjustments for version 18
Browse files Browse the repository at this point in the history
This is preparation to add compatibility with previous versions.

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Aug 14, 2024
1 parent 29182ce commit 52bf6ac
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 73 deletions.
3 changes: 1 addition & 2 deletions app/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,8 +1688,7 @@ std::string temporaryPath() {

int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType targetType, bool preserve) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "actions.cpp::metacopy"
<< " source = " << source << " target = " << tgt << '\n';
std::cerr << "actions.cpp::metacopy source = " << source << " target = " << tgt << '\n';
#endif

// read the source metadata
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/datasets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct EXIV2API DataSet {
TypeId type_; //!< Exiv2 default type
uint16_t recordId_; //!< Record id
const char* photoshop_; //!< Photoshop string
}; // struct DataSet
};

//! IPTC dataset reference, implemented as a static class.
class EXIV2API IptcDataSets {
Expand Down
5 changes: 2 additions & 3 deletions include/exiv2/matroskavideo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ struct MatroskaTag {
return _process == Composite;
}
void dump(std::ostream& os) const {
os << " MatroskaTag "
<< " id: [0x" << std::hex << _id << "] label:[" << _label << "] type:[" << _type << "] process :[" << _process
<< "]\n";
os << " MatroskaTag id: [0x" << std::hex << _id << "] label:[" << _label << "] type:[" << _type << "] process :["
<< _process << "]\n";
}
};
} // namespace Internal
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct EXIV2API TagInfo {
TypeId typeId_; //!< Type id
int16_t count_; //!< The number of values (not bytes!), 0=any, -1=count not known.
PrintFct printFct_; //!< Pointer to tag print function
}; // struct TagInfo
};

//! Access to Exif group and tag lists and misc. tag reference methods, implemented as a static class.
class EXIV2API ExifTags {
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class EXIV2API CommentValue : public StringValueBase {
CharsetId charsetId_; //!< Charset id
const char* name_; //!< Name of the charset
const char* code_; //!< Code of the charset
}; // struct CharsetTable
};

//! Charset information lookup functions. Implemented as a static class.
class EXIV2API CharsetInfo {
Expand Down
3 changes: 2 additions & 1 deletion samples/easyaccess-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ static void printFct(EasyAccessFct fct, Exiv2::ExifData ed, const char* label) {
std::cout << " (" << std::setw(35) << pos->key() << ") : " << pos->print(&ed) << "\n";
} else {
std::cout << " (" << std::setw(35) << " "
<< ") : \n";
<< ") : "
<< "\n";
}
}

Expand Down
5 changes: 2 additions & 3 deletions samples/exifprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ int main(int argc, char* const argv[]) {
&& (shortLong.find(i->key()) == shortLong.end() ||
(type != Exiv2::unsignedShort && type != Exiv2::unsignedLong)) // can be short or long!
) {
std::cerr << i->key() << " type " << i->typeName() << " (" << type << ")"
<< " expected " << Exiv2::TypeInfo::typeName(tagInfo->typeId_) << " (" << tagInfo->typeId_ << ")"
<< '\n';
std::cerr << i->key() << " type " << i->typeName() << " (" << type << ") expected "
<< Exiv2::TypeInfo::typeName(tagInfo->typeId_) << " (" << tagInfo->typeId_ << ")" << '\n';
rc = 2;
}
}
Expand Down
9 changes: 3 additions & 6 deletions samples/getopt-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,19 @@ class Params : public Util::Getopt {
*/
int getopt(int argc, char** const argv) {
int rc = Util::Getopt::getopt(argc, argv, ::optstring);
std::cout << "Params::getopt()"
<< " rc = " << rc << '\n';
std::cout << "Params::getopt() rc = " << rc << '\n';
return rc;
}

//! Handle options and their arguments.
int option(int opt, const std::string& optarg, int optopt) override {
std::cout << "Params::option()"
<< " opt = " << opt << " optarg = " << optarg << " optopt = " << optopt << '\n';
std::cout << "Params::option() opt = " << opt << " optarg = " << optarg << " optopt = " << optopt << '\n';
return 0;
}

//! Handle non-option parameters.
int nonoption(const std::string& argv) override {
std::cout << "Params::nonoption()"
<< " " << argv << '\n';
std::cout << "Params::nonoption() " << argv << '\n';
return 0;
}
}; // class Params
Expand Down
3 changes: 1 addition & 2 deletions samples/ini-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ int main() {
std::cerr << "Can't load '" << ini << "'" << '\n';
return EXIT_FAILURE;
}
std::cout << "Config loaded from : '" << ini << "' "
<< "version=" << reader.GetInteger("protocol", "version", -1)
std::cout << "Config loaded from : '" << ini << "' version=" << reader.GetInteger("protocol", "version", -1)
<< ", name=" << reader.Get("user", "name", "UNKNOWN")
<< ", email=" << reader.Get("user", "email", "UNKNOWN") << ", pi=" << reader.GetReal("user", "pi", -1)
<< ", active=" << reader.GetBoolean("user", "active", true) << '\n';
Expand Down
3 changes: 1 addition & 2 deletions samples/prevtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ int main(int argc, char* const argv[]) try {
Exiv2::PreviewPropertiesList list = loader.getPreviewProperties();
for (auto&& pos : list) {
std::cout << pos.mimeType_ << " preview, type " << pos.id_ << ", " << pos.size_ << " bytes, " << pos.width_ << 'x'
<< pos.height_ << " pixels"
<< "\n";
<< pos.height_ << " pixels\n";

Exiv2::PreviewImage preview = loader.getPreviewImage(pos);
auto s = preview.writeFile(filename + "_" + std::to_string(pos.width_) + "x" + std::to_string(pos.height_));
Expand Down
10 changes: 2 additions & 8 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,10 +1482,7 @@ void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, size_t from, s
const std::string urlencodeData = urlencode(encodeData.data());

std::stringstream ss;
ss << "path=" << hostInfo_.Path << "&"
<< "from=" << from << "&"
<< "to=" << to << "&"
<< "data=" << urlencodeData;
ss << "path=" << hostInfo_.Path << "&from=" << from << "&to=" << to << "&data=" << urlencodeData;
std::string postData = ss.str();

// create the header
Expand Down Expand Up @@ -1664,10 +1661,7 @@ void CurlIo::CurlImpl::writeRemote(const byte* data, size_t size, size_t from, s
// url encode
const std::string urlencodeData = urlencode(encodeData.data());
std::stringstream ss;
ss << "path=" << hostInfo.Path << "&"
<< "from=" << from << "&"
<< "to=" << to << "&"
<< "data=" << urlencodeData;
ss << "path=" << hostInfo.Path << "&from=" << from << "&to=" << to << "&data=" << urlencodeData;
std::string postData = ss.str();

curl_easy_setopt(curl_, CURLOPT_POSTFIELDS, postData.c_str());
Expand Down
4 changes: 2 additions & 2 deletions src/bmffimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ std::string BmffImage::toAscii(uint32_t n) {
// show 0 as _
std::replace(result.begin(), result.end(), '\0', '_');
// show non 7-bit printable ascii as .
std::replace_if(
result.begin(), result.end(), [](char c) { return c < 32 || c > 126; }, '.');
auto f = [](char c) { return c < 32 || c > 126; };
std::replace_if(result.begin(), result.end(), f, '.');
return result;
}

Expand Down
15 changes: 5 additions & 10 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= fired & 1;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Fired"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Fired to " << to << '\n';
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Return"));
Expand All @@ -1062,8 +1061,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= (ret & 3) << 1;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Return"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Return to " << to << '\n';
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Mode"));
Expand All @@ -1073,8 +1071,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= (mode & 3) << 3;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Mode"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Mode to " << to << '\n';
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Function"));
Expand All @@ -1084,8 +1081,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= (function & 1) << 5;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Function"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Function to " << to << '\n';
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:RedEyeMode"));
Expand All @@ -1096,8 +1092,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= (red & 1) << 6;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:RedEyeMode"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:RedEyeMode to " << to << '\n';
#endif
}
if (erase_)
Expand Down
14 changes: 10 additions & 4 deletions src/fff.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ be considered as real pixels */
unsigned char stripeFields; //!< Number of striped fields this image consists of
unsigned char reserved; //!< For future use - should be set to 0
unsigned short reserved1; //!< For future use - should be set to 0
} GEOMETRIC_INFO_T; //!< sizeof struct == 32 bytes

} GEOMETRIC_INFO_T; //!< sizeof struct == 32 bytes

struct IMAGEINFO_T {
unsigned long imageTime; //!< Time in seconds since 1970-01-01 00:00 (UTC)
Expand Down Expand Up @@ -233,13 +234,15 @@ struct DISTR_DATA_T {

short reserved; //!< For future use
long reserved2[3];

}; //!< sizeof struct == 64 bytes

typedef struct _pres_par_t {
signed long level; /* Level as normalized pixel value (apix), Level is defined as middle of
span (in pixel units) */
signed long span; /* Span as normalized pixel value (apix) */
BYTE reserved[40];

} PRES_PAR_T; /* sizeof struct == 48 bytes */

/**
Expand Down Expand Up @@ -282,7 +285,8 @@ struct OBJECT_PAR_T {

float relHum; //!< relative humidity
long reserved[4]; //!< For future use - should be set to 0
}; //!< sizeof struct == 48 bytes

}; //!< sizeof struct == 48 bytes

struct TEMP_CALIB_T {
long Reserved1[2];
Expand Down Expand Up @@ -344,7 +348,8 @@ struct TEMPSENSOR_DATA_T {
char pzTSName[SYSIMG_NAMELEN + 1];
ULONG captureTime; //!< TS updated; time in seconds since 1970-01-01 00:00
ULONG captureMilliTime; //!< TS updated; Milliseconds since last second
}; //!< sizeof struct == 28 bytes

}; //!< sizeof struct == 28 bytes

/** Detector parameter struct */
struct DETECTOR_PARAM_T {
Expand All @@ -360,7 +365,8 @@ struct EXTENDED_IMAGEINFO_T {
DETECTOR_PARAM_T detectorPars[20]; //!< Currently used detector parameters like
//! used bias, offsets. Usage is camera
//! dependent
}; //!< sizeof struct == 960 bytes

}; //!< sizeof struct == 960 bytes

struct _bidata_t {
GEOMETRIC_INFO_T GeometricInfo; // 32 bytes
Expand Down
7 changes: 3 additions & 4 deletions src/jp2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,12 @@ void Jp2Image::readMetadata() {
throw Error(ErrorCode::kerCorruptedMetadata);
}
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: "
<< "subBox = " << toAscii(subBox.type) << " length = " << subBox.length << '\n';
std::cout << "Exiv2::Jp2Image::readMetadata: subBox = " << toAscii(subBox.type)
<< " length = " << subBox.length << '\n';
#endif
if (subBox.type == kJp2BoxTypeColorSpec && subBox.length != 15) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: "
<< "Color data found" << '\n';
std::cout << "Exiv2::Jp2Image::readMetadata: Color data found\n";
#endif

const size_t pad = 3; // 3 padding bytes 2 0 0
Expand Down
12 changes: 4 additions & 8 deletions src/photoshop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,21 @@ int Photoshop::locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag,
position += psSize;
if (position + 4 > sizePsData) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: "
<< "Invalid or extended Photoshop IRB\n";
std::cerr << "Warning: Invalid or extended Photoshop IRB\n";
#endif
return -2;
}
uint32_t dataSize = getULong(pPsData + position, bigEndian);
position += 4;
if (dataSize > (sizePsData - position)) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: "
<< "Invalid Photoshop IRB data size " << dataSize << " or extended Photoshop IRB\n";
std::cerr << "Warning: Invalid Photoshop IRB data size " << dataSize << " or extended Photoshop IRB\n";
#endif
return -2;
}
#ifdef EXIV2_DEBUG_MESSAGES
if ((dataSize & 1) && position + dataSize == sizePsData) {
std::cerr << "Warning: "
<< "Photoshop IRB data is not padded to even size\n";
std::cerr << "Warning: Photoshop IRB data is not padded to even size\n";
}
#endif
if (type == psTag) {
Expand All @@ -94,8 +91,7 @@ int Photoshop::locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag,
#endif
if (position < sizePsData) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: "
<< "Invalid or extended Photoshop IRB\n";
std::cerr << "Warning: Invalid or extended Photoshop IRB\n";
#endif
return -2;
}
Expand Down
3 changes: 1 addition & 2 deletions src/pngchunk_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ void PngChunk::parseChunkContent(Image* pImage, const byte* key, size_t keySize,
xmpPacket.assign(arr.c_str(), arr.size());
if (auto idx = xmpPacket.find_first_of('<'); idx != std::string::npos && idx > 0) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Removing " << idx << " characters "
<< "from the beginning of the XMP packet\n";
EXV_WARNING << "Removing " << idx << " characters from the beginning of the XMP packet\n";
#endif
xmpPacket = xmpPacket.substr(idx);
}
Expand Down
6 changes: 2 additions & 4 deletions src/pngimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ void PngImage::doWriteMetadata(BasicIo& outIo) {
throw Error(ErrorCode::kerImageWriteFailed);
}
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: build eXIf"
<< " chunk (length: " << blob.size() << ")" << '\n';
std::cout << "Exiv2::PngImage::doWriteMetadata: build eXIf chunk (length: " << blob.size() << ")\n";
#endif
}
}
Expand Down Expand Up @@ -631,8 +630,7 @@ void PngImage::doWriteMetadata(BasicIo& outIo) {
throw Error(ErrorCode::kerImageWriteFailed);
}
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: build iCCP"
<< " chunk (length: " << chunkLength << ")" << '\n';
std::cout << "Exiv2::PngImage::doWriteMetadata: build iCCP chunk (length: " << chunkLength << ")\n";
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static char privatehid[] = "@(#)private.h 7.53";
#endif /* !defined TYPE_BIT */

#ifndef TYPE_SIGNED
#define TYPE_SIGNED(type) (((type)-1) < 0)
#define TYPE_SIGNED(type) (((type) - 1) < 0)
#endif /* !defined TYPE_SIGNED */

#ifndef INT_STRLEN_MAXIMUM
Expand Down
11 changes: 3 additions & 8 deletions src/tiffvisitor_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ void TiffDecoder::decodeIptc(const TiffEntryBase* object) {
return;
}
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to decode IPTC block found in "
<< "Directory Image, entry 0x83bb\n";

EXV_WARNING << "Failed to decode IPTC block found in Directory Image, entry 0x83bb\n";
#endif
}

Expand All @@ -326,9 +324,7 @@ void TiffDecoder::decodeIptc(const TiffEntryBase* object) {
return;
}
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to decode IPTC block found in "
<< "Directory Image, entry 0x8649\n";

EXV_WARNING << "Failed to decode IPTC block found in Directory Image, entry 0x8649\n";
#endif
}
} // TiffMetadataDecoder::decodeIptc
Expand Down Expand Up @@ -1235,8 +1231,7 @@ void TiffReader::readTiffEntry(TiffEntryBase* object) {
if (p + 12 > pLast_) {
#ifndef SUPPRESS_WARNINGS
EXV_ERROR << "Entry in directory " << groupName(object->group())
<< "requests access to memory beyond the data buffer. "
<< "Skipping entry.\n";
<< "requests access to memory beyond the data buffer. Skipping entry.\n";
#endif
return;
}
Expand Down

0 comments on commit 52bf6ac

Please sign in to comment.