Building Fix for a negative value check for gcc < 4.8

This commit is contained in:
Markus Gans 2018-10-26 07:43:23 +02:00
parent c4e333bc8b
commit 96edb762c7
12 changed files with 46 additions and 17 deletions

View File

@ -1,3 +1,6 @@
2018-10-26 Markus Gans <guru.mail@muenster.de>
* Building Fix for a negative value check (gcc < 4.8)
2018-10-21 Markus Gans <guru.mail@muenster.de> 2018-10-21 Markus Gans <guru.mail@muenster.de>
* Moving static attributes from FApplication to FWidget * Moving static attributes from FApplication to FWidget

View File

@ -245,7 +245,7 @@ Class digramm
License License
------- -------
GNU Lesser General Public License Version 3 GNU Lesser General Public License Version 3
Please send bug reports to Please send bug reports to
-------------------------- --------------------------

View File

@ -20,7 +20,7 @@ if [ "$CPU_COUNT" -eq 0 ]
then then
if command -v nproc >/dev/null 2>&1 if command -v nproc >/dev/null 2>&1
then then
CPU_COUNT="$(nproc 2>/dev/null)" || CPU_COUNT="0" CPU_COUNT="$(nproc 2>/dev/null)" || CPU_COUNT="0"
fi fi
fi fi

2
debian/watch vendored
View File

@ -1,2 +1,2 @@
version=3 version=3
opts=passive https://github.com/gansm/finalcut/archive/([\d.]+)\.tar.gz opts=passive https://github.com/gansm/finalcut/archive/([\d.]+)\.tar.gz

View File

@ -34,7 +34,7 @@ debug:
profile: profile:
$(MAKE) $(MAKEFILE) PROFILE="-pg" $(MAKE) $(MAKEFILE) PROFILE="-pg"
.PHONY: clean .PHONY: clean
clean: clean:
$(RM) $(SRCS:%.cpp=%) *.gcno *.gcda *~ $(RM) $(SRCS:%.cpp=%) *.gcno *.gcda *~

View File

@ -11,7 +11,7 @@ Name: @PACKAGE@
Version: @VERSION@ Version: @VERSION@
Release: %{buildno} Release: %{buildno}
License: LGPL-3.0 License: LGPL-3.0
Summary: The Final Cut Summary: The Final Cut
Url: https://github.com/gansm/finalcut/ Url: https://github.com/gansm/finalcut/
Group: System/Libraries Group: System/Libraries
Source: finalcut-%{version}.tar.gz Source: finalcut-%{version}.tar.gz
@ -111,7 +111,7 @@ make %{?_smp_mflags} V=1
make install libdir=${RPM_BUILD_ROOT}%{_libdir}/ \ make install libdir=${RPM_BUILD_ROOT}%{_libdir}/ \
includedir=${RPM_BUILD_ROOT}%{_includedir} \ includedir=${RPM_BUILD_ROOT}%{_includedir} \
bindir=${RPM_BUILD_ROOT}%{_bindir} \ bindir=${RPM_BUILD_ROOT}%{_bindir} \
docdir=${RPM_BUILD_ROOT}/%{_docdir}/finalcut/ docdir=${RPM_BUILD_ROOT}/%{_docdir}/finalcut/
rm -f ${RPM_BUILD_ROOT}%{_libdir}/libfinal.la rm -f ${RPM_BUILD_ROOT}%{_libdir}/libfinal.la
%post -n %{libsoname} -p /sbin/ldconfig %post -n %{libsoname} -p /sbin/ldconfig

View File

