[mingw-taglib] Initial import (#1077935)

David King amigadave at fedoraproject.org
Fri Apr 25 12:42:08 UTC 2014


commit ddb6a61c52d7c61a4ff02254b52be1368d643fe2
Author: David King <amigadave at amigadave.com>
Date:   Fri Apr 25 13:41:32 2014 +0100

    Initial import (#1077935)

 .gitignore                                     |    1 +
 0002-Fixed-ABI-breakage-in-TagLib-String.patch |  107 +++++++++++++++++++
 0003-Rewrote-ByteVector-replace-simpler.patch  |  131 ++++++++++++++++++++++++
 mingw-taglib.spec                              |  116 +++++++++++++++++++++
 sources                                        |    1 +
 taglib-1.5rc1-multilib.patch                   |   20 ++++
 taglib-mingw.patch                             |   22 ++++
 7 files changed, 398 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..57c22aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/taglib-1.9.1.tar.gz
diff --git a/0002-Fixed-ABI-breakage-in-TagLib-String.patch b/0002-Fixed-ABI-breakage-in-TagLib-String.patch
new file mode 100644
index 0000000..930439f
--- /dev/null
+++ b/0002-Fixed-ABI-breakage-in-TagLib-String.patch
@@ -0,0 +1,107 @@
+From 3bf30af66c8fd77a88d9379a0956ddb2fc70dc20 Mon Sep 17 00:00:00 2001
+From: Tsuda Kageyu <tsuda.kageyu at gmail.com>
+Date: Wed, 6 Nov 2013 17:01:21 +0900
+Subject: [PATCH 2/6] Fixed ABI breakage in TagLib::String
+
+---
+ taglib/toolkit/tstring.cpp | 20 ++++++++++++++++++--
+ taglib/toolkit/tstring.h   | 12 ++++++++++--
+ tests/test_string.cpp      | 14 ++++++++++++++
+ 3 files changed, 42 insertions(+), 4 deletions(-)
+
+diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp
+index 75a9833..fb6e947 100644
+--- a/taglib/toolkit/tstring.cpp
++++ b/taglib/toolkit/tstring.cpp
+@@ -209,8 +209,16 @@ String::String(const std::string &s, Type t)
+ String::String(const wstring &s, Type t)
+   : d(new StringPrivate())
+ {
+-  if(t == UTF16 || t == UTF16BE || t == UTF16LE)
++  if(t == UTF16 || t == UTF16BE || t == UTF16LE) {
++    // This looks ugly but needed for the compatibility with TagLib1.8. 
++    // Should be removed in TabLib2.0.
++    if (t == UTF16BE)
++      t = WCharByteOrder;
++    else if (t == UTF16LE)
++      t = (WCharByteOrder == UTF16LE ? UTF16BE : UTF16LE);
++
+     copyFromUTF16(s.c_str(), s.length(), t);
++  }
+   else {
+     debug("String::String() -- A TagLib::wstring should not contain Latin1 or UTF-8.");
+   }
+@@ -219,8 +227,16 @@ String::String(const wstring &s, Type t)
+ String::String(const wchar_t *s, Type t)
+   : d(new StringPrivate())
+ {
+-  if(t == UTF16 || t == UTF16BE || t == UTF16LE)
++  if(t == UTF16 || t == UTF16BE || t == UTF16LE) {
++    // This looks ugly but needed for the compatibility with TagLib1.8. 
++    // Should be removed in TabLib2.0.
++    if (t == UTF16BE)
++      t = WCharByteOrder;
++    else if (t == UTF16LE)
++      t = (WCharByteOrder == UTF16LE ? UTF16BE : UTF16LE);
++
+     copyFromUTF16(s, ::wcslen(s), t);
++  }
+   else {
+     debug("String::String() -- A const wchar_t * should not contain Latin1 or UTF-8.");
+   }
+diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h
+index 57945be..605b9c2 100644
+--- a/taglib/toolkit/tstring.h
++++ b/taglib/toolkit/tstring.h
+@@ -134,13 +134,21 @@ namespace TagLib {
+ 
+     /*!
+      * Makes a deep copy of the data in \a s.
++     *
++     * /note If \a t is UTF16LE, the byte order of \a s will be swapped regardless 
++     * of the CPU byte order.  If UTF16BE, it will not be swapped.  This behavior
++     * will be changed in TagLib2.0.
+      */
+-    String(const wstring &s, Type t = WCharByteOrder);
++    String(const wstring &s, Type t = UTF16BE);
+ 
+     /*!
+      * Makes a deep copy of the data in \a s.
++     *
++     * /note If \a t is UTF16LE, the byte order of \a s will be swapped regardless 
++     * of the CPU byte order.  If UTF16BE, it will not be swapped.  This behavior
++     * will be changed in TagLib2.0.
+      */
+-    String(const wchar_t *s, Type t = WCharByteOrder);
++    String(const wchar_t *s, Type t = UTF16BE);
+ 
+     /*!
+      * Makes a deep copy of the data in \a c.
+diff --git a/tests/test_string.cpp b/tests/test_string.cpp
+index a815a0b..9a574b3 100644
+--- a/tests/test_string.cpp
++++ b/tests/test_string.cpp
+@@ -75,6 +75,20 @@ public:
+ 	String unicode3(L"\u65E5\u672C\u8A9E");
+ 	CPPUNIT_ASSERT(*(unicode3.toCWString() + 1) == L'\u672C');
+ 
++    String unicode4(L"\u65e5\u672c\u8a9e", String::UTF16BE);
++    CPPUNIT_ASSERT(unicode4[1] == L'\u672c');
++
++    String unicode5(L"\u65e5\u672c\u8a9e", String::UTF16LE);
++    CPPUNIT_ASSERT(unicode5[1] == L'\u2c67');
++
++    wstring stduni = L"\u65e5\u672c\u8a9e";
++
++    String unicode6(stduni, String::UTF16BE);
++    CPPUNIT_ASSERT(unicode6[1] == L'\u672c');
++
++    String unicode7(stduni, String::UTF16LE);
++    CPPUNIT_ASSERT(unicode7[1] == L'\u2c67');
++
+     CPPUNIT_ASSERT(strcmp(String::number(0).toCString(), "0") == 0);
+     CPPUNIT_ASSERT(strcmp(String::number(12345678).toCString(), "12345678") == 0);
+     CPPUNIT_ASSERT(strcmp(String::number(-12345678).toCString(), "-12345678") == 0);
+-- 
+1.8.4.2
+
diff --git a/0003-Rewrote-ByteVector-replace-simpler.patch b/0003-Rewrote-ByteVector-replace-simpler.patch
new file mode 100644
index 0000000..0b134ec
--- /dev/null
+++ b/0003-Rewrote-ByteVector-replace-simpler.patch
@@ -0,0 +1,131 @@
+From 4a7d31c87bf41c1de21cb725176d5b34c2a95720 Mon Sep 17 00:00:00 2001
+From: Tsuda Kageyu <tsuda.kageyu at gmail.com>
+Date: Thu, 14 Nov 2013 14:05:32 +0900
+Subject: [PATCH 3/6] Rewrote ByteVector::replace() simpler
+
+---
+ taglib/toolkit/tbytevector.cpp | 77 +++++++++++++++---------------------------
+ tests/test_bytevector.cpp      |  5 +++
+ 2 files changed, 33 insertions(+), 49 deletions(-)
+
+diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp
+index b658246..566a20f 100644
+--- a/taglib/toolkit/tbytevector.cpp
++++ b/taglib/toolkit/tbytevector.cpp
+@@ -31,6 +31,7 @@
+ #include <iostream>
+ #include <cstdio>
+ #include <cstring>
++#include <cstddef>
+ 
+ #include <tstring.h>
+ #include <tdebug.h>
+@@ -508,62 +509,40 @@ ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &wit
+   if(pattern.size() == 0 || pattern.size() > size())
+     return *this;
+ 
+-  const uint withSize = with.size();
+-  const uint patternSize = pattern.size();
+-  int offset = 0;
++  const size_t withSize    = with.size();
++  const size_t patternSize = pattern.size();
++  const ptrdiff_t diff = withSize - patternSize;
++  
++  size_t offset = 0;
++  while (true)
++  {
++    offset = find(pattern, offset);
++    if(offset == static_cast<size_t>(-1)) // Use npos in taglib2.
++      break;
+ 
+-  if(withSize == patternSize) {
+-    // I think this case might be common enough to optimize it
+     detach();
+-    offset = find(pattern);
+-    while(offset >= 0) {
+-      ::memcpy(data() + offset, with.data(), withSize);
+-      offset = find(pattern, offset + withSize);
+-    }
+-    return *this;
+-  }
+ 
+-  // calculate new size:
+-  uint newSize = 0;
+-  for(;;) {
+-    int next = find(pattern, offset);
+-    if(next < 0) {
+-      if(offset == 0)
+-        // pattern not found, do nothing:
+-        return *this;
+-      newSize += size() - offset;
+-      break;
++    if(diff < 0) {
++      ::memmove(
++        data() + offset + withSize, 
++        data() + offset + patternSize, 
++        size() - offset - patternSize);
++      resize(size() + diff);
+     }
+-    newSize += (next - offset) + withSize;
+-    offset = next + patternSize;
+-  }
+-
+-  // new private data of appropriate size:
+-  ByteVectorPrivate *newData = new ByteVectorPrivate(newSize, 0);
+-  char *target = DATA(newData);
+-  const char *source = data();
+-
+-  // copy modified data into new private data:
+-  offset = 0;
+-  for(;;) {
+-    int next = find(pattern, offset);
+-    if(next < 0) {
+-      ::memcpy(target, source + offset, size() - offset);
+-      break;
++    else if(diff > 0) {
++      resize(size() + diff);
++      ::memmove(
++        data() + offset + withSize, 
++        data() + offset + patternSize, 
++        size() - diff - offset - patternSize);
+     }
+-    int chunkSize = next - offset;
+-    ::memcpy(target, source + offset, chunkSize);
+-    target += chunkSize;
+-    ::memcpy(target, with.data(), withSize);
+-    target += withSize;
+-    offset += chunkSize + patternSize;
+-  }
+ 
+-  // replace private data:
+-  if(d->deref())
+-    delete d;
++    ::memcpy(data() + offset, with.data(), with.size());
+ 
+-  d = newData;
++    offset += withSize;
++    if(offset > size() - patternSize)
++      break;
++  }
+ 
+   return *this;
+ }
+diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp
+index 9efd23a..eca74f8 100644
+--- a/tests/test_bytevector.cpp
++++ b/tests/test_bytevector.cpp
+@@ -239,6 +239,11 @@ public:
+       a.replace(ByteVector("ab"), ByteVector());
+       CPPUNIT_ASSERT_EQUAL(ByteVector("cdf"), a);
+     }
++    {
++      ByteVector a("abcdabf");
++      a.replace(ByteVector("bf"), ByteVector("x"));
++      CPPUNIT_ASSERT_EQUAL(ByteVector("abcdax"), a);
++    }
+   }
+ 
+ };
+-- 
+1.8.4.2
+
diff --git a/mingw-taglib.spec b/mingw-taglib.spec
new file mode 100644
index 0000000..ed56e0a
--- /dev/null
+++ b/mingw-taglib.spec
@@ -0,0 +1,116 @@
+%{?mingw_package_header}
+
+%global _basename taglib
+
+%bcond_without tests
+
+Name:       mingw-%{_basename}
+Summary:    Audio Meta-Data Library
+Version:    1.9.1
+Release:    3%{?dist}
+
+License:    LGPLv2 or MPLv1.1
+URL:        http://taglib.github.com/
+Source0:    https://github.com/%{_basename}/%{_basename}/releases/download/v%{version}/%{_basename}-%{version}.tar.gz
+Patch0:     taglib-mingw.patch
+Patch1:     taglib-1.5rc1-multilib.patch
+
+## upstream patches
+Patch1002:  0002-Fixed-ABI-breakage-in-TagLib-String.patch
+Patch1003:  0003-Rewrote-ByteVector-replace-simpler.patch
+
+BuildArch:      noarch
+
+BuildRequires:  mingw32-filesystem >= 95
+BuildRequires:  mingw32-gcc
+BuildRequires:  mingw32-gcc-c++
+BuildRequires:  mingw32-zlib
+
+BuildRequires:  mingw64-filesystem >= 95
+BuildRequires:  mingw64-gcc
+BuildRequires:  mingw64-gcc-c++
+BuildRequires:  mingw64-zlib
+
+BuildRequires:  cmake
+%if %{with tests}
+#BuildRequires: cppunit-devel
+%endif
+
+%description
+TagLib is a library for reading and editing the meta-data of several
+popular audio formats. Currently it supports both ID3v1 and ID3v2 for MP3
+files, Ogg Vorbis comments and ID3 tags and Vorbis comments in FLAC, MPC,
+Speex, WavPack, TrueAudio files, as well as APE Tags.
+
+
+%package -n mingw32-%{_basename}
+Summary: MinGW Windows version of TagLib for the win32 target
+Group: Development/Libraries
+
+%description -n mingw32-%{_basename}
+TagLib is a library for reading and editing the meta-data of several
+popular audio formats.
+This is the MinGW version, built for the win32 target.
+
+%package -n mingw64-%{_basename}
+Summary: MinGW Windows version of TagLib for the win64 target
+Group: Development/Libraries
+
+%description -n mingw64-%{_basename}
+TagLib is a library for reading and editing the meta-data of several
+popular audio formats.
+This is the MinGW version, built for the win64 target.
+
+
+%{?mingw_debug_package}
+
+
+%prep
+%setup -q -n %{_basename}-%{version}
+%patch0 -p1
+%patch1 -p1 -b .multilib
+
+%patch1002 -p1 -b .0002
+%patch1003 -p1 -b .0003
+
+
+%build
+%{mingw_cmake} \
+  %{?with_tests:-DBUILD_TESTS:BOOL=ON} \
+  ..
+%{mingw_make} %{?_smp_mflags}
+
+
+%install
+%{mingw_make} install/fast DESTDIR=%{buildroot}
+
+
+%files -n mingw32-%{_basename}
+%doc AUTHORS COPYING.LGPL COPYING.MPL NEWS
+%{mingw32_bindir}/libtag.dll
+%{mingw32_bindir}/libtag_c.dll
+%{mingw32_bindir}/taglib-config.cmd
+%{mingw32_includedir}/taglib/
+%{mingw32_libdir}/libtag.dll.a
+%{mingw32_libdir}/libtag_c.dll.a
+%{mingw32_libdir}/pkgconfig/taglib.pc
+%{mingw32_libdir}/pkgconfig/taglib_c.pc
+
+%files -n mingw64-%{_basename}
+%doc AUTHORS COPYING.LGPL COPYING.MPL NEWS
+%{mingw64_bindir}/libtag.dll
+%{mingw64_bindir}/libtag_c.dll
+%{mingw64_bindir}/taglib-config.cmd
+%{mingw64_includedir}/taglib/
+%{mingw64_libdir}/libtag.dll.a
+%{mingw64_libdir}/libtag_c.dll.a
+%{mingw64_libdir}/pkgconfig/taglib.pc
+%{mingw64_libdir}/pkgconfig/taglib_c.pc
+
+
+%changelog
+* Fri Apr 25 2014 David King <amigadave at amigadave.com> 1.9.1-3
+- Update to 1.9.1-3 from Fedora (#1077935)
+
+* Fri May 17 2013 Steven Boswell <ulatekh at yahoo.com> 1.8-3.20121215git
+- Ported Fedora package to MinGW
diff --git a/sources b/sources
index e69de29..c2b4dc3 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+0d35df96822bbd564c5504cb3c2e4d86  taglib-1.9.1.tar.gz
diff --git a/taglib-1.5rc1-multilib.patch b/taglib-1.5rc1-multilib.patch
new file mode 100644
index 0000000..4f0cb40
--- /dev/null
+++ b/taglib-1.5rc1-multilib.patch
@@ -0,0 +1,20 @@
+diff -up taglib-1.5rc1/taglib-config.cmake.multilib-2 taglib-1.5rc1/taglib-config.cmake
+--- taglib-1.5rc1/taglib-config.cmake.multilib-2	2008-01-29 19:30:00.000000000 -0600
++++ taglib-1.5rc1/taglib-config.cmake	2008-02-13 06:41:11.000000000 -0600
+@@ -16,7 +16,6 @@ EOH
+ 
+ prefix=${CMAKE_INSTALL_PREFIX}
+ exec_prefix=${CMAKE_INSTALL_PREFIX}
+-libdir=${LIB_INSTALL_DIR}
+ includedir=${INCLUDE_INSTALL_DIR}
+ 
+ flags=""
+@@ -29,7 +28,7 @@ while test $# -gt 0
+ do
+   case $1 in
+     --libs)
+-	  flags="$flags -L$libdir -ltag"
++	  flags="$flags -ltag"
+ 	  ;;
+     --cflags)
+ 	  flags="$flags -I$includedir/taglib"
diff --git a/taglib-mingw.patch b/taglib-mingw.patch
new file mode 100644
index 0000000..fac3aea
--- /dev/null
+++ b/taglib-mingw.patch
@@ -0,0 +1,22 @@
+--- taglib-1.8-orig/bindings/c/CMakeLists.txt	2012-11-27 15:54:08.000000000 -0700
++++ taglib-1.8/bindings/c/CMakeLists.txt	2013-05-15 10:26:53.733323191 -0700
+@@ -61,7 +61,7 @@
+ 	PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/taglib
+ )
+ 
+-if(NOT WIN32 AND NOT BUILD_FRAMEWORK)
++if((MINGW OR NOT WIN32) AND NOT BUILD_FRAMEWORK)
+ 	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/taglib_c.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib_c.pc)
+ 	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/taglib_c.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+ endif()
+--- taglib-1.8-orig/CMakeLists.txt	2012-11-27 15:54:08.000000000 -0700
++++ taglib-1.8/CMakeLists.txt	2013-05-15 10:26:47.661551500 -0700
+@@ -76,7 +76,7 @@
+   install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/taglib-config.cmd DESTINATION ${BIN_INSTALL_DIR})
+ endif()
+ 
+-if(NOT WIN32 AND NOT BUILD_FRAMEWORK)
++if((MINGW OR NOT WIN32) AND NOT BUILD_FRAMEWORK)
+   configure_file(${CMAKE_CURRENT_SOURCE_DIR}/taglib.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib.pc )
+   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/taglib.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+ endif()


More information about the scm-commits mailing list