diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | lib/ephy-string.c | 50 | ||||
-rw-r--r-- | lib/ephy-string.h | 9 | ||||
-rw-r--r-- | src/ephy-tab.c | 10 |
4 files changed, 42 insertions, 37 deletions
@@ -1,5 +1,15 @@ 2003-12-13 Christian Persch <chpe@cvs.gnome.org> + * lib/ephy-string.c: (ephy_string_shorten), (ephy_string_to_int), + (ephy_string_blank_chr), (ephy_string_elide_underscores), + (ephy_string_double_underscores): + * lib/ephy-string.h: + * src/ephy-tab.c: (ephy_tab_set_link_message): + + Convert control chars to blanks. + +2003-12-13 Christian Persch <chpe@cvs.gnome.org> + * embed/print-dialog.c: (ephy_print_setup_dialog_new): * lib/ephy-stock-icons.c: (ephy_stock_icons_init): * lib/ephy-stock-icons.h: diff --git a/lib/ephy-string.c b/lib/ephy-string.c index 1c4ff358d..a2882c685 100644 --- a/lib/ephy-string.c +++ b/lib/ephy-string.c @@ -17,7 +17,7 @@ */ #ifdef HAVE_CONFIG_H -#include <config.h> +#include "config.h" #endif #include "ephy-string.h" @@ -39,9 +39,9 @@ * it can still split a sequence of combining characters */ char * -ephy_string_shorten (const gchar *str, gint target_length) +ephy_string_shorten (const char *str, int target_length) { - gchar *new_str; + char *new_str; glong actual_length; gulong bytes; @@ -71,7 +71,8 @@ ephy_string_to_int (const char *string, gulong *integer) char *parse_end; /* Check for the case of an empty string. */ - if (string == NULL || *string == '\0') { + if (string == NULL || *string == '\0') + { return FALSE; } @@ -80,13 +81,16 @@ ephy_string_to_int (const char *string, gulong *integer) result = strtol (string, &parse_end, 0); /* Check that the result is in range. */ - if ((result == G_MINLONG || result == G_MAXLONG) && errno == ERANGE) { + if ((result == G_MINLONG || result == G_MAXLONG) && errno == ERANGE) + { return FALSE; } /* Check that all the trailing characters are spaces. */ - while (*parse_end != '\0') { - if (!g_ascii_isspace (*parse_end++)) { + while (*parse_end != '\0') + { + if (!g_ascii_isspace (*parse_end++)) + { return FALSE; } } @@ -107,33 +111,34 @@ ephy_string_to_int (const char *string, gulong *integer) * of @remove_this. */ char * -ephy_string_strip_chr (const char *source, char remove_this) +ephy_string_blank_chr (char *source) { - char *result, *out; - const char *in; + char *p; - if (source == NULL) { + if (source == NULL) + { return NULL; } - result = g_new (char, strlen (source) + 1); - in = source; - out = result; - do { - if (*in != remove_this) { - *out++ = *in; + p = source; + while (*p != '\0') + { + if ((guchar) *p < 0x20) + { + *p = ' '; } - } while (*in++ != '\0'); + p++; + } - return result; + return source; } /* copied from egg-toolbar-editor.c */ char * -ephy_string_elide_underscores (const gchar *original) +ephy_string_elide_underscores (const char *original) { - gchar *q, *result; - const gchar *p; + char *q, *result; + const char *p; gboolean last_underscore; q = result = g_malloc (strlen (original) + 1); @@ -194,4 +199,3 @@ ephy_string_double_underscores (const char *string) return escaped; } - diff --git a/lib/ephy-string.h b/lib/ephy-string.h index 6cfbd892f..f2907219f 100644 --- a/lib/ephy-string.h +++ b/lib/ephy-string.h @@ -28,13 +28,12 @@ G_BEGIN_DECLS gboolean ephy_string_to_int (const char *string, gulong *integer); -char *ephy_string_strip_chr (const char *source, - char remove_this); +char *ephy_string_blank_chr (char *source); -char *ephy_string_shorten (const gchar *str, - gint target_length); +char *ephy_string_shorten (const char *str, + int target_length); -char *ephy_string_elide_underscores (const gchar *original); +char *ephy_string_elide_underscores (const char *original); char *ephy_string_double_underscores (const char *string); diff --git a/src/ephy-tab.c b/src/ephy-tab.c index fb4c26393..5df39cec9 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -450,18 +450,10 @@ ephy_tab_get_load_status (EphyTab *tab) static void ephy_tab_set_link_message (EphyTab *tab, char *message) { - char *tmp1, *tmp2; - g_return_if_fail (EPHY_IS_TAB (tab)); - tmp1 = ephy_string_strip_chr (message, '\r'); - tmp2 = ephy_string_strip_chr (tmp1, '\n'); - g_free (tab->priv->link_message); - tab->priv->link_message = tmp2; - - g_free (tmp1); - g_free (message); + tab->priv->link_message = ephy_string_blank_chr (message); g_object_notify (G_OBJECT (tab), "message"); } |