Skip to content

Commit

Permalink
core: move floating point functions to own header file
Browse files Browse the repository at this point in the history
This were in subsurface-string.h for unknown reasons.

Signed-off-by: Berthold Stoeger <[email protected]>
  • Loading branch information
bstoeger authored and atdotde committed Aug 30, 2022
1 parent 6170150 commit aa4b48f
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 20 deletions.
1 change: 1 addition & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
string-format.h
string-format.cpp
strtod.c
subsurface-float.h
subsurface-string.h
subsurfacestartup.c
subsurfacestartup.h
Expand Down
1 change: 1 addition & 0 deletions core/libdivecomputer.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "gettext.h"
#include "divesite.h"
#include "sample.h"
#include "subsurface-float.h"
#include "subsurface-string.h"
#include "device.h"
#include "dive.h"
Expand Down
3 changes: 2 additions & 1 deletion core/parse-xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
#include "dive.h"
#include "divesite.h"
#include "errorhelper.h"
#include "subsurface-string.h"
#include "parse.h"
#include "subsurface-float.h"
#include "subsurface-string.h"
#include "subsurface-time.h"
#include "trip.h"
#include "device.h"
Expand Down
2 changes: 1 addition & 1 deletion core/settings/qPrefDisplay.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "core/subsurface-string.h"
#include "qPrefDisplay.h"
#include "qPrefPrivate.h"
#include "core/subsurface-float.h"

#include <QApplication>
#include <QFont>
Expand Down
2 changes: 1 addition & 1 deletion core/settings/qPrefPrivate.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "qPrefPrivate.h"
#include "core/subsurface-string.h"
#include "core/subsurface-float.h"

#include <QSettings>

Expand Down
24 changes: 24 additions & 0 deletions core/subsurface-float.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef SUBSURFACE_FLOAT_H
#define SUBSURFACE_FLOAT_H

#include <math.h>

#ifdef __cplusplus
extern "C" {
#endif

static inline bool nearly_equal(double a, double b)
{
return fabs(a - b) <= 1e-6 * fmax(fabs(a), fabs(b));
}

static inline bool nearly_0(double fp)
{
return fabs(fp) <= 1e-6;
}

#ifdef __cplusplus
}
#endif
#endif // SUBSURFACE_FLOAT_H
11 changes: 0 additions & 11 deletions core/subsurface-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include <math.h>

// shared generic definitions and macros
// mostly about strings, but a couple of math macros are here as well
Expand All @@ -27,16 +26,6 @@
extern "C" {
#endif

static inline bool nearly_equal(double a, double b)
{
return fabs(a - b) <= 1e-6 * fmax(fabs(a), fabs(b));
}

static inline bool nearly_0(double fp)
{
return fabs(fp) <= 1e-6;
}

// string handling

static inline bool same_string(const char *a, const char *b)
Expand Down
3 changes: 1 addition & 2 deletions desktop-widgets/downloadfromdivecomputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "core/qthelper.h"
#include "core/divelist.h"
#include "core/settings/qPrefDiveComputer.h"
#include "core/subsurface-float.h"
#include "core/subsurface-string.h"
#include "core/uemis.h"
#include "core/downloadfromdcthread.h"
Expand Down Expand Up @@ -169,8 +170,6 @@ void DownloadFromDCWidget::DC##num##Clicked() \
}
#endif



DCBUTTON(1)
DCBUTTON(2)
DCBUTTON(3)
Expand Down
2 changes: 1 addition & 1 deletion mobile-widgets/themeinterface.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "themeinterface.h"
#include "core/subsurface-string.h"
#include "core/subsurface-float.h"
#include "qmlmanager.h"
#include "core/metrics.h"
#include "core/settings/qPrefDisplay.h"
Expand Down
2 changes: 1 addition & 1 deletion profile-widget/divecartesianaxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "profile-widget/divetextitem.h"
#include "core/profile.h"
#include "core/qthelper.h"
#include "core/subsurface-string.h"
#include "core/subsurface-float.h"
#include "profile-widget/animationfunctions.h"
#include "profile-widget/divelineitem.h"
#include "profile-widget/profilescene.h"
Expand Down
2 changes: 1 addition & 1 deletion profile-widget/qmlprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "profilescene.h"
#include "mobile-widgets/qmlmanager.h"
#include "core/errorhelper.h"
#include "core/subsurface-string.h"
#include "core/subsurface-float.h"
#include "core/metrics.h"
#include <QTransform>
#include <QScreen>
Expand Down
2 changes: 1 addition & 1 deletion tests/testunitconversion.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "testunitconversion.h"
#include "core/dive.h"
#include "core/subsurface-string.h"
#include "core/subsurface-float.h"

void TestUnitConversion::testUnitConversions()
{
Expand Down

0 comments on commit aa4b48f

Please sign in to comment.