Group :: System/Libraries
RPM: libtag
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: taglib-1.5-ds-rcc.patch
Download
Download
diff -Naur taglib-1.5/configure.in taglib-1.5.rcc/configure.in
--- taglib-1.5/configure.in 2008-02-13 02:53:05 +0300
+++ taglib-1.5.rcc/configure.in 2008-02-25 16:18:20 +0300
@@ -98,6 +98,20 @@
AC_SUBST(AUTODIRS)
+AC_CHECK_LIB(rcc, rccInit,[
+ AC_CHECK_HEADERS(librcc.h,[
+ LIBRCC_LIBS="-lrcc"
+ LIBRCC_INCLUDES="-DHAVE_LIBRCC"
+ ],[
+ LIBRCC_LIBS=""
+ LIBRCC_INCLUDES=""
+])],[
+ LIBRCC_LIBS=""
+ LIBRCC_INCLUDES=""
+])
+AC_SUBST(LIBRCC_LIBS)
+AC_SUBST(LIBRCC_INCLUDES)
+
#AM_INIT_AUTOMAKE(taglib,1.0)
dnl don't remove the below
dnl AC_OUTPUT(taglib-config)
diff -Naur taglib-1.5/configure.in.in taglib-1.5.rcc/configure.in.in
--- taglib-1.5/configure.in.in 2008-01-30 04:34:06 +0300
+++ taglib-1.5.rcc/configure.in.in 2008-02-25 16:18:52 +0300
@@ -94,6 +94,20 @@
AC_SUBST(AUTODIRS)
+AC_CHECK_LIB(rcc, rccInit,[
+ AC_CHECK_HEADERS(librcc.h,[
+ LIBRCC_LIBS="-lrcc"
+ LIBRCC_INCLUDES="-DHAVE_LIBRCC"
+ ],[
+ LIBRCC_LIBS=""
+ LIBRCC_INCLUDES=""
+])],[
+ LIBRCC_LIBS=""
+ LIBRCC_INCLUDES=""
+])
+AC_SUBST(LIBRCC_LIBS)
+AC_SUBST(LIBRCC_INCLUDES)
+
#AM_INIT_AUTOMAKE(taglib,1.0)
dnl don't remove the below
dnl AC_OUTPUT(taglib-config)
diff -Naur taglib-1.5/taglib/mpeg/id3v1/id3v1tag.cpp taglib-1.5.rcc/taglib/mpeg/id3v1/id3v1tag.cpp
--- taglib-1.5/taglib/mpeg/id3v1/id3v1tag.cpp 2008-02-04 18:14:45 +0300
+++ taglib-1.5.rcc/taglib/mpeg/id3v1/id3v1tag.cpp 2008-02-25 16:21:06 +0300
@@ -59,17 +59,12 @@
String ID3v1::StringHandler::parse(const ByteVector &data) const
{
- return String(data, String::Latin1).stripWhiteSpace();
+ return String(data, String::Latin1ID3);
}
ByteVector ID3v1::StringHandler::render(const String &s) const
{
- if(!s.isLatin1())
- {
- return ByteVector();
- }
-
- return s.data(String::Latin1);
+ return s.data(String::Latin1ID3);
}
////////////////////////////////////////////////////////////////////////////////
@@ -240,7 +235,7 @@
d->track = uchar(data[offset + 29]);
}
else
- d->comment = data.mid(offset, 30);
+ d->comment = TagPrivate::stringHandler->parse(data.mid(offset, 30));
offset += 30;
diff -Naur taglib-1.5/taglib/mpeg/id3v2/frames/commentsframe.cpp taglib-1.5.rcc/taglib/mpeg/id3v2/frames/commentsframe.cpp
--- taglib-1.5/taglib/mpeg/id3v2/frames/commentsframe.cpp 2008-02-04 18:14:46 +0300
+++ taglib-1.5.rcc/taglib/mpeg/id3v2/frames/commentsframe.cpp 2008-02-25 16:59:03 +0300
@@ -136,7 +136,7 @@
return;
}
- d->textEncoding = String::Type(data[0]);
+ d->textEncoding = String::ID3Type(data[0]);
d->language = data.mid(1, 3);
int byteAlign = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2;
@@ -153,16 +153,13 @@
{
ByteVector v;
- String::Type encoding = d->textEncoding;
+ String::Type textEncoding = String::ID3WType(d->textEncoding);
- encoding = checkEncoding(d->description, encoding);
- encoding = checkEncoding(d->text, encoding);
-
- v.append(char(encoding));
+ v.append(char(textEncoding));
v.append(d->language.size() == 3 ? d->language : "XXX");
- v.append(d->description.data(encoding));
- v.append(textDelimiter(encoding));
- v.append(d->text.data(encoding));
+ v.append(d->description.data(textEncoding));
+ v.append(textDelimiter(textEncoding));
+ v.append(d->text.data(textEncoding));
return v;
}
diff -Naur taglib-1.5/taglib/mpeg/id3v2/frames/textidentificationframe.cpp taglib-1.5.rcc/taglib/mpeg/id3v2/frames/textidentificationframe.cpp
--- taglib-1.5/taglib/mpeg/id3v2/frames/textidentificationframe.cpp 2008-02-04 18:14:46 +0300
+++ taglib-1.5.rcc/taglib/mpeg/id3v2/frames/textidentificationframe.cpp 2008-02-25 16:41:13 +0300
@@ -105,7 +105,7 @@
// read the string data type (the first byte of the field data)
- d->textEncoding = String::Type(data[0]);
+ d->textEncoding = String::ID3Type(data[0]);
// split the byte array into chunks based on the string type (two byte delimiter
// for unicode encodings)
@@ -139,11 +139,11 @@
ByteVector TextIdentificationFrame::renderFields() const
{
- String::Type encoding = checkEncoding(d->fieldList, d->textEncoding);
+ String::Type textEncoding = String::ID3WType(d->textEncoding);
ByteVector v;
- v.append(char(encoding));
+ v.append(char(textEncoding));
for(StringList::ConstIterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) {
@@ -152,9 +152,9 @@
// encoding.
if(it != d->fieldList.begin())
- v.append(textDelimiter(encoding));
+ v.append(textDelimiter(textEncoding));
- v.append((*it).data(encoding));
+ v.append((*it).data(textEncoding));
}
return v;
diff -Naur taglib-1.5/taglib/toolkit/Makefile.am taglib-1.5.rcc/taglib/toolkit/Makefile.am
--- taglib-1.5/taglib/toolkit/Makefile.am 2008-01-11 03:54:01 +0300
+++ taglib-1.5.rcc/taglib/toolkit/Makefile.am 2008-02-25 16:42:31 +0300
@@ -1,15 +1,16 @@
INCLUDES = \
-I$(top_srcdir)/taglib \
- $(all_includes)
+ $(all_includes) @LIBRCC_INCLUDES@
+libtoolkit_la_LDFLAGS = @LIBRCC_LIBS@
noinst_LTLIBRARIES = libtoolkit.la
libtoolkit_la_SOURCES = \
- tstring.cpp tstringlist.cpp tbytevector.cpp \
+ rccpatch.cpp tstring.cpp tstringlist.cpp tbytevector.cpp \
tbytevectorlist.cpp tfile.cpp tdebug.cpp unicode.cpp
taglib_include_HEADERS = \
- taglib.h tstring.h tlist.h tlist.tcc tstringlist.h \
+ rccpatch.h taglib.h tstring.h tlist.h tlist.tcc tstringlist.h \
tbytevector.h tbytevectorlist.h tfile.h \
tmap.h tmap.tcc
diff -Naur taglib-1.5/taglib/toolkit/rccpatch.cpp taglib-1.5.rcc/taglib/toolkit/rccpatch.cpp
--- taglib-1.5/taglib/toolkit/rccpatch.cpp 1970-01-01 03:00:00 +0300
+++ taglib-1.5.rcc/taglib/toolkit/rccpatch.cpp 2008-02-25 16:16:31 +0300
@@ -0,0 +1,202 @@
+#include <stdlib.h>
+
+#include <string>
+#include "tstring.h"
+#include "tbytevector.h"
+
+#ifdef HAVE_LIBRCC
+# include <librcc.h>
+#endif /* HAVE_LIBRCC */
+
+
+#ifdef HAVE_LIBRCC
+# define ID3_CLASS 0
+# define ID3V2_CLASS 1
+# define UTF_CLASS 2
+# define OUT_CLASS 3
+static rcc_class classes[] = {
+ { "id3", RCC_CLASS_STANDARD, NULL, NULL, "ID3 Encoding", 0 },
+ { "id3v2", RCC_CLASS_STANDARD, "id3", NULL, "ID3 v.2 Encoding", 0 },
+ { "utf", RCC_CLASS_KNOWN, "UTF-8", NULL, "Unicode Encoding", 0},
+ { "out", RCC_CLASS_TRANSLATE_LOCALE, "LC_CTYPE", NULL, "Output Encoding", 0 },
+ { NULL, RCC_CLASS_STANDARD, NULL, NULL, NULL, 0 }
+};
+
+static int rcc_initialized = 0;
+
+static rcc_context ctx = NULL;
+#endif /* HAVE_LIBRCC */
+
+
+void rccPatchFree() {
+#ifdef HAVE_LIBRCC
+ if (rcc_initialized) {
+ rccFree();
+ rcc_initialized = 0;
+ }
+#endif /* HAVE_LIBRCC */
+}
+
+void rccPatchInit() {
+#ifdef HAVE_LIBRCC
+ if (rcc_initialized) return;
+ rccInit();
+ rccInitDefaultContext(NULL, 0, 0, classes, 0);
+ rccLoad(NULL, "xmms");
+ rccInitDb4(NULL, NULL, 0);
+ rcc_initialized = 1;
+#endif /* HAVE_LIBRCC */
+}
+
+void rccPatchSetContext(void *newctx) {
+#ifdef HAVE_LIBRCC
+ if (newctx) {
+ ctx = (rcc_context)newctx;
+ rcc_initialized = 1;
+ }
+#endif /* HAVE_LIBRCC */
+}
+
+static void rccPatchTryInit() {
+#ifdef HAVE_LIBRCC
+ if (!rcc_initialized) {
+ rccPatchInit();
+ if (rcc_initialized) atexit(rccPatchFree);
+ }
+#endif /* HAVE_LIBRCC */
+}
+
+char *rccPatchRecode(const char *str, size_t len, size_t *rlen) {
+#ifdef HAVE_LIBRCC
+ rccPatchTryInit();
+
+ return rccSizedRecode(ctx, ID3_CLASS, OUT_CLASS, str, len, rlen);
+#else
+ return NULL;
+#endif /* HAVE_LIBRCC */
+}
+
+TagLib::ByteVector rccPatchRecodeOutput(const std::string &s) {
+ TagLib::ByteVector v;
+#ifdef HAVE_LIBRCC
+ size_t rlen;
+ char *res;
+
+ rccPatchTryInit();
+
+ res = rccSizedRecode(ctx, UTF_CLASS, OUT_CLASS, s.c_str(), s.length(), &rlen);
+ if (res) v.setData(res, rlen);
+ else v.setData(s.c_str(), s.length());
+
+ return v;
+#else
+ v.setData("", 0);
+
+ return v;
+#endif /* HAVE_LIBRCC */
+}
+
+TagLib::ByteVector rccPatchRecodeOutputID3(const std::string &s) {
+ TagLib::ByteVector v;
+#ifdef HAVE_LIBRCC
+ size_t rlen;
+ char *res;
+
+ rccPatchTryInit();
+
+ res = rccSizedRecode(ctx, UTF_CLASS, ID3_CLASS, s.c_str(), s.length(), &rlen);
+ if (res) v.setData(res, rlen);
+ else v.setData(s.c_str(), s.length());
+
+ return v;
+#else
+ v.setData("", 0);
+
+ return v;
+#endif /* HAVE_LIBRCC */
+}
+
+TagLib::ByteVector rccPatchRecodeInput(const std::string &s) {
+ TagLib::ByteVector v;
+#ifdef HAVE_LIBRCC
+ size_t rlen;
+ char *res;
+
+ rccPatchTryInit();
+
+ res = rccSizedRecode(ctx, OUT_CLASS, UTF_CLASS, s.c_str(), s.length(), &rlen);
+ if (res) v.setData(res, rlen);
+ else v.setData(s.c_str(), s.length());
+
+ return v;
+#else
+ v.setData("", 0);
+
+ return v;
+#endif /* HAVE_LIBRCC */
+}
+
+TagLib::ByteVector rccPatchRecodeInputID3(const std::string &s) {
+ TagLib::ByteVector v;
+#ifdef HAVE_LIBRCC
+ size_t rlen;
+ char *res;
+
+ rccPatchTryInit();
+
+ res = rccSizedRecode(ctx, ID3_CLASS, UTF_CLASS, s.c_str(), s.length(), &rlen);
+ if (res) v.setData(res, rlen);
+ else v.setData(s.c_str(), s.length());
+
+ return v;
+#else
+ v.setData("", 0);
+
+ return v;
+#endif /* HAVE_LIBRCC */
+}
+
+TagLib::String::Type rccPatchGetLocaleType() {
+#ifdef HAVE_LIBRCC
+ size_t len;
+ char charset[32];
+
+ rccPatchTryInit();
+
+ if (!rccLocaleGetCharset(charset, NULL, 31)) {
+ if (!strncmp(charset, "UTF", 3)) {
+ len = strlen(charset);
+
+ if (charset[len-1]=='8') return TagLib::String::UTF8;
+ if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
+ if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
+ if (!strcmp(charset+(len-4),"16BE")) return TagLib::String::UTF16BE;
+ }
+ return TagLib::String::Latin1;
+ }
+#endif /* HAVE_LIBRCC */
+ return TagLib::String::UTF8;
+}
+
+TagLib::String::Type rccPatchGetID3Type() {
+#ifdef HAVE_LIBRCC
+ size_t len;
+ const char *charset;
+
+ rccPatchTryInit();
+
+ charset = rccGetCurrentCharsetName(ctx, ID3V2_CLASS);
+ if (charset) {
+ if (!strncmp(charset, "UTF", 3)) {
+ len = strlen(charset);
+
+ if (charset[len-1]=='8') return TagLib::String::UTF8;
+ if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
+ if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
+ if (!strcmp(charset+(len-4),"16BE")) return TagLib::String::UTF16BE;
+ }
+ return TagLib::String::Latin1ID3;
+ }
+#endif /* HAVE_LIBRCC */
+ return TagLib::String::Latin1;
+}
diff -Naur taglib-1.5/taglib/toolkit/rccpatch.h taglib-1.5.rcc/taglib/toolkit/rccpatch.h
--- taglib-1.5/taglib/toolkit/rccpatch.h 1970-01-01 03:00:00 +0300
+++ taglib-1.5.rcc/taglib/toolkit/rccpatch.h 2008-02-25 16:16:31 +0300
@@ -0,0 +1,20 @@
+#ifndef _RCC_PATCH_H
+#define _RCC_PATCH_H
+
+#include <string.h>
+#include "tstring.h"
+#include "tbytevector.h"
+
+void rccPatchFree();
+void rccPatchInit();
+void rccPatchSetContext(void *newctx);
+
+TagLib::ByteVector rccPatchRecodeOutput(const std::string &s);
+TagLib::ByteVector rccPatchRecodeInput(const std::string &s);
+TagLib::ByteVector rccPatchRecodeOutputID3(const std::string &s);
+TagLib::ByteVector rccPatchRecodeInputID3(const std::string &s);
+
+TagLib::String::Type rccPatchGetLocaleType();
+TagLib::String::Type rccPatchGetID3Type();
+
+#endif /* _RCC_PATCH_H */
diff -Naur taglib-1.5/taglib/toolkit/tstring.cpp taglib-1.5.rcc/taglib/toolkit/tstring.cpp
--- taglib-1.5/taglib/toolkit/tstring.cpp 2008-02-04 18:14:45 +0300
+++ taglib-1.5.rcc/taglib/toolkit/tstring.cpp 2008-02-25 16:16:31 +0300
@@ -23,6 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
+#include "rccpatch.h"
#include "tstring.h"
#include "unicode.h"
#include "tdebug.h"
@@ -167,7 +168,7 @@
if(v.isEmpty())
return;
- if(t == Latin1 || t == UTF8) {
+ if(t == Latin1 || t == Latin1ID3 || t == UTF8) {
int length = 0;
d->data.resize(v.size());
@@ -358,10 +359,18 @@
{
ByteVector v;
- switch(t) {
+ if (t == Locale) t = rccPatchGetLocaleType();
+ switch(t) {
+ case Locale:
+ case Latin1ID3:
case Latin1:
{
+ std::string s = to8Bit(true);
+ if (t == Latin1ID3) v = rccPatchRecodeOutputID3(s);
+ else v = rccPatchRecodeOutput(s);
+ if (v.size()) return v;
+
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++)
v.append(char(*it));
break;
@@ -692,6 +701,30 @@
void String::prepare(Type t)
{
+ if (t == Locale) t = rccPatchGetLocaleType();
+
+ if ((t == Latin1)||(t == Latin1ID3)) {
+ std::string s = to8Bit(false);
+ ByteVector v;
+
+ if (t == Latin1ID3) v = rccPatchRecodeInputID3(s);
+ else v = rccPatchRecodeInput(s);
+
+ if (v.size()) {
+ int length = 0;
+ d->data.resize(v.size());
+ wstring::iterator targetIt = d->data.begin();
+ for(ByteVector::ConstIterator it = v.begin(); it != v.end() && (*it); ++it) {
+ *targetIt = uchar(*it);
+ ++targetIt;
+ ++length;
+ }
+ d->data.resize(length);
+ }
+
+ t = UTF8;
+ }
+
switch(t) {
case UTF16:
{
@@ -781,6 +814,17 @@
std::ostream &operator<<(std::ostream &s, const String &str)
{
- s << str.to8Bit();
+ ByteVector bv = str.data(String::Locale);
+ s << bv;
return s;
}
+
+String::Type String::ID3Type(int i) {
+ if (i == Latin1) return Latin1ID3;
+ return Type(i);
+};
+
+String::Type String::ID3WType(Type type) {
+ if ((type == Latin1)||(type == Latin1ID3)) return rccPatchGetID3Type();
+ return type;
+};
diff -Naur taglib-1.5/taglib/toolkit/tstring.h taglib-1.5.rcc/taglib/toolkit/tstring.h
--- taglib-1.5/taglib/toolkit/tstring.h 2008-02-04 18:14:45 +0300
+++ taglib-1.5.rcc/taglib/toolkit/tstring.h 2008-02-25 16:16:31 +0300
@@ -81,6 +81,14 @@
*/
enum Type {
/*!
+ * Determine using current locale settings
+ */
+ Locale = -1,
+ /*!
+ * Latin1 for ID3 tags.
+ */
+ Latin1ID3 = 5,
+ /*!
* IS08859-1, or <i>Latin1</i> encoding. 8 bit characters.
*/
Latin1 = 0,
@@ -103,6 +111,9 @@
UTF16LE = 4
};
+ static Type ID3Type(int i);
+ static Type ID3WType(Type type);
+
/*!
* Constructs an empty String.
*/