Commit 68447ef0 68447ef06f4752ebaf1d47e4f93d2791153459c9 by Sergey Poznyakoff

MH-related bugfixes.

* mailbox/mbx_default.c (plus_expand): Do not treat the part
between initial + and / as user name.
* mh/mh_format.c (print_fmt_segment): New function.
(print_fmt_string): Correctly handle multi-line inputs.
1 parent c0e1fc82
......@@ -268,45 +268,30 @@ user_mailbox_name (const char *user, char **mailbox_name)
static int
plus_expand (const char *file, char **buf)
{
char *user = NULL;
char *path = NULL;
char *home;
const char *folder_dir = mu_folder_directory ();
int status, len;
if ((status = split_shortcut (file, "+=", &path, &user)))
return status;
if (!path)
{
free (user);
return ENOENT;
}
home = get_homedir (user);
home = get_homedir (NULL);
if (!home)
{
free (user);
free (path);
return ENOENT;
}
return ENOENT;
file++;
if (folder_dir[0] == '/' || mu_is_proto (folder_dir))
{
len = strlen (folder_dir) + strlen (path) + 2;
len = strlen (folder_dir) + strlen (file) + 2;
*buf = malloc (len);
sprintf (*buf, "%s/%s", folder_dir, path);
sprintf (*buf, "%s/%s", folder_dir, file);
}
else
{
len = strlen (home) + strlen (folder_dir) + strlen (path) + 3;
len = strlen (home) + strlen (folder_dir) + strlen (file) + 3;
*buf = malloc (len);
sprintf (*buf, "%s/%s/%s", home, folder_dir, path);
sprintf (*buf, "%s/%s/%s", home, folder_dir, file);
}
(*buf)[len-1] = 0;
free (user);
free (path);
free (home);
return 0;
}
......
......@@ -321,10 +321,10 @@ print_string (struct mh_machine *mach, size_t width, char *str)
}
static void
print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str)
print_fmt_segment (struct mh_machine *mach, size_t fmtwidth, char *str,
size_t len)
{
size_t len = strlen (str);
size_t width = mbslen (str);
size_t width = mbsnlen (str, len);
if (fmtwidth && width > fmtwidth)
{
......@@ -346,6 +346,21 @@ print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str)
}
static void
print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str)
{
char *p = strchr (str, '\n');
while (p)
{
print_fmt_segment (mach, fmtwidth, str, p - str + 1);
mach->ind = 0;
str = p + 1;
p = strchr (str, '\n');
}
if (str[0])
print_fmt_segment (mach, fmtwidth, str, strlen (str));
}
static void
reset_fmt_defaults (struct mh_machine *mach)
{
const char *p;
......