summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-05-29 12:25:51 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-05-29 12:25:51 +0300
commite7397c8fad6835f0af76840074729f6c2cb33e7e (patch)
treebdaa41fac3bfc1a8dee9aecd086a7e10d1a911bd
parent491151b751c965cbb1158588a09aa28cc19921f6 (diff)
downloadmailutils-e7397c8fad6835f0af76840074729f6c2cb33e7e.tar.gz
mailutils-e7397c8fad6835f0af76840074729f6c2cb33e7e.tar.bz2
mh: fix folder +/absolute/name
* mh/folder.c (name_prefix_len): Remove global. (install_folder_info,_scan): Take additional argument: length of the name prefix to skip. (folder_scan): New function. (action_print): Don't impose name prefix unconditionally. Call folder_scan to set it up as necessary.
-rw-r--r--mh/folder.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/mh/folder.c b/mh/folder.c
index 356c3785b..3c0285c0c 100644
--- a/mh/folder.c
+++ b/mh/folder.c
@@ -177,6 +177,5 @@ size_t message_count; /* Total number of messages */
-int name_prefix_len; /* Length of the mu_path_folder_dir */
-
void
-install_folder_info (const char *name, struct folder_info const *info)
+install_folder_info (const char *name, struct folder_info const *info,
+ size_t skip_prefix_len)
{
@@ -184,3 +183,3 @@ install_folder_info (const char *name, struct folder_info const *info)
*new_info = *info;
- new_info->name = mu_strdup (new_info->name + name_prefix_len);
+ new_info->name = mu_strdup (new_info->name + skip_prefix_len);
mu_list_append (folder_info_list, new_info);
@@ -212,3 +211,3 @@ read_seq_file (struct folder_info *info, const char *prefix, const char *name)
static void
-_scan (const char *name, size_t depth)
+_scan (const char *name, size_t depth, size_t skip_prefix_len)
{
@@ -250,3 +249,3 @@ _scan (const char *name, size_t depth)
info.name = (char*) name;
- install_folder_info (name, &info);
+ install_folder_info (name, &info, skip_prefix_len);
closedir (dir);
@@ -279,3 +278,3 @@ _scan (const char *name, size_t depth)
info.others++;
- _scan (p, depth+1);
+ _scan (p, depth+1, skip_prefix_len);
}
@@ -308,3 +307,19 @@ _scan (const char *name, size_t depth)
if (depth > 0)
- install_folder_info (name, &info);
+ install_folder_info (name, &info, skip_prefix_len);
+}
+
+static void
+folder_scan (const char *name, size_t depth)
+{
+ const char *folder_dir = mu_folder_directory ();
+ size_t skip_prefix_len;
+
+ skip_prefix_len = strlen (folder_dir);
+ if (folder_dir[skip_prefix_len - 1] == '/')
+ skip_prefix_len++;
+ if (strncmp (name, folder_dir, skip_prefix_len) == 0)
+ skip_prefix_len++; /* skip past the slash */
+ else
+ skip_prefix_len = 0;
+ _scan (name, depth, skip_prefix_len);
}
@@ -378,10 +393,4 @@ action_print (void)
{
- const char *folder_dir = mu_folder_directory ();
mh_seq_name = mh_global_profile_get ("mh-sequences", MH_SEQUENCES_FILE);
- name_prefix_len = strlen (folder_dir);
- if (folder_dir[name_prefix_len - 1] == '/')
- name_prefix_len++;
- name_prefix_len++; /* skip past the slash */
-
mu_list_create (&folder_info_list);
@@ -390,3 +399,3 @@ action_print (void)
{
- _scan (folder_dir, 0);
+ folder_scan (mu_folder_directory (), 0);
}
@@ -395,3 +404,3 @@ action_print (void)
char *p = mh_expand_name (NULL, mh_current_folder (), NAME_ANY);
- _scan (p, 1);
+ folder_scan (p, 1);
free (p);

Return to:

Send suggestions and report system problems to the System administrator.