[epiphany] Simplify ephy_string_shorten()



commit 232c613472b38ff0d0d97338f366024ddb9cd228
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon May 21 22:38:14 2018 -0500

    Simplify ephy_string_shorten()
    
    It's too much effort to add an ellipsis character.

 lib/ephy-string.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/lib/ephy-string.c b/lib/ephy-string.c
index 2bd71a9..aac2c24 100644
--- a/lib/ephy-string.c
+++ b/lib/ephy-string.c
@@ -29,8 +29,6 @@
 #include <string.h>
 #include <sys/types.h>
 
-#define ELLIPSIS "\xe2\x80\xa6"
-
 gboolean
 ephy_string_to_int (const char *string, gulong *integer)
 {
@@ -116,10 +114,11 @@ ephy_string_shorten (char *str,
   /* create string */
   bytes = GPOINTER_TO_UINT (g_utf8_offset_to_pointer (str, target_length - 1) - str);
 
-  new_str = g_new (gchar, bytes + strlen (ELLIPSIS) + 1);
+  /* +1 for ellipsis, +1 for trailing NUL */
+  new_str = g_new (gchar, bytes + 1 + 1);
 
   strncpy (new_str, str, bytes);
-  strncpy (new_str + bytes, ELLIPSIS, strlen (ELLIPSIS) + 1);
+  strcat (new_str, "…");
 
   g_free (str);
 


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