Commit b26be803 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

Contribs: update taglib to 1.10beta

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 9e03d0fb
From 4a7d31c87bf41c1de21cb725176d5b34c2a95720 Mon Sep 17 00:00:00 2001
From: Tsuda Kageyu <tsuda.kageyu@gmail.com>
Date: Thu, 14 Nov 2013 14:05:32 +0900
Subject: [PATCH 2/3] 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.5.2
63a4f06b88b33be716dde3111e62a624995bc020127c9d22f63e918a535ebba858c59308ca4295eeedb29dc72b87d6673db5483f20d9dbf3f56cd93c7ba7ed58 taglib-1.9.1.tar.gz
881b3dc3bee27f199f8a7eefc5a4e35a69555c5244eb5cb34856e733b1e4f33fd3085e0608c7b128c247a71b407faedd488902dee5e632858c610d8f7b7ee67c taglib-1.10beta.tar.gz
--- tablib_orig/taglib/toolkit/trefcounter.h 2015-10-09 14:09:14.162193621 +0200
+++ taglib/taglib/toolkit/trefcounter.h 2015-10-09 14:39:37.009992159 +0200
@@ -29,21 +29,13 @@
#include "taglib_export.h"
#include "taglib.h"
-#ifdef __APPLE__
+#if defined(HAVE_MAC_ATOMIC)
# include <libkern/OSAtomic.h>
-# define TAGLIB_ATOMIC_MAC
-#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#elif defined(HAVE_WIN_ATOMIC)
# define NOMINMAX
# include <windows.h>
-# define TAGLIB_ATOMIC_WIN
-#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \
- && (defined(__i386__) || defined(__i486__) || defined(__i586__) || \
- defined(__i686__) || defined(__x86_64) || defined(__ia64)) \
- && !defined(__INTEL_COMPILER)
-# define TAGLIB_ATOMIC_GCC
-#elif defined(__ia64) && defined(__INTEL_COMPILER)
+#elif defined(HAVE_IA64_ATOMIC)
# include <ia64intrin.h>
-# define TAGLIB_ATOMIC_GCC
#endif
#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
@@ -77,19 +69,19 @@
public:
RefCounterOld() : refCount(1) {}
-#ifdef TAGLIB_ATOMIC_MAC
+#if defined(HAVE_MAC_ATOMIC)
void ref() { OSAtomicIncrement32Barrier(const_cast<int32_t*>(&refCount)); }
bool deref() { return ! OSAtomicDecrement32Barrier(const_cast<int32_t*>(&refCount)); }
int32_t count() { return refCount; }
private:
volatile int32_t refCount;
-#elif defined(TAGLIB_ATOMIC_WIN)
+#elif defined(HAVE_WIN_ATOMIC)
void ref() { InterlockedIncrement(&refCount); }
bool deref() { return ! InterlockedDecrement(&refCount); }
long count() { return refCount; }
private:
volatile long refCount;
-#elif defined(TAGLIB_ATOMIC_GCC)
+#elif defined(HAVE_GCC_ATOMIC)
void ref() { __sync_add_and_fetch(&refCount, 1); }
bool deref() { return ! __sync_sub_and_fetch(&refCount, 1); }
int count() { return refCount; }
# TagLib
TAGLIB_VERSION := 1.9.1
TAGLIB_VERSION := 1.10beta
TAGLIB_URL := http://taglib.github.io/releases/taglib-$(TAGLIB_VERSION).tar.gz
PKGS += taglib
......@@ -15,9 +15,6 @@ $(TARBALLS)/taglib-$(TAGLIB_VERSION).tar.gz:
taglib: taglib-$(TAGLIB_VERSION).tar.gz .sum-taglib
$(UNPACK)
$(APPLY) $(SRC)/taglib/taglib-pc.patch
$(APPLY) $(SRC)/taglib/0002-Rewrote-ByteVector-replace-simpler.patch
$(APPLY) $(SRC)/taglib/fix-atomic-checks.patch
$(MOVE)
.taglib: taglib toolchain.cmake
......
--- taglib-1.8/CMakeLists.txt.orig 2012-09-06 20:03:15.000000000 +0200
+++ taglib-1.8/CMakeLists.txt 2012-09-27 15:24:05.840067656 +0200
@@ -69,10 +69,8 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/taglib-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib-config )
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/taglib-config DESTINATION ${BIN_INSTALL_DIR})
-if(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()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
configure_file(config-taglib.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment