From 23f39b60f709e4e08d47a644ddfdde44dbf51cc2 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 14 Dec 2020 10:31:32 +0000 Subject: [PATCH] Fixing test suite. --- src/actions.cpp | 12 ++++++++++-- src/exif.cpp | 12 ------------ src/tags_int.cpp | 17 ++++++++++++++--- src/tags_int.hpp | 2 ++ test/data/exifdata-test.out | 8 ++++---- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index a6f885a1..9cffc7dc 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -599,8 +599,16 @@ namespace Action { std::cout << " "; first = false; std::ostringstream os; - // #1114 - show negative values for SByte - if (md.typeId() == Exiv2::signedByte) { + // 1431 always translate "comment" tags to show charset= + // sadly md.key() cannot access tagInfo.typeId_ (== comment) + Exiv2::StringSet commentTags; + commentTags.insert("Exif.Photo.UserComment"); + commentTags.insert("Exif.GPSInfo.GPSProcessingMethod"); + commentTags.insert("Exif.GPSInfo.GPSAreaInformation"); + if ( commentTags.find(md.key()) != commentTags.end() ) { + os << md.print(&pImage->exifData()); + } else if (md.typeId() == Exiv2::signedByte) { + // #1114 - show negative values for SByte for ( int c = 0 ; c < md.value().count() ; c++ ) { int value = md.value().toLong(c); os << (c?" ":"") << std::dec << (value < 128 ? value : value - 256); diff --git a/src/exif.cpp b/src/exif.cpp index 78c8ae08..04e6d763 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -225,18 +225,6 @@ namespace Exiv2 { // be careful with comments (User.Photo.UserComment, GPSAreaInfo etc). if ( ti ) { fct = ti->printFct_; - if ( ti->typeId_ == comment ) { - fct=NULL; - const Exiv2::CommentValue* cv = dynamic_cast(&value()); - Exiv2::CommentValue::CharsetId csId = cv->charsetId(); - if ( csId != CommentValue::undefined ) { - os << "charset=" << CommentValue::CharsetInfo::name(csId) << " "; - } - os << cv->comment(); -#if 0 - os << "|| value().toString() = " << value().toString(); -#endif - } } if ( fct ) fct(os, value(), pMetadata); return os; diff --git a/src/tags_int.cpp b/src/tags_int.cpp index 1f9499fa..4c9563aa 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -1776,7 +1776,7 @@ namespace Exiv2 { N_("A tag for Exif users to write keywords or comments on the image " "besides those in , and without the " "character code limitations of the tag."), - exifId, userInfo, comment, 0, printValue), + exifId, userInfo, comment, 0, printComment), TagInfo(0x9290, "SubSecTime", N_("Sub-seconds Time"), N_("A tag used to record fractions of seconds for the tag."), exifId, dateTime, asciiString, 0, printValue), @@ -2204,11 +2204,11 @@ namespace Exiv2 { TagInfo(0x001b, "GPSProcessingMethod", N_("GPS Processing Method"), N_("A character string recording the name of the method used for location finding. " "The string encoding is defined using the same scheme as UserComment."), - gpsId, gpsTags, comment, 0, printValue), + gpsId, gpsTags, comment, 0, printComment), TagInfo(0x001c, "GPSAreaInformation", N_("GPS Area Information"), N_("A character string recording the name of the GPS area." "The string encoding is defined using the same scheme as UserComment."), - gpsId, gpsTags, comment, 0, printValue), + gpsId, gpsTags, comment, 0, printComment), TagInfo(0x001d, "GPSDateStamp", N_("GPS Date Stamp"), N_("A character string recording date and time information relative to UTC " "(Coordinated Universal Time). The format is \"YYYY:MM:DD.\"."), @@ -2461,6 +2461,17 @@ namespace Exiv2 { return os << value; } + std::ostream& printComment(std::ostream& os, const Value& value, const ExifData*) + { + const Exiv2::CommentValue* cv = dynamic_cast(&value); + Exiv2::CommentValue::CharsetId csId = cv->charsetId(); + if ( csId != CommentValue::undefined ) { + os << "charset=" << CommentValue::CharsetInfo::name(csId) << " "; + } + os << cv->comment(); + return os ; + } + std::ostream& printBitmask(std::ostream& os, const Value& value, const ExifData* metadata) { if (value.typeId() == Exiv2::unsignedShort || value.typeId() == Exiv2::signedShort) diff --git a/src/tags_int.hpp b/src/tags_int.hpp index 694624cc..cbd22c4f 100644 --- a/src/tags_int.hpp +++ b/src/tags_int.hpp @@ -362,6 +362,8 @@ namespace Exiv2 { //@{ //! Default print function, using the Value output operator std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*); + //! Print the value of a comment + std::ostream& printComment(std::ostream& os, const Value& value, const ExifData*); //! Print the value converted to a long std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*); //! Print a Rational or URational value in floating point format diff --git a/test/data/exifdata-test.out b/test/data/exifdata-test.out index 2605f0e2..1cc1479c 100644 --- a/test/data/exifdata-test.out +++ b/test/data/exifdata-test.out @@ -819,7 +819,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii +Exif.Photo.UserComment 0x9286 Exif Undefined 44 Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -990,7 +990,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii +Exif.Photo.UserComment 0x9286 Exif Undefined 44 Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -1162,7 +1162,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii +Exif.Photo.UserComment 0x9286 Exif Undefined 44 Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -1334,7 +1334,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii +Exif.Photo.UserComment 0x9286 Exif Undefined 44 Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00