From e47c1f4f28705307c5a2588a496dc3c046bc55d1 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia-Ripoll Date: Sat, 10 Oct 2020 18:20:16 +0200 Subject: [PATCH 1/3] mu_maildir_get_new_path() did not use the right flags separator when creating new file names. --- lib/mu-maildir.c | 56 +++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/lib/mu-maildir.c b/lib/mu-maildir.c index 07f27377..57f6464b 100644 --- a/lib/mu-maildir.c +++ b/lib/mu-maildir.c @@ -779,12 +779,24 @@ get_new_basename (void) g_get_host_name ()); } +static const char* +get_path_separator(const char *path) +{ + const char *cur; + for (cur = &path[strlen(path)-1]; cur > path; --cur) { + if ((*cur == ':' || *cur == '!' || *cur == ';') && + (cur[1] == '2' && cur[2] == ',')) { + return cur; + } + } + return NULL; +} char* mu_maildir_get_new_path (const char *oldpath, const char *new_mdir, MuFlags newflags, gboolean new_name) { - char *mfile, *mdir, *custom_flags, *newpath, flags_sep = ':'; + char *mfile, *mdir, *custom_flags, *newpath, flags_sep = ':'; g_return_val_if_fail (oldpath, NULL); @@ -795,26 +807,30 @@ mu_maildir_get_new_path (const char *oldpath, const char *new_mdir, if (!mdir) return NULL; - if (new_name) + /* determine the name of the location of the flag separator */ + + if (new_name) { + const char *cur; mfile = get_new_basename (); - else { - /* determine the name of the mailfile, stripped of its flags, as - * well as any custom (non-standard) flags */ - char *cur; - mfile = g_path_get_basename (oldpath); - for (cur = &mfile[strlen(mfile)-1]; cur > mfile; --cur) { - if ((*cur == ':' || *cur == '!' || *cur == ';') && - (cur[1] == '2' && cur[2] == ',')) { - /* get the custom flags (if any) */ - custom_flags = - mu_flags_custom_from_str (cur + 3); - /* preserve the existing flags separator - * in the new file name */ - flags_sep = *cur; - cur[0] = '\0'; /* strip the flags */ - break; - } - } + cur = get_path_separator (oldpath); + if (cur) { + /* preserve the existing flags separator + * in the new file name */ + flags_sep = *cur; + } + } else { + char *cur; + mfile = g_path_get_basename (oldpath); + cur = (char*) get_path_separator (mfile); + if (cur) { + /* get the custom flags (if any) */ + custom_flags = + mu_flags_custom_from_str (cur + 3); + /* preserve the existing flags separator + * in the new file name */ + flags_sep = *cur; + cur[0] = '\0'; /* strip the flags */ + } } newpath = get_new_path (new_mdir ? new_mdir : mdir, From dd14ba64ddb03aadc299f3922a8d26cb7ce414fd Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia-Ripoll Date: Fri, 16 Oct 2020 19:22:52 +0200 Subject: [PATCH 2/3] Fixed indentation and name / type conventions to match original --- lib/mu-maildir.c | 59 +++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/lib/mu-maildir.c b/lib/mu-maildir.c index 57f6464b..b83683f8 100644 --- a/lib/mu-maildir.c +++ b/lib/mu-maildir.c @@ -779,24 +779,24 @@ get_new_basename (void) g_get_host_name ()); } -static const char* -get_path_separator(const char *path) +static char* +find_path_separator(const char *path) { - const char *cur; - for (cur = &path[strlen(path)-1]; cur > path; --cur) { - if ((*cur == ':' || *cur == '!' || *cur == ';') && - (cur[1] == '2' && cur[2] == ',')) { - return cur; + const char *cur; + for (cur = &path[strlen(path)-1]; cur > path; --cur) { + if ((*cur == ':' || *cur == '!' || *cur == ';') && + (cur[1] == '2' && cur[2] == ',')) { + return (char*)cur; + } } - } - return NULL; + return NULL; } char* mu_maildir_get_new_path (const char *oldpath, const char *new_mdir, MuFlags newflags, gboolean new_name) { - char *mfile, *mdir, *custom_flags, *newpath, flags_sep = ':'; + char *mfile, *mdir, *custom_flags, *cur, *newpath, flags_sep = ':'; g_return_val_if_fail (oldpath, NULL); @@ -807,30 +807,27 @@ mu_maildir_get_new_path (const char *oldpath, const char *new_mdir, if (!mdir) return NULL; - /* determine the name of the location of the flag separator */ + /* determine the name of the location of the flag separator */ if (new_name) { - const char *cur; mfile = get_new_basename (); - cur = get_path_separator (oldpath); - if (cur) { - /* preserve the existing flags separator - * in the new file name */ - flags_sep = *cur; - } - } else { - char *cur; - mfile = g_path_get_basename (oldpath); - cur = (char*) get_path_separator (mfile); - if (cur) { - /* get the custom flags (if any) */ - custom_flags = - mu_flags_custom_from_str (cur + 3); - /* preserve the existing flags separator - * in the new file name */ - flags_sep = *cur; - cur[0] = '\0'; /* strip the flags */ - } + cur = find_path_separator (oldpath); + if (cur) { + /* preserve the existing flags separator + * in the new file name */ + flags_sep = *cur; + } + } else { + mfile = g_path_get_basename (oldpath); + cur = find_path_separator (mfile); + if (cur) { + /* get the custom flags (if any) */ + custom_flags = mu_flags_custom_from_str (cur + 3); + /* preserve the existing flags separator + * in the new file name */ + flags_sep = *cur; + cur[0] = '\0'; /* strip the flags */ + } } newpath = get_new_path (new_mdir ? new_mdir : mdir, From fbad4760a4a8d6e268334c8377adc9c750fbd927 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia-Ripoll Date: Fri, 16 Oct 2020 19:34:55 +0200 Subject: [PATCH 3/3] Emacs did not use tabs in indenting mu-maildir.c --- lib/mu-maildir.c | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/mu-maildir.c b/lib/mu-maildir.c index b83683f8..a6bb9a33 100644 --- a/lib/mu-maildir.c +++ b/lib/mu-maildir.c @@ -782,21 +782,21 @@ get_new_basename (void) static char* find_path_separator(const char *path) { - const char *cur; - for (cur = &path[strlen(path)-1]; cur > path; --cur) { - if ((*cur == ':' || *cur == '!' || *cur == ';') && - (cur[1] == '2' && cur[2] == ',')) { - return (char*)cur; - } - } - return NULL; + const char *cur; + for (cur = &path[strlen(path)-1]; cur > path; --cur) { + if ((*cur == ':' || *cur == '!' || *cur == ';') && + (cur[1] == '2' && cur[2] == ',')) { + return (char*)cur; + } + } + return NULL; } char* mu_maildir_get_new_path (const char *oldpath, const char *new_mdir, MuFlags newflags, gboolean new_name) { - char *mfile, *mdir, *custom_flags, *cur, *newpath, flags_sep = ':'; + char *mfile, *mdir, *custom_flags, *cur, *newpath, flags_sep = ':'; g_return_val_if_fail (oldpath, NULL); @@ -811,23 +811,23 @@ mu_maildir_get_new_path (const char *oldpath, const char *new_mdir, if (new_name) { mfile = get_new_basename (); - cur = find_path_separator (oldpath); - if (cur) { - /* preserve the existing flags separator - * in the new file name */ - flags_sep = *cur; - } - } else { - mfile = g_path_get_basename (oldpath); - cur = find_path_separator (mfile); - if (cur) { - /* get the custom flags (if any) */ - custom_flags = mu_flags_custom_from_str (cur + 3); - /* preserve the existing flags separator - * in the new file name */ - flags_sep = *cur; - cur[0] = '\0'; /* strip the flags */ - } + cur = find_path_separator (oldpath); + if (cur) { + /* preserve the existing flags separator + * in the new file name */ + flags_sep = *cur; + } + } else { + mfile = g_path_get_basename (oldpath); + cur = find_path_separator (mfile); + if (cur) { + /* get the custom flags (if any) */ + custom_flags = mu_flags_custom_from_str (cur + 3); + /* preserve the existing flags separator + * in the new file name */ + flags_sep = *cur; + cur[0] = '\0'; /* strip the flags */ + } } newpath = get_new_path (new_mdir ? new_mdir : mdir,