[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:39:30 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=ff47483

The following commit has been merged in the master branch:
commit ff47483e85d99a20bf409618ddfa5bd139252eb8
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Tue Jun 3 17:28:46 2008 +0000

    Mainly changes to make MSVC compilers happy, improved accuracy of GPS coordinates conversion.
---
 samples/xmpsample.cpp |   6 +--
 src/convert.cpp       | 113 ++++++++++++++++++++++++++------------------------
 src/tags.cpp          |   2 +-
 src/tags.hpp          |   2 +-
 src/types.cpp         |   4 +-
 5 files changed, 66 insertions(+), 61 deletions(-)

diff --git a/samples/xmpsample.cpp b/samples/xmpsample.cpp
index 7654134..f8b2993 100644
--- a/samples/xmpsample.cpp
+++ b/samples/xmpsample.cpp
@@ -60,16 +60,16 @@ try {
     assert(getv1.ok());
 
     const Exiv2::Value &getv2 = xmpData["Xmp.dc.two"].value();
-    assert(isEqual(getv2.toFloat(), 3.1415)); 
+    assert(isEqual(getv2.toFloat(), 3.1415f)); 
     assert(getv2.ok());
     assert(getv2.toLong() == 3);
     assert(getv2.ok());
     Exiv2::Rational R = getv2.toRational();
     assert(getv2.ok());
-    assert(isEqual(static_cast<float>(R.first) / R.second, 3.1415 ));
+    assert(isEqual(static_cast<float>(R.first) / R.second, 3.1415f ));
 
     const Exiv2::Value &getv3 = xmpData["Xmp.dc.three"].value();
-    assert(isEqual(getv3.toFloat(), 5.0/7.0)); 
+    assert(isEqual(getv3.toFloat(), 5.0f/7.0f)); 
     assert(getv3.ok());
     assert(getv3.toLong() == 0);  // long(5.0 / 7.0) 
     assert(getv3.ok());
diff --git a/src/convert.cpp b/src/convert.cpp
index f33edab..d767b11 100644
--- a/src/convert.cpp
+++ b/src/convert.cpp
@@ -41,6 +41,7 @@ EXIV2_RCSID("@(#) $Id$")
 // + standard includes
 #include <iostream>
 #include <iomanip>
+#include <sstream>
 
 // Adobe XMP Toolkit
 #ifdef EXV_HAVE_XMP_TOOLKIT
@@ -479,7 +480,7 @@ namespace Exiv2 {
         if (pos == exifData_->end()) return;
         if (!prepareXmpTarget(to)) return;
         int year, month, day, hour, min, sec;
-        std::string subsec = "";
+        std::string subsec;
         char buf[30];
 
         if (std::string(from) != "Exif.GPSInfo.GPSTimeStamp") {
@@ -519,8 +520,7 @@ namespace Exiv2 {
             sec = static_cast<int>(dsec);
             dsec -= sec;
 
-            snprintf(buf, sizeof(buf), "%.9f", dsec);
-            buf[sizeof(buf) - 1] = 0;
+            sprintf(buf, "%.9f", dsec);
             subsec = buf + 1;
 
             Exiv2::ExifData::iterator datePos = exifData_->findKey(ExifKey("Exif.GPSInfo.GPSDateStamp"));
@@ -546,7 +546,7 @@ namespace Exiv2 {
             }
         }
 
-        const char *subsecTag = 0;
+        const char* subsecTag = 0;
         if (std::string(from) == "Exif.Image.DateTime") {
             subsecTag = "Exif.Photo.SubSecTime";
         }
@@ -559,13 +559,16 @@ namespace Exiv2 {
 
         if (subsecTag) {
             Exiv2::ExifData::iterator subsec_pos = exifData_->findKey(ExifKey(subsecTag));
-            if (subsec_pos != exifData_->end() && !subsec_pos->value().toString().empty())
+            if (   subsec_pos != exifData_->end()
+                && !subsec_pos->value().toString().empty()) {
                 subsec = std::string(".") + subsec_pos->value().toString();
+            }
             if (erase_) exifData_->erase(subsec_pos);
         }
 
-        snprintf(buf, sizeof(buf), "%4d-%02d-%02dT%02d:%02d:%02d%s", year, month, day, hour, min, sec, subsec.c_str());
-        buf[sizeof(buf) - 1] = 0;
+        if (subsec.size() > 10) subsec = subsec.substr(0, 10);
+        sprintf(buf, "%4d-%02d-%02dT%02d:%02d:%02d%s",
+                year, month, day, hour, min, sec, subsec.c_str());
 
         (*xmpData_)[to] = buf;
         if (erase_) exifData_->erase(pos);
@@ -632,25 +635,34 @@ namespace Exiv2 {
             return;
         }
         Exiv2::ExifData::iterator refPos = exifData_->findKey(ExifKey(std::string(from) + "Ref"));
-        if (refPos == exifData_->end()) return;
-
-        double deg = pos->value().toFloat(0);
-        double min = pos->value().toFloat(1);
-        double sec = pos->value().toFloat(2);
-
-        sec = deg * 3600.0 + min * 60.0 + sec;
-
-        int ideg = static_cast<int>(sec / 3600.0);
-        sec -= ideg * 3600;
-        int imin = static_cast<int>(sec / 60.0);
-        sec -= imin * 60;
-
-        char buf[30];
-
-        snprintf(buf, sizeof(buf), "%d,%d,%.2f%c", ideg, imin, sec, refPos->value().toString().c_str()[0]);
-        buf[sizeof(buf) - 1] = 0;
+        if (refPos == exifData_->end()) {
+#ifndef SUPPRESS_WARNINGS
+            std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+#endif
+            return;
+        }
+        double deg[3];
+        for (int i = 0; i < 3; ++i) {
+            const int32_t z = pos->value().toRational(i).first;
+            const int32_t d = pos->value().toRational(i).second;
+            if (d == 0.0) {
+#ifndef SUPPRESS_WARNINGS
+                std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+#endif
+                return;
+            }
+            // Hack: Need Value::toDouble
+            deg[i] = static_cast<double>(z)/d;
+        }
+        double min = deg[0] * 60.0 + deg[1] + deg[2] / 60.0;
+        int ideg = static_cast<int>(min / 60.0);
+        min -= ideg * 60;
+        std::ostringstream oss;
+        oss << ideg << ","
+            << std::fixed << std::setprecision(7) << min
+            << refPos->value().toString().c_str()[0];
+        (*xmpData_)[to] = oss.str();
 
-        (*xmpData_)[to] = buf;
         if (erase_) exifData_->erase(pos);
         if (erase_) exifData_->erase(refPos);
     }
@@ -713,15 +725,13 @@ namespace Exiv2 {
 
 //          SXMPUtils::ConvertToLocalTime(&datetime);
 
-            snprintf(buf, sizeof(buf),
-                     "%4d:%02d:%02d %02d:%02d:%02d",
-                     static_cast<int>(datetime.year),
-                     static_cast<int>(datetime.month),
-                     static_cast<int>(datetime.day),
-                     static_cast<int>(datetime.hour),
-                     static_cast<int>(datetime.minute),
-                     static_cast<int>(datetime.second));
-            buf[sizeof(buf) - 1] = 0;
+            sprintf(buf, "%4d:%02d:%02d %02d:%02d:%02d",
+                    static_cast<int>(datetime.year),
+                    static_cast<int>(datetime.month),
+                    static_cast<int>(datetime.day),
+                    static_cast<int>(datetime.hour),
+                    static_cast<int>(datetime.minute),
+                    static_cast<int>(datetime.second));
             (*exifData_)[to] = buf;
 
             const char *subsecTag = 0;
@@ -739,27 +749,25 @@ namespace Exiv2 {
                 prepareExifTarget(subsecTag, true);
 
                 if (datetime.nanoSecond) {
-                    snprintf(buf, sizeof(buf), "%09d", static_cast<int>(datetime.nanoSecond));
+                    sprintf(buf, "%09d", static_cast<int>(datetime.nanoSecond));
                     (*exifData_)[subsecTag] = buf;
                 }
             }
         }
         else { // "Exif.GPSInfo.GPSTimeStamp"
-            Rational rhour = floatToRationalCast(datetime.hour);
-            Rational rmin = floatToRationalCast(datetime.minute);
-            Rational rsec = floatToRationalCast(static_cast<float>(datetime.second) + datetime.nanoSecond / 1000000000.0);
+            Rational rhour(datetime.hour, 1);
+            Rational rmin(datetime.minute, 1);
+            Rational rsec = floatToRationalCast(static_cast<float>(datetime.second) + datetime.nanoSecond / 1000000000.0f);
 
             std::ostringstream array;
             array << rhour << " " << rmin << " " << rsec;
             (*exifData_)[to] = array.str();
 
             prepareExifTarget("Exif.GPSInfo.GPSDateStamp", true);
-            snprintf(buf, sizeof(buf),
-                     "%4d:%02d:%02d",
-                     static_cast<int>(datetime.year),
-                     static_cast<int>(datetime.month),
-                     static_cast<int>(datetime.day));
-            buf[sizeof(buf) - 1] = 0;
+            sprintf(buf, "%4d:%02d:%02d",
+                    static_cast<int>(datetime.year),
+                    static_cast<int>(datetime.month),
+                    static_cast<int>(datetime.day));
             (*exifData_)["Exif.GPSInfo.GPSDateStamp"] = buf;
         }
 
@@ -885,7 +893,7 @@ namespace Exiv2 {
             return;
         }
 
-        float deg, min, sec;
+        double deg, min, sec;
         char ref, sep1, sep2;
 
         ref = value[value.length() - 1];
@@ -900,24 +908,21 @@ namespace Exiv2 {
         }
         else {
             sec = (min - static_cast<int>(min)) * 60.0;
-            min = static_cast<int>(min);
+            min = static_cast<double>(static_cast<int>(min));
             sep2 = ',';
         }
 
-        if (in.bad() ||
-            !(ref == 'N' || ref == 'S' || ref == 'E' || ref == 'W') ||
-            sep1 != ',' || sep2 != ',' ||
-            !in.eof()) {
+        if (   in.bad() || !(ref == 'N' || ref == 'S' || ref == 'E' || ref == 'W')
+            || sep1 != ',' || sep2 != ',' || !in.eof()) {
 #ifndef SUPPRESS_WARNINGS
             std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
 #endif
             return;
         }
 
-
-        Rational rdeg = floatToRationalCast(deg);
-        Rational rmin = floatToRationalCast(min);
-        Rational rsec = floatToRationalCast(sec);
+        Rational rdeg = floatToRationalCast(static_cast<float>(deg));
+        Rational rmin = floatToRationalCast(static_cast<float>(min));
+        Rational rsec = floatToRationalCast(static_cast<float>(sec));
 
         std::ostringstream array;
         array << rdeg << " " << rmin << " " << rsec;
diff --git a/src/tags.cpp b/src/tags.cpp
index 081ff49..c49f509 100644
--- a/src/tags.cpp
+++ b/src/tags.cpp
@@ -2082,7 +2082,7 @@ namespace Exiv2 {
 
         char s[5];
         for (int i = 0; i < 4; ++i) {
-            s[i] = value.toLong(i);
+            s[i] = static_cast<char>(value.toLong(i));
         }
         s[4] = '

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list