aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-12-14 06:29:00 +0800
committerChristian Persch <chpe@src.gnome.org>2003-12-14 06:29:00 +0800
commitc7fa7407b02c593b79492a2c57369af10032ec0d (patch)
treeff6d06c79053b7e2399ca5fc104fbc59a30a3de9 /lib
parent0dfeadba7950238d8f31b8a7fd1135e014d133b3 (diff)
downloadgsoc2013-epiphany-c7fa7407b02c593b79492a2c57369af10032ec0d.tar
gsoc2013-epiphany-c7fa7407b02c593b79492a2c57369af10032ec0d.tar.gz
gsoc2013-epiphany-c7fa7407b02c593b79492a2c57369af10032ec0d.tar.bz2
gsoc2013-epiphany-c7fa7407b02c593b79492a2c57369af10032ec0d.tar.lz
gsoc2013-epiphany-c7fa7407b02c593b79492a2c57369af10032ec0d.tar.xz
gsoc2013-epiphany-c7fa7407b02c593b79492a2c57369af10032ec0d.tar.zst
gsoc2013-epiphany-c7fa7407b02c593b79492a2c57369af10032ec0d.zip
Convert control chars to blanks.
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-string.c50
-rw-r--r--lib/ephy-string.h9
2 files changed, 31 insertions, 28 deletions
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);