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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:41:06 UTC 2017


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

The following commit has been merged in the master branch:
commit 3a76ca8ad77ac634546b21068a5aa5719dd6fbb2
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Tue Jan 12 16:29:10 2010 +0000

    #662: Mostly formatting changes and a few tweaks. Move exifcomment tests to bugfixes-test.sh
---
 src/exiv2.cpp                     | 131 +++++++++++++++++++-------------------
 src/value.cpp                     | 118 +++++++++++++++++-----------------
 src/value.hpp                     |  38 +++++------
 test/bugfixes-test.sh             |  43 +++++++++++++
 test/exifcomment-encoding-test.sh |  37 -----------
 5 files changed, 189 insertions(+), 178 deletions(-)

diff --git a/src/exiv2.cpp b/src/exiv2.cpp
index a6e5d15..b766a12 100644
--- a/src/exiv2.cpp
+++ b/src/exiv2.cpp
@@ -118,7 +118,7 @@ namespace {
      */
     bool parseLine(ModifyCmd& modifyCmd,
                    const std::string& line, int num);
-    
+
     /*!
       @brief Parses a string containing backslash-escapes
       @param input Input string, assumed to be UTF-8
@@ -1119,78 +1119,81 @@ namespace {
         std::string result = "";
         for (unsigned int i = 0; i < input.length(); ++i) {
             char ch = input[i];
-            if (ch == '\') {
-                int escapeStart = i;
-                if (input.length() - 1 > i) {
-                    ++i;
-                    ch = input[i];
-                    switch (ch) {
-                        // Escaping of backslash
-                        case '\':
-                        result.push_back('\');
-                        break;
-                        
-                        // Escaping of newline
-                        case 'n':
-                        result.push_back('
');
-                        break;
-                        
-                        // Escaping of tab
-                        case 't':
-                        result.push_back('	');
-                        break;
-                        
-                        // Escaping of unicode
-                        case 'u':
-                        if (input.length() - 4 > i) {
-                            int acc = 0;
-                            for (int j = 0; j < 4; ++j) {
-                                ++i;
-                                acc <<= 4;
-                                if (input[i] >= '0' && input[i] <= '9') {
-                                    acc |= input[i] - '0';
-                                } else if (input[i] >= 'a' && input[i] <= 'f') {
-                                    acc |= input[i] - 'a' + 10;
-                                } else if (input[i] >= 'A' && input[i] <= 'F') {
-                                    acc |= input[i] - 'A' + 10;
-                                } else {
-                                    acc = -1;
-                                    break;
-                                }
-                            }
-                            if (acc == -1) {
-                                result.push_back('\');
-                                i = escapeStart;
-                                break;
-                            }
-                            
-                            std::string ucs2toUtf8 = "";
-                            ucs2toUtf8.push_back((char) ((acc & 0xff00) >> 8));
-                            ucs2toUtf8.push_back((char) (acc & 0x00ff));
-                            
-                            if (Exiv2::convertStringCharset (ucs2toUtf8, "UCS-2BE", "UTF-8")) {
-                                result.append (ucs2toUtf8);
-                            }
-                        } else {
-                            result.push_back('\');
-                            result.push_back(ch);
+            if (ch != '\') {
+                result.push_back(ch);
+                continue;
+            }
+            int escapeStart = i;
+            if (!(input.length() - 1 > i)) {
+                result.push_back(ch);
+                continue;
+            }
+            ++i;
+            ch = input[i];
+            switch (ch) {
+            // Escaping of backslash
+            case '\':
+                result.push_back('\');
+                break;
+
+            // Escaping of newline
+            case 'n':
+                result.push_back('
');
+                break;
+
+            // Escaping of tab
+            case 't':
+                result.push_back('	');
+                break;
+                    
+            // Escaping of unicode
+            case 'u':
+                if (input.length() - 4 > i) {
+                    int acc = 0;
+                    for (int j = 0; j < 4; ++j) {
+                        ++i;
+                        acc <<= 4;
+                        if (input[i] >= '0' && input[i] <= '9') {
+                            acc |= input[i] - '0';
                         }
-                        break;
-                        
-                        default:
+                        else if (input[i] >= 'a' && input[i] <= 'f') {
+                            acc |= input[i] - 'a' + 10;
+                        }
+                        else if (input[i] >= 'A' && input[i] <= 'F') {
+                            acc |= input[i] - 'A' + 10;
+                        }
+                        else {
+                            acc = -1;
+                            break;
+                        }
+                    }
+                    if (acc == -1) {
                         result.push_back('\');
-                        result.push_back(ch);
+                        i = escapeStart;
+                        break;
+                    }
+
+                    std::string ucs2toUtf8 = "";
+                    ucs2toUtf8.push_back((char) ((acc & 0xff00) >> 8));
+                    ucs2toUtf8.push_back((char) (acc & 0x00ff));
+
+                    if (Exiv2::convertStringCharset (ucs2toUtf8, "UCS-2BE", "UTF-8")) {
+                        result.append (ucs2toUtf8);
                     }
-                } else {
+                }
+                else {
+                    result.push_back('\');
                     result.push_back(ch);
                 }
-            } else {
+                break;
+
+            default:
+                result.push_back('\');
                 result.push_back(ch);
             }
         }
-        
         return result;
     }
-    
+
 }
         
diff --git a/src/value.cpp b/src/value.cpp
index 9da69c8..7715b35 100644
--- a/src/value.cpp
+++ b/src/value.cpp
@@ -467,6 +467,7 @@ namespace Exiv2 {
             if (name[name.length()-1] == '"') name = name.substr(0, name.length()-1);
             charsetId_ = CharsetInfo::charsetIdByName(name);
             if (charsetId_ == invalidCharsetId) {
+                charsetId_ = undefined;
 #ifndef SUPPRESS_WARNINGS
                 std::cerr << "Warning: " << Error(28, name) << "
";
 #endif
@@ -476,44 +477,44 @@ namespace Exiv2 {
             if (pos != std::string::npos) c = comment.substr(pos+1);
         }
         value_ = c;
-        
         return 0;
     }
-    
+
     int CommentValue::read(const byte* buf, long len, ByteOrder byteOrder)
     {
-        if (buf) {
-            std::string rawValue = std::string(reinterpret_cast<const char*>(buf), len);
-            if (rawValue.length() < 8) {
-                return 0;
+        if (!buf || len == 0) {
+            return 0;
+        }
+        std::string rawValue(reinterpret_cast<const char*>(buf), len);
+        if (rawValue.length() < 8) {
+            return 0;
+        }
+        charsetId_ = CharsetInfo::charsetIdByCode(rawValue.substr(0, 8));
+        value_ = rawValue.substr(8);
+        switch (charsetId_) {
+        case unicode:
+            if (byteOrder == littleEndian) {
+                Exiv2::convertStringCharset(value_, "UCS-2LE", "UTF-8");
             }
-            charsetId_ = CharsetInfo::charsetIdByCode(rawValue.substr(0, 8));
-            value_ = std::string(rawValue.substr(8));
-            switch (charsetId_) {
-                case unicode:
-                if (byteOrder == littleEndian) {
-                    Exiv2::convertStringCharset(value_, "UCS-2LE", "UTF-8");
-                } else {
-                    Exiv2::convertStringCharset(value_, "UCS-2BE", "UTF-8");
-                }
-                break;
-                
-                case ascii:
-                break;
-                
-                case jis:
-                // The Exif 2.2 specification mentions JIS X 208-1990 as the
-                // encoding for "jis". The problem is that JIS X 208-1990 isn't
-                // a character encoding - that is, it doesn't specify how to
-                // encode a character set into bytes. Candidates (iconv names) are: 
-                // EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-2 and ISO-2022-JP-1. 
-                // Pending a definitive resolution to this, we'll just leave any JIS 
-                // comment as we found it.
-                break;
-                
-                default:
-                break;
+            else {
+                Exiv2::convertStringCharset(value_, "UCS-2BE", "UTF-8");
             }
+            break;
+        case ascii:
+        case undefined:
+        case jis:
+            // JIS: The Exif 2.2 specification mentions JIS X 208-1990 as the
+            // encoding for "jis". The problem is that JIS X 208-1990 isn't
+            // a character encoding - that is, it doesn't specify how to
+            // encode a character set into bytes. Candidates (iconv names) are: 
+            // EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-2 and ISO-2022-JP-1. 
+            // Pending a definitive resolution to this, we'll just leave any JIS 
+            // comment as we found it.
+            break;
+        case invalidCharsetId:
+        case lastCharsetId:
+            charsetId_ = undefined;
+            break;
         }
         return 0;
     }
@@ -523,48 +524,49 @@ namespace Exiv2 {
         if (charsetId_ != undefined) {
             os << "charset=\"" << CharsetInfo::name(charsetId_) << "\" ";
         }
-        return os << comment();
+        return os << value_;
     }
-    
+
     long CommentValue::copy(byte* buf, ByteOrder byteOrder) const
     {
-        std::string encoded = encode (byteOrder);
-        memcpy(buf, encoded.c_str(), encoded.length());
+        std::string encoded = encode(byteOrder);
+        memcpy(buf, encoded.data(), encoded.length());
         return encoded.length();
     }
-    
+
     long CommentValue::count() const
     {
-        return encode(littleEndian).length();
+        return size();
     }
-    
+
     long CommentValue::size() const 
     {
         return encode(littleEndian).length();
     }
-    
+
     std::string CommentValue::encode(ByteOrder byteOrder) const
     {
-        std::string result = "";
-        result.append (std::string(CharsetInfo::code(charsetId()), 8));				
-        switch (charsetId()) {
-            case unicode: {
-                std::string copyOfComment = std::string(comment());
-                if (byteOrder == littleEndian) {
-                    Exiv2::convertStringCharset(copyOfComment, "UTF-8", "UCS-2LE");
-                } else {
-                    Exiv2::convertStringCharset(copyOfComment, "UTF-8", "UCS-2BE");
-                }
-                
-                result.append (copyOfComment);
-                return result;
+        std::string result(CharsetInfo::code(charsetId_), 8);
+        switch (charsetId_) {
+        case unicode: {
+            std::string copyOfComment = value_;
+            if (byteOrder == littleEndian) {
+                Exiv2::convertStringCharset(copyOfComment, "UTF-8", "UCS-2LE");
+            }
+            else {
+                Exiv2::convertStringCharset(copyOfComment, "UTF-8", "UCS-2BE");
             }
-            
-            default:
-                result.append (comment());
-                return result;
+            result.append(copyOfComment);
+            break;
+        }
+        case ascii:
+        case jis:
+        case undefined:
+        case invalidCharsetId:
+        case lastCharsetId:
+            result.append(value_);
+            break;
         }
-        
         return result;
     }
 
diff --git a/src/value.hpp b/src/value.hpp
index b04af13..7bd51f8 100644
--- a/src/value.hpp
+++ b/src/value.hpp
@@ -508,10 +508,12 @@ namespace Exiv2 {
     /*!
       @brief %Value for an Exif comment.
 
-      This can be a plain Ascii string or a multipe byte encoded string. The
-      comment is expected to be encoded in the character set indicated (default
-      undefined), but this is not checked. It is left to caller to decode and
-      encode the string to and from readable text if that is required.
+      The Exif specification provides several charset specifiers to indicate
+      the encoding of the comment string. If charset is 
-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list