[dasher] Use autoconfigure machinery to provide round() function if missing.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher] Use autoconfigure machinery to provide round() function if missing.
- Date: Sun, 27 Jan 2013 12:14:17 +0000 (UTC)
commit f31353a3525e3c2d0b94acedbcb21b1ebcb84785
Author: Patrick Welche <prlw1 cam ac uk>
Date: Sun Jan 27 12:08:02 2013 +0000
Use autoconfigure machinery to provide round() function if missing.
This may be overkill, as I haven't spotted a current system without
a round() function, but the code as it stood was inconsistent
anyway. This finds a raison-d'etre for libdashermisc. While here
use libtool to build all libraries, not just some of them.
https://bugzilla.gnome.org/show_bug.cgi?id=508435
Src/Common/Common.h | 3 +++
Src/Common/Makefile.am | 6 ++++--
Src/Common/round.c | 16 ++++++++++++++++
Src/Common/round.h | 3 +++
Src/DasherCore/AutoSpeedControl.cpp | 15 +--------------
Src/DasherCore/DasherViewSquare.h | 15 ---------------
Src/DasherCore/LanguageModelling/Makefile.am | 4 ++--
Src/DasherCore/Makefile.am | 12 ++++++------
Src/Makefile.am | 7 +++----
configure.ac | 2 ++
10 files changed, 40 insertions(+), 43 deletions(-)
---
diff --git a/Src/Common/Common.h b/Src/Common/Common.h
index 325d2e7..6a96ada 100644
--- a/Src/Common/Common.h
+++ b/Src/Common/Common.h
@@ -30,6 +30,9 @@
#endif
+#ifndef HAVE_ROUND
+#include "round.h"
+#endif
#include "myassert.h"
diff --git a/Src/Common/Makefile.am b/Src/Common/Makefile.am
index b5cb4a7..e69dce0 100644
--- a/Src/Common/Makefile.am
+++ b/Src/Common/Makefile.am
@@ -1,5 +1,5 @@
-noinst_LIBRARIES = libdashermisc.a
-libdashermisc_a_SOURCES = \
+noinst_LTLIBRARIES = libdashermisc.la
+libdashermisc_la_SOURCES = \
AppSettingsData.h \
AppSettingsHeader.h \
Common.h \
@@ -25,6 +25,8 @@ libdashermisc_a_SOURCES = \
# IOstreamDasherEdit.cc I have no idea what this does, but it's broken now
# IOstreamDasherEdit.h
+libdashermisc_la_LIBADD = $(LTLIBOBJS)
+
AM_CXXFLAGS = -I$(srcdir)/../DasherCore
EXTRA_DIST = Common.vcproj Common_vc80.vcproj
diff --git a/Src/Common/round.c b/Src/Common/round.c
new file mode 100644
index 0000000..bc73382
--- /dev/null
+++ b/Src/Common/round.c
@@ -0,0 +1,16 @@
+#include <math.h>
+
+/* Unlike round() from libmath, this function rounds up to the highest
+ * integral value, so round(-1.5)=-1 rather than -2.
+ * This function tends to be called with positive values, in which case
+ * the behaviour is the same: round(1.5)=2.
+ */
+double round(double dVal) {
+ double dF = floor(dVal);
+ double dC = ceil(dVal);
+
+ if(dVal - dF < dC - dVal)
+ return dF;
+ else
+ return dC;
+}
diff --git a/Src/Common/round.h b/Src/Common/round.h
new file mode 100644
index 0000000..f2f5b0a
--- /dev/null
+++ b/Src/Common/round.h
@@ -0,0 +1,3 @@
+extern "C" {
+double round(double);
+}
diff --git a/Src/DasherCore/AutoSpeedControl.cpp b/Src/DasherCore/AutoSpeedControl.cpp
index fd7c146..cb62b81 100644
--- a/Src/DasherCore/AutoSpeedControl.cpp
+++ b/Src/DasherCore/AutoSpeedControl.cpp
@@ -8,20 +8,7 @@
#include <cmath>
#include <cfloat>
-
-#include <string.h>
-
-#ifndef WITH_DARWIN
-double round(double dVal) {
- double dF = floor(dVal);
- double dC = ceil(dVal);
-
- if(dVal - dF < dC - dVal)
- return dF;
- else
- return dC;
-}
-#endif
+#include <cstring>
using namespace Dasher;
diff --git a/Src/DasherCore/DasherViewSquare.h b/Src/DasherCore/DasherViewSquare.h
index 2384083..d948657 100644
--- a/Src/DasherCore/DasherViewSquare.h
+++ b/Src/DasherCore/DasherViewSquare.h
@@ -156,21 +156,6 @@ private:
/// @param pOutput The innermost node covering the crosshair (if any)
void NewRender(CDasherNode * Render, myint y1, myint y2, CTextString *prevText, CExpansionPolicy &policy, double dMaxCost, CDasherNode *&pOutput);
-#ifdef _WIN32
- ///
- /// FIXME - couldn't find windows version of round(double) so here's one!
- /// \param number to be rounded
- ///
- double round(double d)
- {
- if(d - floor(d) < 0.5)
- return floor(d);
- else
- return ceil(d);
-
- };
-#endif
-
/// @name Nonlinearity
/// Implements the non-linear part of the coordinate space mapping
diff --git a/Src/DasherCore/LanguageModelling/Makefile.am b/Src/DasherCore/LanguageModelling/Makefile.am
index b43e9d5..7b0c8cb 100644
--- a/Src/DasherCore/LanguageModelling/Makefile.am
+++ b/Src/DasherCore/LanguageModelling/Makefile.am
@@ -1,6 +1,6 @@
-noinst_LIBRARIES = libdasherlm.a
+noinst_LTLIBRARIES = libdasherlm.la
-libdasherlm_a_SOURCES = \
+libdasherlm_la_SOURCES = \
CTWLanguageModel.cpp \
CTWLanguageModel.h \
DictLanguageModel.cpp \
diff --git a/Src/DasherCore/Makefile.am b/Src/DasherCore/Makefile.am
index dfa344e..de21e23 100644
--- a/Src/DasherCore/Makefile.am
+++ b/Src/DasherCore/Makefile.am
@@ -1,14 +1,14 @@
SUBDIRS = LanguageModelling
-noinst_LIBRARIES = libdashercore.a libdasherprefs.a
+noinst_LTLIBRARIES = libdashercore.la libdasherprefs.la
-libdasherprefs_a_SOURCES = \
+libdasherprefs_la_SOURCES = \
Parameters.h \
Parameters.cpp \
SettingsStore.cpp \
SettingsStore.h
-libdashercore_a_SOURCES = \
+libdashercore_la_SOURCES = \
AbstractXMLParser.cpp \
AbstractXMLParser.h \
Alphabet/AlphIO.cpp \
@@ -147,10 +147,10 @@ libdashercore_a_SOURCES = \
XMLUtil.cpp \
XMLUtil.h
-libdashercore_a_LIBADD = @JAPANESE_SOURCES@
-libdashercore_a_DEPENDENCIES = @JAPANESE_SOURCES@
+libdashercore_la_LIBADD = @JAPANESE_SOURCES@ ../Common/libdashermisc.la
+libdashercore_la_DEPENDENCIES = @JAPANESE_SOURCES@
-EXTRA_libdashercore_a_SOURCES = \
+EXTRA_libdashercore_la_SOURCES = \
CannaConversionHelper.cpp \
CannaConversionHelper.h
diff --git a/Src/Makefile.am b/Src/Makefile.am
index d4835f9..02ee03c 100644
--- a/Src/Makefile.am
+++ b/Src/Makefile.am
@@ -27,12 +27,11 @@ AM_CXXFLAGS += @CSPI_CFLAGS@
endif
dasher_LDADD = \
- Common/libdashermisc.a \
Gtk2/libdashergtk.la \
Gtk2/libdashercontrol.la \
- DasherCore/libdashercore.a \
- DasherCore/libdasherprefs.a \
- DasherCore/LanguageModelling/libdasherlm.a \
+ DasherCore/libdashercore.la \
+ DasherCore/libdasherprefs.la \
+ DasherCore/LanguageModelling/libdasherlm.la \
$(GTKBUILD_LIBS) \
$(SPEECH_LIBS) \
-lexpat
diff --git a/configure.ac b/configure.ac
index 59d6dc2..d3c317b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,7 @@ AC_CONFIG_SRCDIR([Src/main.cc])
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_LIBOBJ_DIR([Src/Common])
AM_INIT_AUTOMAKE([1.8 gnu check-news dist-bzip2])
AM_MAINTAINER_MODE
@@ -51,6 +52,7 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6)
AC_LANG_PUSH(C++)
AC_CHECK_FUNCS(lldiv)
AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
+AC_REPLACE_FUNCS([round])
AC_LANG_POP(C++)
AC_ARG_ENABLE(debug,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]