[evolution-data-server/gnome-2-30] Simplify relationship between full and path names for imapx
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-2-30] Simplify relationship between full and path names for imapx
- Date: Mon, 28 Jun 2010 19:35:57 +0000 (UTC)
commit dad074d2c676646550800a52091c87ffa8be8081
Author: David Woodhouse <David Woodhouse intel com>
Date: Thu Jun 24 00:17:58 2010 +0100
Simplify relationship between full and path names for imapx
There seems to be no point in the %25-style escapes, which we were applying
in full_to_path() only if dir_sep != '/', and then reversing in path_to_full()
unconditionally. Instead, just swap dir_sep with '/'. Aside from simplifying
the code, this also means that the path displayed to the user will be as close
as possible to the real name -- it means that my "be nasty to imapx" test
folder called fish"%sd is displayed properly, instead of as fish"%25sd.
(cherry picked from commit d700a9fbffa73f3017cb0e49ba2c5a66a102e80a)
camel/providers/imapx/camel-imapx-store-summary.c | 71 ++++++---------------
1 files changed, 20 insertions(+), 51 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-store-summary.c b/camel/providers/imapx/camel-imapx-store-summary.c
index 6ee84e7..df313c6 100644
--- a/camel/providers/imapx/camel-imapx-store-summary.c
+++ b/camel/providers/imapx/camel-imapx-store-summary.c
@@ -171,44 +171,26 @@ gchar *
camel_imapx_store_summary_full_to_path(CamelIMAPXStoreSummary *s, const gchar *full_name, gchar dir_sep)
{
gchar *path, *p;
- gint c;
- const gchar *f;
+
+ p = path = g_strdup(full_name);
if (dir_sep != '/') {
- p = path = alloca(strlen(full_name)*3+1);
- f = full_name;
- while ((c = *f++ & 0xff)) {
- if (c == dir_sep)
- *p++ = '/';
- else if (c == '/' || c == '%')
- p += sprintf(p, "%%%02X", c);
- else
- *p++ = c;
+ while (*p) {
+ if (*p == '/')
+ *p = dir_sep;
+ else if (*p == dir_sep)
+ *p = '/';
+ p++;
}
- *p = 0;
- } else
- path = (gchar *)full_name;
-
- return g_strdup(path);
-}
-
-static guint32 hexnib(guint32 c)
-{
- if (c >= '0' && c <= '9')
- return c-'0';
- else if (c>='A' && c <= 'Z')
- return c-'A'+10;
- else
- return 0;
+ }
+ return path;
}
gchar *
camel_imapx_store_summary_path_to_full(CamelIMAPXStoreSummary *s, const gchar *path, gchar dir_sep)
{
gchar *full, *f;
- guint32 c, v = 0;
const gchar *p;
- gint state=0;
gchar *subpath, *last = NULL;
CamelStoreInfo *si;
CamelIMAPXStoreNamespace *ns;
@@ -234,7 +216,6 @@ camel_imapx_store_summary_path_to_full(CamelIMAPXStoreSummary *s, const gchar *p
ns = camel_imapx_store_summary_namespace_find_path(s, path);
- f = full = alloca(strlen(path)*2+1);
if (si)
p = path + strlen(subpath);
else if (ns)
@@ -242,32 +223,20 @@ camel_imapx_store_summary_path_to_full(CamelIMAPXStoreSummary *s, const gchar *p
else
p = path;
- while ((c = camel_utf8_getc((const guchar **)&p))) {
- switch (state) {
- case 0:
- if (c == '%')
- state = 1;
- else {
- if (c == '/')
- c = dir_sep;
- camel_utf8_putc((guchar **) &f, c);
- }
- break;
- case 1:
- state = 2;
- v = hexnib(c)<<4;
- break;
- case 2:
- state = 0;
- v |= hexnib(c);
- camel_utf8_putc((guchar **) &f, v);
- break;
+ printf("p is '%s'\n", p);
+ f = full = g_strdup(p);
+ if (dir_sep != '/') {
+ while (*f) {
+ if (*f == '/')
+ *f = dir_sep;
+ else if (*f == dir_sep)
+ *f = '/';
+ f++;
}
}
- camel_utf8_putc((guchar **) &f, c);
/* merge old path part if required */
- f = g_strdup(full);
+ f = full;
if (si) {
full = g_strdup_printf("%s%s", camel_imapx_store_info_full_name(s, si), f);
g_free(f);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]