[gnome-power-manager] trivial: remove egg-string and it's one user



commit 82effc33340ff8e4520c53c51ca2020031b834b5
Author: Richard Hughes <richard hughsie com>
Date:   Thu Sep 30 17:33:31 2010 +0100

    trivial: remove egg-string and it's one user

 src/Makefile.am      |    2 -
 src/egg-string.c     |  417 --------------------------------------------------
 src/egg-string.h     |   47 ------
 src/gpm-brightness.c |   38 +++++-
 4 files changed, 36 insertions(+), 468 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index d3baebf..2380380 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,8 +61,6 @@ libgpmshared_a_SOURCES =				\
 	gpm-array-float.h				\
 	gpm-idletime.h					\
 	gpm-idletime.c					\
-	egg-string.h					\
-	egg-string.c					\
 	egg-console-kit.h				\
 	egg-console-kit.c				\
 	gpm-common.h					\
diff --git a/src/gpm-brightness.c b/src/gpm-brightness.c
index dcb87f5..8e9ac13 100644
--- a/src/gpm-brightness.c
+++ b/src/gpm-brightness.c
@@ -41,7 +41,6 @@
 #endif /* HAVE_UNISTD_H */
 
 #include "egg-debug.h"
-#include "egg-string.h"
 
 #include "gpm-brightness.h"
 #include "gpm-common.h"
@@ -88,6 +87,41 @@ static guint signals [LAST_SIGNAL] = { 0 };
 static gpointer gpm_brightness_object = NULL;
 
 /**
+ * gpm_brightness_helper_strtoint:
+ * @text: The text the convert
+ * @value: The return numeric return value
+ *
+ * Converts a string into a signed integer value in a safe way.
+ *
+ * Return value: %TRUE if the string was converted correctly
+ **/
+static gboolean
+gpm_brightness_helper_strtoint (const gchar *text, gint *value)
+{
+	gchar *endptr = NULL;
+	gint64 value_raw;
+
+	/* invalid */
+	if (text == NULL)
+		return FALSE;
+
+	/* parse */
+	value_raw = g_ascii_strtoll (text, &endptr, 10);
+
+	/* parsing error */
+	if (endptr == text)
+		return FALSE;
+
+	/* out of range */
+	if (value_raw > G_MAXINT || value_raw < G_MININT)
+		return FALSE;
+
+	/* cast back down to value */
+	*value = (gint) value_raw;
+	return TRUE;
+}
+
+/**
  * gpm_brightness_helper_get_value:
  **/
 static gint
@@ -112,7 +146,7 @@ gpm_brightness_helper_get_value (const gchar *argument)
 	egg_debug ("executing %s retval: %i", command, exit_status);
 
 	/* parse for a number */
-	ret = egg_strtoint (stdout_data, &value);
+	ret = gpm_brightness_helper_strtoint (stdout_data, &value);
 	if (!ret)
 		goto out;
 out:



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