Commit Graph

160 Commits

Author SHA1 Message Date
1635d4d563 clang-tidy: use auto
Found with modernize-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-12-22 13:41:34 +01:00
c9486731d9 Fix MSVC warning needs to have dll-interface (#1185)
Unfortunately, MSVC exports everything (not only public members) when
__declspec(dllexport) is set at the class level via TAGLIB_EXPORT, which
leads to many "needs to have dll-interface to be used by clients" 4251
warnings issued by MSVC, because the std::unique_ptr pimpls are
exported too. As it is not possible to "unexport" private members,
such a warning has to be explicitly suppressed for these cases or
all public and protected class member now have to be exported
for classes derived from a template (StringList, ByteVectorList,
PropertyMap).
2023-12-11 06:35:08 +01:00
ec734bbe08 Fix MSVC warning dllexport and extern are incompatible
C4910: '__declspec(dllexport)' and 'extern' are incompatible on an
explicit instantiation
2023-12-11 06:35:08 +01:00
c7babea74a Fix narrowing warning issued by MSVC 2023-12-11 06:35:08 +01:00
8b3f1a459e Fix issues reported by CppCheck
Many shadowFunction, some useStlAlgorithm, and others.

cppcheck --enable=all --inline-suppr \
  --suppress=noExplicitConstructor --suppress=unusedFunction \
  --suppress=missingIncludeSystem --project=compile_commands.json
2023-12-07 05:00:00 +01:00
131918333b Fix issues reported by Clang Static Analyzer
Some deadcode.DeadStores.

On Debian 12:
CXXFLAGS=-I/usr/include/x86_64-linux-gnu/c++/12 \
cmake -DCMAKE_C_COMPILER=/usr/share/clang/scan-build-14/libexec/ccc-analyzer \
    -DCMAKE_CXX_COMPILER=/usr/share/clang/scan-build-14/libexec/c++-analyzer \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
    -DENABLE_CCACHE=ON -DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON \
    -DCMAKE_BUILD_TYPE=Debug ../taglib
scan-build make
2023-12-07 05:00:00 +01:00
9df243ef74 Separate multiple values in basic tag with " / " instead of " " 2023-12-01 06:22:35 +01:00
6be03b7ae1 Unified interface for complex properties like pictures (#94)
Provides a dynamic interface for properties which cannot be represented
with simple strings, e.g. pictures. The keys of such properties can
be queried using `complexPropertyKeys()`, which could return for example
["PICTURE"]. The property can then be read using
`complexProperties("PICTURE")`, which will return a list of variant maps
containing the picture data and attributes. Adding a picture is as
easy as

    t->setComplexProperties("PICTURE", {
      {
        {"data", data},
        {"pictureType", "Front Cover"},
        {"mimeType", "image/jpeg"}
      }
    });
2023-10-14 09:01:59 +02:00
3f25d3c342 Proofreading (#1155)
---------

Co-authored-by: Urs Fleisch <ufleisch@users.sourceforge.net>
2023-10-08 05:58:33 +02:00
e275abb8a3 Convert private raw pointers to unique_ptr (#1127)
Simplifies the code quite a bit.
2023-09-23 06:46:05 +02:00
48c4bf9c05 change two loops to while (#1147)
and one to for range.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-09-16 13:28:12 +02:00
653c2fe9e1 clang-tidy: use using instead of typedef (#1120)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-09-16 09:06:14 +02:00
7646184d6b unused includes (#1133)
* unused includes

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* Use consistent order of includes

Always include in the following order:
- Own header files
- Standard header files
- System header files
- Project header files (toolkit first)

Exceptions:
- cppunit/extensions/HelperMacros.h must be included after
  header files declaring stream operators
- config.h must be included before its definitions are used

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Co-authored-by: Urs Fleisch <ufleisch@users.sourceforge.net>
2023-09-16 08:22:36 +02:00
37ba5a5cc1 convert missed for loop (#1136)
clang-tidy missed it as the declaration is outside of the loop.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-09-07 11:04:02 -05:00
23186f24ff remove unused typedefs (#1138)
This was done in C++98 times. No longer needed with auto.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-09-07 11:02:55 -05:00
912897cd35 simplify boolean expressions (#1130)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-09-06 21:16:59 +02:00
47c4e0859c Restore const iterators replaced in #1107 (#1128)
Also make sure that the lines calling std algorithms are not
excessively long.
2023-09-06 20:59:01 +02:00
524b588a1e manual range loop conversions (#1126)
* manual range loop conversions

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* Restore const containers where non const temporaries are iterated

* Use std::as_const() instead of const container copies where possible

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Co-authored-by: Urs Fleisch <ufleisch@users.sourceforge.net>
2023-09-06 20:58:13 +02:00
cdc87aec10 clang-tidy: init members by default (#1110)
Found with modernize-use-default-member-init

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-30 16:26:14 +02:00
574604765f Use std algorithms (#1107)
Found with: readability-use-anyofallof

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-09 12:09:28 -05:00
185bb7042e Use unique_ptr for d-pointers (#1095)
* clang-tidy: make deleted members public

One oversight of modernize-use-equals-delete is that the C++11 way of
doing this is to make it public, which makes the warning still trigger.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* clang-tidy: add missing deleted functions

Found with cppcoreguidelines-special-member-functions

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* unique_ptr conversions

unique_ptr is a safer and cleaner way to handle d pointers.

Also added missing = default.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-07 15:08:40 -05:00
dcef356e3f Replace raw buffers with std containers (#1101)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-06 17:46:59 -05:00
d314bfa06a Make sure that own header file is included first
Each header corresponding to a .cpp file must be self-contained,
and can be #included without prerequisites.
2023-07-22 07:09:58 +02:00
cc7d23cdf5 Consistently use quote form when including our own headers 2023-07-22 07:09:58 +02:00
231772b2ad clang-tidy: Delete unimplemented private constructors
run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-equals-delete' -fix
2023-07-22 07:09:58 +02:00
77ab5e9689 Narrow the scope of iterators
Also make sure that it is visible at first glance that iterators are
not taken from temporaries.
2023-07-22 07:09:58 +02:00
c2c9e8989c clang-tidy: Use auto where it improves the readability
run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-auto' \
-config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
-fix

Manually fixed some wrong `const auto` replacements and verified
that all types are deduced correctly.
2023-07-22 07:09:58 +02:00
63922f2676 Avoid unnecessary detaching of containers
If only a constant iterator is needed, make the container const if
possible, otherwise use cbegin() and cend() to get a constant iterator
without detaching the container.

These fixes are needed so that `auto` can deduce the correct
iterator type.
2023-07-22 07:09:58 +02:00
abc6c31890 clang-tidy: Use nullptr instead of 0
run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-nullptr' -fix
2023-07-22 07:09:58 +02:00
9867bc947e clang-tidy: Use override keyword
run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-override' -fix
2023-07-22 07:09:58 +02:00
ceb142c9bd Remove functions documented (but not marked) as deprecated
Clean up other stuff with comments about binary incompatibility,
but only as far as to mostly keep source compatibility.
2023-07-09 07:01:37 +02:00
a33cc0635a Remove deprecated stuff 2023-07-09 07:01:37 +02:00
ca8c2e07ec Support large files over 2GB on Windows (#1089)
Backport of 4dcf0b41c6
b01f45e141
https://github.com/taglib/taglib/pull/77

Tested with files larger than 2GB which have been created using

sox -n -r 44100 -C 320 large.mp3 synth 58916 sine 440 channels 2
sox -n -r 44100 -C 0 large.flac synth 25459 sine 440 channels 2
sox -n -r 44100 -C 10 large.ogg synth 229806 sine 440 channels 2
sox -n -r 44100 large.wav synth 6692 sine 440 channels 2
ffmpeg -f lavfi -i "sine=frequency=440:duration=244676" -y large.m4a

The only file which was readable with the tagreader example
before this commit was large.ogg. The problem is that long on
Windows is only 32-bit (also in LLP64 data model of 64-bit
compilation target) and all the file offsets using long are
too small for large files. Now long is replaced by offset_t
(defined to be long long on Windows and off_t on UNIX) for such
cases and some unsigned long are now size_t, which has the
correct size even on Windows.
2023-07-09 07:01:37 +02:00
983a35f5ae clang-tidy: avoid C casting
Found with google-readability-casting

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-11-28 07:04:42 +01:00
4dc6bdcd28 clang-tidy: add ending namespace comments
Found with google-readability-namespace-comments

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-11-28 07:04:42 +01:00
084108a908 Document replacements for deprecated functions (#1001) 2022-10-26 15:42:49 +02:00
52bf85f8ca FLAC: Do not create map entry if looked up tag does not exist (#931) 2022-02-09 20:07:13 +01:00
a8884c2b17 clang-tidy: don't use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-06-21 06:49:32 +02:00
38d1d4c21c clang-tidy: add ending namespace comments
Found with google-readability-namespace-comments

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-06-21 06:49:32 +02:00
b77e828d4b clang-tidy: remove redundant initializations
Found with readability-redundant-member-init

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-06-21 06:49:32 +02:00
844f07d32d Make tests work with BUILD_SHARED_LIBS=ON on Windows 2021-03-06 14:52:25 +01:00
83aa01c6af Ogg: Set granule position to -1 if no packets finish on page (#864) 2021-02-14 10:04:03 +01:00
c05fa78406 Mark deprected methods and remove internal usage
This does not put the deprecated marker on methods that will or could resolve
to the same overload, e.g.:

void foo(bool bar = true); // <-- not marked
void foo(Bar bar) // <-- since this will have a default argument in the new version
2019-09-11 00:39:37 +02:00
86c0428475 Clear valid flag for invalid Speex files
This matches the corresponding code in vorbisfile.cpp, opusfile.cpp and flagfile.cpp, and fixes taglib/taglib#902.
2019-09-10 11:44:21 +02:00
c8bb6271e5 Merge pull request #917 from ufleisch/ogg-bitrate
Calculate Ogg bitrate without comment size (#874)
2019-09-10 11:14:15 +02:00
2f23892182 Calculate Ogg bitrate without overhead size (#874) 2019-09-02 22:14:41 +02:00
e72a98903f Fix spelling and typos 2019-08-26 23:23:33 +02:00
2c4ae870ec Fixed OOB read when loading invalid ogg flac file. (#868) (#869)
CVE-2018-11439 is caused by a failure to check the minimum length
of a ogg flac header. This header is detailed in full at:
https://xiph.org/flac/ogg_mapping.html. Added more strict checking
for entire header.
2018-10-09 18:46:55 -05:00
f76b1e5429 Rename the functions 'isValidStream' to 'isSupported'.
The name 'isValidStream' is a little misleading because it doesn't check if the stream is really valid. Additionally, 'isSupported' can be naturally overloaded.
2017-02-07 22:36:56 +09:00
931bb042c3 Enable FileRef to detect file types by the actual content of a stream.
FileRef doesn't work with ByteVectorStream as reported at #796, since ByteVectorStream is not associated with a file name and FileRef detects file types based on file extensions.
This commit makes FileRef to work with ByteVectorStream by enabling it to detect file types based on the actual content of a stream.
2017-02-04 23:31:08 +09:00