changeset 17971:13a4f57f53a9

Implement round() if it is not available, using floor(). May close #2281.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Fri, 27 Jul 2007 03:47:12 +0000
parents baccbb0fc91d
children 8f49acac9d1c
files libpurple/protocols/myspace/myspace.c libpurple/protocols/myspace/myspace.h
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Thu Jul 26 16:00:42 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Fri Jul 27 03:47:12 2007 +0000
@@ -170,6 +170,20 @@
 static void msim_lookup_user(MsimSession *session, const gchar *user, 
 		MSIM_USER_LOOKUP_CB cb, gpointer data);
 
+#ifndef round
+double round(double round);
+
+/* round is part of C99, but sometimes is unavailable before then.
+ * Based on http://forums.belution.com/en/cpp/000/050/13.shtml
+ */
+double round(double value)
+{
+    if (value < 0)
+        return -(floor(-value + 0.5));
+    else
+        return   floor( value + 0.5);
+}
+#endif
 
 /** 
  * Load the plugin.
--- a/libpurple/protocols/myspace/myspace.h	Thu Jul 26 16:00:42 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.h	Fri Jul 27 03:47:12 2007 +0000
@@ -24,7 +24,7 @@
 #include <string.h>
 #include <errno.h>	/* for EAGAIN */
 #include <stdarg.h>
-#include <math.h>   /* for round() */
+#include <math.h>
 
 #include <glib.h>