strcmp to == conversions

Does the same thing.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago
parent d5e42da39e
commit e74feff4d8

@ -1475,7 +1475,7 @@ int FixIso::run(const std::string& path) {
}
auto md = Exiv2::isoSpeed(exifData);
if (md != exifData.end()) {
if (strcmp(md->key().c_str(), "Exif.Photo.ISOSpeedRatings") == 0) {
if (md->key() == "Exif.Photo.ISOSpeedRatings") {
if (Params::instance().verbose_) {
std::cout << _("Standard Exif ISO tag exists; not modified\n");
}

@ -1182,7 +1182,7 @@ int64_t parseCommonTargets(const std::string& optArg, const std::string& action)
break;
case 'p': {
if (strcmp(action.c_str(), "extract") == 0) {
if (action == "extract") {
i += static_cast<size_t>(
parsePreviewNumbers(Params::instance().previewNumbers_, optArg, static_cast<int>(i) + 1));
target |= Params::ctPreview;

@ -568,9 +568,8 @@ void IptcKey::decomposeKey() {
auto posDot2 = key_.find('.', posDot1 + 1);
const std::string familyName = key_.substr(0, posDot1);
if (0 != strcmp(familyName.c_str(), familyName_)) {
if (familyName != familyName_)
throw Error(ErrorCode::kerInvalidKey, key_);
}
std::string recordName = key_.substr(posDot1 + 1, posDot2 - posDot1 - 1);
std::string dataSetName = key_.substr(posDot2 + 1);

@ -100,7 +100,7 @@ ExifData::const_iterator isoSpeed(const ExifData& ed) {
iso_val = parseInt64(os.str(), ok);
if (ok && iso_val > 0)
break;
while (strcmp(keys[idx++], md->key().c_str()) != 0 && idx < cnt) {
while (md->key() != keys[idx++] && idx < cnt) {
}
md = ed.end();
}
@ -139,7 +139,7 @@ ExifData::const_iterator isoSpeed(const ExifData& ed) {
md = md_st;
break;
}
while (strcmp(sensKeys->keys[idx++], md_st->key().c_str()) != 0 && idx < sensKeys->count) {
while (md_st->key() != sensKeys->keys[idx++] && idx < sensKeys->count) {
}
}
break;

@ -18,7 +18,7 @@ namespace {
struct XmpPrintInfo {
//! Comparison operator for key
bool operator==(const std::string& key) const {
return 0 == strcmp(key_, key.c_str());
return key == key_;
}
const char* key_; //!< XMP key
@ -4889,9 +4889,8 @@ void XmpProperties::registerNs(const std::string& ns, const std::string& prefix)
const XmpNsInfo* xnp = lookupNsRegistryUnsafe(XmpNsInfo::Prefix(prefix));
if (xnp) {
#ifndef SUPPRESS_WARNINGS
if (strcmp(xnp->ns_, ns2.c_str()) != 0) {
if (ns2 != xnp->ns_)
EXV_WARNING << "Updating namespace URI for " << prefix << " from " << xnp->ns_ << " to " << ns2 << "\n";
}
#endif
unregisterNsUnsafe(xnp->ns_);
}
@ -4998,7 +4997,7 @@ const XmpPropertyInfo* XmpProperties::propertyInfo(const XmpKey& key) {
return nullptr;
const XmpPropertyInfo* pi = nullptr;
for (int j = 0; pl[j].name_; ++j) {
if (0 == strcmp(pl[j].name_, property.c_str())) {
if (property == pl[j].name_) {
pi = pl + j;
break;
}
@ -5158,26 +5157,21 @@ std::string XmpKey::ns() const {
void XmpKey::Impl::decomposeKey(const std::string& key) {
// Get the family name, prefix and property name parts of the key
std::string::size_type pos1 = key.find('.');
if (pos1 == std::string::npos) {
if (pos1 == std::string::npos)
throw Error(ErrorCode::kerInvalidKey, key);
}
std::string familyName = key.substr(0, pos1);
if (0 != strcmp(familyName.c_str(), familyName_)) {
if (familyName != familyName_)
throw Error(ErrorCode::kerInvalidKey, key);
}
std::string::size_type pos0 = pos1 + 1;
pos1 = key.find('.', pos0);
if (pos1 == std::string::npos) {
if (pos1 == std::string::npos)
throw Error(ErrorCode::kerInvalidKey, key);
}
std::string prefix = key.substr(pos0, pos1 - pos0);
if (prefix.empty()) {
if (prefix.empty())
throw Error(ErrorCode::kerInvalidKey, key);
}
std::string property = key.substr(pos1 + 1);
if (property.empty()) {
if (property.empty())
throw Error(ErrorCode::kerInvalidKey, key);
}
// Validate prefix
if (XmpProperties::ns(prefix).empty())

@ -77,7 +77,7 @@ bool GroupInfo::operator==(IfdId ifdId) const {
}
bool GroupInfo::operator==(const GroupName& groupName) const {
return 0 == strcmp(groupName.g_.c_str(), groupName_);
return groupName.g_ == groupName_;
}
const char* ExifTags::sectionName(const ExifKey& key) {
@ -198,9 +198,8 @@ void ExifKey::Impl::decomposeKey(const std::string& key) {
if (pos1 == std::string::npos)
throw Error(ErrorCode::kerInvalidKey, key);
std::string familyName = key.substr(0, pos1);
if (0 != strcmp(familyName.c_str(), familyName_)) {
if (familyName != familyName_)
throw Error(ErrorCode::kerInvalidKey, key);
}
std::string::size_type pos0 = pos1 + 1;
pos1 = key.find('.', pos0);
if (pos1 == std::string::npos)

@ -24,8 +24,8 @@ uint32_t fillGap(Exiv2::Internal::IoWrapper& ioWrapper, uint32_t curr, uint32_t
// class member definitions
namespace Exiv2::Internal {
bool TiffMappingInfo::operator==(const TiffMappingInfo::Key& key) const {
return (0 == strcmp("*", make_) || 0 == strncmp(make_, key.m_.c_str(), strlen(make_))) &&
(Tag::all == extendedTag_ || key.e_ == extendedTag_) && key.g_ == group_;
return (0 == strcmp("*", make_) || key.m_ == make_) && (Tag::all == extendedTag_ || key.e_ == extendedTag_) &&
key.g_ == group_;
}
IoWrapper::IoWrapper(BasicIo& io, const byte* pHeader, size_t size, OffsetWriter* pow) :

@ -27,7 +27,7 @@ class FindExifdatum2 {
}
//! Returns true if group and index match.
bool operator()(const Exiv2::Exifdatum& md) const {
return idx_ == md.idx() && 0 == strcmp(md.groupName().c_str(), groupName_);
return idx_ == md.idx() && md.groupName() == groupName_;
}
private:
@ -38,9 +38,9 @@ class FindExifdatum2 {
Exiv2::ByteOrder stringToByteOrder(const std::string& val) {
Exiv2::ByteOrder bo = Exiv2::invalidByteOrder;
if (0 == strcmp("II", val.c_str()))
if (val == "II")
bo = Exiv2::littleEndian;
else if (0 == strcmp("MM", val.c_str()))
else if (val == "MM")
bo = Exiv2::bigEndian;
return bo;

@ -31,7 +31,7 @@ struct TypeInfoTable {
}
//! Comparison operator for \em name
bool operator==(const std::string& name) const {
return 0 == strcmp(name_, name.c_str());
return name == name_;
}
}; // struct TypeInfoTable

Loading…
Cancel
Save