summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-string.c
diff options
context:
space:
mode:
authorJohn Sullivan <sullivan@src.gnome.org>2000-03-07 02:52:07 +0000
committerJohn Sullivan <sullivan@src.gnome.org>2000-03-07 02:52:07 +0000
commitbc4cb175a70e9913d6316fe2538df5fd4d709d63 (patch)
tree62630057efbd017432ed90e8ad68d7e2e84ea419 /libnautilus-private/nautilus-string.c
parent4019aa50d494a60b1161570029723bc70ba9fff5 (diff)
downloadnautilus-bc4cb175a70e9913d6316fe2538df5fd4d709d63.tar.gz
Lots of work to use Bonobo menu merging. The file manager now merges various
items into the window's menubar, which has been slightly tweaked also.
Diffstat (limited to 'libnautilus-private/nautilus-string.c')
-rw-r--r--libnautilus-private/nautilus-string.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libnautilus-private/nautilus-string.c b/libnautilus-private/nautilus-string.c
index 36a84a65b..d2df8e286 100644
--- a/libnautilus-private/nautilus-string.c
+++ b/libnautilus-private/nautilus-string.c
@@ -167,6 +167,35 @@ nautilus_string_to_int (const char *string, int *integer)
return TRUE;
}
+/**
+ * nautilus_strstrip:
+ * Remove all occurrences of a character from a string. The
+ * original string is modified, and also returned for convenience.
+ *
+ * @string_null_allowed: The string to be stripped.
+ * @remove_this: The char to remove from @string_null_allowed
+ *
+ * Return value: @string_null_allowed, after removing all occurrences
+ * of @remove_this.
+ */
+char *
+nautilus_strstrip (char *string_null_allowed, char remove_this)
+{
+ if (string_null_allowed != NULL) {
+ char *pos;
+
+ pos = string_null_allowed;
+ while (*pos != '\0') {
+ if (*pos == remove_this) {
+ g_memmove (pos, pos + 1, strlen (pos));
+ }
+ ++pos;
+ }
+ }
+
+ return string_null_allowed;
+}
+
gboolean
nautilus_eat_string_to_int (char *string, int *integer)
{
@@ -203,6 +232,7 @@ void
nautilus_self_check_string (void)
{
int integer;
+ char *test_string;
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_strlen (NULL), 0);
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_strlen (""), 0);
@@ -261,6 +291,16 @@ nautilus_self_check_string (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_strdup_prefix ("foo:bar", ":"), "foo");
NAUTILUS_CHECK_STRING_RESULT (nautilus_strdup_prefix ("footle:bar", "tle:"), "foo");
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_strstrip (NULL, '_'), NULL);
+ test_string = g_strdup ("foo");
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_strstrip (test_string, '_'), "foo");
+ test_string = g_strdup ("_foo");
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_strstrip (test_string, '_'), "foo");
+ test_string = g_strdup ("foo_");
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_strstrip (test_string, '_'), "foo");
+ test_string = g_strdup ("_foo_");
+ NAUTILUS_CHECK_STRING_RESULT (nautilus_strstrip (test_string, '_'), "foo");
+
#define TEST_INTEGER_CONVERSION_FUNCTIONS(string, boolean_result, integer_result) \
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_string_to_int (string, &integer), boolean_result); \
NAUTILUS_CHECK_INTEGER_RESULT (call_string_to_int (string), integer_result); \