From c1e3d65b683b0483c8c19659bd22c44a5e7334e3 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 5 Feb 2016 10:53:56 +0900 Subject: [PATCH 01/74] Fix a typo in NEWS --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 787f2d3b..e4b30a44 100644 --- a/NEWS +++ b/NEWS @@ -34,7 +34,7 @@ TagLib 1.11 (Jan 30, 2016) * Fixed updating the comment field of Vorbis comments. * Fixed reading date and time in ID3v2.3 tags. * Marked ByteVector::null and ByteVector::isNull() deprecated. - * Marked String::null and ByteVector::isNull() deprecated. + * Marked String::null and String:isNull() deprecated. * Marked XiphComment::removeField() deprecated. * Marked Ogg::Page::getCopyWithNewPageSequenceNumber() deprecated. It returns null. * Marked custom integer types deprecated. From 31894f47f68877b0d7589e5e4295a4d63b5efa6f Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 5 Feb 2016 19:57:09 +0900 Subject: [PATCH 02/74] Fix another typo in NEWS. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index e4b30a44..cdc855a1 100644 --- a/NEWS +++ b/NEWS @@ -34,7 +34,7 @@ TagLib 1.11 (Jan 30, 2016) * Fixed updating the comment field of Vorbis comments. * Fixed reading date and time in ID3v2.3 tags. * Marked ByteVector::null and ByteVector::isNull() deprecated. - * Marked String::null and String:isNull() deprecated. + * Marked String::null and String::isNull() deprecated. * Marked XiphComment::removeField() deprecated. * Marked Ogg::Page::getCopyWithNewPageSequenceNumber() deprecated. It returns null. * Marked custom integer types deprecated. From fffff35ca5fcf9e7670cf22ebe1ba25e5dc807bd Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 6 Feb 2016 01:27:36 +0900 Subject: [PATCH 03/74] Correct the license information. --- taglib/it/itfile.cpp | 11 +++-- taglib/it/itproperties.cpp | 11 +++-- taglib/it/itproperties.h | 10 ++-- taglib/mod/modfile.cpp | 11 +++-- taglib/mod/modfile.h | 10 ++-- taglib/mod/modfilebase.cpp | 11 +++-- taglib/mod/modfilebase.h | 10 ++-- taglib/mod/modproperties.cpp | 11 +++-- taglib/mod/modproperties.h | 10 ++-- taglib/mod/modtag.cpp | 11 +++-- taglib/mod/modtag.h | 10 ++-- .../frames/generalencapsulatedobjectframe.cpp | 1 + .../frames/generalencapsulatedobjectframe.h | 1 + .../frames/unsynchronizedlyricsframe.cpp | 1 + taglib/mpeg/id3v2/frames/urllinkframe.cpp | 1 + taglib/mpeg/id3v2/frames/urllinkframe.h | 1 + taglib/s3m/s3mfile.cpp | 11 +++-- taglib/s3m/s3mfile.h | 10 ++-- taglib/s3m/s3mproperties.cpp | 11 +++-- taglib/s3m/s3mproperties.h | 10 ++-- taglib/toolkit/tpropertymap.cpp | 11 +++-- taglib/toolkit/tpropertymap.h | 10 ++-- taglib/xm/xmfile.cpp | 10 ++-- taglib/xm/xmfile.h | 10 ++-- taglib/xm/xmproperties.cpp | 13 +++-- taglib/xm/xmproperties.h | 10 ++-- tests/main.cpp | 25 ++++++++++ tests/test_aiff.cpp | 25 ++++++++++ tests/test_ape.cpp | 25 ++++++++++ tests/test_apetag.cpp | 25 ++++++++++ tests/test_asf.cpp | 25 ++++++++++ tests/test_bytevector.cpp | 47 +++++++++--------- tests/test_bytevectorlist.cpp | 25 ++++++++++ tests/test_bytevectorstream.cpp | 25 ++++++++++ tests/test_file.cpp | 14 ++++-- tests/test_fileref.cpp | 25 ++++++++++ tests/test_flac.cpp | 25 ++++++++++ tests/test_flacpicture.cpp | 25 ++++++++++ tests/test_flacunknownmetadatablock.cpp | 25 ++++++++++ tests/test_id3v1.cpp | 25 ++++++++++ tests/test_id3v2.cpp | 25 ++++++++++ tests/test_info.cpp | 25 ++++++++++ tests/test_it.cpp | 10 ++-- tests/test_list.cpp | 47 +++++++++--------- tests/test_map.cpp | 25 ++++++++++ tests/test_mod.cpp | 10 ++-- tests/test_mp4.cpp | 25 ++++++++++ tests/test_mp4coverart.cpp | 25 ++++++++++ tests/test_mp4item.cpp | 25 ++++++++++ tests/test_mpc.cpp | 25 ++++++++++ tests/test_mpeg.cpp | 25 ++++++++++ tests/test_ogg.cpp | 25 ++++++++++ tests/test_oggflac.cpp | 25 ++++++++++ tests/test_opus.cpp | 25 ++++++++++ tests/test_propertymap.cpp | 25 ++++++++++ tests/test_riff.cpp | 25 ++++++++++ tests/test_s3m.cpp | 10 ++-- tests/test_speex.cpp | 25 ++++++++++ tests/test_string.cpp | 47 +++++++++--------- tests/test_synchdata.cpp | 48 ++++++++++--------- tests/test_trueaudio.cpp | 25 ++++++++++ tests/test_wav.cpp | 25 ++++++++++ tests/test_wavpack.cpp | 25 ++++++++++ tests/test_xiphcomment.cpp | 25 ++++++++++ tests/test_xm.cpp | 10 ++-- tests/utils.h | 25 ++++++++++ 66 files changed, 1072 insertions(+), 173 deletions(-) diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index 647491e9..19dee235 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "tstringlist.h" #include "itfile.h" #include "tdebug.h" diff --git a/taglib/it/itproperties.cpp b/taglib/it/itproperties.cpp index 426a6f2d..8f686dc7 100644 --- a/taglib/it/itproperties.cpp +++ b/taglib/it/itproperties.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "itproperties.h" using namespace TagLib; diff --git a/taglib/it/itproperties.h b/taglib/it/itproperties.h index d65a8c28..be1c9d26 100644 --- a/taglib/it/itproperties.h +++ b/taglib/it/itproperties.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_ITPROPERTIES_H diff --git a/taglib/mod/modfile.cpp b/taglib/mod/modfile.cpp index d207516e..00d330eb 100644 --- a/taglib/mod/modfile.cpp +++ b/taglib/mod/modfile.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "modfile.h" #include "tstringlist.h" #include "tdebug.h" diff --git a/taglib/mod/modfile.h b/taglib/mod/modfile.h index c45ede24..b66452d7 100644 --- a/taglib/mod/modfile.h +++ b/taglib/mod/modfile.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_MODFILE_H diff --git a/taglib/mod/modfilebase.cpp b/taglib/mod/modfilebase.cpp index 0cc15e86..e6a3114f 100644 --- a/taglib/mod/modfilebase.cpp +++ b/taglib/mod/modfilebase.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "tdebug.h" #include "modfilebase.h" diff --git a/taglib/mod/modfilebase.h b/taglib/mod/modfilebase.h index 5f76ccb0..bae97167 100644 --- a/taglib/mod/modfilebase.h +++ b/taglib/mod/modfilebase.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_MODFILEBASE_H diff --git a/taglib/mod/modproperties.cpp b/taglib/mod/modproperties.cpp index f5591298..ed3df94d 100644 --- a/taglib/mod/modproperties.cpp +++ b/taglib/mod/modproperties.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "modproperties.h" using namespace TagLib; diff --git a/taglib/mod/modproperties.h b/taglib/mod/modproperties.h index 6b424089..47122943 100644 --- a/taglib/mod/modproperties.h +++ b/taglib/mod/modproperties.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_MODPROPERTIES_H diff --git a/taglib/mod/modtag.cpp b/taglib/mod/modtag.cpp index 2e3cbb6d..616d8c1b 100644 --- a/taglib/mod/modtag.cpp +++ b/taglib/mod/modtag.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "modtag.h" #include "tstringlist.h" #include "tpropertymap.h" diff --git a/taglib/mod/modtag.h b/taglib/mod/modtag.h index 1810fe11..b9cad20a 100644 --- a/taglib/mod/modtag.h +++ b/taglib/mod/modtag.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_MODTAG_H diff --git a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp index fa3509b1..48248294 100644 --- a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp +++ b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp @@ -1,6 +1,7 @@ /*************************************************************************** copyright : (C) 2002 - 2008 by Scott Wheeler email : wheeler@kde.org + copyright : (C) 2006 by Aaron VonderHaar email : avh4@users.sourceforge.net ***************************************************************************/ diff --git a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h index 42f854cc..769dfb02 100644 --- a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h +++ b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h @@ -1,6 +1,7 @@ /*************************************************************************** copyright : (C) 2002 - 2008 by Scott Wheeler email : wheeler@kde.org + copyright : (C) 2006 by Aaron VonderHaar email : avh4@users.sourceforge.net ***************************************************************************/ diff --git a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp index f97cdc5a..01ccc68e 100644 --- a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp @@ -1,6 +1,7 @@ /*************************************************************************** copyright : (C) 2002 - 2008 by Scott Wheeler email : wheeler@kde.org + copyright : (C) 2006 by Urs Fleisch email : ufleisch@users.sourceforge.net ***************************************************************************/ diff --git a/taglib/mpeg/id3v2/frames/urllinkframe.cpp b/taglib/mpeg/id3v2/frames/urllinkframe.cpp index e59a80dd..42d80712 100644 --- a/taglib/mpeg/id3v2/frames/urllinkframe.cpp +++ b/taglib/mpeg/id3v2/frames/urllinkframe.cpp @@ -1,6 +1,7 @@ /*************************************************************************** copyright : (C) 2002 - 2008 by Scott Wheeler email : wheeler@kde.org + copyright : (C) 2006 by Urs Fleisch email : ufleisch@users.sourceforge.net ***************************************************************************/ diff --git a/taglib/mpeg/id3v2/frames/urllinkframe.h b/taglib/mpeg/id3v2/frames/urllinkframe.h index 7ac966b2..d9ac1093 100644 --- a/taglib/mpeg/id3v2/frames/urllinkframe.h +++ b/taglib/mpeg/id3v2/frames/urllinkframe.h @@ -1,6 +1,7 @@ /*************************************************************************** copyright : (C) 2002 - 2008 by Scott Wheeler email : wheeler@kde.org + copyright : (C) 2006 by Urs Fleisch email : ufleisch@users.sourceforge.net ***************************************************************************/ diff --git a/taglib/s3m/s3mfile.cpp b/taglib/s3m/s3mfile.cpp index 923a80ad..ebd637af 100644 --- a/taglib/s3m/s3mfile.cpp +++ b/taglib/s3m/s3mfile.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "s3mfile.h" #include "tstringlist.h" #include "tdebug.h" diff --git a/taglib/s3m/s3mfile.h b/taglib/s3m/s3mfile.h index 5f452977..4011bd14 100644 --- a/taglib/s3m/s3mfile.h +++ b/taglib/s3m/s3mfile.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_S3MFILE_H diff --git a/taglib/s3m/s3mproperties.cpp b/taglib/s3m/s3mproperties.cpp index 9633a0fe..69654b1a 100644 --- a/taglib/s3m/s3mproperties.cpp +++ b/taglib/s3m/s3mproperties.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "s3mproperties.h" using namespace TagLib; diff --git a/taglib/s3m/s3mproperties.h b/taglib/s3m/s3mproperties.h index 4b14e97f..92b2a274 100644 --- a/taglib/s3m/s3mproperties.h +++ b/taglib/s3m/s3mproperties.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_S3MPROPERTIES_H diff --git a/taglib/toolkit/tpropertymap.cpp b/taglib/toolkit/tpropertymap.cpp index 1c6a47d9..b3e1ec3a 100644 --- a/taglib/toolkit/tpropertymap.cpp +++ b/taglib/toolkit/tpropertymap.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "tpropertymap.h" using namespace TagLib; diff --git a/taglib/toolkit/tpropertymap.h b/taglib/toolkit/tpropertymap.h index c1b835be..5933b89b 100644 --- a/taglib/toolkit/tpropertymap.h +++ b/taglib/toolkit/tpropertymap.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_PROPERTYMAP_H_ diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index 0a3b950e..e0c8db57 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #include "tstringlist.h" diff --git a/taglib/xm/xmfile.h b/taglib/xm/xmfile.h index ae48a511..9211078a 100644 --- a/taglib/xm/xmfile.h +++ b/taglib/xm/xmfile.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_XMFILE_H diff --git a/taglib/xm/xmproperties.cpp b/taglib/xm/xmproperties.cpp index 5002a4e5..39a9fa0a 100644 --- a/taglib/xm/xmproperties.cpp +++ b/taglib/xm/xmproperties.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - copyright :(C) 2011 by Mathias Panzenböck + copyright : (C) 2011 by Mathias Panzenböck email : grosser.meister.morti@gmx.net ***************************************************************************/ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,10 +15,15 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ + #include "xmproperties.h" using namespace TagLib; diff --git a/taglib/xm/xmproperties.h b/taglib/xm/xmproperties.h index db948815..24a52217 100644 --- a/taglib/xm/xmproperties.h +++ b/taglib/xm/xmproperties.h @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef TAGLIB_XMPROPERTIES_H diff --git a/tests/main.cpp b/tests/main.cpp index c83c9d13..86a4208c 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_aiff.cpp b/tests/test_aiff.cpp index b0204a2d..9619b1d8 100644 --- a/tests/test_aiff.cpp +++ b/tests/test_aiff.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_ape.cpp b/tests/test_ape.cpp index 12ca2db8..81f4425d 100644 --- a/tests/test_ape.cpp +++ b/tests/test_ape.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2010 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_apetag.cpp b/tests/test_apetag.cpp index b45b516c..653de750 100644 --- a/tests/test_apetag.cpp +++ b/tests/test_apetag.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2010 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_asf.cpp b/tests/test_asf.cpp index 0098fdc3..f0d8853d 100644 --- a/tests/test_asf.cpp +++ b/tests/test_asf.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2008 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 9ff71272..8cd209f1 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -1,26 +1,27 @@ -/* Copyright (C) 2003 Scott Wheeler - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ #include #include diff --git a/tests/test_bytevectorlist.cpp b/tests/test_bytevectorlist.cpp index ff5ef2fe..6fe325b8 100644 --- a/tests/test_bytevectorlist.cpp +++ b/tests/test_bytevectorlist.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_bytevectorstream.cpp b/tests/test_bytevectorstream.cpp index 7f6df152..c7b0f105 100644 --- a/tests/test_bytevectorstream.cpp +++ b/tests/test_bytevectorstream.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2011 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include diff --git a/tests/test_file.cpp b/tests/test_file.cpp index 5c4aaa0f..f00a3115 100644 --- a/tests/test_file.cpp +++ b/tests/test_file.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - copyright : (C) 2014 by Lukas Lalinsky - email : lukas@oxygene.sk + copyright : (C) 2015 by Tsuda Kageyu + email : tsuda.kageyu@gmail.com ***************************************************************************/ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #include diff --git a/tests/test_fileref.cpp b/tests/test_fileref.cpp index d7945e48..16ae3a16 100644 --- a/tests/test_fileref.cpp +++ b/tests/test_fileref.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_flac.cpp b/tests/test_flac.cpp index cf59ef37..e3b43ab9 100644 --- a/tests/test_flac.cpp +++ b/tests/test_flac.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_flacpicture.cpp b/tests/test_flacpicture.cpp index c5043d2f..6613c598 100644 --- a/tests/test_flacpicture.cpp +++ b/tests/test_flacpicture.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2010 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_flacunknownmetadatablock.cpp b/tests/test_flacunknownmetadatablock.cpp index 881078dd..d08a9bae 100644 --- a/tests/test_flacunknownmetadatablock.cpp +++ b/tests/test_flacunknownmetadatablock.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2012 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_id3v1.cpp b/tests/test_id3v1.cpp index e778419a..3358aead 100644 --- a/tests/test_id3v1.cpp +++ b/tests/test_id3v1.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index e8d87fce..f5e5981f 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/tests/test_info.cpp b/tests/test_info.cpp index 6b583b2c..4302a249 100644 --- a/tests/test_info.cpp +++ b/tests/test_info.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2012 by Tsuda Kageyu + email : tsuda.kageyu@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_it.cpp b/tests/test_it.cpp index 0558884c..75afb54d 100644 --- a/tests/test_it.cpp +++ b/tests/test_it.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #include diff --git a/tests/test_list.cpp b/tests/test_list.cpp index fc303220..e314836a 100644 --- a/tests/test_list.cpp +++ b/tests/test_list.cpp @@ -1,26 +1,27 @@ -/* Copyright (C) 2003 Scott Wheeler - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ #include #include diff --git a/tests/test_map.cpp b/tests/test_map.cpp index c8f6b7f7..3096ff69 100644 --- a/tests/test_map.cpp +++ b/tests/test_map.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_mod.cpp b/tests/test_mod.cpp index b150c7fb..e1c07b7f 100644 --- a/tests/test_mod.cpp +++ b/tests/test_mod.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #include diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp index 46292d3b..dd36b21b 100644 --- a/tests/test_mp4.cpp +++ b/tests/test_mp4.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2008 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_mp4coverart.cpp b/tests/test_mp4coverart.cpp index 812a2e5d..49ef0470 100644 --- a/tests/test_mp4coverart.cpp +++ b/tests/test_mp4coverart.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_mp4item.cpp b/tests/test_mp4item.cpp index 37d3f719..a9a5c99a 100644 --- a/tests/test_mp4item.cpp +++ b/tests/test_mp4item.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_mpc.cpp b/tests/test_mpc.cpp index 94613c1e..d8ed984e 100644 --- a/tests/test_mpc.cpp +++ b/tests/test_mpc.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2012 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_mpeg.cpp b/tests/test_mpeg.cpp index 129fcc3c..c1179ee5 100644 --- a/tests/test_mpeg.cpp +++ b/tests/test_mpeg.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_ogg.cpp b/tests/test_ogg.cpp index 6e527f0d..aa0ee421 100644 --- a/tests/test_ogg.cpp +++ b/tests/test_ogg.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_oggflac.cpp b/tests/test_oggflac.cpp index 58781ea0..3b78629e 100644 --- a/tests/test_oggflac.cpp +++ b/tests/test_oggflac.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_opus.cpp b/tests/test_opus.cpp index 1d08d017..0ca6007f 100644 --- a/tests/test_opus.cpp +++ b/tests/test_opus.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2012 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_propertymap.cpp b/tests/test_propertymap.cpp index 49d856a0..855ff67e 100644 --- a/tests/test_propertymap.cpp +++ b/tests/test_propertymap.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2012 by Michael Helmling + email : helmling@mathematik.uni-kl.de + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_riff.cpp b/tests/test_riff.cpp index 8efedf89..5223e905 100644 --- a/tests/test_riff.cpp +++ b/tests/test_riff.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_s3m.cpp b/tests/test_s3m.cpp index 8133e215..fd211d22 100644 --- a/tests/test_s3m.cpp +++ b/tests/test_s3m.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #include diff --git a/tests/test_speex.cpp b/tests/test_speex.cpp index 2bbdbc90..7789a197 100644 --- a/tests/test_speex.cpp +++ b/tests/test_speex.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2015 by Tsuda Kageyu + email : tsuda.kageyu@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_string.cpp b/tests/test_string.cpp index 2ccba7b2..83b47911 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -1,26 +1,27 @@ -/* Copyright (C) 2003 Scott Wheeler - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ #include #include diff --git a/tests/test_synchdata.cpp b/tests/test_synchdata.cpp index 04a5c07b..4cffee14 100644 --- a/tests/test_synchdata.cpp +++ b/tests/test_synchdata.cpp @@ -1,26 +1,28 @@ -/* Copyright (C) 2003 Scott Wheeler - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include diff --git a/tests/test_trueaudio.cpp b/tests/test_trueaudio.cpp index c960f5f7..81393ff3 100644 --- a/tests/test_trueaudio.cpp +++ b/tests/test_trueaudio.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_wav.cpp b/tests/test_wav.cpp index f3bca479..7520cf00 100644 --- a/tests/test_wav.cpp +++ b/tests/test_wav.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2010 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_wavpack.cpp b/tests/test_wavpack.cpp index 39bc1edd..65a27c76 100644 --- a/tests/test_wavpack.cpp +++ b/tests/test_wavpack.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2010 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_xiphcomment.cpp b/tests/test_xiphcomment.cpp index 475e906e..699f60a5 100644 --- a/tests/test_xiphcomment.cpp +++ b/tests/test_xiphcomment.cpp @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2009 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #include #include #include diff --git a/tests/test_xm.cpp b/tests/test_xm.cpp index e4527c74..fcda4f56 100644 --- a/tests/test_xm.cpp +++ b/tests/test_xm.cpp @@ -5,7 +5,7 @@ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * + * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * @@ -15,8 +15,12 @@ * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301 USA * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * ***************************************************************************/ #include diff --git a/tests/utils.h b/tests/utils.h index 99a7c669..7cfe9a8d 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -1,3 +1,28 @@ +/*************************************************************************** + copyright : (C) 2007 by Lukas Lalinsky + email : lukas@oxygene.sk + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + #ifdef HAVE_CONFIG_H #include #endif From fa46185ca4fd2c732a3db286e347a120dc78ff00 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 6 Feb 2016 21:14:12 +0900 Subject: [PATCH 04/74] Add a supplementary note to a comment. --- taglib/fileref.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/taglib/fileref.h b/taglib/fileref.h index 387b2f51..a12b1a9b 100644 --- a/taglib/fileref.h +++ b/taglib/fileref.h @@ -128,13 +128,16 @@ namespace TagLib { audioPropertiesStyle = AudioProperties::Average); /*! - * Construct a FileRef from an opened \a IOStream. If \a readAudioProperties is true then - * the audio properties will be read using \a audioPropertiesStyle. If - * \a readAudioProperties is false then \a audioPropertiesStyle will be + * Construct a FileRef from an opened \a IOStream. If \a readAudioProperties + * is true then the audio properties will be read using \a audioPropertiesStyle. + * If \a readAudioProperties is false then \a audioPropertiesStyle will be * ignored. * * Also see the note in the class documentation about why you may not want to * use this method in your application. + * + * \note TagLib will *not* take ownership of the stream, the caller is + * responsible for deleting it after the File object. */ explicit FileRef(IOStream* stream, bool readAudioProperties = true, From cc2ccbc20c0cbda37ef4e397e6dbfef81f44792a Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 6 Feb 2016 21:32:03 +0900 Subject: [PATCH 05/74] Test if FileRef chooses a correct File type. --- tests/test_fileref.cpp | 45 ++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/tests/test_fileref.cpp b/tests/test_fileref.cpp index 16ae3a16..2313eb59 100644 --- a/tests/test_fileref.cpp +++ b/tests/test_fileref.cpp @@ -30,6 +30,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include "utils.h" #include @@ -73,6 +81,7 @@ class TestFileRef : public CppUnit::TestFixture public: + template void fileRefSave(const string &filename, const string &ext) { ScopedFileCopy copy(filename, ext); @@ -80,6 +89,7 @@ public: { FileRef f(newname.c_str()); + CPPUNIT_ASSERT(dynamic_cast(f.file())); CPPUNIT_ASSERT(!f.isNull()); f.tag()->setArtist("test artist"); f.tag()->setTitle("test title"); @@ -119,6 +129,7 @@ public: { FileStream fs(newname.c_str()); FileRef f(&fs); + CPPUNIT_ASSERT(dynamic_cast(f.file())); CPPUNIT_ASSERT(!f.isNull()); CPPUNIT_ASSERT_EQUAL(f.tag()->artist(), String("ttest artist")); CPPUNIT_ASSERT_EQUAL(f.tag()->title(), String("ytest title")); @@ -131,81 +142,77 @@ public: void testMusepack() { - fileRefSave("click", ".mpc"); + fileRefSave("click", ".mpc"); } void testASF() { - fileRefSave("silence-1", ".wma"); + fileRefSave("silence-1", ".wma"); } void testVorbis() { - fileRefSave("empty", ".ogg"); + fileRefSave("empty", ".ogg"); } void testSpeex() { - fileRefSave("empty", ".spx"); + fileRefSave("empty", ".spx"); } void testFLAC() { - fileRefSave("no-tags", ".flac"); + fileRefSave("no-tags", ".flac"); } void testMP3() { - fileRefSave("xing", ".mp3"); + fileRefSave("xing", ".mp3"); } void testTrueAudio() { - fileRefSave("empty", ".tta"); + fileRefSave("empty", ".tta"); } void testMP4_1() { - fileRefSave("has-tags", ".m4a"); + fileRefSave("has-tags", ".m4a"); } void testMP4_2() { - fileRefSave("no-tags", ".m4a"); + fileRefSave("no-tags", ".m4a"); } void testMP4_3() { - fileRefSave("no-tags", ".3g2"); + fileRefSave("no-tags", ".3g2"); } void testMP4_4() { - fileRefSave("blank_video", ".m4v"); + fileRefSave("blank_video", ".m4v"); } void testWav() { - fileRefSave("empty", ".wav"); + fileRefSave("empty", ".wav"); } void testOGA_FLAC() { - FileRef f(TEST_FILE_PATH_C("empty_flac.oga")); - CPPUNIT_ASSERT(dynamic_cast(f.file()) == NULL); - CPPUNIT_ASSERT(dynamic_cast(f.file()) != NULL); + fileRefSave("empty_flac", ".oga"); } void testOGA_Vorbis() { - FileRef f(TEST_FILE_PATH_C("empty_vorbis.oga")); - CPPUNIT_ASSERT(dynamic_cast(f.file()) != NULL); - CPPUNIT_ASSERT(dynamic_cast(f.file()) == NULL); + fileRefSave("empty_vorbis", ".oga"); } void testAPE() { - fileRefSave("mac-399", ".ape"); + fileRefSave("mac-399", ".ape"); } void testUnsupported() From 184a151d41918a5184457f025dc200479e7b4044 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 6 Feb 2016 21:56:51 +0900 Subject: [PATCH 06/74] Add some missing FileRef tests. --- tests/test_fileref.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_fileref.cpp b/tests/test_fileref.cpp index 2313eb59..2d77682a 100644 --- a/tests/test_fileref.cpp +++ b/tests/test_fileref.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "utils.h" #include @@ -75,6 +76,8 @@ class TestFileRef : public CppUnit::TestFixture CPPUNIT_TEST(testTrueAudio); CPPUNIT_TEST(testAPE); CPPUNIT_TEST(testWav); + CPPUNIT_TEST(testAIFF_1); + CPPUNIT_TEST(testAIFF_2); CPPUNIT_TEST(testUnsupported); CPPUNIT_TEST(testFileResolver); CPPUNIT_TEST_SUITE_END(); @@ -215,6 +218,16 @@ public: fileRefSave("mac-399", ".ape"); } + void testAIFF_1() + { + fileRefSave("empty", ".aiff"); + } + + void testAIFF_2() + { + fileRefSave("alaw", ".aifc"); + } + void testUnsupported() { FileRef f1(TEST_FILE_PATH_C("no-extension")); From 5a155ef4ce9e41950250682475e80e7eb13a00c5 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sun, 7 Feb 2016 04:46:40 +0900 Subject: [PATCH 07/74] Fix memory leaks when saving Ogg files. --- taglib/ogg/oggfile.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/taglib/ogg/oggfile.cpp b/taglib/ogg/oggfile.cpp index 2a922981..6520cc32 100644 --- a/taglib/ogg/oggfile.cpp +++ b/taglib/ogg/oggfile.cpp @@ -262,12 +262,13 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) // TODO: This pagination method isn't accurate for what's being done here. // This should account for real possibilities like non-aligned packets and such. - const List pages = Page::paginate(packets, - Page::SinglePagePerGroup, - firstPage->header()->streamSerialNumber(), - firstPage->pageSequenceNumber(), - firstPage->header()->firstPacketContinued(), - lastPage->header()->lastPacketCompleted()); + List pages = Page::paginate(packets, + Page::SinglePagePerGroup, + firstPage->header()->streamSerialNumber(), + firstPage->pageSequenceNumber(), + firstPage->header()->firstPacketContinued(), + lastPage->header()->lastPacketCompleted()); + pages.setAutoDelete(true); // Write the pages. From 45a3bdb6951dee17e56d2de08b5d164b8a8f744d Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Wed, 10 Feb 2016 11:08:30 +0000 Subject: [PATCH 08/74] Properly mark functions as virtual --- taglib/mod/modtag.h | 28 ++++++++++++++-------------- taglib/mp4/mp4tag.h | 30 +++++++++++++++--------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/taglib/mod/modtag.h b/taglib/mod/modtag.h index b9cad20a..dee06617 100644 --- a/taglib/mod/modtag.h +++ b/taglib/mod/modtag.h @@ -54,39 +54,39 @@ namespace TagLib { * Returns the track name; if no track name is present in the tag * String::null will be returned. */ - String title() const; + virtual String title() const; /*! * Not supported by module files. Therefore always returns String::null. */ - String artist() const; + virtual String artist() const; /*! * Not supported by module files. Therefore always returns String::null. */ - String album() const; + virtual String album() const; /*! * Returns the track comment derived from the instrument/sample/pattern * names; if no comment is present in the tag String::null will be * returned. */ - String comment() const; + virtual String comment() const; /*! * Not supported by module files. Therefore always returns String::null. */ - String genre() const; + virtual String genre() const; /*! * Not supported by module files. Therefore always returns 0. */ - unsigned int year() const; + virtual unsigned int year() const; /*! * Not supported by module files. Therefore always returns 0. */ - unsigned int track() const; + virtual unsigned int track() const; /*! * Returns the name of the tracker used to create/edit the module file. @@ -105,17 +105,17 @@ namespace TagLib { * Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20 * characters. */ - void setTitle(const String &title); + virtual void setTitle(const String &title); /*! * Not supported by module files and therefore ignored. */ - void setArtist(const String &artist); + virtual void setArtist(const String &artist); /*! * Not supported by module files and therefore ignored. */ - void setAlbum(const String &album); + virtual void setAlbum(const String &album); /*! * Sets the comment to \a comment. If \a comment is String::null then @@ -134,22 +134,22 @@ namespace TagLib { * Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22 * characters. */ - void setComment(const String &comment); + virtual void setComment(const String &comment); /*! * Not supported by module files and therefore ignored. */ - void setGenre(const String &genre); + virtual void setGenre(const String &genre); /*! * Not supported by module files and therefore ignored. */ - void setYear(unsigned int year); + virtual void setYear(unsigned int year); /*! * Not supported by module files and therefore ignored. */ - void setTrack(unsigned int track); + virtual void setTrack(unsigned int track); /*! * Sets the tracker name to \a trackerName. If \a trackerName is diff --git a/taglib/mp4/mp4tag.h b/taglib/mp4/mp4tag.h index 7a73b3fe..d477a86e 100644 --- a/taglib/mp4/mp4tag.h +++ b/taglib/mp4/mp4tag.h @@ -50,24 +50,24 @@ namespace TagLib { public: Tag(); Tag(TagLib::File *file, Atoms *atoms); - ~Tag(); + virtual ~Tag(); bool save(); - String title() const; - String artist() const; - String album() const; - String comment() const; - String genre() const; - unsigned int year() const; - unsigned int track() const; + virtual String title() const; + virtual String artist() const; + virtual String album() const; + virtual String comment() const; + virtual String genre() const; + virtual unsigned int year() const; + virtual unsigned int track() const; - void setTitle(const String &value); - void setArtist(const String &value); - void setAlbum(const String &value); - void setComment(const String &value); - void setGenre(const String &value); - void setYear(unsigned int value); - void setTrack(unsigned int value); + virtual void setTitle(const String &value); + virtual void setArtist(const String &value); + virtual void setAlbum(const String &value); + virtual void setComment(const String &value); + virtual void setGenre(const String &value); + virtual void setYear(unsigned int value); + virtual void setTrack(unsigned int value); virtual bool isEmpty() const; From aa339eba87f7fc99c83243808588ee20512def19 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 11 Feb 2016 20:47:55 +0900 Subject: [PATCH 09/74] Fix a wrong test for base64 decoding. --- tests/test_bytevector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 8cd209f1..159502dd 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -429,7 +429,7 @@ public: CPPUNIT_ASSERT_EQUAL(e3, s3.toBase64()); // Decode - CPPUNIT_ASSERT_EQUAL(sempty, eempty.toBase64()); + CPPUNIT_ASSERT_EQUAL(sempty, ByteVector::fromBase64(eempty)); CPPUNIT_ASSERT_EQUAL(s0, ByteVector::fromBase64(e0)); CPPUNIT_ASSERT_EQUAL(s1, ByteVector::fromBase64(e1)); CPPUNIT_ASSERT_EQUAL(s2, ByteVector::fromBase64(e2)); From ab2267f9aae8643a6ff1a8809dc745cd97d2cb48 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 13 Feb 2016 15:38:35 +0900 Subject: [PATCH 10/74] Find Boost properly. check_cxx_source_compiles() depends on the Visual Studio settings. --- ConfigureChecks.cmake | 32 ++++++++++++++------------------ taglib/CMakeLists.txt | 8 ++++++++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index a9f9f17a..0e6eb628 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -34,6 +34,13 @@ if(NOT ${SIZEOF_DOUBLE} EQUAL 8) message(FATAL_ERROR "TagLib requires that double is 64-bit wide.") endif() +# Determine whether Boost "header-only" libraries are installed. + +find_package(Boost) +if(Boost_FOUND) + set(Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") +endif() + # Determine which kind of atomic operations your compiler supports. check_cxx_source_compiles(" @@ -47,15 +54,10 @@ check_cxx_source_compiles(" " HAVE_STD_ATOMIC) if(NOT HAVE_STD_ATOMIC) - check_cxx_source_compiles(" - #include - int main() { - boost::atomic x(1); - x.fetch_add(1); - x.fetch_sub(1); - return 0; - } - " HAVE_BOOST_ATOMIC) + find_package(Boost COMPONENTS atomic) + if(Boost_ATOMIC_FOUND) + set(HAVE_BOOST_ATOMIC 1) + endif() if(NOT HAVE_BOOST_ATOMIC) check_cxx_source_compiles(" @@ -107,15 +109,9 @@ endif() # Determine which kind of byte swap functions your compiler supports. -check_cxx_source_compiles(" - #include - int main() { - boost::endian::endian_reverse(static_cast(1)); - boost::endian::endian_reverse(static_cast(1)); - boost::endian::endian_reverse(static_cast(1)); - return 0; - } -" HAVE_BOOST_BYTESWAP) +if(Boost_FOUND AND NOT (Boost_VERSION VERSION_LESS "1.58.0")) + set(HAVE_BOOST_BYTESWAP 1) +endif() if(NOT HAVE_BOOST_BYTESWAP) check_cxx_source_compiles(" diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt index 5a047bf1..8e67d709 100644 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -32,6 +32,10 @@ elseif(HAVE_ZLIB_SOURCE) include_directories(${ZLIB_SOURCE}) endif() +if(HAVE_BOOST_ATOMIC OR HAVE_BOOST_BYTESWAP) + include_directories(${Boost_INCLUDE_DIR}) +endif() + set(tag_HDRS tag.h fileref.h @@ -343,6 +347,10 @@ if(ZLIB_FOUND) target_link_libraries(tag ${ZLIB_LIBRARIES}) endif() +if(HAVE_BOOST_ATOMIC) + target_link_libraries(tag ${Boost_ATOMIC_LIBRARY}) +endif() + set_target_properties(tag PROPERTIES VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH} SOVERSION ${TAGLIB_SOVERSION_MAJOR} From bb006e41d702afeca1c8ff56dc7c748666f9938f Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sun, 14 Feb 2016 03:17:37 +0900 Subject: [PATCH 11/74] Disable Boost Endian library for now. It's not detected properly depending on the environment. --- ConfigureChecks.cmake | 77 +++++++++++++++++------------------------ config.h.cmake | 1 - taglib/CMakeLists.txt | 2 +- taglib/toolkit/tutils.h | 22 +++--------- 4 files changed, 37 insertions(+), 65 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 0e6eb628..aef79294 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -34,13 +34,6 @@ if(NOT ${SIZEOF_DOUBLE} EQUAL 8) message(FATAL_ERROR "TagLib requires that double is 64-bit wide.") endif() -# Determine whether Boost "header-only" libraries are installed. - -find_package(Boost) -if(Boost_FOUND) - set(Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") -endif() - # Determine which kind of atomic operations your compiler supports. check_cxx_source_compiles(" @@ -109,64 +102,58 @@ endif() # Determine which kind of byte swap functions your compiler supports. -if(Boost_FOUND AND NOT (Boost_VERSION VERSION_LESS "1.58.0")) - set(HAVE_BOOST_BYTESWAP 1) -endif() +check_cxx_source_compiles(" + int main() { + __builtin_bswap16(0); + __builtin_bswap32(0); + __builtin_bswap64(0); + return 0; + } +" HAVE_GCC_BYTESWAP) -if(NOT HAVE_BOOST_BYTESWAP) +if(NOT HAVE_GCC_BYTESWAP) check_cxx_source_compiles(" + #include int main() { - __builtin_bswap16(0); - __builtin_bswap32(0); - __builtin_bswap64(0); + __bswap_16(0); + __bswap_32(0); + __bswap_64(0); return 0; } - " HAVE_GCC_BYTESWAP) + " HAVE_GLIBC_BYTESWAP) - if(NOT HAVE_GCC_BYTESWAP) + if(NOT HAVE_GLIBC_BYTESWAP) check_cxx_source_compiles(" - #include + #include int main() { - __bswap_16(0); - __bswap_32(0); - __bswap_64(0); + _byteswap_ushort(0); + _byteswap_ulong(0); + _byteswap_uint64(0); return 0; } - " HAVE_GLIBC_BYTESWAP) + " HAVE_MSC_BYTESWAP) - if(NOT HAVE_GLIBC_BYTESWAP) + if(NOT HAVE_MSC_BYTESWAP) check_cxx_source_compiles(" - #include + #include int main() { - _byteswap_ushort(0); - _byteswap_ulong(0); - _byteswap_uint64(0); + OSSwapInt16(0); + OSSwapInt32(0); + OSSwapInt64(0); return 0; } - " HAVE_MSC_BYTESWAP) + " HAVE_MAC_BYTESWAP) - if(NOT HAVE_MSC_BYTESWAP) + if(NOT HAVE_MAC_BYTESWAP) check_cxx_source_compiles(" - #include + #include int main() { - OSSwapInt16(0); - OSSwapInt32(0); - OSSwapInt64(0); + swap16(0); + swap32(0); + swap64(0); return 0; } - " HAVE_MAC_BYTESWAP) - - if(NOT HAVE_MAC_BYTESWAP) - check_cxx_source_compiles(" - #include - int main() { - swap16(0); - swap32(0); - swap64(0); - return 0; - } - " HAVE_OPENBSD_BYTESWAP) - endif() + " HAVE_OPENBSD_BYTESWAP) endif() endif() endif() diff --git a/config.h.cmake b/config.h.cmake index 7ac72410..cfaa8eac 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,7 +1,6 @@ /* config.h. Generated by cmake from config.h.cmake */ /* Defined if your compiler supports some byte swap functions */ -#cmakedefine HAVE_BOOST_BYTESWAP 1 #cmakedefine HAVE_GCC_BYTESWAP 1 #cmakedefine HAVE_GLIBC_BYTESWAP 1 #cmakedefine HAVE_MSC_BYTESWAP 1 diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt index 8e67d709..cc2b7611 100644 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -32,7 +32,7 @@ elseif(HAVE_ZLIB_SOURCE) include_directories(${ZLIB_SOURCE}) endif() -if(HAVE_BOOST_ATOMIC OR HAVE_BOOST_BYTESWAP) +if(HAVE_BOOST_ATOMIC) include_directories(${Boost_INCLUDE_DIR}) endif() diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index 9a81fd8b..69eccec2 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -34,9 +34,7 @@ # include #endif -#if defined(HAVE_BOOST_BYTESWAP) -# include -#elif defined(HAVE_MSC_BYTESWAP) +#if defined(HAVE_MSC_BYTESWAP) # include #elif defined(HAVE_GLIBC_BYTESWAP) # include @@ -61,11 +59,7 @@ namespace TagLib */ inline unsigned short byteSwap(unsigned short x) { -#if defined(HAVE_BOOST_BYTESWAP) - - return boost::endian::endian_reverse(static_cast(x)); - -#elif defined(HAVE_GCC_BYTESWAP) +#if defined(HAVE_GCC_BYTESWAP) return __builtin_bswap16(x); @@ -97,11 +91,7 @@ namespace TagLib */ inline unsigned int byteSwap(unsigned int x) { -#if defined(HAVE_BOOST_BYTESWAP) - - return boost::endian::endian_reverse(static_cast(x)); - -#elif defined(HAVE_GCC_BYTESWAP) +#if defined(HAVE_GCC_BYTESWAP) return __builtin_bswap32(x); @@ -136,11 +126,7 @@ namespace TagLib */ inline unsigned long long byteSwap(unsigned long long x) { -#if defined(HAVE_BOOST_BYTESWAP) - - return boost::endian::endian_reverse(static_cast(x)); - -#elif defined(HAVE_GCC_BYTESWAP) +#if defined(HAVE_GCC_BYTESWAP) return __builtin_bswap64(x); From c349ba3a31cba91a9043d26876e5017c61ae24b1 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sun, 14 Feb 2016 03:21:21 +0900 Subject: [PATCH 12/74] Add OS X settings to travis.yml. --- .editorconfig | 4 ++-- .travis.yml | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 32b8a7df..f16a353f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,12 +8,12 @@ root = true insert_final_newline = true # 2 space indentation -[*.{h,cpp,tcc,cmake}] +[*.{h,cpp,tcc,cmake,yml}] indent_style = space indent_size = 2 # Trim traling whitespaces -[*.{h,cpp,tcc,cmake}] +[*.{h,cpp,tcc,cmake,yml}] trim_trailing_whitespace = true # UTF-8 without BOM diff --git a/.travis.yml b/.travis.yml index c5ec8862..d724ae9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,28 @@ language: cpp + sudo: false + +os: + - linux + - osx + compiler: - gcc - clang + addons: apt: packages: - - libcppunit-dev + - libcppunit-dev - zlib1g-dev + +matrix: + exclude: + - os: osx + compiler: gcc + +install: + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install cppunit; fi + script: cmake -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BINDINGS=ON . && make && make check From d037b8c9081579ea35336e498e288b3b8cc8bb08 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 15 Feb 2016 00:22:18 +0900 Subject: [PATCH 13/74] Make sure we don't write UTF8 or UTF16BE to ID3v2.3 tags. --- .../frames/generalencapsulatedobjectframe.cpp | 17 ++++++++---- taglib/mpeg/id3v2/frames/ownershipframe.cpp | 26 ++++++++++++------- .../frames/unsynchronizedlyricsframe.cpp | 14 +++++++--- taglib/mpeg/id3v2/id3v2frame.cpp | 6 ++--- tests/test_id3v2.cpp | 26 +++++++++++++++++-- 5 files changed, 65 insertions(+), 24 deletions(-) diff --git a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp index 48248294..1c773837 100644 --- a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp +++ b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp @@ -27,6 +27,7 @@ ***************************************************************************/ #include +#include #include "generalencapsulatedobjectframe.h" @@ -152,15 +153,21 @@ void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data) ByteVector GeneralEncapsulatedObjectFrame::renderFields() const { + StringList sl; + sl.append(d->fileName); + sl.append(d->description); + + const String::Type encoding = checkTextEncoding(sl, d->textEncoding); + ByteVector data; - data.append(char(d->textEncoding)); + data.append(char(encoding)); data.append(d->mimeType.data(String::Latin1)); data.append(textDelimiter(String::Latin1)); - data.append(d->fileName.data(d->textEncoding)); - data.append(textDelimiter(d->textEncoding)); - data.append(d->description.data(d->textEncoding)); - data.append(textDelimiter(d->textEncoding)); + data.append(d->fileName.data(encoding)); + data.append(textDelimiter(encoding)); + data.append(d->description.data(encoding)); + data.append(textDelimiter(encoding)); data.append(d->data); return data; diff --git a/taglib/mpeg/id3v2/frames/ownershipframe.cpp b/taglib/mpeg/id3v2/frames/ownershipframe.cpp index 9451c4c4..83a59824 100644 --- a/taglib/mpeg/id3v2/frames/ownershipframe.cpp +++ b/taglib/mpeg/id3v2/frames/ownershipframe.cpp @@ -24,9 +24,10 @@ ***************************************************************************/ #include +#include +#include #include "ownershipframe.h" -#include using namespace TagLib; using namespace ID3v2; @@ -113,24 +114,24 @@ void OwnershipFrame::setTextEncoding(String::Type encoding) void OwnershipFrame::parseFields(const ByteVector &data) { int pos = 0; - + // Get the text encoding d->textEncoding = String::Type(data[0]); pos += 1; - + // Read the price paid this is a null terminate string d->pricePaid = readStringField(data, String::Latin1, &pos); - + // If we don't have at least 8 bytes left then don't parse the rest of the // data if(data.size() - pos < 8) { return; } - + // Read the date purchased YYYYMMDD d->datePurchased = String(data.mid(pos, 8)); pos += 8; - + // Read the seller if(d->textEncoding == String::Latin1) d->seller = Tag::latin1StringHandler()->parse(data.mid(pos)); @@ -140,14 +141,19 @@ void OwnershipFrame::parseFields(const ByteVector &data) ByteVector OwnershipFrame::renderFields() const { + StringList sl; + sl.append(d->seller); + + const String::Type encoding = checkTextEncoding(sl, d->textEncoding); + ByteVector v; - - v.append(char(d->textEncoding)); + + v.append(char(encoding)); v.append(d->pricePaid.data(String::Latin1)); v.append(textDelimiter(String::Latin1)); v.append(d->datePurchased.data(String::Latin1)); - v.append(d->seller.data(d->textEncoding)); - + v.append(d->seller.data(encoding)); + return v; } diff --git a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp index 01ccc68e..3d610c9a 100644 --- a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp @@ -169,13 +169,19 @@ void UnsynchronizedLyricsFrame::parseFields(const ByteVector &data) ByteVector UnsynchronizedLyricsFrame::renderFields() const { + StringList sl; + sl.append(d->description); + sl.append(d->text); + + const String::Type encoding = checkTextEncoding(sl, d->textEncoding); + ByteVector v; - v.append(char(d->textEncoding)); + v.append(char(encoding)); v.append(d->language.size() == 3 ? d->language : "XXX"); - v.append(d->description.data(d->textEncoding)); - v.append(textDelimiter(d->textEncoding)); - v.append(d->text.data(d->textEncoding)); + v.append(d->description.data(encoding)); + v.append(textDelimiter(encoding)); + v.append(d->text.data(encoding)); return v; } diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index 52180447..a9d48f71 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -97,10 +97,10 @@ unsigned int Frame::headerSize(unsigned int version) ByteVector Frame::textDelimiter(String::Type t) { - ByteVector d = char(0); if(t == String::UTF16 || t == String::UTF16BE || t == String::UTF16LE) - d.append(char(0)); - return d; + return ByteVector(2, '\0'); + else + return ByteVector(1, '\0'); } const String Frame::instrumentPrefix("PERFORMER:"); diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index f5e5981f..8b9e5b3f 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -70,7 +70,8 @@ class TestID3v2 : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TestID3v2); CPPUNIT_TEST(testUnsynchDecode); - CPPUNIT_TEST(testDowngradeUTF8ForID3v23); + CPPUNIT_TEST(testDowngradeUTF8ForID3v23_1); + CPPUNIT_TEST(testDowngradeUTF8ForID3v23_2); CPPUNIT_TEST(testUTF16BEDelimiter); CPPUNIT_TEST(testUTF16Delimiter); CPPUNIT_TEST(testReadStringField); @@ -130,7 +131,7 @@ public: CPPUNIT_ASSERT_EQUAL(String("My babe just cares for me"), f.tag()->title()); } - void testDowngradeUTF8ForID3v23() + void testDowngradeUTF8ForID3v23_1() { ScopedFileCopy copy("xing", ".mp3"); string newname = copy.fileName(); @@ -154,6 +155,27 @@ public: CPPUNIT_ASSERT_EQUAL(String::UTF16, f2.textEncoding()); } + void testDowngradeUTF8ForID3v23_2() + { + ScopedFileCopy copy("xing", ".mp3"); + + ID3v2::UnsynchronizedLyricsFrame *f + = new ID3v2::UnsynchronizedLyricsFrame(String::UTF8); + f->setText("Foo"); + + MPEG::File file(copy.fileName().c_str()); + file.ID3v2Tag(true)->addFrame(f); + file.save(MPEG::File::ID3v2, true, 3); + CPPUNIT_ASSERT(file.hasID3v2Tag()); + + ByteVector data = f->render(); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4+4+2+1+3+2+2+6+2), data.size()); + + ID3v2::UnsynchronizedLyricsFrame f2(data); + CPPUNIT_ASSERT_EQUAL(String("Foo"), f2.text()); + CPPUNIT_ASSERT_EQUAL(String::UTF16, f2.textEncoding()); + } + void testUTF16BEDelimiter() { ID3v2::TextIdentificationFrame f(ByteVector("TPE1"), String::UTF16BE); From f8f7cb0904ea789d3b1a012635102bd139ad9e2c Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 15 Feb 2016 00:26:41 +0900 Subject: [PATCH 14/74] Update NEWS. --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index cdc855a1..74695376 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ TagLib 1.11 (Jan 30, 2016) * Better handling of PCM WAV files with a 'fact' chunk. * Better handling of corrupted APE tags. + * Fixed text encoding when saving certain frames in ID3v2.3 tags. * Several smaller bug fixes and performance improvements. 1.11 BETA: From f3016c0892e8944ecf497eb513b7ed79b4848c02 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 15 Feb 2016 01:36:17 +0900 Subject: [PATCH 15/74] Enable Boost Endian library again. It should be detected properly now. --- ConfigureChecks.cmake | 75 ++++++++++++++++++++++++++--------------- config.h.cmake | 1 + taglib/CMakeLists.txt | 2 +- taglib/toolkit/tutils.h | 22 +++++++++--- 4 files changed, 67 insertions(+), 33 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index aef79294..6f3c82ec 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -34,6 +34,13 @@ if(NOT ${SIZEOF_DOUBLE} EQUAL 8) message(FATAL_ERROR "TagLib requires that double is 64-bit wide.") endif() +# Enable check_cxx_source_compiles() to work with Boost "header-only" libraries. + +find_package(Boost) +if(Boost_FOUND) + set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${Boost_INCLUDE_DIRS}") +endif() + # Determine which kind of atomic operations your compiler supports. check_cxx_source_compiles(" @@ -103,57 +110,69 @@ endif() # Determine which kind of byte swap functions your compiler supports. check_cxx_source_compiles(" + #include int main() { - __builtin_bswap16(0); - __builtin_bswap32(0); - __builtin_bswap64(0); + boost::endian::endian_reverse(static_cast(1)); + boost::endian::endian_reverse(static_cast(1)); + boost::endian::endian_reverse(static_cast(1)); return 0; } -" HAVE_GCC_BYTESWAP) +" HAVE_BOOST_BYTESWAP) -if(NOT HAVE_GCC_BYTESWAP) +if(NOT HAVE_BOOST_BYTESWAP) check_cxx_source_compiles(" - #include int main() { - __bswap_16(0); - __bswap_32(0); - __bswap_64(0); + __builtin_bswap16(0); + __builtin_bswap32(0); + __builtin_bswap64(0); return 0; } - " HAVE_GLIBC_BYTESWAP) + " HAVE_GCC_BYTESWAP) - if(NOT HAVE_GLIBC_BYTESWAP) + if(NOT HAVE_GCC_BYTESWAP) check_cxx_source_compiles(" - #include + #include int main() { - _byteswap_ushort(0); - _byteswap_ulong(0); - _byteswap_uint64(0); + __bswap_16(0); + __bswap_32(0); + __bswap_64(0); return 0; } - " HAVE_MSC_BYTESWAP) + " HAVE_GLIBC_BYTESWAP) - if(NOT HAVE_MSC_BYTESWAP) + if(NOT HAVE_GLIBC_BYTESWAP) check_cxx_source_compiles(" - #include + #include int main() { - OSSwapInt16(0); - OSSwapInt32(0); - OSSwapInt64(0); + _byteswap_ushort(0); + _byteswap_ulong(0); + _byteswap_uint64(0); return 0; } - " HAVE_MAC_BYTESWAP) + " HAVE_MSC_BYTESWAP) - if(NOT HAVE_MAC_BYTESWAP) + if(NOT HAVE_MSC_BYTESWAP) check_cxx_source_compiles(" - #include + #include int main() { - swap16(0); - swap32(0); - swap64(0); + OSSwapInt16(0); + OSSwapInt32(0); + OSSwapInt64(0); return 0; } - " HAVE_OPENBSD_BYTESWAP) + " HAVE_MAC_BYTESWAP) + + if(NOT HAVE_MAC_BYTESWAP) + check_cxx_source_compiles(" + #include + int main() { + swap16(0); + swap32(0); + swap64(0); + return 0; + } + " HAVE_OPENBSD_BYTESWAP) + endif() endif() endif() endif() diff --git a/config.h.cmake b/config.h.cmake index cfaa8eac..7ac72410 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,6 +1,7 @@ /* config.h. Generated by cmake from config.h.cmake */ /* Defined if your compiler supports some byte swap functions */ +#cmakedefine HAVE_BOOST_BYTESWAP 1 #cmakedefine HAVE_GCC_BYTESWAP 1 #cmakedefine HAVE_GLIBC_BYTESWAP 1 #cmakedefine HAVE_MSC_BYTESWAP 1 diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt index cc2b7611..c30929fc 100644 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -32,7 +32,7 @@ elseif(HAVE_ZLIB_SOURCE) include_directories(${ZLIB_SOURCE}) endif() -if(HAVE_BOOST_ATOMIC) +if(HAVE_BOOST_BYTESWAP OR HAVE_BOOST_ATOMIC) include_directories(${Boost_INCLUDE_DIR}) endif() diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index 69eccec2..bacbc2dd 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -34,7 +34,9 @@ # include #endif -#if defined(HAVE_MSC_BYTESWAP) +#if defined(HAVE_BOOST_BYTESWAP) +# include +#elif defined(HAVE_MSC_BYTESWAP) # include #elif defined(HAVE_GLIBC_BYTESWAP) # include @@ -59,7 +61,11 @@ namespace TagLib */ inline unsigned short byteSwap(unsigned short x) { -#if defined(HAVE_GCC_BYTESWAP) +#if defined(HAVE_BOOST_BYTESWAP) + + return boost::endian::endian_reverse(x); + +#elif defined(HAVE_GCC_BYTESWAP) return __builtin_bswap16(x); @@ -91,7 +97,11 @@ namespace TagLib */ inline unsigned int byteSwap(unsigned int x) { -#if defined(HAVE_GCC_BYTESWAP) +#if defined(HAVE_BOOST_BYTESWAP) + + return boost::endian::endian_reverse(x); + +#elif defined(HAVE_GCC_BYTESWAP) return __builtin_bswap32(x); @@ -126,7 +136,11 @@ namespace TagLib */ inline unsigned long long byteSwap(unsigned long long x) { -#if defined(HAVE_GCC_BYTESWAP) +#if defined(HAVE_BOOST_BYTESWAP) + + return boost::endian::endian_reverse(x); + +#elif defined(HAVE_GCC_BYTESWAP) return __builtin_bswap64(x); From c08e0b13572b0275e42e1168ff09a80ceb6aea2c Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 15 Feb 2016 01:49:23 +0900 Subject: [PATCH 16/74] Reorganize some redundant or missing tests. --- tests/test_bytevector.cpp | 232 ++++++++++++++++++++------------------ tests/test_string.cpp | 86 ++++++-------- 2 files changed, 158 insertions(+), 160 deletions(-) diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 159502dd..f5e93d5f 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -23,7 +23,8 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#include +#define _USE_MATH_DEFINES +#include #include #include #include @@ -37,10 +38,13 @@ class TestByteVector : public CppUnit::TestFixture CPPUNIT_TEST(testByteVector); CPPUNIT_TEST(testFind1); CPPUNIT_TEST(testFind2); + CPPUNIT_TEST(testFind3); CPPUNIT_TEST(testRfind1); CPPUNIT_TEST(testRfind2); + CPPUNIT_TEST(testRfind3); CPPUNIT_TEST(testToHex); - CPPUNIT_TEST(testNumericCoversion); + CPPUNIT_TEST(testIntegerConversion); + CPPUNIT_TEST(testFloatingPointConversion); CPPUNIT_TEST(testReplace); CPPUNIT_TEST(testIterator); CPPUNIT_TEST(testResize); @@ -49,78 +53,19 @@ class TestByteVector : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_END(); public: - - void testConversion(unsigned int i, unsigned char a, unsigned char b, unsigned char c, unsigned char d) - { - ByteVector v(4, 0); - - v[3] = a; - v[2] = b; - v[1] = c; - v[0] = d; - CPPUNIT_ASSERT(v.toUInt(false) == i); - - v[0] = a; - v[1] = b; - v[2] = c; - v[3] = d; - CPPUNIT_ASSERT(v.toUInt() == i); - } - void testByteVector() { - ByteVector v("foobar"); - - CPPUNIT_ASSERT(v.find("ob") == 2); - CPPUNIT_ASSERT(v.find('b') == 3); - - ByteVector n(4, 0); - n[0] = 1; - CPPUNIT_ASSERT(n.toUInt(true) == 16777216); - CPPUNIT_ASSERT(n.toUInt(false) == 1); - CPPUNIT_ASSERT(ByteVector::fromUInt(16777216, true) == n); - CPPUNIT_ASSERT(ByteVector::fromUInt(1, false) == n); - - CPPUNIT_ASSERT(ByteVector::fromUInt(0xa0).toUInt() == 0xa0); - - testConversion(0x000000a0, 0x00, 0x00, 0x00, 0xa0); - testConversion(0xd50bf072, 0xd5, 0x0b, 0xf0, 0x72); - - ByteVector intVector(2, 0); - intVector[0] = char(0xfc); - intVector[1] = char(0x00); - CPPUNIT_ASSERT(intVector.toShort() == -1024); - intVector[0] = char(0x04); - intVector[1] = char(0x00); - CPPUNIT_ASSERT(intVector.toShort() == 1024); - - CPPUNIT_ASSERT(ByteVector::fromLongLong(1).toLongLong() == 1); - CPPUNIT_ASSERT(ByteVector::fromLongLong(0).toLongLong() == 0); - CPPUNIT_ASSERT(ByteVector::fromLongLong(0xffffffffffffffffLL).toLongLong() == -1); - CPPUNIT_ASSERT(ByteVector::fromLongLong(0xfffffffffffffffeLL).toLongLong() == -2); - CPPUNIT_ASSERT(ByteVector::fromLongLong(1024).toLongLong() == 1024); - - ByteVector a1("foo"); - a1.append("bar"); - CPPUNIT_ASSERT(a1 == "foobar"); - - ByteVector a2("foo"); - a2.append("b"); - CPPUNIT_ASSERT(a2 == "foob"); - - ByteVector a3; - a3.append("b"); - CPPUNIT_ASSERT(a3 == "b"); - ByteVector s1("foo"); CPPUNIT_ASSERT(ByteVectorList::split(s1, " ").size() == 1); ByteVector s2("f"); CPPUNIT_ASSERT(ByteVectorList::split(s2, " ").size() == 1); - CPPUNIT_ASSERT(ByteVector().size() == 0); - CPPUNIT_ASSERT(ByteVector("asdf").clear().size() == 0); - CPPUNIT_ASSERT(ByteVector("asdf").clear() == ByteVector()); + CPPUNIT_ASSERT(ByteVector().isEmpty()); + CPPUNIT_ASSERT_EQUAL(0U, ByteVector().size()); + CPPUNIT_ASSERT(ByteVector("asdf").clear().isEmpty()); + CPPUNIT_ASSERT_EQUAL(0U, ByteVector("asdf").clear().size()); + CPPUNIT_ASSERT_EQUAL(ByteVector(), ByteVector("asdf").clear()); ByteVector i("blah blah"); ByteVector j("blah"); @@ -161,6 +106,20 @@ public: CPPUNIT_ASSERT_EQUAL(-1, ByteVector("\x01\x02", 2).find("\x01\x03")); } + void testFind3() + { + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S')); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 0)); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 1)); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 2)); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 3)); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 4)); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find('S', 5)); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find('S', 6)); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find('S', 7)); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find('S', 8)); + } + void testRfind1() { CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 0)); @@ -197,6 +156,20 @@ public: CPPUNIT_ASSERT_EQUAL(10, r4.rfind("OggS", 12)); } + void testRfind3() + { + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 0)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 1)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 2)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 3)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 4)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 5)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 6)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 7)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 8)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O')); + } + void testToHex() { ByteVector v("\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f", 16); @@ -204,50 +177,71 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("f0e1d2c3b4a5968778695a4b3c2d1e0f"), v.toHex()); } - void testNumericCoversion() + void testIntegerConversion() { - CPPUNIT_ASSERT_EQUAL((unsigned short)0xFFFF, ByteVector("\xff\xff", 2).toUShort()); - CPPUNIT_ASSERT_EQUAL((unsigned short)0x0001, ByteVector("\x00\x01", 2).toUShort()); - CPPUNIT_ASSERT_EQUAL((unsigned short)0x0100, ByteVector("\x00\x01", 2).toUShort(false)); - CPPUNIT_ASSERT_EQUAL((unsigned short)0xFF01, ByteVector("\xFF\x01", 2).toUShort()); - CPPUNIT_ASSERT_EQUAL((unsigned short)0x01FF, ByteVector("\xFF\x01", 2).toUShort(false)); + const ByteVector data("\x00\xff\x01\xff\x00\xff\x01\xff\x00\xff\x01\xff\x00\xff", 14); - const unsigned char PI32LE[] = { 0x00, 0xdb, 0x0f, 0x49, 0x40 }; - const unsigned char PI32BE[] = { 0x00, 0x40, 0x49, 0x0f, 0xdb }; - const unsigned char PI64LE[] = { 0x00, 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40 }; - const unsigned char PI64BE[] = { 0x00, 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18 }; - const unsigned char PI80LE[] = { 0x00, 0x00, 0xc0, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0xc9, 0x00, 0x40 }; - const unsigned char PI80BE[] = { 0x00, 0x40, 0x00, 0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc0, 0x00 }; + CPPUNIT_ASSERT_EQUAL((short)0x00ff, data.toShort()); + CPPUNIT_ASSERT_EQUAL((short)0xff00, data.toShort(false)); + CPPUNIT_ASSERT_EQUAL((short)0xff01, data.toShort(5U)); + CPPUNIT_ASSERT_EQUAL((short)0x01ff, data.toShort(5U, false)); + CPPUNIT_ASSERT_EQUAL((short)0xff, data.toShort(13U)); + CPPUNIT_ASSERT_EQUAL((short)0xff, data.toShort(13U, false)); - ByteVector pi32le(reinterpret_cast(PI32LE), 5); - CPPUNIT_ASSERT_EQUAL(31415, static_cast(pi32le.toFloat32LE(1) * 10000)); + CPPUNIT_ASSERT_EQUAL((unsigned short)0x00ff, data.toUShort()); + CPPUNIT_ASSERT_EQUAL((unsigned short)0xff00, data.toUShort(false)); + CPPUNIT_ASSERT_EQUAL((unsigned short)0xff01, data.toUShort(5U)); + CPPUNIT_ASSERT_EQUAL((unsigned short)0x01ff, data.toUShort(5U, false)); + CPPUNIT_ASSERT_EQUAL((unsigned short)0xff, data.toUShort(13U)); + CPPUNIT_ASSERT_EQUAL((unsigned short)0xff, data.toUShort(13U, false)); - ByteVector pi32be(reinterpret_cast(PI32BE), 5); - CPPUNIT_ASSERT_EQUAL(31415, static_cast(pi32be.toFloat32BE(1) * 10000)); + CPPUNIT_ASSERT_EQUAL(0x00ff01ffU, data.toUInt()); + CPPUNIT_ASSERT_EQUAL(0xff01ff00U, data.toUInt(false)); + CPPUNIT_ASSERT_EQUAL(0xff01ff00U, data.toUInt(5U)); + CPPUNIT_ASSERT_EQUAL(0x00ff01ffU, data.toUInt(5U, false)); + CPPUNIT_ASSERT_EQUAL(0x00ffU, data.toUInt(12U)); + CPPUNIT_ASSERT_EQUAL(0xff00U, data.toUInt(12U, false)); - ByteVector pi64le(reinterpret_cast(PI64LE), 9); - CPPUNIT_ASSERT_EQUAL(31415, static_cast(pi64le.toFloat64LE(1) * 10000)); + CPPUNIT_ASSERT_EQUAL(0x00ff01U, data.toUInt(0U, 3U)); + CPPUNIT_ASSERT_EQUAL(0x01ff00U, data.toUInt(0U, 3U, false)); + CPPUNIT_ASSERT_EQUAL(0xff01ffU, data.toUInt(5U, 3U)); + CPPUNIT_ASSERT_EQUAL(0xff01ffU, data.toUInt(5U, 3U, false)); + CPPUNIT_ASSERT_EQUAL(0x00ffU, data.toUInt(12U, 3U)); + CPPUNIT_ASSERT_EQUAL(0xff00U, data.toUInt(12U, 3U, false)); - ByteVector pi64be(reinterpret_cast(PI64BE), 9); - CPPUNIT_ASSERT_EQUAL(31415, static_cast(pi64be.toFloat64BE(1) * 10000)); + CPPUNIT_ASSERT_EQUAL((long long)0x00ff01ff00ff01ffULL, data.toLongLong()); + CPPUNIT_ASSERT_EQUAL((long long)0xff01ff00ff01ff00ULL, data.toLongLong(false)); + CPPUNIT_ASSERT_EQUAL((long long)0xff01ff00ff01ff00ULL, data.toLongLong(5U)); + CPPUNIT_ASSERT_EQUAL((long long)0x00ff01ff00ff01ffULL, data.toLongLong(5U, false)); + CPPUNIT_ASSERT_EQUAL((long long)0x00ffU, data.toLongLong(12U)); + CPPUNIT_ASSERT_EQUAL((long long)0xff00U, data.toLongLong(12U, false)); +} - ByteVector pi80le(reinterpret_cast(PI80LE), 11); - CPPUNIT_ASSERT_EQUAL(31415, static_cast(pi80le.toFloat80LE(1) * 10000)); + void testFloatingPointConversion() + { + const double Tolerance = 1.0e-7; - ByteVector pi80be(reinterpret_cast(PI80BE), 11); - CPPUNIT_ASSERT_EQUAL(31415, static_cast(pi80be.toFloat80BE(1) * 10000)); + const ByteVector pi32le("\xdb\x0f\x49\x40", 4); + CPPUNIT_ASSERT(::abs(pi32le.toFloat32LE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT_EQUAL(pi32le, ByteVector::fromFloat32LE(pi32le.toFloat32LE(0))); - ByteVector pi32le2 = ByteVector::fromFloat32LE(pi32le.toFloat32LE(1)); - CPPUNIT_ASSERT(memcmp(pi32le.data() + 1, pi32le2.data(), 4) == 0); + const ByteVector pi32be("\x40\x49\x0f\xdb", 4); + CPPUNIT_ASSERT(::abs(pi32be.toFloat32BE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT_EQUAL(pi32be, ByteVector::fromFloat32BE(pi32be.toFloat32BE(0))); - ByteVector pi32be2 = ByteVector::fromFloat32BE(pi32be.toFloat32BE(1)); - CPPUNIT_ASSERT(memcmp(pi32be.data() + 1, pi32be2.data(), 4) == 0); + const ByteVector pi64le("\x18\x2d\x44\x54\xfb\x21\x09\x40", 8); + CPPUNIT_ASSERT(::abs(pi64le.toFloat64LE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT_EQUAL(pi64le, ByteVector::fromFloat64LE(pi64le.toFloat64LE(0))); - ByteVector pi64le2 = ByteVector::fromFloat64LE(pi64le.toFloat64LE(1)); - CPPUNIT_ASSERT(memcmp(pi64le.data() + 1, pi64le2.data(), 8) == 0); + const ByteVector pi64be("\x40\x09\x21\xfb\x54\x44\x2d\x18", 8); + CPPUNIT_ASSERT(::abs(pi64be.toFloat64BE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT_EQUAL(pi64be, ByteVector::fromFloat64BE(pi64be.toFloat64BE(0))); - ByteVector pi64be2 = ByteVector::fromFloat64BE(pi64be.toFloat64BE(1)); - CPPUNIT_ASSERT(memcmp(pi64be.data() + 1, pi64be2.data(), 8) == 0); + const ByteVector pi80le("\x00\xc0\x68\x21\xa2\xda\x0f\xc9\x00\x40", 10); + CPPUNIT_ASSERT(::abs(pi80le.toFloat80LE(0) - M_PI) < Tolerance); + + const ByteVector pi80be("\x40\x00\xc9\x0f\xda\xa2\x21\x68\xc0\x00", 10); + CPPUNIT_ASSERT(::abs(pi80be.toFloat80BE(0) - M_PI) < Tolerance); } void testReplace() @@ -392,16 +386,40 @@ public: void testAppend() { - ByteVector v1("taglib"); - ByteVector v2 = v1; + ByteVector v1("foo"); + v1.append("bar"); + CPPUNIT_ASSERT_EQUAL(ByteVector("foobar"), v1); - v1.append("ABC"); - CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC"), v1); - v1.append('1'); - v1.append('2'); - v1.append('3'); - CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC123"), v1); - CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v2); + ByteVector v2("foo"); + v2.append("b"); + CPPUNIT_ASSERT_EQUAL(ByteVector("foob"), v2); + + ByteVector v3; + v3.append("b"); + CPPUNIT_ASSERT_EQUAL(ByteVector("b"), v3); + + ByteVector v4("foo"); + v4.append(v1); + CPPUNIT_ASSERT_EQUAL(ByteVector("foofoobar"), v4); + + ByteVector v5("foo"); + v5.append('b'); + CPPUNIT_ASSERT_EQUAL(ByteVector("foob"), v5); + + ByteVector v6; + v6.append('b'); + CPPUNIT_ASSERT_EQUAL(ByteVector("b"), v6); + + ByteVector v7("taglib"); + ByteVector v8 = v7; + + v7.append("ABC"); + CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC"), v7); + v7.append('1'); + v7.append('2'); + v7.append('3'); + CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC123"), v7); + CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v8); } void testBase64() diff --git a/tests/test_string.cpp b/tests/test_string.cpp index 83b47911..3fa28b69 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -43,9 +43,11 @@ class TestString : public CppUnit::TestFixture CPPUNIT_TEST(testAppendCharDetach); CPPUNIT_TEST(testAppendStringDetach); CPPUNIT_TEST(testToInt); + CPPUNIT_TEST(testFromInt); CPPUNIT_TEST(testSubstr); CPPUNIT_TEST(testNewline); - CPPUNIT_TEST(testEncode); + CPPUNIT_TEST(testEncodeNonLatin1); + CPPUNIT_TEST(testEncodeEmpty); CPPUNIT_TEST(testIterator); CPPUNIT_TEST_SUITE_END(); @@ -105,31 +107,12 @@ public: 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); - - String n = "123"; - CPPUNIT_ASSERT(n.toInt() == 123); - - n = "-123"; - CPPUNIT_ASSERT(n.toInt() == -123); - - CPPUNIT_ASSERT(String("0").toInt() == 0); - CPPUNIT_ASSERT(String("1").toInt() == 1); - CPPUNIT_ASSERT(String(" foo ").stripWhiteSpace() == String("foo")); CPPUNIT_ASSERT(String("foo ").stripWhiteSpace() == String("foo")); CPPUNIT_ASSERT(String(" foo").stripWhiteSpace() == String("foo")); CPPUNIT_ASSERT(memcmp(String("foo").data(String::Latin1).data(), "foo", 3) == 0); CPPUNIT_ASSERT(memcmp(String("f").data(String::Latin1).data(), "f", 1) == 0); - - // Check to make sure that the BOM is there and that the data size is correct - - const ByteVector utf16 = unicode.data(String::UTF16); - CPPUNIT_ASSERT(utf16.size() == 2 + (unicode.size() * 2)); - CPPUNIT_ASSERT(unicode == String(utf16, String::UTF16)); } void testUTF16Encode() @@ -247,6 +230,9 @@ public: CPPUNIT_ASSERT_EQUAL(String("123aa").toInt(), 123); CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123); + CPPUNIT_ASSERT_EQUAL(String("0000").toInt(), 0); + CPPUNIT_ASSERT_EQUAL(String("0001").toInt(), 1); + String("2147483648").toInt(&ok); CPPUNIT_ASSERT_EQUAL(ok, false); @@ -254,6 +240,13 @@ public: CPPUNIT_ASSERT_EQUAL(ok, false); } + void testFromInt() + { + CPPUNIT_ASSERT_EQUAL(String::number(0), String("0")); + CPPUNIT_ASSERT_EQUAL(String::number(12345678), String("12345678")); + CPPUNIT_ASSERT_EQUAL(String::number(-12345678), String("-12345678")); + } + void testSubstr() { CPPUNIT_ASSERT_EQUAL(String("01"), String("0123456").substr(0, 2)); @@ -277,41 +270,28 @@ public: CPPUNIT_ASSERT_EQUAL(L'\x0a', String(crlf)[4]); } - void testEncode() + void testEncodeNonLatin1() { - String jpn(L"\u65E5\u672C\u8A9E"); - ByteVector jpn1 = jpn.data(String::Latin1); - ByteVector jpn2 = jpn.data(String::UTF8); - ByteVector jpn3 = jpn.data(String::UTF16); - ByteVector jpn4 = jpn.data(String::UTF16LE); - ByteVector jpn5 = jpn.data(String::UTF16BE); - std::string jpn6 = jpn.to8Bit(false); - std::string jpn7 = jpn.to8Bit(true); + const String jpn(L"\u65E5\u672C\u8A9E"); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x2C\x9E"), jpn.data(String::Latin1)); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn.data(String::UTF8)); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE\xE5\x65\x2C\x67\x9E\x8A"), jpn.data(String::UTF16)); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x65\x2C\x67\x9E\x8A"), jpn.data(String::UTF16LE)); + CPPUNIT_ASSERT_EQUAL(ByteVector("\x65\xE5\x67\x2C\x8A\x9E"), jpn.data(String::UTF16BE)); + CPPUNIT_ASSERT_EQUAL(std::string("\xE5\x2C\x9E"), jpn.to8Bit(false)); + CPPUNIT_ASSERT_EQUAL(std::string("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn.to8Bit(true)); + } - CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x2C\x9E"), jpn1); - CPPUNIT_ASSERT_EQUAL(ByteVector("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn2); - CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE\xE5\x65\x2C\x67\x9E\x8A"), jpn3); - CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x65\x2C\x67\x9E\x8A"), jpn4); - CPPUNIT_ASSERT_EQUAL(ByteVector("\x65\xE5\x67\x2C\x8A\x9E"), jpn5); - CPPUNIT_ASSERT_EQUAL(std::string("\xE5\x2C\x9E"), jpn6); - CPPUNIT_ASSERT_EQUAL(std::string("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn7); - - String empty; - ByteVector empty1 = empty.data(String::Latin1); - ByteVector empty2 = empty.data(String::UTF8); - ByteVector empty3 = empty.data(String::UTF16); - ByteVector empty4 = empty.data(String::UTF16LE); - ByteVector empty5 = empty.data(String::UTF16BE); - std::string empty6 = empty.to8Bit(false); - std::string empty7 = empty.to8Bit(true); - - CPPUNIT_ASSERT(empty1.isEmpty()); - CPPUNIT_ASSERT(empty2.isEmpty()); - CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE"), empty3); - CPPUNIT_ASSERT(empty4.isEmpty()); - CPPUNIT_ASSERT(empty5.isEmpty()); - CPPUNIT_ASSERT(empty6.empty()); - CPPUNIT_ASSERT(empty7.empty()); + void testEncodeEmpty() + { + const String empty; + CPPUNIT_ASSERT(empty.data(String::Latin1).isEmpty()); + CPPUNIT_ASSERT(empty.data(String::UTF8).isEmpty()); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE"), empty.data(String::UTF16)); + CPPUNIT_ASSERT(empty.data(String::UTF16LE).isEmpty()); + CPPUNIT_ASSERT(empty.data(String::UTF16BE).isEmpty()); + CPPUNIT_ASSERT(empty.to8Bit(false).empty()); + CPPUNIT_ASSERT(empty.to8Bit(true).empty()); } void testIterator() From 455e827e1ea3688454109de140259da4d1444fe9 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 15 Feb 2016 02:18:42 +0900 Subject: [PATCH 17/74] Explicitly set a false flag in ConfigureChecks.cmake. --- ConfigureChecks.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 6f3c82ec..0f2b6d87 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -57,6 +57,8 @@ if(NOT HAVE_STD_ATOMIC) find_package(Boost COMPONENTS atomic) if(Boost_ATOMIC_FOUND) set(HAVE_BOOST_ATOMIC 1) + else() + set(HAVE_BOOST_ATOMIC 0) endif() if(NOT HAVE_BOOST_ATOMIC) From 46eacaeba4dc1fcf356b2eead9fd7cd4062b8565 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 15 Feb 2016 20:53:27 +0900 Subject: [PATCH 18/74] Inline functions had better have internal linkages. This also removes useless inline specifiers. --- bindings/c/tag_c.cpp | 4 +- taglib/ape/apeproperties.cpp | 2 +- taglib/ape/apetag.cpp | 2 +- taglib/asf/asfutils.h | 107 +++++++------ taglib/fileref.cpp | 18 +-- taglib/mp4/mp4file.cpp | 2 +- taglib/mpeg/mpegutils.h | 36 +++-- taglib/ogg/oggfile.cpp | 2 +- taglib/riff/riffutils.h | 19 ++- taglib/toolkit/tfilestream.cpp | 16 +- taglib/toolkit/tstring.cpp | 28 ++-- taglib/toolkit/tutils.h | 280 +++++++++++++++++---------------- 12 files changed, 263 insertions(+), 253 deletions(-) diff --git a/bindings/c/tag_c.cpp b/bindings/c/tag_c.cpp index 33c61229..04c54956 100644 --- a/bindings/c/tag_c.cpp +++ b/bindings/c/tag_c.cpp @@ -50,7 +50,7 @@ namespace bool unicodeStrings = true; bool stringManagementEnabled = true; - inline char *stringToCharArray(const String &s) + char *stringToCharArray(const String &s) { const std::string str = s.to8Bit(unicodeStrings); @@ -65,7 +65,7 @@ namespace #endif } - inline String charArrayToString(const char *s) + String charArrayToString(const char *s) { return String(s, unicodeStrings ? String::UTF8 : String::Latin1); } diff --git a/taglib/ape/apeproperties.cpp b/taglib/ape/apeproperties.cpp index 26efd15f..dee7e8c0 100644 --- a/taglib/ape/apeproperties.cpp +++ b/taglib/ape/apeproperties.cpp @@ -133,7 +133,7 @@ unsigned int APE::Properties::sampleFrames() const namespace { - inline int headerVersion(const ByteVector &header) + int headerVersion(const ByteVector &header) { if(header.size() < 6 || !header.startsWith("MAC ")) return -1; diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index d49d0700..dfbd3076 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -47,7 +47,7 @@ using namespace APE; namespace { - inline bool isKeyValid(const char *key, size_t length) + bool isKeyValid(const char *key, size_t length) { const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", 0 }; diff --git a/taglib/asf/asfutils.h b/taglib/asf/asfutils.h index e3595a70..a8ecd70d 100644 --- a/taglib/asf/asfutils.h +++ b/taglib/asf/asfutils.h @@ -34,65 +34,68 @@ namespace TagLib { namespace ASF { - - inline unsigned short readWORD(File *file, bool *ok = 0) + namespace { - const ByteVector v = file->readBlock(2); - if(v.size() != 2) { - if(ok) *ok = false; - return 0; - } - if(ok) *ok = true; - return v.toUShort(false); - } - inline unsigned int readDWORD(File *file, bool *ok = 0) - { - const ByteVector v = file->readBlock(4); - if(v.size() != 4) { - if(ok) *ok = false; - return 0; - } - if(ok) *ok = true; - return v.toUInt(false); - } - - inline long long readQWORD(File *file, bool *ok = 0) - { - const ByteVector v = file->readBlock(8); - if(v.size() != 8) { - if(ok) *ok = false; - return 0; - } - if(ok) *ok = true; - return v.toLongLong(false); - } - - inline String readString(File *file, int length) - { - ByteVector data = file->readBlock(length); - unsigned int size = data.size(); - while (size >= 2) { - if(data[size - 1] != '\0' || data[size - 2] != '\0') { - break; + inline unsigned short readWORD(File *file, bool *ok = 0) + { + const ByteVector v = file->readBlock(2); + if(v.size() != 2) { + if(ok) *ok = false; + return 0; } - size -= 2; + if(ok) *ok = true; + return v.toUShort(false); } - if(size != data.size()) { - data.resize(size); - } - return String(data, String::UTF16LE); - } - inline ByteVector renderString(const String &str, bool includeLength = false) - { - ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false); - if(includeLength) { - data = ByteVector::fromShort(data.size(), false) + data; + inline unsigned int readDWORD(File *file, bool *ok = 0) + { + const ByteVector v = file->readBlock(4); + if(v.size() != 4) { + if(ok) *ok = false; + return 0; + } + if(ok) *ok = true; + return v.toUInt(false); } - return data; - } + inline long long readQWORD(File *file, bool *ok = 0) + { + const ByteVector v = file->readBlock(8); + if(v.size() != 8) { + if(ok) *ok = false; + return 0; + } + if(ok) *ok = true; + return v.toLongLong(false); + } + + inline String readString(File *file, int length) + { + ByteVector data = file->readBlock(length); + unsigned int size = data.size(); + while (size >= 2) { + if(data[size - 1] != '\0' || data[size - 2] != '\0') { + break; + } + size -= 2; + } + if(size != data.size()) { + data.resize(size); + } + return String(data, String::UTF16LE); + } + + inline ByteVector renderString(const String &str, bool includeLength = false) + { + ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false); + if(includeLength) { + data = ByteVector::fromShort(data.size(), false) + data; + } + return data; + } + + } } } diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 950b3f8a..3a7f2c65 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -62,42 +62,42 @@ namespace // Templatized internal functions. T should be String or IOStream*. template - inline FileName toFileName(T arg) + FileName toFileName(T arg) { debug("FileRef::toFileName(): This version should never be called."); return FileName(L""); } template <> - inline FileName toFileName(IOStream *arg) + FileName toFileName(IOStream *arg) { return arg->name(); } template <> - inline FileName toFileName(FileName arg) + FileName toFileName(FileName arg) { return arg; } template - inline File *resolveFileType(T arg, bool readProperties, - AudioProperties::ReadStyle style) + File *resolveFileType(T arg, bool readProperties, + AudioProperties::ReadStyle style) { debug("FileRef::resolveFileType(): This version should never be called."); return 0; } template <> - inline File *resolveFileType(IOStream *arg, bool readProperties, - AudioProperties::ReadStyle style) + File *resolveFileType(IOStream *arg, bool readProperties, + AudioProperties::ReadStyle style) { return 0; } template <> - inline File *resolveFileType(FileName arg, bool readProperties, - AudioProperties::ReadStyle style) + File *resolveFileType(FileName arg, bool readProperties, + AudioProperties::ReadStyle style) { ResolverList::ConstIterator it = fileTypeResolvers.begin(); for(; it != fileTypeResolvers.end(); ++it) { diff --git a/taglib/mp4/mp4file.cpp b/taglib/mp4/mp4file.cpp index d0a6c4c6..3733fb40 100644 --- a/taglib/mp4/mp4file.cpp +++ b/taglib/mp4/mp4file.cpp @@ -34,7 +34,7 @@ using namespace TagLib; namespace { - inline bool checkValid(const MP4::AtomList &list) + bool checkValid(const MP4::AtomList &list) { for(MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) { diff --git a/taglib/mpeg/mpegutils.h b/taglib/mpeg/mpegutils.h index 5a7e0e6a..e35f752f 100644 --- a/taglib/mpeg/mpegutils.h +++ b/taglib/mpeg/mpegutils.h @@ -34,25 +34,27 @@ namespace TagLib { namespace MPEG { - - /*! - * MPEG frames can be recognized by the bit pattern 11111111 111, so the - * first byte is easy to check for, however checking to see if the second byte - * starts with \e 111 is a bit more tricky, hence these functions. - */ - - inline bool firstSyncByte(unsigned char byte) + namespace { - return (byte == 0xFF); + + /*! + * MPEG frames can be recognized by the bit pattern 11111111 111, so the + * first byte is easy to check for, however checking to see if the second byte + * starts with \e 111 is a bit more tricky, hence these functions. + */ + inline bool firstSyncByte(unsigned char byte) + { + return (byte == 0xFF); + } + + inline bool secondSynchByte(unsigned char byte) + { + // 0xFF is possible in theory, but it's very unlikely be a header. + + return (byte != 0xFF && ((byte & 0xE0) == 0xE0)); + } + } - - inline bool secondSynchByte(unsigned char byte) - { - // 0xFF is possible in theory, but it's very unlikely be a header. - - return (byte != 0xFF && ((byte & 0xE0) == 0xE0)); - } - } } diff --git a/taglib/ogg/oggfile.cpp b/taglib/ogg/oggfile.cpp index 6520cc32..86b0b076 100644 --- a/taglib/ogg/oggfile.cpp +++ b/taglib/ogg/oggfile.cpp @@ -37,7 +37,7 @@ using namespace TagLib; namespace { // Returns the first packet index of the right next page to the given one. - inline unsigned int nextPacketIndex(const Ogg::Page *page) + unsigned int nextPacketIndex(const Ogg::Page *page) { if(page->header()->lastPacketCompleted()) return page->firstPacketIndex() + page->packetCount(); diff --git a/taglib/riff/riffutils.h b/taglib/riff/riffutils.h index 14b8508e..ecb985a4 100644 --- a/taglib/riff/riffutils.h +++ b/taglib/riff/riffutils.h @@ -34,18 +34,23 @@ namespace TagLib { namespace RIFF { - inline bool isValidChunkName(const ByteVector &name) + namespace { - if(name.size() != 4) - return false; - for(ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) { - const int c = static_cast(*it); - if(c < 32 || 127 < c) + inline bool isValidChunkName(const ByteVector &name) + { + if(name.size() != 4) return false; + + for(ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) { + const int c = static_cast(*it); + if(c < 32 || 127 < c) + return false; + } + + return true; } - return true; } } } diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index e20412f2..5205bae0 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -47,7 +47,7 @@ namespace const FileHandle InvalidFileHandle = INVALID_HANDLE_VALUE; - inline FileHandle openFile(const FileName &path, bool readOnly) + FileHandle openFile(const FileName &path, bool readOnly) { const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); @@ -59,12 +59,12 @@ namespace return InvalidFileHandle; } - inline void closeFile(FileHandle file) + void closeFile(FileHandle file) { CloseHandle(file); } - inline size_t readFile(FileHandle file, ByteVector &buffer) + size_t readFile(FileHandle file, ByteVector &buffer) { DWORD length; if(ReadFile(file, buffer.data(), static_cast(buffer.size()), &length, NULL)) @@ -73,7 +73,7 @@ namespace return 0; } - inline size_t writeFile(FileHandle file, const ByteVector &buffer) + size_t writeFile(FileHandle file, const ByteVector &buffer) { DWORD length; if(WriteFile(file, buffer.data(), static_cast(buffer.size()), &length, NULL)) @@ -94,22 +94,22 @@ namespace const FileHandle InvalidFileHandle = 0; - inline FileHandle openFile(const FileName &path, bool readOnly) + FileHandle openFile(const FileName &path, bool readOnly) { return fopen(path, readOnly ? "rb" : "rb+"); } - inline void closeFile(FileHandle file) + void closeFile(FileHandle file) { fclose(file); } - inline size_t readFile(FileHandle file, ByteVector &buffer) + size_t readFile(FileHandle file, ByteVector &buffer) { return fread(buffer.data(), sizeof(char), buffer.size(), file); } - inline size_t writeFile(FileHandle file, const ByteVector &buffer) + size_t writeFile(FileHandle file, const ByteVector &buffer) { return fwrite(buffer.data(), sizeof(char), buffer.size(), file); } diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 8a596e4c..56daf33f 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -29,12 +29,6 @@ # include #endif -#include "tstring.h" -#include "tdebug.h" -#include "tstringlist.h" -#include "trefcounter.h" -#include "tutils.h" - #include #include #include @@ -47,12 +41,17 @@ # include "unicode.h" #endif +#include +#include +#include +#include +#include + namespace { using namespace TagLib; - inline size_t UTF16toUTF8( - const wchar_t *src, size_t srcLength, char *dst, size_t dstLength) + size_t UTF16toUTF8(const wchar_t *src, size_t srcLength, char *dst, size_t dstLength) { size_t len = 0; @@ -84,8 +83,7 @@ namespace return len; } - inline size_t UTF8toUTF16( - const char *src, size_t srcLength, wchar_t *dst, size_t dstLength) + size_t UTF8toUTF16(const char *src, size_t srcLength, wchar_t *dst, size_t dstLength) { size_t len = 0; @@ -118,7 +116,7 @@ namespace } // Returns the native format of std::wstring. - inline String::Type wcharByteOrder() + String::Type wcharByteOrder() { if(Utils::systemByteOrder() == Utils::LittleEndian) return String::UTF16LE; @@ -128,7 +126,7 @@ namespace // Converts a Latin-1 string into UTF-16(without BOM/CPU byte order) // and copies it to the internal buffer. - inline void copyFromLatin1(std::wstring &data, const char *s, size_t length) + void copyFromLatin1(std::wstring &data, const char *s, size_t length) { data.resize(length); @@ -138,7 +136,7 @@ namespace // Converts a UTF-8 string into UTF-16(without BOM/CPU byte order) // and copies it to the internal buffer. - inline void copyFromUTF8(std::wstring &data, const char *s, size_t length) + void copyFromUTF8(std::wstring &data, const char *s, size_t length) { data.resize(length); @@ -150,7 +148,7 @@ namespace // Converts a UTF-16 (with BOM), UTF-16LE or UTF16-BE string into // UTF-16(without BOM/CPU byte order) and copies it to the internal buffer. - inline void copyFromUTF16(std::wstring &data, const wchar_t *s, size_t length, String::Type t) + void copyFromUTF16(std::wstring &data, const wchar_t *s, size_t length, String::Type t) { bool swap; if(t == String::UTF16) { @@ -184,7 +182,7 @@ namespace // Converts a UTF-16 (with BOM), UTF-16LE or UTF16-BE string into // UTF-16(without BOM/CPU byte order) and copies it to the internal buffer. - inline void copyFromUTF16(std::wstring &data, const char *s, size_t length, String::Type t) + void copyFromUTF16(std::wstring &data, const char *s, size_t length, String::Type t) { bool swap; if(t == String::UTF16) { diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index bacbc2dd..6653e47b 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -55,235 +55,237 @@ namespace TagLib { namespace Utils { - - /*! - * Reverses the order of bytes in an 16-bit integer. - */ - inline unsigned short byteSwap(unsigned short x) + namespace { + + /*! + * Reverses the order of bytes in an 16-bit integer. + */ + inline unsigned short byteSwap(unsigned short x) + { #if defined(HAVE_BOOST_BYTESWAP) - return boost::endian::endian_reverse(x); + return boost::endian::endian_reverse(x); #elif defined(HAVE_GCC_BYTESWAP) - return __builtin_bswap16(x); + return __builtin_bswap16(x); #elif defined(HAVE_MSC_BYTESWAP) - return _byteswap_ushort(x); + return _byteswap_ushort(x); #elif defined(HAVE_GLIBC_BYTESWAP) - return __bswap_16(x); + return __bswap_16(x); #elif defined(HAVE_MAC_BYTESWAP) - return OSSwapInt16(x); + return OSSwapInt16(x); #elif defined(HAVE_OPENBSD_BYTESWAP) - return swap16(x); + return swap16(x); #else - return ((x >> 8) & 0xff) | ((x & 0xff) << 8); + return ((x >> 8) & 0xff) | ((x & 0xff) << 8); #endif - } + } - /*! - * Reverses the order of bytes in an 32-bit integer. - */ - inline unsigned int byteSwap(unsigned int x) - { + /*! + * Reverses the order of bytes in an 32-bit integer. + */ + inline unsigned int byteSwap(unsigned int x) + { #if defined(HAVE_BOOST_BYTESWAP) - return boost::endian::endian_reverse(x); + return boost::endian::endian_reverse(x); #elif defined(HAVE_GCC_BYTESWAP) - return __builtin_bswap32(x); + return __builtin_bswap32(x); #elif defined(HAVE_MSC_BYTESWAP) - return _byteswap_ulong(x); + return _byteswap_ulong(x); #elif defined(HAVE_GLIBC_BYTESWAP) - return __bswap_32(x); + return __bswap_32(x); #elif defined(HAVE_MAC_BYTESWAP) - return OSSwapInt32(x); + return OSSwapInt32(x); #elif defined(HAVE_OPENBSD_BYTESWAP) - return swap32(x); + return swap32(x); #else - return ((x & 0xff000000u) >> 24) - | ((x & 0x00ff0000u) >> 8) - | ((x & 0x0000ff00u) << 8) - | ((x & 0x000000ffu) << 24); + return ((x & 0xff000000u) >> 24) + | ((x & 0x00ff0000u) >> 8) + | ((x & 0x0000ff00u) << 8) + | ((x & 0x000000ffu) << 24); #endif - } + } - /*! - * Reverses the order of bytes in an 64-bit integer. - */ - inline unsigned long long byteSwap(unsigned long long x) - { + /*! + * Reverses the order of bytes in an 64-bit integer. + */ + inline unsigned long long byteSwap(unsigned long long x) + { #if defined(HAVE_BOOST_BYTESWAP) - return boost::endian::endian_reverse(x); + return boost::endian::endian_reverse(x); #elif defined(HAVE_GCC_BYTESWAP) - return __builtin_bswap64(x); + return __builtin_bswap64(x); #elif defined(HAVE_MSC_BYTESWAP) - return _byteswap_uint64(x); + return _byteswap_uint64(x); #elif defined(HAVE_GLIBC_BYTESWAP) - return __bswap_64(x); + return __bswap_64(x); #elif defined(HAVE_MAC_BYTESWAP) - return OSSwapInt64(x); + return OSSwapInt64(x); #elif defined(HAVE_OPENBSD_BYTESWAP) - return swap64(x); + return swap64(x); #else - return ((x & 0xff00000000000000ull) >> 56) - | ((x & 0x00ff000000000000ull) >> 40) - | ((x & 0x0000ff0000000000ull) >> 24) - | ((x & 0x000000ff00000000ull) >> 8) - | ((x & 0x00000000ff000000ull) << 8) - | ((x & 0x0000000000ff0000ull) << 24) - | ((x & 0x000000000000ff00ull) << 40) - | ((x & 0x00000000000000ffull) << 56); + return ((x & 0xff00000000000000ull) >> 56) + | ((x & 0x00ff000000000000ull) >> 40) + | ((x & 0x0000ff0000000000ull) >> 24) + | ((x & 0x000000ff00000000ull) >> 8) + | ((x & 0x00000000ff000000ull) << 8) + | ((x & 0x0000000000ff0000ull) << 24) + | ((x & 0x000000000000ff00ull) << 40) + | ((x & 0x00000000000000ffull) << 56); #endif - } + } - /*! - * Returns a formatted string just like standard sprintf(), but makes use of - * safer functions such as snprintf() if available. - */ - inline String formatString(const char *format, ...) - { - // Sufficient buffer size for the current internal uses. - // Consider changing this value when you use this function. + /*! + * Returns a formatted string just like standard sprintf(), but makes use of + * safer functions such as snprintf() if available. + */ + inline String formatString(const char *format, ...) + { + // Sufficient buffer size for the current internal uses. + // Consider changing this value when you use this function. - static const size_t BufferSize = 128; + static const size_t BufferSize = 128; - va_list args; - va_start(args, format); + va_list args; + va_start(args, format); - char buf[BufferSize]; - int length; + char buf[BufferSize]; + int length; #if defined(HAVE_VSNPRINTF) - length = vsnprintf(buf, BufferSize, format, args); + length = vsnprintf(buf, BufferSize, format, args); #elif defined(HAVE_VSPRINTF_S) - length = vsprintf_s(buf, format, args); + length = vsprintf_s(buf, format, args); #else - // The last resort. May cause a buffer overflow. + // The last resort. May cause a buffer overflow. - length = vsprintf(buf, format, args); - if(length >= BufferSize) { - debug("Utils::formatString() - Buffer overflow! Returning an empty string."); - length = -1; - } + length = vsprintf(buf, format, args); + if(length >= BufferSize) { + debug("Utils::formatString() - Buffer overflow! Returning an empty string."); + length = -1; + } #endif - va_end(args); + va_end(args); - if(length > 0) - return String(buf); - else - return String(); - } - - /*! - * Returns whether the two strings s1 and s2 are equal, ignoring the case of - * the characters. - * - * We took the trouble to define this one here, since there are some - * incompatible variations of case insensitive strcmp(). - */ - inline bool equalsIgnoreCase(const char *s1, const char *s2) - { - while(*s1 != '\0' && *s2 != '\0' && ::tolower(*s1) == ::tolower(*s2)) { - s1++; - s2++; + if(length > 0) + return String(buf); + else + return String(); } - return (*s1 == '\0' && *s2 == '\0'); + /*! + * Returns whether the two strings s1 and s2 are equal, ignoring the case of + * the characters. + * + * We took the trouble to define this one here, since there are some + * incompatible variations of case insensitive strcmp(). + */ + inline bool equalsIgnoreCase(const char *s1, const char *s2) + { + while(*s1 != '\0' && *s2 != '\0' && ::tolower(*s1) == ::tolower(*s2)) { + s1++; + s2++; + } + + return (*s1 == '\0' && *s2 == '\0'); + } + + /*! + * The types of byte order of the running system. + */ + enum ByteOrder + { + //! Little endian systems. + LittleEndian, + //! Big endian systems. + BigEndian + }; + + /*! + * Returns the integer byte order of the system. + */ + inline ByteOrder systemByteOrder() + { + union { + int i; + char c; + } u; + + u.i = 1; + if(u.c == 1) + return LittleEndian; + else + return BigEndian; + } + + /*! + * Returns the IEEE754 byte order of the system. + */ + inline ByteOrder floatByteOrder() + { + union { + double d; + char c; + } u; + + // 1.0 is stored in memory like 0x3FF0000000000000 in canonical form. + // So the first byte is zero if little endian. + + u.d = 1.0; + if(u.c == 0) + return LittleEndian; + else + return BigEndian; + } } - - /*! - * The types of byte order of the running system. - */ - enum ByteOrder - { - //! Little endian systems. - LittleEndian, - //! Big endian systems. - BigEndian - }; - - /*! - * Returns the integer byte order of the system. - */ - inline ByteOrder systemByteOrder() - { - union { - int i; - char c; - } u; - - u.i = 1; - if(u.c == 1) - return LittleEndian; - else - return BigEndian; - } - - /*! - * Returns the IEEE754 byte order of the system. - */ - inline ByteOrder floatByteOrder() - { - union { - double d; - char c; - } u; - - // 1.0 is stored in memory like 0x3FF0000000000000 in canonical form. - // So the first byte is zero if little endian. - - u.d = 1.0; - if(u.c == 0) - return LittleEndian; - else - return BigEndian; - } - } } From 552185a8b8c291a096b92572c26ff41b8320fbce Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Tue, 16 Feb 2016 20:35:27 +0900 Subject: [PATCH 19/74] Cast the parameters of boost::endian::endian_reverse(), just in case. --- taglib/toolkit/tutils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index 6653e47b..e3e4f6c3 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -65,7 +65,7 @@ namespace TagLib { #if defined(HAVE_BOOST_BYTESWAP) - return boost::endian::endian_reverse(x); + return boost::endian::endian_reverse(static_cast(x)); #elif defined(HAVE_GCC_BYTESWAP) @@ -101,7 +101,7 @@ namespace TagLib { #if defined(HAVE_BOOST_BYTESWAP) - return boost::endian::endian_reverse(x); + return boost::endian::endian_reverse(static_cast(x)); #elif defined(HAVE_GCC_BYTESWAP) @@ -140,7 +140,7 @@ namespace TagLib { #if defined(HAVE_BOOST_BYTESWAP) - return boost::endian::endian_reverse(x); + return boost::endian::endian_reverse(static_cast(x)); #elif defined(HAVE_GCC_BYTESWAP) From dadfe7979953dda7ae04ca1c3638495943dedf6d Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 17 Feb 2016 22:06:36 +0900 Subject: [PATCH 20/74] Remove more useless inline specifiers. They are no longer needed since the unnamed namespaces have solved the ODR violation. --- taglib/asf/asfutils.h | 10 +++++----- taglib/mpeg/mpegutils.h | 4 ++-- taglib/riff/riffutils.h | 2 +- taglib/toolkit/tutils.h | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/taglib/asf/asfutils.h b/taglib/asf/asfutils.h index a8ecd70d..4bca5fa6 100644 --- a/taglib/asf/asfutils.h +++ b/taglib/asf/asfutils.h @@ -37,7 +37,7 @@ namespace TagLib namespace { - inline unsigned short readWORD(File *file, bool *ok = 0) + unsigned short readWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(2); if(v.size() != 2) { @@ -48,7 +48,7 @@ namespace TagLib return v.toUShort(false); } - inline unsigned int readDWORD(File *file, bool *ok = 0) + unsigned int readDWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(4); if(v.size() != 4) { @@ -59,7 +59,7 @@ namespace TagLib return v.toUInt(false); } - inline long long readQWORD(File *file, bool *ok = 0) + long long readQWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(8); if(v.size() != 8) { @@ -70,7 +70,7 @@ namespace TagLib return v.toLongLong(false); } - inline String readString(File *file, int length) + String readString(File *file, int length) { ByteVector data = file->readBlock(length); unsigned int size = data.size(); @@ -86,7 +86,7 @@ namespace TagLib return String(data, String::UTF16LE); } - inline ByteVector renderString(const String &str, bool includeLength = false) + ByteVector renderString(const String &str, bool includeLength = false) { ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false); if(includeLength) { diff --git a/taglib/mpeg/mpegutils.h b/taglib/mpeg/mpegutils.h index e35f752f..cc484f25 100644 --- a/taglib/mpeg/mpegutils.h +++ b/taglib/mpeg/mpegutils.h @@ -42,12 +42,12 @@ namespace TagLib * first byte is easy to check for, however checking to see if the second byte * starts with \e 111 is a bit more tricky, hence these functions. */ - inline bool firstSyncByte(unsigned char byte) + bool firstSyncByte(unsigned char byte) { return (byte == 0xFF); } - inline bool secondSynchByte(unsigned char byte) + bool secondSynchByte(unsigned char byte) { // 0xFF is possible in theory, but it's very unlikely be a header. diff --git a/taglib/riff/riffutils.h b/taglib/riff/riffutils.h index ecb985a4..4078385b 100644 --- a/taglib/riff/riffutils.h +++ b/taglib/riff/riffutils.h @@ -37,7 +37,7 @@ namespace TagLib namespace { - inline bool isValidChunkName(const ByteVector &name) + bool isValidChunkName(const ByteVector &name) { if(name.size() != 4) return false; diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index e3e4f6c3..0a3e14db 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -61,7 +61,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 16-bit integer. */ - inline unsigned short byteSwap(unsigned short x) + unsigned short byteSwap(unsigned short x) { #if defined(HAVE_BOOST_BYTESWAP) @@ -97,7 +97,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 32-bit integer. */ - inline unsigned int byteSwap(unsigned int x) + unsigned int byteSwap(unsigned int x) { #if defined(HAVE_BOOST_BYTESWAP) @@ -136,7 +136,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 64-bit integer. */ - inline unsigned long long byteSwap(unsigned long long x) + unsigned long long byteSwap(unsigned long long x) { #if defined(HAVE_BOOST_BYTESWAP) @@ -180,7 +180,7 @@ namespace TagLib * Returns a formatted string just like standard sprintf(), but makes use of * safer functions such as snprintf() if available. */ - inline String formatString(const char *format, ...) + String formatString(const char *format, ...) { // Sufficient buffer size for the current internal uses. // Consider changing this value when you use this function. @@ -228,7 +228,7 @@ namespace TagLib * We took the trouble to define this one here, since there are some * incompatible variations of case insensitive strcmp(). */ - inline bool equalsIgnoreCase(const char *s1, const char *s2) + bool equalsIgnoreCase(const char *s1, const char *s2) { while(*s1 != '\0' && *s2 != '\0' && ::tolower(*s1) == ::tolower(*s2)) { s1++; @@ -252,7 +252,7 @@ namespace TagLib /*! * Returns the integer byte order of the system. */ - inline ByteOrder systemByteOrder() + ByteOrder systemByteOrder() { union { int i; @@ -269,7 +269,7 @@ namespace TagLib /*! * Returns the IEEE754 byte order of the system. */ - inline ByteOrder floatByteOrder() + ByteOrder floatByteOrder() { union { double d; From a9acca5d817932e9362ed28b9641b05a1aac0683 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 18 Feb 2016 03:07:38 +0900 Subject: [PATCH 21/74] Decode unsynchronized ID3v2 frames efficiently. It makes a great difference when decoding huge unsynchronized ID3v2 frames. --- NEWS | 1 + taglib/mpeg/id3v2/id3v2synchdata.cpp | 26 ++++++++++++++++++++++---- tests/test_synchdata.cpp | 9 +++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 74695376..5fbfb7ee 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ TagLib 1.11 (Jan 30, 2016) * Better handling of PCM WAV files with a 'fact' chunk. * Better handling of corrupted APE tags. + * Efficient decoding of unsynchronized ID3v2 frames. * Fixed text encoding when saving certain frames in ID3v2.3 tags. * Several smaller bug fixes and performance improvements. diff --git a/taglib/mpeg/id3v2/id3v2synchdata.cpp b/taglib/mpeg/id3v2/id3v2synchdata.cpp index b16c1987..5ef419ec 100644 --- a/taglib/mpeg/id3v2/id3v2synchdata.cpp +++ b/taglib/mpeg/id3v2/id3v2synchdata.cpp @@ -74,11 +74,29 @@ ByteVector SynchData::fromUInt(unsigned int value) ByteVector SynchData::decode(const ByteVector &data) { + // We have this optimized method instead of using ByteVector::replace(), + // since it makes a great difference when decoding huge unsynchronized frames. + + if(data.size() < 2) + return data; + ByteVector result = data; - ByteVector pattern(2, char(0)); - pattern[0] = '\xFF'; - pattern[1] = '\x00'; + char *begin = result.data(); + char *end = begin + result.size(); - return result.replace(pattern, '\xFF'); + char *dst = begin; + const char *src = begin; + + do { + *dst++ = *src++; + + if(*(src - 1) == '\xff' && *src == '\x00') + src++; + + } while (src < end); + + result.resize(static_cast(dst - begin)); + + return result; } diff --git a/tests/test_synchdata.cpp b/tests/test_synchdata.cpp index 4cffee14..bbd74d8b 100644 --- a/tests/test_synchdata.cpp +++ b/tests/test_synchdata.cpp @@ -40,6 +40,7 @@ class TestID3v2SynchData : public CppUnit::TestFixture CPPUNIT_TEST(testToUIntBrokenAndTooLarge); CPPUNIT_TEST(testDecode1); CPPUNIT_TEST(testDecode2); + CPPUNIT_TEST(testDecode3); CPPUNIT_TEST_SUITE_END(); public: @@ -104,6 +105,14 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\x44", 2), a); } + void testDecode3() + { + ByteVector a("\xff\xff\x00", 3); + a = ID3v2::SynchData::decode(a); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, a.size()); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xff", 2), a); + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2SynchData); From 07d95e0dc008e49356650ce0fec06c96d28b77f0 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 18 Feb 2016 03:47:02 +0900 Subject: [PATCH 22/74] Add an overload of ByteVector::replace() which takes chars. Currently, this is only way of using ByteVector::replace(). --- taglib/mod/modfilebase.cpp | 2 +- taglib/toolkit/tbytevector.cpp | 18 ++++++++++++++++-- taglib/toolkit/tbytevector.h | 6 ++++++ taglib/xm/xmfile.cpp | 2 +- tests/test_bytevector.cpp | 5 +++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/taglib/mod/modfilebase.cpp b/taglib/mod/modfilebase.cpp index e6a3114f..142f669f 100644 --- a/taglib/mod/modfilebase.cpp +++ b/taglib/mod/modfilebase.cpp @@ -54,7 +54,7 @@ bool Mod::FileBase::readString(String &s, unsigned long size) { data.resize(index); } - data.replace((char) 0xff, ' '); + data.replace('\xff', ' '); s = data; return true; diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 47c9dd31..22ce2d4f 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -475,18 +475,32 @@ bool ByteVector::endsWith(const ByteVector &pattern) const return containsAt(pattern, size() - pattern.size()); } +ByteVector &ByteVector::replace(char oldByte, char newByte) +{ + detach(); + + for(ByteVector::Iterator it = begin(); it != end(); ++it) { + if(*it == oldByte) + *it = newByte; + } + + return *this; +} + ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &with) { if(pattern.size() == 0 || pattern.size() > size()) return *this; + if(pattern.size() == 1 && with.size() == 1) + return replace(pattern[0], with[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) - { + while (true) { offset = find(pattern, offset); if(offset == static_cast(-1)) // Use npos in taglib2. break; diff --git a/taglib/toolkit/tbytevector.h b/taglib/toolkit/tbytevector.h index e897307e..e1549bb9 100644 --- a/taglib/toolkit/tbytevector.h +++ b/taglib/toolkit/tbytevector.h @@ -179,6 +179,12 @@ namespace TagLib { */ bool endsWith(const ByteVector &pattern) const; + /*! + * Replaces \a oldByte with \a newByte and returns a reference to the + * ByteVector after the operation. This \e does modify the vector. + */ + ByteVector &replace(char oldByte, char newByte); + /*! * Replaces \a pattern with \a with and returns a reference to the ByteVector * after the operation. This \e does modify the vector. diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index e0c8db57..9192e9bf 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -134,7 +134,7 @@ public: if(index > -1) { data.resize(index); } - data.replace((char) 0xff, ' '); + data.replace('\xff', ' '); value = data; return count; } diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index f5e93d5f..f7c9b6ee 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -266,6 +266,11 @@ public: a.replace(ByteVector("a"), ByteVector("x")); CPPUNIT_ASSERT_EQUAL(ByteVector("xbcdxbf"), a); } + { + ByteVector a("abcdabf"); + a.replace('a', 'x'); + CPPUNIT_ASSERT_EQUAL(ByteVector("xbcdxbf"), a); + } { ByteVector a("abcdabf"); a.replace(ByteVector("ab"), ByteVector("xy")); From 6a9db50c03c421956db949340b302c32f8dc61ad Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 18 Feb 2016 03:51:42 +0900 Subject: [PATCH 23/74] Revert "Remove more useless inline specifiers." This reverts commit dadfe7979953dda7ae04ca1c3638495943dedf6d. --- taglib/asf/asfutils.h | 10 +++++----- taglib/mpeg/mpegutils.h | 4 ++-- taglib/riff/riffutils.h | 2 +- taglib/toolkit/tutils.h | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/taglib/asf/asfutils.h b/taglib/asf/asfutils.h index 4bca5fa6..a8ecd70d 100644 --- a/taglib/asf/asfutils.h +++ b/taglib/asf/asfutils.h @@ -37,7 +37,7 @@ namespace TagLib namespace { - unsigned short readWORD(File *file, bool *ok = 0) + inline unsigned short readWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(2); if(v.size() != 2) { @@ -48,7 +48,7 @@ namespace TagLib return v.toUShort(false); } - unsigned int readDWORD(File *file, bool *ok = 0) + inline unsigned int readDWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(4); if(v.size() != 4) { @@ -59,7 +59,7 @@ namespace TagLib return v.toUInt(false); } - long long readQWORD(File *file, bool *ok = 0) + inline long long readQWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(8); if(v.size() != 8) { @@ -70,7 +70,7 @@ namespace TagLib return v.toLongLong(false); } - String readString(File *file, int length) + inline String readString(File *file, int length) { ByteVector data = file->readBlock(length); unsigned int size = data.size(); @@ -86,7 +86,7 @@ namespace TagLib return String(data, String::UTF16LE); } - ByteVector renderString(const String &str, bool includeLength = false) + inline ByteVector renderString(const String &str, bool includeLength = false) { ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false); if(includeLength) { diff --git a/taglib/mpeg/mpegutils.h b/taglib/mpeg/mpegutils.h index cc484f25..e35f752f 100644 --- a/taglib/mpeg/mpegutils.h +++ b/taglib/mpeg/mpegutils.h @@ -42,12 +42,12 @@ namespace TagLib * first byte is easy to check for, however checking to see if the second byte * starts with \e 111 is a bit more tricky, hence these functions. */ - bool firstSyncByte(unsigned char byte) + inline bool firstSyncByte(unsigned char byte) { return (byte == 0xFF); } - bool secondSynchByte(unsigned char byte) + inline bool secondSynchByte(unsigned char byte) { // 0xFF is possible in theory, but it's very unlikely be a header. diff --git a/taglib/riff/riffutils.h b/taglib/riff/riffutils.h index 4078385b..ecb985a4 100644 --- a/taglib/riff/riffutils.h +++ b/taglib/riff/riffutils.h @@ -37,7 +37,7 @@ namespace TagLib namespace { - bool isValidChunkName(const ByteVector &name) + inline bool isValidChunkName(const ByteVector &name) { if(name.size() != 4) return false; diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index 0a3e14db..e3e4f6c3 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -61,7 +61,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 16-bit integer. */ - unsigned short byteSwap(unsigned short x) + inline unsigned short byteSwap(unsigned short x) { #if defined(HAVE_BOOST_BYTESWAP) @@ -97,7 +97,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 32-bit integer. */ - unsigned int byteSwap(unsigned int x) + inline unsigned int byteSwap(unsigned int x) { #if defined(HAVE_BOOST_BYTESWAP) @@ -136,7 +136,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 64-bit integer. */ - unsigned long long byteSwap(unsigned long long x) + inline unsigned long long byteSwap(unsigned long long x) { #if defined(HAVE_BOOST_BYTESWAP) @@ -180,7 +180,7 @@ namespace TagLib * Returns a formatted string just like standard sprintf(), but makes use of * safer functions such as snprintf() if available. */ - String formatString(const char *format, ...) + inline String formatString(const char *format, ...) { // Sufficient buffer size for the current internal uses. // Consider changing this value when you use this function. @@ -228,7 +228,7 @@ namespace TagLib * We took the trouble to define this one here, since there are some * incompatible variations of case insensitive strcmp(). */ - bool equalsIgnoreCase(const char *s1, const char *s2) + inline bool equalsIgnoreCase(const char *s1, const char *s2) { while(*s1 != '\0' && *s2 != '\0' && ::tolower(*s1) == ::tolower(*s2)) { s1++; @@ -252,7 +252,7 @@ namespace TagLib /*! * Returns the integer byte order of the system. */ - ByteOrder systemByteOrder() + inline ByteOrder systemByteOrder() { union { int i; @@ -269,7 +269,7 @@ namespace TagLib /*! * Returns the IEEE754 byte order of the system. */ - ByteOrder floatByteOrder() + inline ByteOrder floatByteOrder() { union { double d; From 887f3b28e552bde425be7b8a8a2459e3e9066c11 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 18 Feb 2016 14:29:17 +0900 Subject: [PATCH 24/74] Add a TODO comment in ByteVector::replace(). --- taglib/toolkit/tbytevector.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 22ce2d4f..62f0fbef 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -489,6 +489,8 @@ ByteVector &ByteVector::replace(char oldByte, char newByte) ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &with) { + // TODO: This takes O(n!) time in the worst case. Rewrite it to run in O(n) time. + if(pattern.size() == 0 || pattern.size() > size()) return *this; From 2166d703e05cf975894195d04527d5d2aaa5c656 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 18 Feb 2016 14:34:16 +0900 Subject: [PATCH 25/74] Small fix in style. --- taglib/mpeg/id3v2/id3v2synchdata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/mpeg/id3v2/id3v2synchdata.cpp b/taglib/mpeg/id3v2/id3v2synchdata.cpp index 5ef419ec..ddcd95b3 100644 --- a/taglib/mpeg/id3v2/id3v2synchdata.cpp +++ b/taglib/mpeg/id3v2/id3v2synchdata.cpp @@ -94,7 +94,7 @@ ByteVector SynchData::decode(const ByteVector &data) if(*(src - 1) == '\xff' && *src == '\x00') src++; - } while (src < end); + } while(src < end); result.resize(static_cast(dst - begin)); From 8c4b484e673290644d31d11a114c7359d8ff5876 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 19 Feb 2016 20:58:09 +0900 Subject: [PATCH 26/74] Fix a possible out-of-bounds access in SynchData::decode(). This also avoids an extra memory copy. --- taglib/mpeg/id3v2/id3v2synchdata.cpp | 20 ++++++++------------ tests/test_synchdata.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/taglib/mpeg/id3v2/id3v2synchdata.cpp b/taglib/mpeg/id3v2/id3v2synchdata.cpp index ddcd95b3..2aa99999 100644 --- a/taglib/mpeg/id3v2/id3v2synchdata.cpp +++ b/taglib/mpeg/id3v2/id3v2synchdata.cpp @@ -77,26 +77,22 @@ ByteVector SynchData::decode(const ByteVector &data) // We have this optimized method instead of using ByteVector::replace(), // since it makes a great difference when decoding huge unsynchronized frames. - if(data.size() < 2) - return data; + ByteVector result(data.size()); - ByteVector result = data; + ByteVector::ConstIterator src = data.begin(); + ByteVector::Iterator dst = result.begin(); - char *begin = result.data(); - char *end = begin + result.size(); - - char *dst = begin; - const char *src = begin; - - do { + while(src < data.end() - 1) { *dst++ = *src++; if(*(src - 1) == '\xff' && *src == '\x00') src++; + } - } while(src < end); + if(src < data.end()) + *dst++ = *src++; - result.resize(static_cast(dst - begin)); + result.resize(static_cast(dst - result.begin())); return result; } diff --git a/tests/test_synchdata.cpp b/tests/test_synchdata.cpp index bbd74d8b..b4ec4096 100644 --- a/tests/test_synchdata.cpp +++ b/tests/test_synchdata.cpp @@ -41,6 +41,7 @@ class TestID3v2SynchData : public CppUnit::TestFixture CPPUNIT_TEST(testDecode1); CPPUNIT_TEST(testDecode2); CPPUNIT_TEST(testDecode3); + CPPUNIT_TEST(testDecode4); CPPUNIT_TEST_SUITE_END(); public: @@ -113,6 +114,14 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xff", 2), a); } + void testDecode4() + { + ByteVector a("\xff\xff\xff", 3); + a = ID3v2::SynchData::decode(a); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, a.size()); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xff\xff", 3), a); + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2SynchData); From 98a57744c3a167d48e935e654619dc9b4fb57123 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 20 Feb 2016 11:50:47 +0900 Subject: [PATCH 27/74] Add some tests for ByteVector::replace(). --- tests/test_bytevector.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index f7c9b6ee..32968965 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -265,36 +265,50 @@ public: ByteVector a("abcdabf"); a.replace(ByteVector("a"), ByteVector("x")); CPPUNIT_ASSERT_EQUAL(ByteVector("xbcdxbf"), a); + a.replace(ByteVector("x"), ByteVector("a")); + CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a); } { ByteVector a("abcdabf"); a.replace('a', 'x'); CPPUNIT_ASSERT_EQUAL(ByteVector("xbcdxbf"), a); + a.replace('x', 'a'); + CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a); } { ByteVector a("abcdabf"); a.replace(ByteVector("ab"), ByteVector("xy")); CPPUNIT_ASSERT_EQUAL(ByteVector("xycdxyf"), a); + a.replace(ByteVector("xy"), ByteVector("ab")); + CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a); } { ByteVector a("abcdabf"); a.replace(ByteVector("a"), ByteVector("")); CPPUNIT_ASSERT_EQUAL(ByteVector("bcdbf"), a); + a.replace(ByteVector(""), ByteVector("a")); + CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a); } { ByteVector a("abcdabf"); - a.replace(ByteVector("ab"), ByteVector("x")); - CPPUNIT_ASSERT_EQUAL(ByteVector("xcdxf"), a); + a.replace(ByteVector("b"), ByteVector("")); + CPPUNIT_ASSERT_EQUAL(ByteVector("acdaf"), a); + a.replace(ByteVector(""), ByteVector("b")); + CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a); } { - ByteVector a("abcdabf"); - a.replace(ByteVector("ab"), ByteVector()); - CPPUNIT_ASSERT_EQUAL(ByteVector("cdf"), a); + ByteVector a("abcdabc"); + a.replace(ByteVector("c"), ByteVector("")); + CPPUNIT_ASSERT_EQUAL(ByteVector("abdab"), a); + a.replace(ByteVector(""), ByteVector("c")); + CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabc"), a); } { - ByteVector a("abcdabf"); - a.replace(ByteVector("bf"), ByteVector("x")); - CPPUNIT_ASSERT_EQUAL(ByteVector("abcdax"), a); + ByteVector a("abcdaba"); + a.replace(ByteVector("a"), ByteVector("")); + CPPUNIT_ASSERT_EQUAL(ByteVector("bcdb"), a); + a.replace(ByteVector(""), ByteVector("a")); + CPPUNIT_ASSERT_EQUAL(ByteVector("abcdaba"), a); } } From 7d8aa7b8bdc30e8446adc8a33c0502ac257f728c Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 20 Feb 2016 19:42:46 +0900 Subject: [PATCH 28/74] ByteVector::append() can't take the vector itself. --- taglib/toolkit/tbytevector.cpp | 16 ++++++++++------ tests/test_bytevector.cpp | 12 ++++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 62f0fbef..841b5667 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -554,12 +554,16 @@ int ByteVector::endsWithPartialMatch(const ByteVector &pattern) const ByteVector &ByteVector::append(const ByteVector &v) { - if(v.d->length != 0) { - detach(); - unsigned int originalSize = size(); - resize(originalSize + v.size()); - ::memcpy(data() + originalSize, v.data(), v.size()); - } + if(v.isEmpty()) + return *this; + + detach(); + + const unsigned int originalSize = size(); + const unsigned int appendSize = v.size(); + + resize(originalSize + v.size()); + ::memcpy(data() + originalSize, v.data(), appendSize); return *this; } diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 32968965..12393b50 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -48,7 +48,8 @@ class TestByteVector : public CppUnit::TestFixture CPPUNIT_TEST(testReplace); CPPUNIT_TEST(testIterator); CPPUNIT_TEST(testResize); - CPPUNIT_TEST(testAppend); + CPPUNIT_TEST(testAppend1); + CPPUNIT_TEST(testAppend2); CPPUNIT_TEST(testBase64); CPPUNIT_TEST_SUITE_END(); @@ -403,7 +404,7 @@ public: CPPUNIT_ASSERT_EQUAL(-1, c.find('C')); } - void testAppend() + void testAppend1() { ByteVector v1("foo"); v1.append("bar"); @@ -441,6 +442,13 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v8); } + void testAppend2() + { + ByteVector a("1234"); + a.append(a); + CPPUNIT_ASSERT_EQUAL(ByteVector("12341234"), a); + } + void testBase64() { ByteVector sempty; From 01054009ac327958622b58efc50de746b36fd142 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sun, 21 Feb 2016 00:43:33 +0900 Subject: [PATCH 29/74] Make the code in ByteVector::append() a bit more clearer. --- taglib/toolkit/tbytevector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 841b5667..0d6538d9 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -562,7 +562,7 @@ ByteVector &ByteVector::append(const ByteVector &v) const unsigned int originalSize = size(); const unsigned int appendSize = v.size(); - resize(originalSize + v.size()); + resize(originalSize + appendSize); ::memcpy(data() + originalSize, v.data(), appendSize); return *this; From 710166e32d12c9fe0b0dc5f5f6fed15b6b9f1e32 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sun, 21 Feb 2016 23:16:48 +0900 Subject: [PATCH 30/74] Separate zlib related code rather than having several #ifdef blocks. --- taglib/CMakeLists.txt | 1 + taglib/mpeg/id3v2/id3v2frame.cpp | 61 ++------------ taglib/mpeg/id3v2/id3v2framefactory.cpp | 10 +-- taglib/toolkit/tzlib.cpp | 107 ++++++++++++++++++++++++ taglib/toolkit/tzlib.h | 54 ++++++++++++ tests/test_id3v2.cpp | 40 ++++----- 6 files changed, 190 insertions(+), 83 deletions(-) create mode 100644 taglib/toolkit/tzlib.cpp create mode 100644 taglib/toolkit/tzlib.h diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt index c30929fc..f248d0d1 100644 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -309,6 +309,7 @@ set(toolkit_SRCS toolkit/tpropertymap.cpp toolkit/trefcounter.cpp toolkit/tdebuglistener.cpp + toolkit/tzlib.cpp ) if(NOT WIN32) diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index a9d48f71..d065f2ae 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -23,22 +23,16 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#ifdef HAVE_CONFIG_H -#include -#endif - -#if HAVE_ZLIB -#include -#endif - #include #include #include +#include #include "id3v2tag.h" #include "id3v2frame.h" #include "id3v2synchdata.h" + #include "tpropertymap.h" #include "frames/textidentificationframe.h" #include "frames/urllinkframe.h" @@ -251,60 +245,21 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const frameDataOffset += 4; } -#if HAVE_ZLIB - if(d->header->compression() && - !d->header->encryption()) - { + if(zlib::isAvailable() && d->header->compression() && !d->header->encryption()) { if(frameData.size() <= frameDataOffset) { debug("Compressed frame doesn't have enough data to decode"); return ByteVector(); } - z_stream stream = {}; - - if(inflateInit(&stream) != Z_OK) - return ByteVector(); - - ByteVector inData = frameData; - - stream.avail_in = static_cast(inData.size() - frameDataOffset); - stream.next_in = reinterpret_cast(inData.data() + frameDataOffset); - - static const unsigned int chunkSize = 1024; - - ByteVector outData; - ByteVector chunk(chunkSize); - - do { - stream.avail_out = static_cast(chunk.size()); - stream.next_out = reinterpret_cast(chunk.data()); - - int result = inflate(&stream, Z_NO_FLUSH); - - if(result == Z_STREAM_ERROR || - result == Z_NEED_DICT || - result == Z_DATA_ERROR || - result == Z_MEM_ERROR) - { - if(result != Z_STREAM_ERROR) - inflateEnd(&stream); - debug("Error reading compressed stream"); - return ByteVector(); - } - - outData.append(stream.avail_out == 0 ? chunk : chunk.mid(0, chunk.size() - stream.avail_out)); - } while(stream.avail_out == 0); - - inflateEnd(&stream); - - if(frameDataLength != outData.size()) + const ByteVector outData = zlib::decompress(frameData.mid(frameDataOffset)); + if(frameDataLength != outData.size()) { debug("frameDataLength does not match the data length returned by zlib"); + } return outData; } - else -#endif - return frameData.mid(frameDataOffset, frameDataLength); + + return frameData.mid(frameDataOffset, frameDataLength); } String Frame::readStringField(const ByteVector &data, String::Type encoding, int *position) diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index cfa6be23..bbeb56f0 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -23,11 +23,8 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#ifdef HAVE_CONFIG_H -#include -#endif - #include +#include #include "id3v2framefactory.h" #include "id3v2synchdata.h" @@ -174,12 +171,11 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader) // TagLib doesn't mess with encrypted frames, so just treat them // as unknown frames. -#if !defined(HAVE_ZLIB) || HAVE_ZLIB == 0 - if(header->compression()) { + if(!zlib::isAvailable() && header->compression()) { debug("Compressed frames are currently not supported."); return new UnknownFrame(data, header); } -#endif + if(header->encryption()) { debug("Encrypted frames are currently not supported."); return new UnknownFrame(data, header); diff --git a/taglib/toolkit/tzlib.cpp b/taglib/toolkit/tzlib.cpp new file mode 100644 index 00000000..7198b630 --- /dev/null +++ b/taglib/toolkit/tzlib.cpp @@ -0,0 +1,107 @@ +/*************************************************************************** + copyright : (C) 2016 by Tsuda Kageyu + email : tsuda.kageyu@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_ZLIB +# include +#endif + +#include +#include + +#include "tzlib.h" + +using namespace TagLib; + +bool zlib::isAvailable() +{ +#ifdef HAVE_ZLIB + + return true; + +#else + + return false; + +#endif +} + +ByteVector zlib::decompress(const ByteVector &data) +{ +#ifdef HAVE_ZLIB + + z_stream stream = {}; + + if(inflateInit(&stream) != Z_OK) { + debug("zlib::decompress() - Failed to initizlize zlib."); + return ByteVector(); + } + + ByteVector inData = data; + + stream.avail_in = static_cast(inData.size()); + stream.next_in = reinterpret_cast(inData.data()); + + const unsigned int chunkSize = 1024; + + ByteVector outData; + + do { + const size_t offset = outData.size(); + outData.resize(outData.size() + chunkSize); + + stream.avail_out = static_cast(chunkSize); + stream.next_out = reinterpret_cast(outData.data() + offset); + + const int result = inflate(&stream, Z_NO_FLUSH); + + if(result == Z_STREAM_ERROR || + result == Z_NEED_DICT || + result == Z_DATA_ERROR || + result == Z_MEM_ERROR) + { + if(result != Z_STREAM_ERROR) + inflateEnd(&stream); + + debug("zlib::decompress() - Error reading compressed stream."); + return ByteVector(); + } + + outData.resize(outData.size() - stream.avail_out); + } while(stream.avail_out == 0); + + inflateEnd(&stream); + + return outData; + +#else + + return ByteVector(); + +#endif +} diff --git a/taglib/toolkit/tzlib.h b/taglib/toolkit/tzlib.h new file mode 100644 index 00000000..b1f1fcaf --- /dev/null +++ b/taglib/toolkit/tzlib.h @@ -0,0 +1,54 @@ +/*************************************************************************** + copyright : (C) 2016 by Tsuda Kageyu + email : tsuda.kageyu@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + +#ifndef TAGLIB_TZLIB_H +#define TAGLIB_TZLIB_H + +#include + +// THIS FILE IS NOT A PART OF THE TAGLIB API + +#ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header + +namespace TagLib { + + namespace zlib { + + /*! + * Returns whether or not zlib is installed and ready to use. + */ + bool isAvailable(); + + /*! + * Decompress \a data by zlib. + */ + ByteVector decompress(const ByteVector &data); + + } +} + +#endif + +#endif diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index 8b9e5b3f..a560658b 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -23,10 +23,6 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include @@ -48,6 +44,7 @@ #include #include #include +#include #include #include "utils.h" @@ -767,26 +764,23 @@ public: MPEG::File f(TEST_FILE_PATH_C("compressed_id3_frame.mp3"), false); CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("APIC")); -#ifdef HAVE_ZLIB + if(zlib::isAvailable()) { + ID3v2::AttachedPictureFrame *frame + = dynamic_cast(f.ID3v2Tag()->frameListMap()["APIC"].front()); + CPPUNIT_ASSERT(frame); + CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType()); + CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type()); + CPPUNIT_ASSERT_EQUAL(String(""), frame->description()); + CPPUNIT_ASSERT_EQUAL((unsigned int)86414, frame->picture().size()); + } + else { + // Skip the test if ZLIB is not installed. + // The message "Compressed frames are currently not supported." will be displayed. - ID3v2::AttachedPictureFrame *frame - = dynamic_cast(f.ID3v2Tag()->frameListMap()["APIC"].front()); - CPPUNIT_ASSERT(frame); - CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType()); - CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type()); - CPPUNIT_ASSERT_EQUAL(String(""), frame->description()); - CPPUNIT_ASSERT_EQUAL((unsigned int)86414, frame->picture().size()); - -#else - - // Skip the test if ZLIB is not installed. - // The message "Compressed frames are currently not supported." will be displayed. - - ID3v2::UnknownFrame *frame - = dynamic_cast(f.ID3v2Tag()->frameListMap()["APIC"].front()); - CPPUNIT_ASSERT(frame); - -#endif + ID3v2::UnknownFrame *frame + = dynamic_cast(f.ID3v2Tag()->frameListMap()["APIC"].front()); + CPPUNIT_ASSERT(frame); + } } void testW000() From 8d09f12847e9c3227f1b6f1f1d839eea02cb45d4 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 22 Feb 2016 00:35:11 +0900 Subject: [PATCH 31/74] Remove some #ifdefs and #includes no longer used. --- taglib/mp4/mp4atom.cpp | 4 ---- taglib/mpeg/id3v2/id3v2tag.cpp | 6 +----- taglib/toolkit/tbytevector.cpp | 8 ++------ taglib/toolkit/tstring.cpp | 7 ++----- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/taglib/mp4/mp4atom.cpp b/taglib/mp4/mp4atom.cpp index 1a5c3208..6ea0cb62 100644 --- a/taglib/mp4/mp4atom.cpp +++ b/taglib/mp4/mp4atom.cpp @@ -23,10 +23,6 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index af80e4f5..4c00ab6f 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -23,10 +23,6 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include @@ -470,7 +466,7 @@ ByteVector ID3v2::Tag::render() const void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const { -#ifdef NO_ITUNES_HACKS +#ifdef NO_ITUNES_HACKS const char *unsupportedFrames[] = { "ASPI", "EQU2", "RVA2", "SEEK", "SIGN", "TDRL", "TDTG", "TMOO", "TPRO", "TSOA", "TSOT", "TSST", "TSOP", 0 diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 0d6538d9..6494a448 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -23,10 +23,6 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include @@ -37,8 +33,8 @@ #include #include -#include "trefcounter.h" -#include "tutils.h" +#include +#include #include "tbytevector.h" diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 56daf33f..01a69266 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -25,10 +25,6 @@ // This class assumes that std::basic_string has a contiguous and null-terminated buffer. -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include #include @@ -41,12 +37,13 @@ # include "unicode.h" #endif -#include #include #include #include #include +#include "tstring.h" + namespace { using namespace TagLib; From c0a909b70984318d7d1fe64dbd0f000f2bb793f9 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 22 Feb 2016 01:39:40 +0900 Subject: [PATCH 32/74] Fix a broken indent. --- taglib/toolkit/tzlib.cpp | 74 ++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/taglib/toolkit/tzlib.cpp b/taglib/toolkit/tzlib.cpp index 7198b630..3d49732a 100644 --- a/taglib/toolkit/tzlib.cpp +++ b/taglib/toolkit/tzlib.cpp @@ -55,49 +55,49 @@ ByteVector zlib::decompress(const ByteVector &data) { #ifdef HAVE_ZLIB - z_stream stream = {}; + z_stream stream = {}; - if(inflateInit(&stream) != Z_OK) { - debug("zlib::decompress() - Failed to initizlize zlib."); + if(inflateInit(&stream) != Z_OK) { + debug("zlib::decompress() - Failed to initizlize zlib."); + return ByteVector(); + } + + ByteVector inData = data; + + stream.avail_in = static_cast(inData.size()); + stream.next_in = reinterpret_cast(inData.data()); + + const unsigned int chunkSize = 1024; + + ByteVector outData; + + do { + const size_t offset = outData.size(); + outData.resize(outData.size() + chunkSize); + + stream.avail_out = static_cast(chunkSize); + stream.next_out = reinterpret_cast(outData.data() + offset); + + const int result = inflate(&stream, Z_NO_FLUSH); + + if(result == Z_STREAM_ERROR || + result == Z_NEED_DICT || + result == Z_DATA_ERROR || + result == Z_MEM_ERROR) + { + if(result != Z_STREAM_ERROR) + inflateEnd(&stream); + + debug("zlib::decompress() - Error reading compressed stream."); return ByteVector(); } - ByteVector inData = data; + outData.resize(outData.size() - stream.avail_out); + } while(stream.avail_out == 0); - stream.avail_in = static_cast(inData.size()); - stream.next_in = reinterpret_cast(inData.data()); + inflateEnd(&stream); - const unsigned int chunkSize = 1024; - - ByteVector outData; - - do { - const size_t offset = outData.size(); - outData.resize(outData.size() + chunkSize); - - stream.avail_out = static_cast(chunkSize); - stream.next_out = reinterpret_cast(outData.data() + offset); - - const int result = inflate(&stream, Z_NO_FLUSH); - - if(result == Z_STREAM_ERROR || - result == Z_NEED_DICT || - result == Z_DATA_ERROR || - result == Z_MEM_ERROR) - { - if(result != Z_STREAM_ERROR) - inflateEnd(&stream); - - debug("zlib::decompress() - Error reading compressed stream."); - return ByteVector(); - } - - outData.resize(outData.size() - stream.avail_out); - } while(stream.avail_out == 0); - - inflateEnd(&stream); - - return outData; + return outData; #else From 520da50bc52bd6cecff5e9c4840682809bd591b6 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 22 Feb 2016 22:27:18 +0900 Subject: [PATCH 33/74] Always update the global RIFF size when updating RIFF files. --- taglib/riff/rifffile.cpp | 38 +++++++++++++++++++++++++++----------- taglib/riff/rifffile.h | 5 +++++ tests/test_riff.cpp | 12 +++++++++++- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index b1064cc1..bf52e19e 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -48,11 +48,14 @@ class RIFF::File::FilePrivate public: FilePrivate(Endianness endianness) : endianness(endianness), - size(0) {} + size(0), + sizeOffset(0) {} const Endianness endianness; unsigned int size; + long sizeOffset; + std::vector chunks; }; @@ -129,11 +132,6 @@ ByteVector RIFF::File::chunkData(unsigned int i) void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) { - // First we update the global size - - d->size += ((data.size() + 1) & ~1) - (d->chunks[i].size + d->chunks[i].padding); - insert(ByteVector::fromUInt(d->size, d->endianness == BigEndian), 4, 4); - // Now update the specific chunk writeChunk(chunkName(i), data, d->chunks[i].offset - 8, d->chunks[i].size + d->chunks[i].padding + 8); @@ -145,6 +143,10 @@ void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) for(i++; i < d->chunks.size(); i++) d->chunks[i].offset = d->chunks[i-1].offset + 8 + d->chunks[i-1].size + d->chunks[i-1].padding; + + // Update the global size. + + updateGlobalSize(); } void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data) @@ -177,11 +179,6 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo unsigned long offset = d->chunks.back().offset + d->chunks.back().size; - // First we update the global size - - d->size += (offset & 1) + data.size() + 8; - insert(ByteVector::fromUInt(d->size, d->endianness == BigEndian), 4, 4); - // Now add the chunk to the file writeChunk(name, data, offset, std::max(0, length() - offset), (offset & 1) ? 1 : 0); @@ -200,6 +197,10 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo chunk.padding = (data.size() & 0x01) ? 1 : 0; d->chunks.push_back(chunk); + + // Update the global size. + + updateGlobalSize(); } void RIFF::File::removeChunk(unsigned int i) @@ -216,6 +217,10 @@ void RIFF::File::removeChunk(unsigned int i) for(; it != d->chunks.end(); ++it) it->offset -= removeSize; + + // Update the global size. + + updateGlobalSize(); } void RIFF::File::removeChunk(const ByteVector &name) @@ -237,6 +242,7 @@ void RIFF::File::read() seek(baseOffset + 4); d->size = readBlock(4).toUInt(bigEndian); + d->sizeOffset = baseOffset + 4; seek(baseOffset + 12); @@ -298,3 +304,13 @@ void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, } insert(combined, offset, replace); } + +void RIFF::File::updateGlobalSize() +{ + const Chunk first = d->chunks.front(); + const Chunk last = d->chunks.back(); + d->size = last.offset + last.size + last.padding - first.offset + 12; + + const ByteVector data = ByteVector::fromUInt(d->size, d->endianness == BigEndian); + insert(data, d->sizeOffset, 4); +} diff --git a/taglib/riff/rifffile.h b/taglib/riff/rifffile.h index 52e75134..8425d8c9 100644 --- a/taglib/riff/rifffile.h +++ b/taglib/riff/rifffile.h @@ -148,6 +148,11 @@ namespace TagLib { unsigned long offset, unsigned long replace = 0, unsigned int leadingPadding = 0); + /*! + * Update the global RIFF size based on the current internal structure. + */ + void updateGlobalSize(); + class FilePrivate; FilePrivate *d; }; diff --git a/tests/test_riff.cpp b/tests/test_riff.cpp index 5223e905..f9a20dfb 100644 --- a/tests/test_riff.cpp +++ b/tests/test_riff.cpp @@ -211,7 +211,7 @@ public: CPPUNIT_ASSERT_EQUAL((unsigned int)(3), f.chunkDataSize(3)); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3)); CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(3)); - CPPUNIT_ASSERT_EQUAL((unsigned int)(4411 - 8), f.riffSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4412 - 8), f.riffSize()); } { PublicRIFF f(filename.c_str()); @@ -234,6 +234,8 @@ public: PublicRIFF f(filename.c_str()); + CPPUNIT_ASSERT_EQUAL(5928U, f.riffSize()); + CPPUNIT_ASSERT_EQUAL(5936L, f.length()); CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.chunkName(0)); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(1)); @@ -243,6 +245,8 @@ public: const ByteVector data(0x400, ' '); f.setChunkData("SSND", data); + CPPUNIT_ASSERT_EQUAL(1070U, f.riffSize()); + CPPUNIT_ASSERT_EQUAL(1078L, f.length()); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0026 + 8), f.chunkOffset(1)); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x042E + 8), f.chunkOffset(2)); @@ -255,6 +259,8 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4)); f.setChunkData(0, data); + CPPUNIT_ASSERT_EQUAL(2076U, f.riffSize()); + CPPUNIT_ASSERT_EQUAL(2084L, f.length()); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0414 + 8), f.chunkOffset(1)); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x081C + 8), f.chunkOffset(2)); @@ -267,6 +273,8 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4)); f.removeChunk("SSND"); + CPPUNIT_ASSERT_EQUAL(1044U, f.riffSize()); + CPPUNIT_ASSERT_EQUAL(1052L, f.length()); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0414 + 8), f.chunkOffset(1)); @@ -276,6 +284,8 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4)); f.removeChunk(0); + CPPUNIT_ASSERT_EQUAL(12U, f.riffSize()); + CPPUNIT_ASSERT_EQUAL(20L, f.length()); CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); f.seek(f.chunkOffset(0) - 8); From e8ef0e0a4b462a185f612e01541519a150ee3343 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 22 Feb 2016 23:12:34 +0900 Subject: [PATCH 34/74] Improve the padding handling of RIFF files a bit. --- taglib/riff/rifffile.cpp | 119 +++++++++++++++++++++++---------------- taglib/riff/rifffile.h | 3 +- 2 files changed, 71 insertions(+), 51 deletions(-) diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index bf52e19e..4b031ae2 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -134,15 +134,22 @@ void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) { // Now update the specific chunk - writeChunk(chunkName(i), data, d->chunks[i].offset - 8, d->chunks[i].size + d->chunks[i].padding + 8); + std::vector::iterator it = d->chunks.begin(); + std::advance(it, i); - d->chunks[i].size = data.size(); - d->chunks[i].padding = (data.size() & 0x01) ? 1 : 0; + const int originalSize = it->size + it->padding; + + writeChunk(it->name, data, it->offset - 8, it->size + it->padding + 8); + + it->size = data.size(); + it->padding = data.size() % 1; + + const int diff = it->size + it->padding - originalSize; // Now update the internal offsets - for(i++; i < d->chunks.size(); i++) - d->chunks[i].offset = d->chunks[i-1].offset + 8 + d->chunks[i-1].size + d->chunks[i-1].padding; + for(++it; it != d->chunks.end(); ++it) + it->offset += diff; // Update the global size. @@ -177,24 +184,35 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo // Couldn't find an existing chunk, so let's create a new one. - unsigned long offset = d->chunks.back().offset + d->chunks.back().size; + // Adjust the padding of the last chunk to place the new chunk at even position. - // Now add the chunk to the file + Chunk &last = d->chunks.back(); - writeChunk(name, data, offset, std::max(0, length() - offset), (offset & 1) ? 1 : 0); + long offset = last.offset + last.size + last.padding; + if(offset & 1) { + if(last.padding == 1) { + last.padding = 0; // This should not happen unless the file is corrupted. + offset--; + removeBlock(offset, 1); + } + else { + insert(ByteVector("\0", 1), offset, 0); + last.padding = 1; + offset++; + } + } + + // Now add the chunk to the file. + + writeChunk(name, data, offset, 0); // And update our internal structure - if(offset & 1) { - d->chunks.back().padding = 1; - offset++; - } - Chunk chunk; - chunk.name = name; - chunk.size = data.size(); - chunk.offset = offset + 8; - chunk.padding = (data.size() & 0x01) ? 1 : 0; + chunk.name = name; + chunk.size = data.size(); + chunk.offset = offset + 8; + chunk.padding = data.size() % 2; d->chunks.push_back(chunk); @@ -205,9 +223,6 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo void RIFF::File::removeChunk(unsigned int i) { - if(i >= d->chunks.size()) - return; - std::vector::iterator it = d->chunks.begin(); std::advance(it, i); @@ -238,18 +253,24 @@ void RIFF::File::removeChunk(const ByteVector &name) void RIFF::File::read() { const bool bigEndian = (d->endianness == BigEndian); - const long baseOffset = tell(); - seek(baseOffset + 4); + long offset = tell(); + + offset += 4; + d->sizeOffset = offset; + + seek(offset); d->size = readBlock(4).toUInt(bigEndian); - d->sizeOffset = baseOffset + 4; - seek(baseOffset + 12); + offset += 8; + seek(offset); // + 8: chunk header at least, fix for additional junk bytes - while(tell() + 8 <= length()) { - ByteVector chunkName = readBlock(4); - unsigned int chunkSize = readBlock(4).toUInt(bigEndian); + while(offset + 8 <= length()) { + + seek(offset); + const ByteVector chunkName = readBlock(4); + const unsigned int chunkSize = readBlock(4).toUInt(bigEndian); if(!isValidChunkName(chunkName)) { debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID"); @@ -263,24 +284,26 @@ void RIFF::File::read() break; } + offset += 8; + Chunk chunk; - chunk.name = chunkName; - chunk.size = chunkSize; - chunk.offset = tell(); + chunk.name = chunkName; + chunk.size = chunkSize; + chunk.offset = offset; - seek(chunk.size, Current); + offset += chunk.size; + + seek(offset); + + // Check padding - // check padding chunk.padding = 0; - long uPosNotPadded = tell(); - if((uPosNotPadded & 0x01) != 0) { - ByteVector iByte = readBlock(1); - if((iByte.size() != 1) || (iByte[0] != 0)) { - // not well formed, re-seek - seek(uPosNotPadded, Beginning); - } - else { + + if(offset & 1) { + const ByteVector iByte = readBlock(1); + if(iByte.size() == 1 && iByte[0] == '\0') { chunk.padding = 1; + offset++; } } @@ -289,26 +312,24 @@ void RIFF::File::read() } void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, - unsigned long offset, unsigned long replace, - unsigned int leadingPadding) + unsigned long offset, unsigned long replace) { ByteVector combined; - if(leadingPadding) { - combined.append(ByteVector(leadingPadding, '\x00')); - } + combined.append(name); combined.append(ByteVector::fromUInt(data.size(), d->endianness == BigEndian)); combined.append(data); - if((data.size() & 0x01) != 0) { - combined.append('\x00'); - } + + if(data.size() & 1) + combined.resize(combined.size() + 1, '\0'); + insert(combined, offset, replace); } void RIFF::File::updateGlobalSize() { const Chunk first = d->chunks.front(); - const Chunk last = d->chunks.back(); + const Chunk last = d->chunks.back(); d->size = last.offset + last.size + last.padding - first.offset + 12; const ByteVector data = ByteVector::fromUInt(d->size, d->endianness == BigEndian); diff --git a/taglib/riff/rifffile.h b/taglib/riff/rifffile.h index 8425d8c9..5c606b4a 100644 --- a/taglib/riff/rifffile.h +++ b/taglib/riff/rifffile.h @@ -145,8 +145,7 @@ namespace TagLib { void read(); void writeChunk(const ByteVector &name, const ByteVector &data, - unsigned long offset, unsigned long replace = 0, - unsigned int leadingPadding = 0); + unsigned long offset, unsigned long replace = 0); /*! * Update the global RIFF size based on the current internal structure. From 2aea23aed258555c3671e183c1327cd485f99028 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 22 Feb 2016 23:17:17 +0900 Subject: [PATCH 35/74] Add some debug messages to RIFF::File, just in case. --- taglib/riff/rifffile.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index 4b031ae2..f9d33e10 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -100,31 +100,50 @@ unsigned int RIFF::File::chunkCount() const unsigned int RIFF::File::chunkDataSize(unsigned int i) const { + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkPadding() - Index out of range. Returning 0."); + return 0; + } + return d->chunks[i].size; } unsigned int RIFF::File::chunkOffset(unsigned int i) const { + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkPadding() - Index out of range. Returning 0."); + return 0; + } + return d->chunks[i].offset; } unsigned int RIFF::File::chunkPadding(unsigned int i) const { + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkPadding() - Index out of range. Returning 0."); + return 0; + } + return d->chunks[i].padding; } ByteVector RIFF::File::chunkName(unsigned int i) const { - if(i >= chunkCount()) + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkName() - Index out of range. Returning an empty vector."); return ByteVector(); + } return d->chunks[i].name; } ByteVector RIFF::File::chunkData(unsigned int i) { - if(i >= chunkCount()) + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkData() - Index out of range. Returning an empty vector."); return ByteVector(); + } seek(d->chunks[i].offset); return readBlock(d->chunks[i].size); @@ -132,6 +151,11 @@ ByteVector RIFF::File::chunkData(unsigned int i) void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) { + if(i >= d->chunks.size()) { + debug("RIFF::File::setChunkData() - Index out of range."); + return; + } + // Now update the specific chunk std::vector::iterator it = d->chunks.begin(); @@ -223,6 +247,11 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo void RIFF::File::removeChunk(unsigned int i) { + if(i >= d->chunks.size()) { + debug("RIFF::File::removeChunk() - Index out of range."); + return; + } + std::vector::iterator it = d->chunks.begin(); std::advance(it, i); From 11abffc0f6c9d09c004e32a24dc876c61c4eec91 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 22 Feb 2016 23:27:46 +0900 Subject: [PATCH 36/74] Update NEWS. --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 5fbfb7ee..1b3ae2c2 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ TagLib 1.11 (Jan 30, 2016) * Better handling of corrupted APE tags. * Efficient decoding of unsynchronized ID3v2 frames. * Fixed text encoding when saving certain frames in ID3v2.3 tags. + * Fixed updating the size of RIFF files when removing chunks. * Several smaller bug fixes and performance improvements. 1.11 BETA: From 6c27a32de8a5b00e159f766bf1176dca1124ebf1 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 24 Feb 2016 21:32:25 +0900 Subject: [PATCH 37/74] Skip a useless debug message. --- taglib/mpeg/id3v2/id3v2frame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index d065f2ae..1f896fa6 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -252,7 +252,7 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const } const ByteVector outData = zlib::decompress(frameData.mid(frameDataOffset)); - if(frameDataLength != outData.size()) { + if(!outData.isEmpty() && frameDataLength != outData.size()) { debug("frameDataLength does not match the data length returned by zlib"); } From a27199b7722b857bc6c4bc4cad5afa6bebc5c5d2 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 24 Feb 2016 00:26:37 +0900 Subject: [PATCH 38/74] Support Boost iostreams library to decode compressed ID3v2 frames in additiion to zlib. This will help Windows users build TagLib without zlib source. --- ConfigureChecks.cmake | 9 ++++++++ config.h.cmake | 1 + taglib/CMakeLists.txt | 6 ++++- taglib/toolkit/tzlib.cpp | 47 +++++++++++++++++++++++++++++++++++----- 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 0f2b6d87..ee4fdc2e 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -225,6 +225,15 @@ if(NOT ZLIB_SOURCE) else() set(HAVE_ZLIB 0) endif() + + if(NOT HAVE_ZLIB) + find_package(Boost COMPONENTS iostreams zlib) + if(Boost_IOSTREAMS_FOUND AND Boost_ZLIB_FOUND) + set(HAVE_BOOST_ZLIB 1) + else() + set(HAVE_BOOST_ZLIB 0) + endif() + endif() endif() # Determine whether CppUnit is installed. diff --git a/config.h.cmake b/config.h.cmake index 7ac72410..7eb5993f 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -25,6 +25,7 @@ /* Defined if zlib is installed */ #cmakedefine HAVE_ZLIB 1 +#cmakedefine HAVE_BOOST_ZLIB 1 /* Indicates whether debug messages are shown even in release mode */ #cmakedefine TRACE_IN_RELEASE 1 diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt index f248d0d1..000f7937 100644 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -32,7 +32,7 @@ elseif(HAVE_ZLIB_SOURCE) include_directories(${ZLIB_SOURCE}) endif() -if(HAVE_BOOST_BYTESWAP OR HAVE_BOOST_ATOMIC) +if(HAVE_BOOST_BYTESWAP OR HAVE_BOOST_ATOMIC OR HAVE_BOOST_ZLIB) include_directories(${Boost_INCLUDE_DIR}) endif() @@ -352,6 +352,10 @@ if(HAVE_BOOST_ATOMIC) target_link_libraries(tag ${Boost_ATOMIC_LIBRARY}) endif() +if(HAVE_BOOST_ZLIB) + target_link_libraries(tag ${Boost_IOSTREAMS_LIBRARY} ${Boost_ZLIB_LIBRARY}) +endif() + set_target_properties(tag PROPERTIES VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH} SOVERSION ${TAGLIB_SOVERSION_MAJOR} diff --git a/taglib/toolkit/tzlib.cpp b/taglib/toolkit/tzlib.cpp index 3d49732a..40158fd2 100644 --- a/taglib/toolkit/tzlib.cpp +++ b/taglib/toolkit/tzlib.cpp @@ -27,8 +27,11 @@ # include #endif -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) # include +#elif defined(HAVE_BOOST_ZLIB) +# include +# include #endif #include @@ -40,7 +43,7 @@ using namespace TagLib; bool zlib::isAvailable() { -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BOOST_ZLIB) return true; @@ -53,7 +56,7 @@ bool zlib::isAvailable() ByteVector zlib::decompress(const ByteVector &data) { -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) z_stream stream = {}; @@ -81,9 +84,9 @@ ByteVector zlib::decompress(const ByteVector &data) const int result = inflate(&stream, Z_NO_FLUSH); if(result == Z_STREAM_ERROR || - result == Z_NEED_DICT || - result == Z_DATA_ERROR || - result == Z_MEM_ERROR) + result == Z_NEED_DICT || + result == Z_DATA_ERROR || + result == Z_MEM_ERROR) { if(result != Z_STREAM_ERROR) inflateEnd(&stream); @@ -99,6 +102,38 @@ ByteVector zlib::decompress(const ByteVector &data) return outData; +#elif defined(HAVE_BOOST_ZLIB) + + using namespace boost::iostreams; + + struct : public sink + { + ByteVector data; + + typedef char char_type; + typedef sink_tag category; + + std::streamsize write(char const* s, std::streamsize n) + { + const unsigned int originalSize = data.size(); + + data.resize(static_cast(originalSize + n)); + ::memcpy(data.data() + originalSize, s, static_cast(n)); + + return n; + } + } sink; + + try { + zlib_decompressor().write(sink, data.data(), data.size()); + } + catch(const zlib_error &) { + debug("zlib::decompress() - Error reading compressed stream."); + return ByteVector(); + } + + return sink.data; + #else return ByteVector(); From 5a3265d03189d830c1efdf863a7f238ba33e52ea Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 3 Mar 2016 05:02:14 +0900 Subject: [PATCH 39/74] Update NEWS for v1.11 BETA 2. --- NEWS | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 1b3ae2c2..d7decc5d 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ -TagLib 1.11 (Jan 30, 2016) -========================== +TagLib 1.11 (Mar 4, 2016) +========================= + +1.11 BETA 2: * Better handling of PCM WAV files with a 'fact' chunk. * Better handling of corrupted APE tags. From 1a824198727cb2a0989bb6797729193e7a0664ce Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 3 Mar 2016 10:06:51 +0900 Subject: [PATCH 40/74] Add myself to maintainers. --- AUTHORS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index e996d941..e2b73429 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,6 +2,8 @@ Scott Wheeler Author, maintainer Lukas Lalinsky Implementation of multiple new file formats, many bug fixes, maintainer +Tsuda Kageyu + A lot of bug fixes and performance improvements, maintainer. Ismael Orenstein Xing header implementation Allan Sandfeld Jensen @@ -10,8 +12,6 @@ Teemu Tervo Numerous bug reports and fixes Mathias Panzenböck Mod, S3M, IT and XM metadata implementations -Tsuda Kageyu - A lot of fixes and improvements, i.e. memory copy reduction etc. Please send all patches and questions to taglib-devel@kde.org rather than to individual developers! From ff8b6a91e7fbb9c0b5849c652d423904fe41ede8 Mon Sep 17 00:00:00 2001 From: Karel Patlejch Date: Sun, 6 Mar 2016 21:15:18 +0100 Subject: [PATCH 41/74] Fixed bug #725 - changed the maximum length of an APE key to 255 --- taglib/ape/apetag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index dfbd3076..89ef8ff4 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -51,7 +51,7 @@ namespace { const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", 0 }; - if(length < 2 || length > 16) + if(length < 2 || length > 255) return false; // only allow printable ASCII including space (32..126) From 7d270a7e20c85b5a14bc612be5055abb3b72a9d8 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 10 Mar 2016 21:38:08 +0900 Subject: [PATCH 42/74] Update NEWS. --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index d7decc5d..7509d4e2 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ TagLib 1.11 (Mar 4, 2016) ========================= + * Fixed reading APE items with long keys. + 1.11 BETA 2: * Better handling of PCM WAV files with a 'fact' chunk. From b2a67687041de639db119af27c530a2631c18c29 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 14 Mar 2016 20:35:09 +0900 Subject: [PATCH 43/74] Don't stop parsing an ID3v2 SYLT frame when its description is empty. --- NEWS | 1 + .../id3v2/frames/synchronizedlyricsframe.cpp | 2 +- tests/test_id3v2.cpp | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 7509d4e2..2defc51a 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ TagLib 1.11 (Mar 4, 2016) ========================= * Fixed reading APE items with long keys. + * Fixed reading ID3v2 SYLT frames when description is empty. 1.11 BETA 2: diff --git a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp index 4fb2e15a..c3b50c7e 100644 --- a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp @@ -158,7 +158,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) int pos = 6; d->description = readStringField(data, d->textEncoding, &pos); - if(d->description.isEmpty()) + if(pos == 6) return; /* diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index a560658b..d5ba9f29 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -94,6 +94,7 @@ class TestID3v2 : public CppUnit::TestFixture CPPUNIT_TEST(testParseOwnershipFrame); CPPUNIT_TEST(testRenderOwnershipFrame); CPPUNIT_TEST(testParseSynchronizedLyricsFrame); + CPPUNIT_TEST(testParseSynchronizedLyricsFrameWithEmptyDescritpion); CPPUNIT_TEST(testRenderSynchronizedLyricsFrame); CPPUNIT_TEST(testParseEventTimingCodesFrame); CPPUNIT_TEST(testRenderEventTimingCodesFrame); @@ -527,6 +528,35 @@ public: CPPUNIT_ASSERT_EQUAL((unsigned int)4567, stl[1].time); } + void testParseSynchronizedLyricsFrameWithEmptyDescritpion() + { + ID3v2::SynchronizedLyricsFrame f( + ByteVector("SYLT" // Frame ID + "\x00\x00\x00\x21" // Frame size + "\x00\x00" // Frame flags + "\x00" // Text encoding + "eng" // Language + "\x02" // Time stamp format + "\x01" // Content type + "\x00" // Content descriptor + "Example\x00" // 1st text + "\x00\x00\x04\xd2" // 1st time stamp + "Lyrics\x00" // 2nd text + "\x00\x00\x11\xd7", 40)); // 2nd time stamp + CPPUNIT_ASSERT_EQUAL(String::Latin1, f.textEncoding()); + CPPUNIT_ASSERT_EQUAL(ByteVector("eng", 3), f.language()); + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::AbsoluteMilliseconds, + f.timestampFormat()); + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::Lyrics, f.type()); + CPPUNIT_ASSERT(f.description().isEmpty()); + ID3v2::SynchronizedLyricsFrame::SynchedTextList stl = f.synchedText(); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, stl.size()); + CPPUNIT_ASSERT_EQUAL(String("Example"), stl[0].text); + CPPUNIT_ASSERT_EQUAL((unsigned int)1234, stl[0].time); + CPPUNIT_ASSERT_EQUAL(String("Lyrics"), stl[1].text); + CPPUNIT_ASSERT_EQUAL((unsigned int)4567, stl[1].time); + } + void testRenderSynchronizedLyricsFrame() { ID3v2::SynchronizedLyricsFrame f; From 7627ae48ed2e63eb5dea13ec701f2da53c8314fb Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 17 Mar 2016 22:50:34 +0900 Subject: [PATCH 44/74] Change some static_casts to dynamic_casts in test_id3v2.cpp. static_casts are unsafe and some of following tests doesn't work well with them. --- tests/test_id3v2.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index d5ba9f29..93a3d2c2 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -249,7 +249,7 @@ public: "d\x00" "\x00", 14); ID3v2::AttachedPictureFrame *frame = - static_cast(factory->createFrame(data, (unsigned int)2)); + dynamic_cast(factory->createFrame(data, (unsigned int)2)); CPPUNIT_ASSERT(frame); CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), frame->mimeType()); @@ -269,8 +269,8 @@ public: "\x01" "d\x00" "\x00", 14); - ID3v2::AttachedPictureFrame *frame = - static_cast(factory->createFrame(data, (unsigned int)2)); + ID3v2::UnknownFrame *frame = + dynamic_cast(factory->createFrame(data, (unsigned int)2)); CPPUNIT_ASSERT(frame); @@ -663,7 +663,7 @@ public: "\x00" // Encoding "(22)Death Metal", 26); // Text ID3v2::TextIdentificationFrame *frame = - static_cast(factory->createFrame(data, (unsigned int)3)); + dynamic_cast(factory->createFrame(data, (unsigned int)3)); CPPUNIT_ASSERT_EQUAL((unsigned int)1, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("Death Metal"), frame->fieldList()[0]); @@ -682,7 +682,7 @@ public: "\x00" // Encoding "(4)Eurodisco", 23); // Text ID3v2::TextIdentificationFrame *frame = - static_cast(factory->createFrame(data, (unsigned int)3)); + dynamic_cast(factory->createFrame(data, (unsigned int)3)); CPPUNIT_ASSERT_EQUAL((unsigned int)2, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("4"), frame->fieldList()[0]); CPPUNIT_ASSERT_EQUAL(String("Eurodisco"), frame->fieldList()[1]); @@ -701,7 +701,7 @@ public: "\0" // Encoding "14\0Eurodisco", 23); // Text ID3v2::TextIdentificationFrame *frame = - static_cast(factory->createFrame(data, (unsigned int)4)); + dynamic_cast(factory->createFrame(data, (unsigned int)4)); CPPUNIT_ASSERT_EQUAL((unsigned int)2, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("14"), frame->fieldList()[0]); CPPUNIT_ASSERT_EQUAL(String("Eurodisco"), frame->fieldList()[1]); @@ -757,11 +757,11 @@ public: } { MPEG::File bar(newname.c_str()); - tf = static_cast(bar.ID3v2Tag()->frameList("TDOR").front()); + tf = dynamic_cast(bar.ID3v2Tag()->frameList("TDOR").front()); CPPUNIT_ASSERT(tf); CPPUNIT_ASSERT_EQUAL((unsigned int)1, tf->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("2011"), tf->fieldList().front()); - tf = static_cast(bar.ID3v2Tag()->frameList("TDRC").front()); + tf = dynamic_cast(bar.ID3v2Tag()->frameList("TDRC").front()); CPPUNIT_ASSERT(tf); CPPUNIT_ASSERT_EQUAL((unsigned int)1, tf->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("2012-04-17T12:01"), tf->fieldList().front()); From 76f8ff388fc6965f4f7ca848c3fa3f11ca95150f Mon Sep 17 00:00:00 2001 From: Dirk Vanden Boer Date: Sun, 20 Mar 2016 20:33:04 +0100 Subject: [PATCH 45/74] Also ignore the virtual destructor warning when compiling with clang --- taglib/toolkit/taglib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h index 5a1204dc..bd4886bd 100644 --- a/taglib/toolkit/taglib.h +++ b/taglib/toolkit/taglib.h @@ -32,7 +32,7 @@ #define TAGLIB_MINOR_VERSION 11 #define TAGLIB_PATCH_VERSION 0 -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1)) +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1)) || defined(__clang__) #define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"") #else #define TAGLIB_IGNORE_MISSING_DESTRUCTOR From 0a85f9b227db1432ae3fa27b235ec806b9ad3cf6 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 22 Apr 2016 09:27:04 +0900 Subject: [PATCH 46/74] Revert "Hide a private static variable." This reverts commit 25ffbcb4b9b04326edd1d25a785b686951a0f235. # Conflicts: # taglib/mpeg/id3v2/id3v2framefactory.cpp # taglib/mpeg/id3v2/id3v2framefactory.h --- taglib/mpeg/id3v2/id3v2framefactory.cpp | 4 ++-- taglib/mpeg/id3v2/id3v2framefactory.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index bbeb56f0..0fbb87d0 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -102,13 +102,14 @@ public: } }; +FrameFactory FrameFactory::factory; + //////////////////////////////////////////////////////////////////////////////// // public members //////////////////////////////////////////////////////////////////////////////// FrameFactory *FrameFactory::instance() { - static FrameFactory factory; return &factory; } @@ -538,4 +539,3 @@ bool FrameFactory::updateFrame(Frame::Header *header) const return true; } - diff --git a/taglib/mpeg/id3v2/id3v2framefactory.h b/taglib/mpeg/id3v2/id3v2framefactory.h index c3875dc5..33c7f67e 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.h +++ b/taglib/mpeg/id3v2/id3v2framefactory.h @@ -66,7 +66,6 @@ namespace TagLib { { public: static FrameFactory *instance(); - /*! * Create a frame based on \a data. \a synchSafeInts should only be set * false if we are parsing an old tag (v2.3 or older) that does not support @@ -153,6 +152,8 @@ namespace TagLib { FrameFactory(const FrameFactory &); FrameFactory &operator=(const FrameFactory &); + static FrameFactory factory; + class FrameFactoryPrivate; FrameFactoryPrivate *d; }; From 1b878102f02ed5ab371d6ac88c5d8e226f094c7c Mon Sep 17 00:00:00 2001 From: Svyatoslav Mishyn Date: Fri, 22 Apr 2016 16:46:15 +0300 Subject: [PATCH 47/74] c: fix a typo readble => readable --- bindings/c/tag_c.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/c/tag_c.h b/bindings/c/tag_c.h index 2e8b752f..8d5f85ff 100644 --- a/bindings/c/tag_c.h +++ b/bindings/c/tag_c.h @@ -124,7 +124,7 @@ TAGLIB_C_EXPORT TagLib_File *taglib_file_new_type(const char *filename, TagLib_F TAGLIB_C_EXPORT void taglib_file_free(TagLib_File *file); /*! - * Returns true if the file is open and readble and valid information for + * Returns true if the file is open and readable and valid information for * the Tag and / or AudioProperties was found. */ @@ -137,7 +137,7 @@ TAGLIB_C_EXPORT BOOL taglib_file_is_valid(const TagLib_File *file); TAGLIB_C_EXPORT TagLib_Tag *taglib_file_tag(const TagLib_File *file); /*! - * Returns a pointer to the the audio properties associated with this file. This + * Returns a pointer to the audio properties associated with this file. This * will be freed automatically when the file is freed. */ TAGLIB_C_EXPORT const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file); From d8e50779616ea4a5e79cdf71bf7bf049b531ec3d Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 29 Apr 2016 17:26:33 +0900 Subject: [PATCH 48/74] Update NEWS. --- NEWS | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2defc51a..a3e2f0df 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ -TagLib 1.11 (Mar 4, 2016) -========================= +TagLib 1.11 (Apr 29, 2016) +========================== + +1.11: * Fixed reading APE items with long keys. * Fixed reading ID3v2 SYLT frames when description is empty. From 9b995544e4ca27c4162638b3048b1633cab4048b Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 14 May 2016 09:58:19 +0900 Subject: [PATCH 49/74] Fix reading table of contents frames with a lot of children. --- .../mpeg/id3v2/frames/tableofcontentsframe.cpp | 6 +++--- tests/data/toc_many_children.mp3 | Bin 0 -> 11525 bytes tests/test_id3v2.cpp | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tests/data/toc_many_children.mp3 diff --git a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp index 50720359..f7971250 100644 --- a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp +++ b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp @@ -272,9 +272,9 @@ void TableOfContentsFrame::parseFields(const ByteVector &data) int pos = 0; unsigned int embPos = 0; d->elementID = readStringField(data, String::Latin1, &pos).data(String::Latin1); - d->isTopLevel = (data.at(pos) & 2) > 0; - d->isOrdered = (data.at(pos++) & 1) > 0; - unsigned int entryCount = data.at(pos++); + d->isTopLevel = (data.at(pos) & 2) != 0; + d->isOrdered = (data.at(pos++) & 1) != 0; + unsigned int entryCount = static_cast(data.at(pos++)); for(unsigned int i = 0; i < entryCount; i++) { ByteVector childElementID = readStringField(data, String::Latin1, &pos).data(String::Latin1); d->childElements.append(childElementID); diff --git a/tests/data/toc_many_children.mp3 b/tests/data/toc_many_children.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..168c47981fb866c759a5a845175977b95ce01b23 GIT binary patch literal 11525 zcmeI2ZHQE57=|Bn)h(^8EVV4x+RD%Myyu*mIa3je23i|QY$PFMwT986n{6RfU=$%y zAW>u>R3PCGAqxqih=mL!j3WFYArv80Bz;hX^nu;?u-Lgc&~L`F70AoBDB8}Az)*{~&%v4ao~(s+=?gFGJ8;z2zg zG~z)K51R2Hv|n0ZJLroCef6L(AN2Ku76fewS`oA()s9p5$h0HVj!Zi;?Z~tv(~e9#GVRE;BiD{xJ96#FwIkP#Tsv~@$h9Naj$Aux+ELSv zns(H*qoy4-?Wk!-O*?AZQPYmPcGR__t{rvlsB1@EJL=j|*N(b&)U~6b9S!YhXh%ak z8rsp&j)rzLw40DLOTlWD72%{j;3}rwWFyWP3>rEM^ihR z+R@aGrgk*7BP3c95^V{I)`UcRLZU?>(Wa1SRYFQ@3F6vR@=ttK+#^ItMC60znn!z|+ zRHVewkx5$_hl`SwI9f947~^nJlM+WyCNEjKf7$N*rC8(#<$rl%>Sc zmMKGw!$n<69DSMcIn$X-tuI*5M7r^zcIOUfeZk@fW+&rt))%alVE$qp&iaC7Rpi|D zjKf)9um*!U$T*z!1q(JVT<0?mXMMry4(0{M;jAzCRRHE^#^J0l_`M-Ab%1d=>kBS5 z!5m;ZbD8x87p5Z9<}eOteZgfcm~D*1SzmC`3+6cEaMl-GBI8%-D#qcgFSwuvvzKu= z>kBTwMJ|}mIGptb7wcd~7>BdI;L;w&H923BbXD6!&zUjy%d?T zhH*IS3pS%*_A?G=eZkgMUBs%{ZL(1)FG*%T_WDXMMqz z8_XWY;jAy%po`3$#yFhy1>1Qr!%SzcZhgV#AIuTP;jAwh6^P8jo1IlSob?5R1u(l9 zhqJz53?VYR6^FCFU}ynuka0Nc3q~AZ4lxdAeZfFPhAm)z zV;s)FK!T*LZ;K@OM?7>BdIVC*9@r-yMk>kEcNV4h_h&iaCp5}5B8hqJz5 z03~u|KjU!L7mTaG>|-3x`hww>$W=2KhqJz56b5E1<8am&49>tDV;s) zuCTsfCkGz%U_NIY&iaC3qR2e_F)w#G>kCGY zV0JPNXMMq-63kzW!&zT2))cvVJ>ziJ7Ysqc9Aq5M`htkG!nV74(1XMMrY8O(9U z;jAwhQHxx+ig7sW3kKR?_A(9^eOan=H;lhUuAk1F#!W5H>!L8QB;EqUv>en3|9vQVMlk{f(8;nOrampmkSKkx`*CNrx7mWE?V7IMkZ@E?OtDXq`t^I27p6 zqEW^pD;&Zd7TlHSWjwONA>5DwwVmPf~UD;&bDDo|fD4yl9Sl6|d7@Y0ncOILbig+r}b@X|dX z_jqK5L#=6WGEF3z=8+W+wdTReFvww#tZ=9`5l)VPJmQfR4z*^&{AxnskrfWLrov$t z$Xy;;;ZSQX%rh+&kF0R0H5pC^K@NH(eHnj@e*)v5!2k3UIQ8eggXTwHz3IWtc=E#5 z9r>+dK3_#1sU^e?~tmaMN?Y?<(Bd{6mkZ+HK4kx{|>_~X!1cgKGi z|NAWc1X{*T9F+;X@dNaT{%ad<>qZ literal 0 HcmV?d00001 diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index 93a3d2c2..4f58bdd6 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -118,6 +118,7 @@ class TestID3v2 : public CppUnit::TestFixture CPPUNIT_TEST(testShrinkPadding); CPPUNIT_TEST(testEmptyFrame); CPPUNIT_TEST(testDuplicateTags); + CPPUNIT_TEST(testParseTOCFrameWithManyChildren); CPPUNIT_TEST_SUITE_END(); public: @@ -1217,6 +1218,12 @@ public: } } + void testParseTOCFrameWithManyChildren() + { + MPEG::File f(TEST_FILE_PATH_C("toc_many_children.mp3")); + CPPUNIT_ASSERT(f.isValid()); + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2); From 3e47a036fbbe5117377018fbbe4cbdd49319196e Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 14 May 2016 10:46:42 +0900 Subject: [PATCH 50/74] Update NEWS. --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index a3e2f0df..b43a8ec2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +========================== + + * Fixed reading ID3v2 CTOC frames with a lot of entries. + TagLib 1.11 (Apr 29, 2016) ========================== From 75e3ec73aadf43f64be36c41128304fcc0446e61 Mon Sep 17 00:00:00 2001 From: Jake Welton Date: Sun, 14 Aug 2016 22:02:33 +0100 Subject: [PATCH 51/74] Change string to end offset --- taglib/mpeg/id3v2/frames/chapterframe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/mpeg/id3v2/frames/chapterframe.cpp b/taglib/mpeg/id3v2/frames/chapterframe.cpp index 44cdf5e7..d45af5fb 100644 --- a/taglib/mpeg/id3v2/frames/chapterframe.cpp +++ b/taglib/mpeg/id3v2/frames/chapterframe.cpp @@ -198,7 +198,7 @@ String ChapterFrame::toString() const s += ", start offset: " + String::number(d->startOffset); if(d->endOffset != 0xFFFFFFFF) - s += ", start offset: " + String::number(d->endOffset); + s += ", end offset: " + String::number(d->endOffset); if(!d->embeddedFrameList.isEmpty()) { StringList frameIDs; From 9f28e037feb5fb7f10c731f7dc05aa8ea9465125 Mon Sep 17 00:00:00 2001 From: evpobr Date: Sat, 20 Aug 2016 22:37:53 +0500 Subject: [PATCH 52/74] Move cmake_minimum_required at the top --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 298ee7e3..fb024720 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ -project(taglib) - cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) +project(taglib) + if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.12) cmake_policy(SET CMP0022 OLD) endif() From c9bdd416efb5e46c8180b934985bd98adc4c2180 Mon Sep 17 00:00:00 2001 From: Festus Hagen Date: Thu, 25 Aug 2016 15:03:44 -0400 Subject: [PATCH 53/74] Add BUILD_SHARED_LIBS option for CMake GUI. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 298ee7e3..dc7e4890 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ if(DEFINED ENABLE_STATIC) message(FATAL_ERROR "This option is no longer available, use BUILD_SHARED_LIBS instead") endif() +option(BUILD_SHARED_LIBS "Build shared libraries" OFF) if(NOT BUILD_SHARED_LIBS) add_definitions(-DTAGLIB_STATIC) endif() From 7e90313690e716a0c761436aacde72cafb3f7d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Andr=C3=A9?= Date: Thu, 15 Sep 2016 16:30:16 +0200 Subject: [PATCH 54/74] Fix defect in ByteVectorStream::seek when Position==End. --- taglib/toolkit/tbytevectorstream.cpp | 2 +- tests/test_bytevectorstream.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/taglib/toolkit/tbytevectorstream.cpp b/taglib/toolkit/tbytevectorstream.cpp index 5e200b3d..74b2eced 100644 --- a/taglib/toolkit/tbytevectorstream.cpp +++ b/taglib/toolkit/tbytevectorstream.cpp @@ -137,7 +137,7 @@ void ByteVectorStream::seek(long offset, Position p) d->position += offset; break; case End: - d->position = length() - offset; + d->position = length() + offset; // offset is expected to be negative break; } } diff --git a/tests/test_bytevectorstream.cpp b/tests/test_bytevectorstream.cpp index c7b0f105..f8308c6d 100644 --- a/tests/test_bytevectorstream.cpp +++ b/tests/test_bytevectorstream.cpp @@ -38,6 +38,7 @@ class TestByteVectorStream : public CppUnit::TestFixture CPPUNIT_TEST(testReadBlock); CPPUNIT_TEST(testRemoveBlock); CPPUNIT_TEST(testInsert); + CPPUNIT_TEST(testSeekEnd); CPPUNIT_TEST_SUITE_END(); public: @@ -112,6 +113,19 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("yyx123foa"), *stream.data()); } + void testSeekEnd() + { + ByteVector v("abcdefghijklmnopqrstuvwxyz"); + ByteVectorStream stream(v); + CPPUNIT_ASSERT_EQUAL(26L, stream.length()); + + stream.seek(-4, IOStream::End); + CPPUNIT_ASSERT_EQUAL(ByteVector("w"), stream.readBlock(1)); + + stream.seek(-25, IOStream::End); + CPPUNIT_ASSERT_EQUAL(ByteVector("b"), stream.readBlock(1)); + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestByteVectorStream); From 0dac721ce226f330777c25f6fae9b099d29630bb Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 26 Sep 2016 17:48:44 +0900 Subject: [PATCH 55/74] Update NEWS. --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index b43a8ec2..e02c6fd3 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ========================== * Fixed reading ID3v2 CTOC frames with a lot of entries. + * Fixed seeking ByteVectorStream from the end. TagLib 1.11 (Apr 29, 2016) ========================== From 97aaa0f97940065233334cfb8eaf5d672ac6dfda Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 19 Oct 2016 15:57:28 +0900 Subject: [PATCH 56/74] Restore the ABI breakage by bringing back a removed private static variable. --- taglib/toolkit/tstring.cpp | 6 ++++++ taglib/toolkit/tstring.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 01a69266..83287905 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -787,6 +787,12 @@ void String::detach() if(d->count() > 1) String(d->data.c_str()).swap(*this); } + +//////////////////////////////////////////////////////////////////////////////// +// private members +//////////////////////////////////////////////////////////////////////////////// + +const String::Type String::WCharByteOrder = wcharByteOrder(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h index 97e9ff66..b1be04b8 100644 --- a/taglib/toolkit/tstring.h +++ b/taglib/toolkit/tstring.h @@ -536,6 +536,13 @@ namespace TagLib { void detach(); private: + /*! + * \deprecated This variable is no longer used, but NEVER remove this. It + * may lead to a linkage error. + */ + // BIC: remove + static const Type WCharByteOrder; + class StringPrivate; StringPrivate *d; }; From 69c65284a599ace31894b3059bda9c0e37b9ffaa Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 22 Oct 2016 01:06:57 +0900 Subject: [PATCH 57/74] Update NEWS. --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index e02c6fd3..aa957b0e 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,9 @@ -========================== +TagLib 1.11.1 (Oct ??, 2016) +============================ * Fixed reading ID3v2 CTOC frames with a lot of entries. * Fixed seeking ByteVectorStream from the end. + * Fixed binary incompatible change in TagLib::String. TagLib 1.11 (Apr 29, 2016) ========================== From 6a96a6426a4895a529c3bcde52d7cfe290b4d95a Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 22 Oct 2016 02:11:16 +0900 Subject: [PATCH 58/74] Replace a possibly non-free file in the test suite. --- tests/data/id3v22-tda.mp3 | Bin 8192 -> 4096 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/data/id3v22-tda.mp3 b/tests/data/id3v22-tda.mp3 index d89ae1c4473cfeec3d8c9a1ecf8c2fe0f4570506..b0545ea6f087d8784816eb4dcbd530f7df8a6465 100644 GIT binary patch literal 4096 zcmeH}`8Sje8^`alZ?jOAA`Ph+k+Dk(AxmVLu_PL_ShJ43n!*q;IqswGRAV!<+=rJThPcm;wNbB1{obmO{J| z6yUo;0`L^9spJ*lV9x`G?KP^?KN6E7-u){2g^5W1WN{R;St9nvnjLk5q5Xb*NzT48 zMj@|ZQD;#my)(bA$SGQrD~9ThbiVlXRr39hD!i9L=wz^MNR_n3`T6mijoNGMG z-q$J1dluz=uv5qvSLzSR;6OmqXkH-DL1_mYM~CZF3JURo74`#I@Fh?&xoVP$8IVmR ze05FAP|Wa%u$!LGJ?-v-9%vSSHm^kI%k3LR%yqPPYDDIWzEyKu6Y z^3ctvgzzRuF;6lBy! z?SFHB6SAy4@RN+Rc6;ZVQHR6(=F#oVtchgiua+*)*PCrSA)o_jUNBgP1X_+Hf(0c( zln9DI3h7bSEvJYqn&5DsR=?LNA!YB=J-*oeoUL5un^fWD$xcX1k zj#(><6}^uZeKQSWV=Ecm5o?(t3MnkvLj^DG)9k}pmrE&hF^#u1lk8RF3mdRd=HazrL9=7Kv7%N!I6;_ z;W5a{#9O9F&(a>;mudTy>CSNec+98%PexuF>lr=7^<%~#jokvDr?~POhf2R0PPA?= zf`FW8|5yQO3M=F&D8w&d3V@bt2kYIpIon5HyD5z;dhD?S?W$6uxoT8V7kTEa)zwQk z%6p3sj9X#HHq1$M|TRke=lp5UB&GmJK%AoFy0pbZJaT?x7e7AWQw$~ zIig;>Cdk$4VHxVTpZ|5}W36;UwM5#jJP62l-P`M-U@C`!LLq9Sb8yP-vpCKaoSHCk z-|BIh9q$t9RzBMAkZ~?HtyaPNNsO10mFOp8Z?=`kcd}^lTDbqdDU>-dvcA| zr&{?nHzH*6@vaQ-27c>Y_m4}?D^|A!IN5e@&HhpzVLz$gvan5gAh7)Bj(xcG8498C zqTyjhZp=_J917Y{%3T3cd+WMoxIRM>8t$px4eExv{rO$11bl;g_-t2mj#FfDYlh^X z)I!FS$Jbsn?M^kSUnoNMOL+}VExNqJ`4u>0+MCxEB7^%5wl>OC4htv)h+cjH$Z{Gm zP$JXpD!CUpI`oF}BQ!+6u?jy|;|8$bjJ?&b zKHU_-2Pu?9Jf5zq-6i`AGyG6m9rbdlHgMp8PyRED!cxkC8B6|cS)RSsEO z8K>?$TH94PdhpQkOjX&a$Q<+<%dT&<+ExGalil1YFQZ9CPk-acOEMwBc>o3PvzcSgoC7)hshOMt4deVDQbe z=O$fZp5a7WJWjDDBKk!B9mer-*X)$QJWJV0&3WbJiTe7bY-($kdRls_crf>Bf5%x8 z1XTK;#cC>ol>il*;1@uE;R7ykXx}A0YuynfspwP}K1)<&s2O^ExIQgkHQ4IZV)Jb_ zrAHSVbDf9|%1IH{v>y`}-|js8t4F+YcDi5B_zw?b=cJ6S{WF*=5D)_ng?4a*)8X`? z!wb(C?i})Aegn<2kuSYzCZ1a5M0WjEfg!YpyBTHiqpG6Cyzfjjc*G71n7iw53|9ROHIlq6ybfIx#_nu6czfD-rwiu#rs zEfIP*9DKDen1)crjI6E34r>~@1(T!DTVI$5JoYD2W#t)slKDuc-B_)T1NydhsyMzi z6g#!huYuf=-qx4k0s*nnywl*(NQV|4eEQ75KsxZS#&=cCc@rKow>{qyv?Ag3*xqJs zPSt+9scBk22UQj1dIvqVoG{5ZRq z)18sUFLU%0^Ck}`(%bQpdxH|BcMVB>^$Osh?qPgaJ1lp}KUn|3oIV6Jg65q8f!e`Y zZ3n|=$1VieI6klfcx^*l+CPP3|XkNrWK(M!O!#5UWIdEA0 zYie6mtBKF9vy1mcaFCOhJzEwB1_ucS1t%^{)t@_})^uB`NU6~#{o#!9EvdQRzj;eG zPfo`akD7#acrUvk>;5>g3IV+XQx4vD&{Yo-Al?eXdk9#+wnJ{X*;JhsFTH$wQ)W0q zai|uHGC4E!p&)KpU3wEr%e9xa`$(^hl#!U~7{@yDd+4#$prGKp{-qr*9KD=fjr_fIbPcotR+0ate{P6N z{IiUR$bZWKMn+-)zycsxm62YorbrKWR^7j~pQA79zsKMnPXHr5Q2>AfO2|i#T>QOo zbAXYGA^;EoA}|qgz(`RG0H}fgLCruD0Pq1(z{ngI7y%$AA}RtHDeD3N1mJ=3{-x;u z)BiK@f1LsBRX+HiVlYuMKmZ`JI^2D4x0nI|Y%)Lu00Qs;h0MCnvi7@ebf7R|b?SFJBG$6XZd;+UT;eVEub`!@U5 z-yNPcr^SaQ=B0c^jkO|;syJ(RJG?sxar%;7tG%oPnY}SXQvJ4rlY=e;BKX>g$!+C&i8*P8np4;KwHqsQ_Vum?v zy3s0tIcyujdFs^W(#qH7*kaX0hdJ$Kec#h}KJ5M1`rrK5@_%ZVzjg;Q2QvTS;7})r z@^CHO=&<+jd>>D{IVjyo*D<$r>yx7>^W-y;!}RE7dtj_o@Qf+KPY^^8iVn z;O<3i;2K`*o4+_LR%007bMy2>k)kZA99&e z%?02k;N)2Wiak>-7W?PPvs)S<6rcow=mRt7NEBbZ-7dAN_&M$&vT%iEqa2!hS z+vD{99S_;6D-F~h1dQTyqEGb_H+*Wt5`?MnoPCn zf2B z3FL3aqBohtN~oes*rU0r!%L_lxw(l3NP$i6cy5|nwZAwY3LgRh8ll6 z5S|vka6XP3WmHiS4u=;`&~ppUK^R2^3Imw?*=z?2^gbZxd-AH5S$8NuFYU^{m)-In zXU#O^Y$6w2ALg&tT63yEDJ0mU*YBl^HQ}rO#mQiE2Y@@kNS*>fM1bN2GXo&dDugv0 z$D1-xM3V=ATb}f7aEqVRST@gX{kVVd+jFU?k}PH|Mlme32M?h1j|Oc#{YGL$LU<4s zb8xl9PQqY`#a`;$eQ$YLeVgLdqSqblrKp32VgLaA{5Nk*c|04k06^z(#hbKoL$Mgm zg{;o^zU|v7wq?JbLst@?#|(_ybd}K9ta^N<)6IwIk2CHfFPQe4kYxk#fD#gboSE?Wrq|vFsz0u z=Wfuf_G&XS{`ix|u+>vn$BMnIbEwgVpupedXEe?2J(7q>Je`Rj(tt!YMr)r3F%(od zMlo(u7UZjugr<_*(5hcx-F~4Fc#c<(Uj`XeaE%(qxMnE8lBd+bq*U!TU#Uu!l(iVd zBk4m|SG9Nu>{tondi48DT*fZM8uaV(EM@Qsl0t*88l+0NY>k$N+GLY9?U$0RB#pFu z*`D?}l%|Op8jigR%FDa{mgpEySn@;;%>4X3VCnIYX*cXx8sxtq=lG(lTZqmV zeZpW)<7#-uqoiFUfp8%@BEil68P_*(J=?8~bf_bCeH#Kg7Fu&r{}tn73*geVNKT4Jgr6zBeBNw%W2k% zvtu^=4z~QCUHCCcw^E2yNz&?LNZ&S;6z+spy%%aY_*69I_>y?WS?P3_av@lZvBtL2 zm6z(YFmhO^6L^}09@3ZbF-cgJm$;-SD#;4`}d+7(gT3r`%w2UDwW8Ee(f|2*g9 zD~}=%=)4kTf2>8Dg85wNQ{uGEy%hE<{Dlz0L3`3-I_PGT&^whE_>3xNrL11nS+7LS z8V7C97oBb6_a!NcBAj-VHU{i`--C+WZnn_EA27tvGnus^-iJOAh)kA^Q=Jw|3yzYe zUlXbQeNAt4L>|Y>-FPq_JlA=DV_ZC~t0}h${Iz}a^4Ip*xlhjiG$1hNo4~C=gQ9tV zC&1Bt6NrbWbczi}>fIb$3C-lFkI3+0UZ92<2wnv!+33%SoeXRR9Al0J?%ZqnKu1WN z!IGQ7Y#C9K5Wk}foxAwOhITcM2%K1|;8-a2To$5N(lJq}rh8T)mmg8MW*fzfm@Gmm zM8-VletPd1c62Hnw?DyqMY5fm?ulVm50`$gfxMy9r{BU6p-y8#mGey|S|JipAWO@K zoSCFc3$^Q;(CJLC_5aY#49ju#&>mD$CO70#lnU2j@AHus&LAVyPzjuSNt;hlAQc5M zt*2)q|mW4DqT)is*6!I*Nh+5i^B~DxPSD3U4X`4HKxLYB) z@jCl`AVllT`7xk4+*<@IQE_s9ELKq|H70AGxvO+nY`PbeUM;TJl zXZ+Y@Vq}}6=gW{ntX$4AOJS;n2*@CS#d3r|p=_?b`Es&e8)_*1^!!*|O=<3Pc6h53 zLk5U{=8YK#^cLV+Crg5-(4i%oJ@nwr@0+;QhR?Q>a5_oeq?L>ArcP*P%ual?JDT4) zZs)6U7GCt4Ob@v$~Lvf2<4elseh%_+q`DuN32dwqzDoq;;lGZ_I^*AV$lT z8`Hw2L>$oND}c;JNAm0delPIqSNRnwRXaVZ~xousuv9=pF!@9X34Q8NCJ%GUTpoyEh_tB z)rTAJo{&)}^AR0*=^qsn%UD>~D+6JB?buU_wm%Q1rHBvT6^Zed6ilh>NN@(a9<|Zw ziB;VtYayU_O`@bx>Iu@1e3@DdFXzjw?Rq7?_?c;M^J#101EG&`XT7n1Zmag^YrMN{ z80?*E+F+CJuX^7p#L$hOVCx10$*u-GNf>jjdLZHLq@f}RQRbc z@fwi1m*aX?dk9I$3n`B=xbt(HLbV4Y{M^~38NR|<9st+Kk~tZU!6c=r6Hl@A z4dZzq(HpI4gkH{eEvpW_H(NMuNX1g_+sIBIeSEujM=hhT39~L1{SvXmXfAY@T6@^5 zS)H?{>`<{heXdA<_jkH@EsuJ#&D#7Ean)vD=$Y-xq%)9h2@0@z-&aEm?cu-xF z=#jnJ!)#CcKFBVsD=dC49el-jw|T1kHjkgMm4{nDd8@Pei5uU~dZ#smk4+MDth;fm z?!SJY)(DHHh^{RYue|LdTUlU8@iESTk*xP&3O-Q=VbkFKD9Ud>kqS9A9W;(qL)Ail zPP)DhTE5JWy-@-iVoVze9~Yfl(;~PYK`_sKOe3cKT& zpIIuz{J+jpB{-Vw%tHiS=M4xCsSK z3m@TY-!LrGkd_EnPZvVG>Z@xDffW-Ik6Kz7mPu-9`Yc-B#M46Si1HY2oSGex z+~v8{hrv4gf(%GyO#(~X+=ZF)hQ5>5*H-anJ&?Xrr`FiuSGU_aqg>Op4Mou$!)0 z)_zVRWf5K8^l}+%_#gp5fjIHBlq8xKu-&Wp*vl!0CozNo;UnECuZIf2K3IOxsMJGBfoa#Xc@ltKl2ayvabLtsB$l8}GIK zwsunlQu3WhIPH|_{YofByc>_jQBd=`!gr9-_N=E7S|W|xXY_JNpk+5dNP9z29LP?8wO2}rN@fs=8)%UCpLO}`hw@g zjxs`*8MBEabK%Z~u~La+(I0Zv*#pRQ0+xRVf0>h{%Y{@E@hNOnerE17O!Qx9B5gn2 zx7hzIm$4vqB0fBDl!O*9tx=q5)nuE$Ep*+#{E811gVKxjyu0Yr1IkX$h}lI$S!wo- zM)mY5(VqiSr1WT-;dUAXOd?=*JA99F*rd@?5IOzyD&%8~GUwvOeUuvCEd_ggj~Bbo zYqK4}ig;hYK@Th`Ltn?6b^WrvK0rLl8SiI*ajiX{_`zMha@^o%J-8_Ty`j!icW0Ad zLMuLr-QFin7Z`0d8V}!reQlnGg^OSM2`sIui0U23#jcat2(PDxUfN^}7ArPmuh1UI z<3|Ca)$)%>W(4s>HF=4p>!IG=-5wzr?QvaQfoIsIKBM`qA0S03i<}8T@*M;;jz)Pd=0sJE zzBkw&X%O4Ku=3Jt-w3d7^=Kx{FN($z!N?!%nO}C7FL5!yMVMN|%(gn6(DI{4ziLa+ z=C|K-W`q`4XDmN2&R~NXnmrQ1fC=o!Sfi`N@0)S1~4;V#17T=tu3czh#LR?zX<6_%vRQMJVFQt)Fo z+b*7d&-gmr!IXDpdr{~3r!IZCpw8}blN+>MH&JlO?W}*%^tn4!tXq_?T+XTKwa4Z}f6-`vqedr3}I%*#(b-_!`avEgX5b2Xq{+I--~ z6^*F(GJ)G<57(%K={|2PT1EV1V&yF6T+pA~c(w$`GbP zHVT3#KSyfcC&ts`21i>x=SifdmfINClff4tNCklanAB+X6|8$7UlX+a@ds zN)v%GOO_&jng>BTj?}$XvNhYy{3Cjk;g^AalTrHI?04t%>x=@o>XzG<3J0n2VYPO$ z=)jYUSxuu?w{j=xcqoz^^Y%Xd>@dG26}GOkJFym5bd+5>nmkS{>KPGj8^rU*INq0P z`a9n-&#t_C&Wiab!Hbh%a^2@CtuN+IEfYaYi@`2F3(CB%<1@uCCuyjm-Xlg?YbXZ? zU7yUQoi0<~Z~2~Z`Iy$*>7*wroL_5_k`Q_%k6O?2rxJ!OlWH3)4PadO$ArowsnbmJ zQ*4gODK6gW4#sxGFfN3ChJMi(*Rbt!yx!p1k`r%zdm{RWlXS5M?jo_I%_-12wX9L& zOrh2Zv#dIY!@|;>*Hz1$^AkN{$~&cFU#!dT zpZ32I5A$GEu{+k>q+?t*s`YrVxC zyBl7dVT$h#l{yYh4O2f3^YRS2o4HhlkmNo}(&S6MpIxh?#`z9#E8-W6aD%2cOmA_= zM-a`swm&}j%&b`VrBL%#q_B0z9>!dt^BU7FmJgv>!aQuEVDL9k{if3&Rp8-OS=LID zM}S&gn-mNDO}UpzH_QoXG34$|I_M1-`sDkkG0>-|<)K|-i;1Xk=z9+1DzrwULOJSD z5a`fbA8d`-O)lg_4rt_qUA6;x%hOfEDAkP$*N~43%pHp@_%dT*rkZ(i8kGI;knoix zQQ}_n=gpT%oyW_6uI~VO!M|RbSF6TqpM8m8kfRT(P(foa-#I8M69N!QEn`DrEsLbs z51n#RZ)kYgjH~2eZqkKrCuijQmeD@p80$#12%fW|nu23Z@wszE96oDUlPwe5Wkdl) zyh{9|BL{elaNFO3|JI$EQgB&;s>mm=I$AOLhehq<0uXHB$IH;vDLMPn_vN zy_=3C(#t0jPaeW{xl#|gDUC$Gu1`Sw()XrwG~w+TnCAV_H%+DLns6v97)p=1o#>#> zS>?Kt{GB-QT4DENTmcbRYuDA}IjzzhvtL*g0|Sh<{3|Obh>IwwmHe6PV42u(S!n8s zxK$YNja>yn6|bF@KCYe7cuO$0FH-sIU>e+rS+G~oMc6>yV!EYDnNpvd>qScL##mSN z&+z_sb@ssQEM}W+<4<{oR6a#w%A@ED=VlDg@5>a~#oyts{1R`A>fYMOa+btg#9b>v>n<-);o;-!A~``joSmSs}8UG{5z|hM|adsCoz7 zI!KR>#KW5VrI`!U883eFSyiM*S;yl`Xbl~`F8jogr{cZX%2BRuZdiP7Q?xW4z3bp_ zN9#gDML2eYDtXD7BP{UVRwkc12MHUTywN)IC3_2ru2%gN2JtE5*>K3-UIX*>v$sqk z{Dbc2Xqiba25#(i=r>sqIUCyty~;i-Oa@0@FqH^PX6_k%$tS9U1!;z(wz>6N98Z*bzhsmJ zZczs%@)VM=yXL+rJG9c@UDREBdAD!j^({!8`(mfQ)$5(iQDiM-OGe zC`)}$EBvj!qJ3vmO&}Rc#klAM%w>h0tcVbj=xn_a9a_HHgT`H|oaB z=YNcqn(_(WmUcGt45~mwf8Y&DTsnJdt=vm&oV>VZiN4KAlPUPN<<%FNU#zSIml~YL zb9Tw})h9$WX5**=)-WoxwLfKZU)|R8B7#Ko9QZEm@DNOR&1C5{mi}E3HSz z_;pC-p=0Hiqyt`>3uwQ6y4NpJ&Chc>r%zVy5oIv6Xf}fvWf2<;wiWRVE<9$ggf8B= gmDHtvN}cDCqAKF<0a+$?5x+?`8dJRcf}i@o0H*sZg#Z8m From 597dcde72adc3033e378d7eba7ee7e8d701b4934 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Sat, 22 Oct 2016 02:45:52 +0900 Subject: [PATCH 59/74] Update the version to v1.11.1. --- CMakeLists.txt | 4 ++-- taglib/toolkit/taglib.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f21297e1..a59efc9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,9 +90,9 @@ endif() # 2. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0. # 3. If any interfaces have been added since the last public release, then increment age. # 4. If any interfaces have been removed since the last public release, then set age to 0. -set(TAGLIB_SOVERSION_CURRENT 17) +set(TAGLIB_SOVERSION_CURRENT 18) set(TAGLIB_SOVERSION_REVISION 0) -set(TAGLIB_SOVERSION_AGE 16) +set(TAGLIB_SOVERSION_AGE 17) math(EXPR TAGLIB_SOVERSION_MAJOR "${TAGLIB_SOVERSION_CURRENT} - ${TAGLIB_SOVERSION_AGE}") math(EXPR TAGLIB_SOVERSION_MINOR "${TAGLIB_SOVERSION_AGE}") diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h index bd4886bd..f2e7a9de 100644 --- a/taglib/toolkit/taglib.h +++ b/taglib/toolkit/taglib.h @@ -30,7 +30,7 @@ #define TAGLIB_MAJOR_VERSION 1 #define TAGLIB_MINOR_VERSION 11 -#define TAGLIB_PATCH_VERSION 0 +#define TAGLIB_PATCH_VERSION 1 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1)) || defined(__clang__) #define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"") From deffe83fd04f7d6fa2ef496b02efb7563d5dea02 Mon Sep 17 00:00:00 2001 From: Alberto Fustinoni Date: Sun, 23 Oct 2016 12:32:16 +0900 Subject: [PATCH 60/74] Use newer file system calls when in Windows 8+ to allow compilation as WinRT asembly --- taglib/toolkit/tfilestream.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 5205bae0..54f7ffe9 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -51,10 +51,22 @@ namespace { const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); - if(!path.wstr().empty()) - return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - else if(!path.str().empty()) - return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if(!path.wstr().empty()) + { +#if (_WIN32_WINNT >= 0x0602) + return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); +#else + return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); +#endif + } + else if(!path.str().empty()) + { +#if (_WIN32_WINNT >= 0x0602) + return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); +#else + return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); +#endif + } else return InvalidFileHandle; } @@ -437,7 +449,13 @@ long FileStream::length() #ifdef _WIN32 SetLastError(NO_ERROR); +#if (_WIN32_WINNT >= 0x0602) + LARGE_INTEGER fSize; + GetFileSizeEx(d->file, &fSize); + LONGLONG fileSize = fSize.QuadPart; +#else const DWORD fileSize = GetFileSize(d->file, NULL); +#endif if(GetLastError() == NO_ERROR) { return static_cast(fileSize); } From 1cc047c953a297a7ffff4f518427c20e280d66a2 Mon Sep 17 00:00:00 2001 From: Alberto Fustinoni Date: Sun, 23 Oct 2016 20:17:49 +0900 Subject: [PATCH 61/74] Styling --- taglib/toolkit/tfilestream.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 54f7ffe9..cd582d06 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -52,21 +52,17 @@ namespace const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); if(!path.wstr().empty()) - { #if (_WIN32_WINNT >= 0x0602) - return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); + return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); #else - return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); #endif - } else if(!path.str().empty()) - { #if (_WIN32_WINNT >= 0x0602) - return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); + return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); #else - return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); #endif - } else return InvalidFileHandle; } From 606f6c0e74df01c1f7902ef0eb99bef669e95c23 Mon Sep 17 00:00:00 2001 From: Alberto Fustinoni Date: Sun, 23 Oct 2016 23:25:16 +0900 Subject: [PATCH 62/74] Better define guards --- taglib/toolkit/tfilestream.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index cd582d06..19199c10 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -52,13 +52,13 @@ namespace const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); if(!path.wstr().empty()) -#if (_WIN32_WINNT >= 0x0602) +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); #else return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); #endif else if(!path.str().empty()) -#if (_WIN32_WINNT >= 0x0602) +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); #else return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); @@ -445,7 +445,7 @@ long FileStream::length() #ifdef _WIN32 SetLastError(NO_ERROR); -#if (_WIN32_WINNT >= 0x0602) +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) LARGE_INTEGER fSize; GetFileSizeEx(d->file, &fSize); LONGLONG fileSize = fSize.QuadPart; From e36a9cabb9882e61276161c23834d966d62073b7 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 24 Oct 2016 12:03:23 +0900 Subject: [PATCH 63/74] Update NEWS. --- NEWS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index aa957b0e..0eae0c31 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,9 @@ -TagLib 1.11.1 (Oct ??, 2016) +TagLib 1.11.1 (Oct 24, 2016) ============================ + * Fixed binary incompatible change in TagLib::String. * Fixed reading ID3v2 CTOC frames with a lot of entries. * Fixed seeking ByteVectorStream from the end. - * Fixed binary incompatible change in TagLib::String. TagLib 1.11 (Apr 29, 2016) ========================== From 757f5ebc966a236cb2d9a345b1f7a88dbb2079ea Mon Sep 17 00:00:00 2001 From: Alberto Fustinoni Date: Mon, 24 Oct 2016 21:19:31 +0900 Subject: [PATCH 64/74] Refactoring --- taglib/toolkit/tfilestream.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 19199c10..8599bccd 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -50,21 +50,17 @@ namespace FileHandle openFile(const FileName &path, bool readOnly) { const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); - + +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) + return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); +#else if(!path.wstr().empty()) -#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) - return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); -#else return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); -#endif else if(!path.str().empty()) -#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) - return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); -#else return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); -#endif else return InvalidFileHandle; +#endif } void closeFile(FileHandle file) From ff5b2dc96f96d00b38a819c6a48caae03f63be7e Mon Sep 17 00:00:00 2001 From: Alberto Fustinoni Date: Mon, 24 Oct 2016 21:22:57 +0900 Subject: [PATCH 65/74] Whitespace --- taglib/toolkit/tfilestream.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 8599bccd..1a740c92 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -52,12 +52,12 @@ namespace const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) - return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); + return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); #else - if(!path.wstr().empty()) - return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if(!path.wstr().empty()) + return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); else if(!path.str().empty()) - return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); else return InvalidFileHandle; #endif From b2fa124451440ffa4b7aabff9e4ad640c03baed5 Mon Sep 17 00:00:00 2001 From: Alberto Fustinoni Date: Mon, 24 Oct 2016 21:24:53 +0900 Subject: [PATCH 66/74] formatting --- taglib/toolkit/tfilestream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 1a740c92..3f186cca 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -56,7 +56,7 @@ namespace #else if(!path.wstr().empty()) return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - else if(!path.str().empty()) + else if(!path.str().empty()) return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); else return InvalidFileHandle; From 06ca9a099df130dc9b5e241a761198822a5de55f Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 27 Oct 2016 15:10:34 +0900 Subject: [PATCH 67/74] Check if file size <= LONG_MAX. --- taglib/toolkit/tfilestream.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 3f186cca..229b65c4 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -50,7 +50,7 @@ namespace FileHandle openFile(const FileName &path, bool readOnly) { const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); - + #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) return CreateFile2(path.toString().toCWString(), access, FILE_SHARE_READ, OPEN_EXISTING, NULL); #else @@ -442,14 +442,14 @@ long FileStream::length() SetLastError(NO_ERROR); #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) - LARGE_INTEGER fSize; - GetFileSizeEx(d->file, &fSize); - LONGLONG fileSize = fSize.QuadPart; + LARGE_INTEGER fileSize; + GetFileSizeEx(d->file, &fileSize); #else - const DWORD fileSize = GetFileSize(d->file, NULL); + ULARGE_INTEGER fileSize; + fileSize.LowPart = GetFileSize(d->file, &fileSize.HighPart); #endif - if(GetLastError() == NO_ERROR) { - return static_cast(fileSize); + if(GetLastError() == NO_ERROR && fileSize.QuadPart <= LONG_MAX) { + return static_cast(fileSize.QuadPart); } else { debug("FileStream::length() -- Failed to get the file size."); From d2b3547254f52d18a65e62fc1133e5de25016601 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 27 Oct 2016 15:15:22 +0900 Subject: [PATCH 68/74] Add a test for File::truncate(). --- tests/test_file.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_file.cpp b/tests/test_file.cpp index f00a3115..9aae07fe 100644 --- a/tests/test_file.cpp +++ b/tests/test_file.cpp @@ -45,6 +45,7 @@ class TestFile : public CppUnit::TestFixture CPPUNIT_TEST(testFindInSmallFile); CPPUNIT_TEST(testRFindInSmallFile); CPPUNIT_TEST(testSeek); + CPPUNIT_TEST(testTruncate); CPPUNIT_TEST_SUITE_END(); public: @@ -129,6 +130,24 @@ public: CPPUNIT_ASSERT_EQUAL((long)4428, f.tell()); } + void testTruncate() + { + ScopedFileCopy copy("empty", ".ogg"); + std::string name = copy.fileName(); + + { + PlainFile f(name.c_str()); + CPPUNIT_ASSERT_EQUAL(4328L, f.length()); + + f.truncate(2000); + CPPUNIT_ASSERT_EQUAL(2000L, f.length()); + } + { + PlainFile f(name.c_str()); + CPPUNIT_ASSERT_EQUAL(2000L, f.length()); + } + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestFile); From aa5f9bb221564d655cdcc8def1aa88d1e68ae213 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 27 Oct 2016 15:23:24 +0900 Subject: [PATCH 69/74] Suppress some warnings in test. --- tests/test_bytevector.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 12393b50..1e063b71 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -223,26 +223,26 @@ public: const double Tolerance = 1.0e-7; const ByteVector pi32le("\xdb\x0f\x49\x40", 4); - CPPUNIT_ASSERT(::abs(pi32le.toFloat32LE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT(std::abs(pi32le.toFloat32LE(0) - M_PI) < Tolerance); CPPUNIT_ASSERT_EQUAL(pi32le, ByteVector::fromFloat32LE(pi32le.toFloat32LE(0))); const ByteVector pi32be("\x40\x49\x0f\xdb", 4); - CPPUNIT_ASSERT(::abs(pi32be.toFloat32BE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT(std::abs(pi32be.toFloat32BE(0) - M_PI) < Tolerance); CPPUNIT_ASSERT_EQUAL(pi32be, ByteVector::fromFloat32BE(pi32be.toFloat32BE(0))); const ByteVector pi64le("\x18\x2d\x44\x54\xfb\x21\x09\x40", 8); - CPPUNIT_ASSERT(::abs(pi64le.toFloat64LE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT(std::abs(pi64le.toFloat64LE(0) - M_PI) < Tolerance); CPPUNIT_ASSERT_EQUAL(pi64le, ByteVector::fromFloat64LE(pi64le.toFloat64LE(0))); const ByteVector pi64be("\x40\x09\x21\xfb\x54\x44\x2d\x18", 8); - CPPUNIT_ASSERT(::abs(pi64be.toFloat64BE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT(std::abs(pi64be.toFloat64BE(0) - M_PI) < Tolerance); CPPUNIT_ASSERT_EQUAL(pi64be, ByteVector::fromFloat64BE(pi64be.toFloat64BE(0))); const ByteVector pi80le("\x00\xc0\x68\x21\xa2\xda\x0f\xc9\x00\x40", 10); - CPPUNIT_ASSERT(::abs(pi80le.toFloat80LE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT(std::abs(pi80le.toFloat80LE(0) - M_PI) < Tolerance); const ByteVector pi80be("\x40\x00\xc9\x0f\xda\xa2\x21\x68\xc0\x00", 10); - CPPUNIT_ASSERT(::abs(pi80be.toFloat80BE(0) - M_PI) < Tolerance); + CPPUNIT_ASSERT(std::abs(pi80be.toFloat80BE(0) - M_PI) < Tolerance); } void testReplace() From d53ca6f7369dc7299c2991fa1fb9e4d80f534cf3 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 27 Oct 2016 15:40:14 +0900 Subject: [PATCH 70/74] Update NEWS. --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 0eae0c31..88e859a0 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +============================ + + * Added support for WinRT. + TagLib 1.11.1 (Oct 24, 2016) ============================ From 711b35cc6e23d72f4a04a19ed3ce7aa6e6c9d342 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 28 Oct 2016 11:19:51 +0900 Subject: [PATCH 71/74] Encourage compilers to optimize out debug() and debugData(). It's sort of like a throwback, but I found that debug(const String &s) {} doesn't prevent a String from being constructed and the error messages from being embedded. --- taglib/toolkit/tdebug.cpp | 12 ++++-------- taglib/toolkit/tdebug.h | 14 +++++++++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/taglib/toolkit/tdebug.cpp b/taglib/toolkit/tdebug.cpp index 557baed6..d630791c 100644 --- a/taglib/toolkit/tdebug.cpp +++ b/taglib/toolkit/tdebug.cpp @@ -27,6 +27,8 @@ #include #endif +#if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) + #include "tdebug.h" #include "tstring.h" #include "tdebuglistener.h" @@ -43,17 +45,11 @@ namespace TagLib void debug(const String &s) { -#if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) - debugListener->printMessage("TagLib: " + s + "\n"); - -#endif } void debugData(const ByteVector &v) { -#if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) - for(size_t i = 0; i < v.size(); ++i) { std::string bits = std::bitset<8>(v[i]).to_string(); @@ -63,7 +59,7 @@ namespace TagLib debugListener->printMessage(msg); } - -#endif } } + +#endif diff --git a/taglib/toolkit/tdebug.h b/taglib/toolkit/tdebug.h index bd94d159..80d00d39 100644 --- a/taglib/toolkit/tdebug.h +++ b/taglib/toolkit/tdebug.h @@ -32,10 +32,11 @@ namespace TagLib { class ByteVector; #ifndef DO_NOT_DOCUMENT +#if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) /*! - * A simple function that outputs the debug messages to the listener. - * The default listener redirects the messages to \a stderr when NDEBUG is + * A simple function that outputs the debug messages to the listener. + * The default listener redirects the messages to \a stderr when NDEBUG is * not defined. * * \warning Do not use this outside of TagLib, it could lead to undefined @@ -45,7 +46,7 @@ namespace TagLib { * \internal */ void debug(const String &s); - + /*! * For debugging binary data. * @@ -56,6 +57,13 @@ namespace TagLib { * \internal */ void debugData(const ByteVector &v); + +#else + + #define debug(x) ((void)0) + #define debugData(x) ((void)0) + +#endif } #endif From 65a24bbc512eb3c2e1396523dd2f68ecaea0507d Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 28 Oct 2016 14:22:50 +0900 Subject: [PATCH 72/74] Remove some useless seek()/tell() from RIFF::File. --- taglib/riff/rifffile.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index f9d33e10..7ac2c034 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -292,7 +292,6 @@ void RIFF::File::read() d->size = readBlock(4).toUInt(bigEndian); offset += 8; - seek(offset); // + 8: chunk header at least, fix for additional junk bytes while(offset + 8 <= length()) { @@ -307,28 +306,24 @@ void RIFF::File::read() break; } - if(static_cast(tell()) + chunkSize > length()) { + if(static_cast(offset) + 8 + chunkSize > length()) { debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid size (larger than the file size)"); setValid(false); break; } - offset += 8; - Chunk chunk; - chunk.name = chunkName; - chunk.size = chunkSize; - chunk.offset = offset; + chunk.name = chunkName; + chunk.size = chunkSize; + chunk.offset = offset + 8; + chunk.padding = 0; - offset += chunk.size; - - seek(offset); + offset = chunk.offset + chunk.size; // Check padding - chunk.padding = 0; - if(offset & 1) { + seek(offset); const ByteVector iByte = readBlock(1); if(iByte.size() == 1 && iByte[0] == '\0') { chunk.padding = 1; From 935534aa5327a5b605e84e4643591fd6cc585594 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 28 Oct 2016 15:19:35 +0900 Subject: [PATCH 73/74] Backport a test from taglib2 branch. --- tests/test_string.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_string.cpp b/tests/test_string.cpp index 3fa28b69..f9f1a2dd 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -46,6 +46,7 @@ class TestString : public CppUnit::TestFixture CPPUNIT_TEST(testFromInt); CPPUNIT_TEST(testSubstr); CPPUNIT_TEST(testNewline); + CPPUNIT_TEST(testUpper); CPPUNIT_TEST(testEncodeNonLatin1); CPPUNIT_TEST(testEncodeEmpty); CPPUNIT_TEST(testIterator); @@ -270,6 +271,14 @@ public: CPPUNIT_ASSERT_EQUAL(L'\x0a', String(crlf)[4]); } + void testUpper() + { + String s1 = "tagLIB 012 strING"; + String s2 = s1.upper(); + CPPUNIT_ASSERT_EQUAL(String("tagLIB 012 strING"), s1); + CPPUNIT_ASSERT_EQUAL(String("TAGLIB 012 STRING"), s2); + } + void testEncodeNonLatin1() { const String jpn(L"\u65E5\u672C\u8A9E"); From 005441faaa373f93f30adede374aa7a7c6c7476f Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Fri, 28 Oct 2016 15:25:50 +0900 Subject: [PATCH 74/74] Prevent overflows, just in case. --- taglib/riff/rifffile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index 7ac2c034..f874f7ad 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -161,19 +161,19 @@ void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) std::vector::iterator it = d->chunks.begin(); std::advance(it, i); - const int originalSize = it->size + it->padding; + const long long originalSize = static_cast(it->size) + it->padding; writeChunk(it->name, data, it->offset - 8, it->size + it->padding + 8); it->size = data.size(); - it->padding = data.size() % 1; + it->padding = data.size() % 2; - const int diff = it->size + it->padding - originalSize; + const long long diff = static_cast(it->size) + it->padding - originalSize; // Now update the internal offsets for(++it; it != d->chunks.end(); ++it) - it->offset += diff; + it->offset += static_cast(diff); // Update the global size.