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.
Showing
2 changed files
with
27 additions
and
27 deletions
... | @@ -268,45 +268,30 @@ user_mailbox_name (const char *user, char **mailbox_name) | ... | @@ -268,45 +268,30 @@ user_mailbox_name (const char *user, char **mailbox_name) |
268 | static int | 268 | static int |
269 | plus_expand (const char *file, char **buf) | 269 | plus_expand (const char *file, char **buf) |
270 | { | 270 | { |
271 | char *user = NULL; | ||
272 | char *path = NULL; | ||
273 | char *home; | 271 | char *home; |
274 | const char *folder_dir = mu_folder_directory (); | 272 | const char *folder_dir = mu_folder_directory (); |
275 | int status, len; | 273 | int status, len; |
276 | |||
277 | if ((status = split_shortcut (file, "+=", &path, &user))) | ||
278 | return status; | ||
279 | 274 | ||
280 | if (!path) | 275 | home = get_homedir (NULL); |
281 | { | ||
282 | free (user); | ||
283 | return ENOENT; | ||
284 | } | ||
285 | |||
286 | home = get_homedir (user); | ||
287 | if (!home) | 276 | if (!home) |
288 | { | 277 | return ENOENT; |
289 | free (user); | 278 | |
290 | free (path); | 279 | file++; |
291 | return ENOENT; | 280 | |
292 | } | ||
293 | |||
294 | if (folder_dir[0] == '/' || mu_is_proto (folder_dir)) | 281 | if (folder_dir[0] == '/' || mu_is_proto (folder_dir)) |
295 | { | 282 | { |
296 | len = strlen (folder_dir) + strlen (path) + 2; | 283 | len = strlen (folder_dir) + strlen (file) + 2; |
297 | *buf = malloc (len); | 284 | *buf = malloc (len); |
298 | sprintf (*buf, "%s/%s", folder_dir, path); | 285 | sprintf (*buf, "%s/%s", folder_dir, file); |
299 | } | 286 | } |
300 | else | 287 | else |
301 | { | 288 | { |
302 | len = strlen (home) + strlen (folder_dir) + strlen (path) + 3; | 289 | len = strlen (home) + strlen (folder_dir) + strlen (file) + 3; |
303 | *buf = malloc (len); | 290 | *buf = malloc (len); |
304 | sprintf (*buf, "%s/%s/%s", home, folder_dir, path); | 291 | sprintf (*buf, "%s/%s/%s", home, folder_dir, file); |
305 | } | 292 | } |
306 | (*buf)[len-1] = 0; | 293 | (*buf)[len-1] = 0; |
307 | 294 | ||
308 | free (user); | ||
309 | free (path); | ||
310 | free (home); | 295 | free (home); |
311 | return 0; | 296 | return 0; |
312 | } | 297 | } | ... | ... |
... | @@ -321,10 +321,10 @@ print_string (struct mh_machine *mach, size_t width, char *str) | ... | @@ -321,10 +321,10 @@ print_string (struct mh_machine *mach, size_t width, char *str) |
321 | } | 321 | } |
322 | 322 | ||
323 | static void | 323 | static void |
324 | print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str) | 324 | print_fmt_segment (struct mh_machine *mach, size_t fmtwidth, char *str, |
325 | size_t len) | ||
325 | { | 326 | { |
326 | size_t len = strlen (str); | 327 | size_t width = mbsnlen (str, len); |
327 | size_t width = mbslen (str); | ||
328 | 328 | ||
329 | if (fmtwidth && width > fmtwidth) | 329 | if (fmtwidth && width > fmtwidth) |
330 | { | 330 | { |
... | @@ -346,6 +346,21 @@ print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str) | ... | @@ -346,6 +346,21 @@ print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str) |
346 | } | 346 | } |
347 | 347 | ||
348 | static void | 348 | static void |
349 | print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str) | ||
350 | { | ||
351 | char *p = strchr (str, '\n'); | ||
352 | while (p) | ||
353 | { | ||
354 | print_fmt_segment (mach, fmtwidth, str, p - str + 1); | ||
355 | mach->ind = 0; | ||
356 | str = p + 1; | ||
357 | p = strchr (str, '\n'); | ||
358 | } | ||
359 | if (str[0]) | ||
360 | print_fmt_segment (mach, fmtwidth, str, strlen (str)); | ||
361 | } | ||
362 | |||
363 | static void | ||
349 | reset_fmt_defaults (struct mh_machine *mach) | 364 | reset_fmt_defaults (struct mh_machine *mach) |
350 | { | 365 | { |
351 | const char *p; | 366 | const char *p; | ... | ... |
-
Please register or sign in to post a comment