From 32e18fb1a589a2273cbf210919ee7ae7de04d79a Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Mon, 26 Aug 2013 02:42:01 +0300 Subject: [PATCH] remove octet_compare strcmp provides the same functionality --- src/common.c | 26 -------------------------- src/common.h | 1 - src/xmpp/capabilities.c | 6 +++--- src/xmpp/stanza.c | 4 ++-- 4 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/common.c b/src/common.c index da33cc3d..c7ec7d0b 100644 --- a/src/common.c +++ b/src/common.c @@ -225,32 +225,6 @@ prof_getline(FILE *stream) return s; } -int -octet_compare(unsigned char *str1, unsigned char *str2) -{ - if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") == 0)) { - return 0; - } - - if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") != 0)) { - return -1; - } - - if ((strcmp((char *)str1, "") != 0) && (strcmp((char *)str2, "") == 0)) { - return 1; - } - - if (str1[0] == str2[0]) { - return octet_compare(&str1[1], &str2[1]); - } - - if (str1[0] < str2[0]) { - return -1; - } - - return 1; -} - char * release_get_latest() { diff --git a/src/common.h b/src/common.h index 469a63ec..f2b59413 100644 --- a/src/common.h +++ b/src/common.h @@ -79,7 +79,6 @@ char * str_replace(const char *string, const char *substr, int str_contains(char str[], int size, char ch); char* encode_xml(const char * const xml); char * prof_getline(FILE *stream); -int octet_compare(unsigned char *str1, unsigned char *str2); char* release_get_latest(void); gboolean release_is_new(char *found_version); gchar * xdg_get_config_home(void); diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index 2b0a12e5..f38a2749 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -148,15 +148,15 @@ caps_create_sha1_str(xmpp_stanza_t * const query) g_string_append(identity_str, name); } g_string_append(identity_str, "<"); - identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)octet_compare); + identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)strcmp); g_string_free(identity_str, TRUE); } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_FEATURE) == 0) { feature_str = xmpp_stanza_get_attribute(child, "var"); - features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)octet_compare); + features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)strcmp); } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_X) == 0) { if (strcmp(xmpp_stanza_get_ns(child), STANZA_NS_DATA) == 0) { form = stanza_create_form(child); - form_names = g_slist_insert_sorted(form_names, g_strdup(form->form_type), (GCompareFunc)octet_compare); + form_names = g_slist_insert_sorted(form_names, g_strdup(form->form_type), (GCompareFunc)strcmp); g_hash_table_insert(forms, g_strdup(form->form_type), form); } } diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 7d7a0949..97cebc73 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -853,7 +853,7 @@ stanza_create_form(xmpp_stanza_t * const stanza) while (value != NULL) { char *text = xmpp_stanza_get_text(value); if (text != NULL) { - field->values = g_slist_insert_sorted(field->values, strdup(text), (GCompareFunc)octet_compare); + field->values = g_slist_insert_sorted(field->values, strdup(text), (GCompareFunc)strcmp); xmpp_free(ctx, text); } value = xmpp_stanza_get_next(value); @@ -997,5 +997,5 @@ stanza_get_presence_string_from_type(resource_presence_t presence_type) static int _field_compare(FormField *f1, FormField *f2) { - return octet_compare((unsigned char *)f1->var, (unsigned char *)f2->var); + return strcmp(f1->var, f2->var); }