summaryrefslogtreecommitdiff
path: root/eel/eel-string.c
diff options
context:
space:
mode:
Diffstat (limited to 'eel/eel-string.c')
-rw-r--r--eel/eel-string.c216
1 files changed, 0 insertions, 216 deletions
diff --git a/eel/eel-string.c b/eel/eel-string.c
index 5d74c317..61343eec 100644
--- a/eel/eel-string.c
+++ b/eel/eel-string.c
@@ -59,36 +59,6 @@ eel_strcmp (const char *string_a, const char *string_b)
string_b == NULL ? "" : string_b);
}
-int
-eel_strcasecmp (const char *string_a, const char *string_b)
-{
- /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this
- * treat 'NULL < ""', or have a flavor that does that. If we
- * didn't have code that already relies on 'NULL == ""', I
- * would change it right now.
- */
- return g_ascii_strcasecmp (string_a == NULL ? "" : string_a,
- string_b == NULL ? "" : string_b);
-}
-
-int
-eel_strcmp_case_breaks_ties (const char *string_a, const char *string_b)
-{
- int casecmp_result;
-
- /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this
- * treat 'NULL < ""', or have a flavor that does that. If we
- * didn't have code that already relies on 'NULL == ""', I
- * would change it right now.
- */
- casecmp_result = eel_strcasecmp (string_a, string_b);
- if (casecmp_result != 0)
- {
- return casecmp_result;
- }
- return eel_strcmp (string_a, string_b);
-}
-
gboolean
eel_str_is_empty (const char *string_or_null)
{
@@ -96,28 +66,6 @@ eel_str_is_empty (const char *string_or_null)
}
gboolean
-eel_str_is_equal (const char *string_a, const char *string_b)
-{
- /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this
- * treat 'NULL != ""', or have a flavor that does that. If we
- * didn't have code that already relies on 'NULL == ""', I
- * would change it right now.
- */
- return eel_strcmp (string_a, string_b) == 0;
-}
-
-gboolean
-eel_istr_is_equal (const char *string_a, const char *string_b)
-{
- /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this
- * treat 'NULL != ""', or have a flavor that does that. If we
- * didn't have code that already relies on 'NULL == ""', I
- * would change it right now.
- */
- return eel_strcasecmp (string_a, string_b) == 0;
-}
-
-gboolean
eel_str_has_prefix (const char *haystack, const char *needle)
{
return g_str_has_prefix (haystack == NULL ? "" : haystack,
@@ -125,21 +73,6 @@ eel_str_has_prefix (const char *haystack, const char *needle)
}
gboolean
-eel_str_has_suffix (const char *haystack, const char *needle)
-{
- if (needle == NULL)
- {
- return TRUE;
- }
- if (haystack == NULL)
- {
- return needle[0] == '\0';
- }
-
- return g_str_has_suffix (haystack, needle);
-}
-
-gboolean
eel_istr_has_prefix (const char *haystack, const char *needle)
{
const char *h, *n;
@@ -167,43 +100,6 @@ eel_istr_has_prefix (const char *haystack, const char *needle)
return FALSE;
}
-gboolean
-eel_istr_has_suffix (const char *haystack, const char *needle)
-{
- const char *h, *n;
- char hc, nc;
-
- if (needle == NULL)
- {
- return TRUE;
- }
- if (haystack == NULL)
- {
- return needle[0] == '\0';
- }
-
- /* Eat one character at a time. */
- h = haystack + strlen (haystack);
- n = needle + strlen (needle);
- do
- {
- if (n == needle)
- {
- return TRUE;
- }
- if (h == haystack)
- {
- return FALSE;
- }
- hc = *--h;
- nc = *--n;
- hc = g_ascii_tolower (hc);
- nc = g_ascii_tolower (nc);
- }
- while (hc == nc);
- return FALSE;
-}
-
/**
* eel_str_get_prefix:
* Get a new string containing the first part of an existing string.
@@ -244,46 +140,6 @@ eel_str_get_prefix (const char *source,
return g_strndup (source, prefix_start - source);
}
-gboolean
-eel_str_to_int (const char *string, int *integer)
-{
- long result;
- char *parse_end;
-
- /* Check for the case of an empty string. */
- if (string == NULL || *string == '\0')
- {
- return FALSE;
- }
-
- /* Call the standard library routine to do the conversion. */
- errno = 0;
- result = strtol (string, &parse_end, 0);
-
- /* Check that the result is in range. */
- if ((result == G_MINLONG || result == G_MAXLONG) && errno == ERANGE)
- {
- return FALSE;
- }
- if (result < G_MININT || result > G_MAXINT)
- {
- return FALSE;
- }
-
- /* Check that all the trailing characters are spaces. */
- while (*parse_end != '\0')
- {
- if (!g_ascii_isspace (*parse_end++))
- {
- return FALSE;
- }
- }
-
- /* Return the result. */
- *integer = result;
- return TRUE;
-}
-
char *
eel_str_double_underscores (const char *string)
{
@@ -1005,16 +861,6 @@ retry_atomic_decrement:
#if !defined (EEL_OMIT_SELF_CHECK)
-static int
-call_str_to_int (const char *string)
-{
- int integer;
-
- integer = 9999;
- eel_str_to_int (string, &integer);
- return integer;
-}
-
static void
verify_printf (const char *format, ...)
{
@@ -1125,25 +971,6 @@ eel_self_check_string (void)
EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("aaa", "aaab"), FALSE);
EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("aaab", "aaa"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix (NULL, NULL), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix (NULL, ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("", NULL), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("", ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("", "a"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", "a"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("aaab", "aaab"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix (NULL, "a"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", NULL), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("", "a"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", "b"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", "ab"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("ab", "a"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("ab", "b"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("aaa", "baaa"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("baaa", "aaa"), TRUE);
-
EEL_CHECK_STRING_RESULT (eel_str_get_prefix (NULL, NULL), NULL);
EEL_CHECK_STRING_RESULT (eel_str_get_prefix (NULL, "foo"), NULL);
EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("foo", NULL), "foo");
@@ -1201,49 +1028,6 @@ eel_self_check_string (void)
EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 14), "something_even");
EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 13), "something_odd");
-#define TEST_INTEGER_CONVERSION_FUNCTIONS(string, boolean_result, integer_result) \
- EEL_CHECK_BOOLEAN_RESULT (eel_str_to_int (string, &integer), boolean_result); \
- EEL_CHECK_INTEGER_RESULT (call_str_to_int (string), integer_result);
-
- TEST_INTEGER_CONVERSION_FUNCTIONS (NULL, FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("a", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS (".", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("0", TRUE, 0)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("1", TRUE, 1)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("+1", TRUE, 1)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("-1", TRUE, -1)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("2147483647", TRUE, 2147483647)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("2147483648", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("+2147483647", TRUE, 2147483647)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("+2147483648", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("-2147483648", TRUE, INT_MIN)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("-2147483649", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("1a", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("0.0", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("1e1", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("21474836470", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("+21474836470", FALSE, 9999)
- TEST_INTEGER_CONVERSION_FUNCTIONS ("-21474836480", FALSE, 9999)
-
- EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal (NULL, NULL), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal (NULL, ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("", ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("", NULL), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("", ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("foo", "foo"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("foo", "bar"), FALSE);
-
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal (NULL, NULL), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal (NULL, ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("", ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("", NULL), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("", ""), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("foo", "foo"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("foo", "bar"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("Foo", "foo"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("foo", "Foo"), TRUE);
-
EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after (NULL, "bar"), NULL);
EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("", "bar"), "");
EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("foo", "bar"), "foo");