[gtk+] Include C89 fallback code



commit ad73ed298d26a934b587b4703e69f08f8c77d2eb
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Aug 19 14:26:52 2011 +0800

    Include C89 fallback code
    
    gtk/gtkborderimage.c, gtk/gtklabel.c and gtk/gtkstyleproperty.c call
    round() and/or rint(), which was only available in C99 compilers.
    
    This adds the inclusion of the fallback implementation (gtk/fallback-c89.c)
    to define these functions if they are not initially made available by the
    compiler.
    
    Also remove the rint() implementation in gtk/gtklabel.c as it is now in
    the fallback implmentation.

 gtk/gtkborderimage.c   |    5 +++++
 gtk/gtklabel.c         |   25 +++++--------------------
 gtk/gtkstyleproperty.c |    5 +++++
 3 files changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkborderimage.c b/gtk/gtkborderimage.c
index 4f6ded6..d5510ab 100644
--- a/gtk/gtkborderimage.c
+++ b/gtk/gtkborderimage.c
@@ -28,6 +28,11 @@
 
 #include "gtkborderimageprivate.h"
 
+/* this is in case round() is not provided by the compiler, 
+ * such as in the case of C89 compilers, like MSVC
+ */
+#include "fallback-c89.c"
+
 G_DEFINE_BOXED_TYPE (GtkBorderImage, _gtk_border_image,
                      _gtk_border_image_ref, _gtk_border_image_unref)
 
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 6a6f72c..9fadbfd 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -54,6 +54,11 @@
 
 #include "a11y/gtklabelaccessible.h"
 
+/* this is in case rint() is not provided by the compiler, 
+ * such as in the case of C89 compilers, like MSVC
+ */
+#include "fallback-c89.c"
+
 /**
  * SECTION:gtklabel
  * @Short_description: A widget that displays a small to medium amount of text
@@ -230,26 +235,6 @@
  * </refsect2>
  */
 
-
-/*rint() is only available in GCC and/or C99*/
-#if (__STDC_VERSION__ < 199901L && !defined __GNUC__)
-double rint(double x)
-{
-	if (ceil(x+0.5) == floor(x+0.5))
-	{
-		int a = (int)ceil(x);
-		if (a%2 == 0)
-			return ceil(x);
-		else
-			return floor(x);
-	}
-	else
-		return floor(x+0.5);
-}
-#endif
-
-
-
 struct _GtkLabelPrivate
 {
   GtkLabelSelectionInfo *select_info;
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 73200dc..69f2e8e 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -42,6 +42,11 @@
 #include "gtkthemingengine.h"
 #include "gtktypebuiltins.h"
 
+/* this is in case round() is not provided by the compiler, 
+ * such as in the case of C89 compilers, like MSVC
+ */
+#include "fallback-c89.c"
+
 static GHashTable *parse_funcs = NULL;
 static GHashTable *print_funcs = NULL;
 static GHashTable *properties = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]