aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog6
-rw-r--r--camel/providers/imap/camel-imap-utils.c11
-rw-r--r--camel/string-utils.c20
-rw-r--r--camel/string-utils.h7
4 files changed, 36 insertions, 8 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 7bce861e25..035ee3651e 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,11 @@
2000-08-07 Jeffrey Stedfast <fejj@helixcode.com>
+ * providers/imap/camel-imap-utils.c (imap_translate_sexp): Strip
+ all \n's from the expression
+
+ * string-utils.c (strip): New convenience function to strip
+ occurences of a single char from a string
+
* camel-mime-message.c (camel_mime_message_set_subject): Do a
g_strstrip on the subject so we can stop getting those annoying
leading spaces
diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c
index c440d6c165..f1c4c17782 100644
--- a/camel/providers/imap/camel-imap-utils.c
+++ b/camel/providers/imap/camel-imap-utils.c
@@ -369,9 +369,12 @@ char *
imap_translate_sexp (const char *expression)
{
struct sexp_node *root;
- char *sexp;
+ char *sexp, *exp;
- root = get_sexp_node (expression);
+ exp = g_strdup (expression);
+ strip (exp, '\n');
+ root = get_sexp_node (exp);
+ g_free (exp);
d(print_node (root, 0));
d(fprintf (stderr, "\n"));
@@ -466,8 +469,8 @@ imap_translate_sexp (const char *expression)
char *sexp;
esexp = e_sexp_new ();
-
- e_sexp_input_text (esexp, expression, strlen (expression));
+
+ e_sexp_input_text (esexp, exp, strlen (exp));
e_sexp_parse (esexp);
sexp = stresexptree (esexp->tree);
diff --git a/camel/string-utils.c b/camel/string-utils.c
index 63e9eafabf..023aee16af 100644
--- a/camel/string-utils.c
+++ b/camel/string-utils.c
@@ -31,7 +31,7 @@
gboolean
string_equal_for_glist (gconstpointer v, gconstpointer v2)
{
- return (!strcmp ( ((const gchar *)v), ((const gchar*)v2))) == 0;
+ return (!strcmp ( ((const gchar *)v), ((const gchar*)v2))) == 0;
}
/* utility func : frees a gchar element in a GList */
@@ -181,10 +181,26 @@ string_unquote (gchar *string)
/* if the string is quoted, unquote it */
g_return_if_fail (string != NULL);
-
+
if (*string == '"' && *(string + strlen (string) - 1) == '"') {
*(string + strlen (string) - 1) = '\0';
if (*string)
memmove (string, string+1, strlen (string));
}
}
+
+gchar *
+strip (gchar *string, gchar c)
+{
+ /* strip all occurances of c from the string */
+ gchar *src, *dst;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ for (src = dst = string; *src; src++)
+ if (*src != c)
+ *dst++ = *src;
+ *dst = '\0';
+
+ return string;
+}
diff --git a/camel/string-utils.h b/camel/string-utils.h
index 4cfef5b746..1556faa1df 100644
--- a/camel/string-utils.h
+++ b/camel/string-utils.h
@@ -54,9 +54,12 @@ GList *string_split (const gchar *string, char sep,
void string_trim (gchar *string, const gchar *chars,
StringTrimOption options);
-gchar *string_prefix (const gchar *s, const gchar *suffix, gboolean *suffix_found);
+gchar *string_prefix (const gchar *s, const gchar *suffix,
+ gboolean *suffix_found);
-void string_unquote (gchar *string);
+void string_unquote (gchar *string);
+
+gchar *strip (gchar *string, gchar c);
#ifdef __cplusplus
}