[2905] in BarnOwl Developers
Re: Fixes to punt and filters
daemon@ATHENA.MIT.EDU (Anders Kaseorg)
Fri Feb 11 02:24:07 2011
Date: Fri, 11 Feb 2011 02:24:03 -0500 (EST)
From: Anders Kaseorg <andersk@MIT.EDU>
To: David A Benjamin <davidben@mit.edu>
cc: barnowl-dev@mit.edu
In-Reply-To: <alpine.DEB.1.10.1102110137400.26366@dr-wily.mit.edu>
On Fri, 11 Feb 2011, David A Benjamin wrote:
> (I'm still amazed glib doesn't give us an owl_text_tr-like function to
> replace it with...)
It gives us g_strsplit and g_strjoinv.
> We probably also want to kill the call in owl_function_smartfilter_cc.
Sure.
Anders
-- 8< --
From 5bbb69d48f9f8fbedb1a44046e82093eb02ddd42 Mon Sep 17 00:00:00 2001
From: Anders Kaseorg <andersk@mit.edu>
Date: Fri, 11 Feb 2011 02:10:48 -0500
Subject: [PATCH 1/2] owl_function_smartfilter_cc: Do not turn spaces into -
Theoretically, this could have resulted in ambiguities with usernames
containing -.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
functions.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/functions.c b/functions.c
index fbc2bff..8ffa3b5 100644
--- a/functions.c
+++ b/functions.c
@@ -2521,7 +2521,6 @@ static char *owl_function_smartfilter_cc(const owl_message *m) {
ccs = owl_message_get_attribute_value(m, "zephyr_ccs");
filtname = owl_sprintf("conversation-%s", ccs);
- owl_text_tr(filtname, ' ', '-');
if (owl_global_get_filter(&g, filtname)) {
return filtname;
--
1.7.4
From c49db66a74e4f5ebf07b8b07b90c0ac7fbf97683 Mon Sep 17 00:00:00 2001
From: Anders Kaseorg <andersk@mit.edu>
Date: Fri, 11 Feb 2011 02:22:14 -0500
Subject: [PATCH 2/2] Replace owl_text_tr with g_strsplit and g_strjoinv
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
logging.c | 6 +++++-
text.c | 14 --------------
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/logging.c b/logging.c
index 90a0453..84dd7dd 100644
--- a/logging.c
+++ b/logging.c
@@ -148,8 +148,12 @@ void owl_log_outgoing(const owl_message *m)
to = short_zuser(owl_message_get_recipient(m));
} else if (owl_message_is_type_jabber(m)) {
+ char **to_split;
to = owl_sprintf("jabber:%s", owl_message_get_recipient(m));
- owl_text_tr(to, '/', '_');
+ to_split = g_strsplit(to, "/", 0);
+ owl_free(to);
+ to = g_strjoinv("_", to_split);
+ g_strfreev(to_split);
} else if (owl_message_is_type_aim(m)) {
char *temp2;
temp = owl_aim_normalize_screenname(owl_message_get_recipient(m));
diff --git a/text.c b/text.c
index c6693bb..95e2b1a 100644
--- a/text.c
+++ b/text.c
@@ -298,20 +298,6 @@ char *owl_text_substitute(const char *in, const char *from, const char *to)
return(out);
}
-/* replace all instances of character a in buff with the character
- * b. buff must be null terminated.
- */
-void owl_text_tr(char *buff, char a, char b)
-{
- int i;
-
- owl_function_debugmsg("In: %s", buff);
- for (i=0; buff[i]!='\0'; i++) {
- if (buff[i]==a) buff[i]=b;
- }
- owl_function_debugmsg("Out: %s", buff);
-}
-
/* Return a string which is like 'in' except that every instance of
* any character in 'toquote' found in 'in' is preceeded by the string
* 'quotestr'. For example, owl_text_quote(in, "+*.", "\") would
--
1.7.4