@ -140,7 +140,7 @@ endif
.cpp.o: .cpp.o:
$(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $< $(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $<
all: dep $(OBJS) all: dep $(OBJS)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR) -o $(LIB).$(VERSION) $(OBJS) $(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR) -o $(LIB).$(VERSION) $(OBJS)
ln -s -f $(LIB).$(VERSION) libfinal.so.$(MAJOR) ln -s -f $(LIB).$(VERSION) libfinal.so.$(MAJOR)
ln -s -f $(LIB).$(MAJOR) libfinal.so ln -s -f $(LIB).$(MAJOR) libfinal.so

View File

@ -1192,7 +1192,7 @@ bool FString::operator > (const FString& s) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FString::insert (const FString& s, int pos) const FString& FString::insert (const FString& s, int pos)
{ {
if ( pos < 0 || uInt(pos) > length ) if ( isNegative(pos) || uInt(pos) > length )
throw std::out_of_range(""); throw std::out_of_range("");
_insert (uInt(pos), s.length, s.string); _insert (uInt(pos), s.length, s.string);

View File

@ -49,6 +49,7 @@
#include <cwchar> #include <cwchar>
#include <cwctype> #include <cwctype>
#include <limits>
#include <iostream> #include <iostream>
#include <new> #include <new>
#include <stdexcept> #include <stdexcept>
@ -134,9 +135,9 @@ class FString
const FString& operator >> (float&); const FString& operator >> (float&);
template <typename IndexT> template <typename IndexT>
wchar_t& operator [] (IndexT); wchar_t& operator [] (const IndexT);
template <typename IndexT> template <typename IndexT>
const wchar_t& operator [] (IndexT) const; const wchar_t& operator [] (const IndexT) const;
const FString& operator () (); const FString& operator () ();
bool operator < (const FString&) const; bool operator < (const FString&) const;
@ -289,9 +290,9 @@ inline const char* FString::getClassName()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename IndexT> template <typename IndexT>
inline wchar_t& FString::operator [] (IndexT pos) inline wchar_t& FString::operator [] (const IndexT pos)
{ {
if ( pos < 0 || pos >= IndexT(length) ) if ( isNegative(pos) || pos >= IndexT(length) )
throw std::out_of_range(""); // Invalid index position throw std::out_of_range(""); // Invalid index position
return string[std::size_t(pos)]; return string[std::size_t(pos)];
@ -299,9 +300,9 @@ inline wchar_t& FString::operator [] (IndexT pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename IndexT> template <typename IndexT>
inline const wchar_t& FString::operator [] (IndexT pos) const inline const wchar_t& FString::operator [] (const IndexT pos) const
{ {
if ( pos < 0 || pos >= IndexT(length) ) if ( isNegative(pos) || pos >= IndexT(length) )
throw std::out_of_range(""); // Invalid index position throw std::out_of_range(""); // Invalid index position
return string[std::size_t(pos)]; return string[std::size_t(pos)];
@ -378,7 +379,7 @@ inline FString::iterator FString::end() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline wchar_t FString::front() const inline wchar_t FString::front() const
{ {
assert( ! isEmpty() ); assert ( ! isEmpty() );
return string[0]; return string[0];
} }

View File

@ -30,6 +30,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <limits>
#include <string> #include <string>
#define null NULL #define null NULL
@ -60,6 +61,30 @@ typedef long double lDouble;
namespace finalcut namespace finalcut
{ {
template <typename T, bool is_signed>
struct is_negative
{
inline bool operator () (const T& x)
{
return x < 0;
}
};
template <typename T>
struct is_negative<T,false>
{
inline bool operator () (const T&)
{
return false;
}
};
template <typename T>
inline bool isNegative (const T& x)
{
return is_negative<T, std::numeric_limits<T>::is_signed>()(x);
}
namespace fc namespace fc
{ {
#pragma pack(push) #pragma pack(push)

View File

@ -33,7 +33,7 @@ debug:
check: test check: test
test: debug test: debug
$(OBJS) | sed -e "s/ OK/\x1b[32m OK\x1b[0m/g" -e "s/ failed/\x1b[31m failed\x1b[0m/g" $(OBJS) | sed -e "s/ OK/\x1b[32m OK\x1b[0m/g" -e "s/ failed/\x1b[31m failed\x1b[0m/g"
profile: profile:
$(MAKE) $(MAKEFILE) PROFILE="-pg" $(MAKE) $(MAKEFILE) PROFILE="-pg"

View File

@ -33,7 +33,7 @@ debug:
check: test check: test
test: debug test: debug
$(OBJS) | sed -e "s/ OK/\x1b[32m OK\x1b[0m/g" -e "s/ failed/\x1b[31m failed\x1b[0m/g" $(OBJS) | sed -e "s/ OK/\x1b[32m OK\x1b[0m/g" -e "s/ failed/\x1b[31m failed\x1b[0m/g"
profile: profile:
$(MAKE) $(MAKEFILE) PROFILE="-pg" $(MAKE) $(MAKEFILE) PROFILE="-pg"