From 6a52075c557c3d64dfa9e6c05ab2b67e30b900f2 Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Mon, 10 Mar 2008 00:55:01 +0000 Subject: Remove sign hack. Signed-off-by: Bradley Smith --- ChangeLog | 3 ++- include/Makefile.am | 1 - include/grobot.h | 1 + include/sign.h | 5 ----- src/Makefile.am | 2 +- src/api.c | 1 - src/grobot.c | 3 +-- src/sign.c | 18 ------------------ 8 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 include/sign.h delete mode 100644 src/sign.c diff --git a/ChangeLog b/ChangeLog index d331819..181bd30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,7 +15,8 @@ Tidy up, and convert GObject style. * src/userinterface.c include/userinterface.h: Tidy up. - * lib/x11plugin.c: + * src/sign.c include/sign.h src/api.c src/grobot.c: + Remove sign hack. 2008-03-08 Bradley Smith diff --git a/include/Makefile.am b/include/Makefile.am index 5f57db1..9217f6d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -22,6 +22,5 @@ EXTRA_DIST =\ map.h\ main.h\ grobot.h\ - sign.h\ userinterface.h diff --git a/include/grobot.h b/include/grobot.h index 6ebcca3..1aeafb2 100644 --- a/include/grobot.h +++ b/include/grobot.h @@ -67,6 +67,7 @@ struct _GRobotClass { /* some convenient macros */ #define G_ROBOT_POSITION_X(robot) ((robot)->x) #define G_ROBOT_POSITION_Y(robot) ((robot)->y) +#define sign(x) (x/abs(x)) /* normal GObject stuff */ GType g_robot_get_type(void) G_GNUC_CONST; diff --git a/include/sign.h b/include/sign.h deleted file mode 100644 index 05fe87d..0000000 --- a/include/sign.h +++ /dev/null @@ -1,5 +0,0 @@ -/* This needs to go. */ - -#include - -gint sign (gint n); diff --git a/src/Makefile.am b/src/Makefile.am index eb3496b..865a5de 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,5 +25,5 @@ INCLUDES = $(GLIB2_CFLAGS) $(GUILE_CFLAGS) -I$(top_builddir)/include \ -DMAPS_PATH=\"$(mapsdir)\" \ -DSCRIPTS_PATH=\"$(schemedir)\" -gnurobots_SOURCES = main.c api.c sign.c map.c grobot.c userinterface.c +gnurobots_SOURCES = main.c api.c map.c grobot.c userinterface.c gnurobots_LDFLAGS = $(GLIB2_LIBS) $(GUILE_LDFLAGS) -lltdl diff --git a/src/api.c b/src/api.c index a34c065..bd8a566 100644 --- a/src/api.c +++ b/src/api.c @@ -26,7 +26,6 @@ #include "api.h" /* GNU Robots API */ #include "main.h" /* for exit_nicely */ -#include "sign.h" /* a hack for +/- sign */ #include "grobot.h" extern GRobot *robot; diff --git a/src/grobot.c b/src/grobot.c index 91c8b32..d39ea91 100644 --- a/src/grobot.c +++ b/src/grobot.c @@ -25,7 +25,6 @@ #include #include #include -#include "sign.h" G_DEFINE_TYPE(GRobot, g_robot, G_TYPE_OBJECT) @@ -374,7 +373,7 @@ g_robot_turn (GRobot *robot, gint num_turns) /* turn left or right? */ - incr = sign (num_turns); + incr = sign(num_turns); for (i = 0; i < abs (num_turns); i++) { diff --git a/src/sign.c b/src/sign.c deleted file mode 100644 index 9b1743e..0000000 --- a/src/sign.c +++ /dev/null @@ -1,18 +0,0 @@ -/* TODO: Either this needs to go, or it needs a copyright header */ - -#include -#include - -/* is there a standard C function to do this? */ - -gint -sign (gint n) -{ - if (n < 0) { - return (-1); - } else if (n > 0) { - return (+1); - } - - return (0); -} -- cgit v1.1