[gnome-software] Use as_utils_string_replace() rather than our own buggy version



commit eb7af311ef5af86762f6c1ca5baf77c8765e5247
Author: Richard Hughes <richard hughsie com>
Date:   Fri Mar 4 08:38:11 2016 +0000

    Use as_utils_string_replace() rather than our own buggy version

 src/gs-app-addon-row.c                  |    2 +-
 src/gs-app-row.c                        |    2 +-
 src/gs-utils.c                          |   37 -------------------------------
 src/gs-utils.h                          |    3 --
 src/plugins/gs-plugin-xdg-app-reviews.c |    2 +-
 5 files changed, 3 insertions(+), 43 deletions(-)
---
diff --git a/src/gs-app-addon-row.c b/src/gs-app-addon-row.c
index c488b41..9682a97 100644
--- a/src/gs-app-addon-row.c
+++ b/src/gs-app-addon-row.c
@@ -79,7 +79,7 @@ gs_app_addon_row_refresh (GsAppAddonRow *row)
 
        /* join the lines */
        str = gs_app_addon_row_get_summary (row);
-       gs_string_replace (str, "\n", " ");
+       as_utils_string_replace (str, "\n", " ");
        gtk_label_set_markup (GTK_LABEL (row->description_label), str->str);
        gtk_label_set_label (GTK_LABEL (row->name_label),
                             gs_app_get_name (row->app));
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index befdc34..93f02c0 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -146,7 +146,7 @@ gs_app_row_refresh (GsAppRow *app_row)
        /* join the description lines */
        str = gs_app_row_get_description (app_row);
        if (str != NULL) {
-               gs_string_replace (str, "\n", " ");
+               as_utils_string_replace (str, "\n", " ");
                gtk_label_set_markup (GTK_LABEL (priv->description_label), str->str);
                g_string_free (str, TRUE);
        } else {
diff --git a/src/gs-utils.c b/src/gs-utils.c
index e2da64e..fbdb1a6 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -342,43 +342,6 @@ gs_app_show_url (GsApp *app, AsUrlKind kind)
                g_warning ("spawn of '%s' failed", url);
 }
 
-guint
-gs_string_replace (GString *string, const gchar *search, const gchar *replace)
-{
-       gchar *tmp;
-       guint count = 0;
-       guint replace_len;
-       guint search_len;
-
-       search_len = strlen (search);
-       replace_len = strlen (replace);
-
-       do {
-               tmp = g_strstr_len (string->str, -1, search);
-               if (tmp == NULL)
-                       goto out;
-
-               /* reallocate the string if required */
-               if (search_len > replace_len) {
-                       g_string_erase (string,
-                                       tmp - string->str,
-                                       search_len - replace_len);
-               }
-               if (search_len < replace_len) {
-                       g_string_insert_len (string,
-                                           tmp - string->str,
-                                           search,
-                                           replace_len - search_len);
-               }
-
-               /* just memcmp in the new string */
-               memcpy (tmp, replace, replace_len);
-               count++;
-       } while (TRUE);
-out:
-       return count;
-}
-
 /**
  * gs_mkdir_parent:
  **/
diff --git a/src/gs-utils.h b/src/gs-utils.h
index 2abdbf3..f65e6e5 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -47,9 +47,6 @@ GtkResponseType
 void    gs_app_show_url                (GsApp          *app,
                                         AsUrlKind       kind);
 
-guint   gs_string_replace              (GString        *string,
-                                        const gchar    *search,
-                                        const gchar    *replace);
 gboolean gs_mkdir_parent               (const gchar    *path,
                                         GError         **error);
 
diff --git a/src/plugins/gs-plugin-xdg-app-reviews.c b/src/plugins/gs-plugin-xdg-app-reviews.c
index 1ec77f1..395b110 100644
--- a/src/plugins/gs-plugin-xdg-app-reviews.c
+++ b/src/plugins/gs-plugin-xdg-app-reviews.c
@@ -958,7 +958,7 @@ gs_plugin_create_app_dummy (const gchar *id)
        GsApp *app = gs_app_new (id);
        g_autoptr(GString) str = NULL;
        str = g_string_new (id);
-       gs_string_replace (str, ".desktop", "");
+       as_utils_string_replace (str, ".desktop", "");
        g_string_prepend (str, "No description is available for ");
        gs_app_set_name (app, GS_APP_QUALITY_LOWEST, "Unknown Application");
        gs_app_set_summary (app, GS_APP_QUALITY_LOWEST, "Application not found");


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