Author: akv
Date: 2010-02-02 21:00:15 +0100 (Tue, 02 Feb 2010)
New Revision: 3154
Modified:
trunk/librawstudio/rs-utils.c
trunk/librawstudio/rs-utils.h
Log:
Added rs_remove_tailing_spaces().
Modified: trunk/librawstudio/rs-utils.c
===================================================================
--- trunk/librawstudio/rs-utils.c 2010-01-31 20:28:08 UTC (rev 3153)
+++ trunk/librawstudio/rs-utils.c 2010-02-02 20:00:15 UTC (rev 3154)
@@ -31,6 +31,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
+#include <string.h>
#define DOTDIR ".rawstudio"
@@ -756,3 +757,28 @@
return ret;
}
+
+/**
+ * Removes tailing spaces from a gchar *
+ * @param str A gchar * to have tailing spaces removed
+ * @return A gchar * with tailing spaces removed
+ */
+gchar *
+rs_remove_tailing_spaces(gchar *str)
+{
+ gint i;
+ gchar *ret;
+
+ for(i = strlen(str)-1; i > 0; i--)
+ {
+ if (str[i] == 0x20)
+ str[i] = 0x00;
+ else
+ i = 0;
+ }
+
+ ret = g_strdup(str);
+ g_free(str);
+
+ return ret;
+}
Modified: trunk/librawstudio/rs-utils.h
===================================================================
--- trunk/librawstudio/rs-utils.h 2010-01-31 20:28:08 UTC (rev 3153)
+++ trunk/librawstudio/rs-utils.h 2010-02-02 20:00:15 UTC (rev 3154)
@@ -176,4 +176,11 @@
gboolean
rs_file_copy(const gchar *source, const gchar *destination);
+/**
+ * Removes tailing spaces from a gchar *
+ * @param str A gchar * to have tailing spaces removed
+ * @return A gchar * with tailing spaces removed
+ */
+gchar * rs_remove_tailing_spaces(gchar *str);
+
#endif /* RS_UTILS_H */
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit