Further improvements in `mail'.
* NEWS: Update. * mail/mail.h (MOPTF_UNSET): New constant. * mail/mailvar.c (MAILVAR_TYPEMASK): New define. (struct mailvar_symbol): Remove `type'. Add `handler'. The latter supplies special handling for certain variables. (mailvar_tab): Update accordingly. Implement "debug" variable. (mailvar_set): Enforce correct variable type in variable-strict mode. Handle MOPTF_UNSET flag. Remove kludgy special handling for some attributes, use sym->handler instead. (set_decode_fallback, set_replyregex) (set_screen, set_mailbox_debug_level, set_debug): New functions. (describe_symbol): Handle alternative symbol types. * mail/set.c: Use MOPTF_UNSET when unsetting the variable. * mail/source.c: Set correct locus. This allows to display locations along with error messages.
Showing
5 changed files
with
25 additions
and
8 deletions
... | @@ -47,7 +47,14 @@ In addition, the form | ... | @@ -47,7 +47,14 @@ In addition, the form |
47 | mail --file=mymbox | 47 | mail --file=mymbox |
48 | 48 | ||
49 | is also allowed. | 49 | is also allowed. |
50 | 50 | ||
51 | ** error locations | ||
52 | |||
53 | Diagnostic messages issued while processing `source' command | ||
54 | include file locations, in compliance with the GNU standards. This | ||
55 | also includes diagnostics issued during processing of the | ||
56 | system or user configuration file. | ||
57 | |||
51 | ** envelope command | 58 | ** envelope command |
52 | 59 | ||
53 | The env[elope] command displays the SMTP envelopes of the messages | 60 | The env[elope] command displays the SMTP envelopes of the messages | ... | ... |
... | @@ -344,6 +344,7 @@ extern void mailvar_variable_format (FILE *fp, | ... | @@ -344,6 +344,7 @@ extern void mailvar_variable_format (FILE *fp, |
344 | 344 | ||
345 | #define MOPTF_OVERWRITE 0x001 | 345 | #define MOPTF_OVERWRITE 0x001 |
346 | #define MOPTF_QUIET 0x002 | 346 | #define MOPTF_QUIET 0x002 |
347 | #define MOPTF_UNSET 0x004 | ||
347 | extern int mailvar_set (const char *name, void *value, | 348 | extern int mailvar_set (const char *name, void *value, |
348 | enum mailvar_type type, int flags); | 349 | enum mailvar_type type, int flags); |
349 | extern int util_isdeleted (size_t msgno); | 350 | extern int util_isdeleted (size_t msgno); | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -48,7 +48,8 @@ mail_set (int argc, char **argv) | ... | @@ -48,7 +48,8 @@ mail_set (int argc, char **argv) |
48 | 48 | ||
49 | if (!strncmp ("no", argv[i], 2) && !value) | 49 | if (!strncmp ("no", argv[i], 2) && !value) |
50 | { | 50 | { |
51 | mailvar_set (&argv[i][2], NULL, mailvar_type_boolean, flags); | 51 | mailvar_set (&argv[i][2], NULL, mailvar_type_boolean, |
52 | flags | MOPTF_UNSET); | ||
52 | } | 53 | } |
53 | else if (value) | 54 | else if (value) |
54 | { | 55 | { | ... | ... |
... | @@ -18,21 +18,25 @@ | ... | @@ -18,21 +18,25 @@ |
18 | 18 | ||
19 | #include "mail.h" | 19 | #include "mail.h" |
20 | 20 | ||
21 | |||
22 | static char * | 21 | static char * |
23 | source_readline (void *closure, int cont MU_ARG_UNUSED) | 22 | source_readline (void *closure, int cont MU_ARG_UNUSED) |
24 | { | 23 | { |
25 | FILE *fp = closure; | 24 | FILE *fp = closure; |
26 | size_t s = 0; | 25 | size_t s = 0; |
27 | char *buf = NULL; | 26 | char *buf = NULL; |
27 | mu_debug_t debug; | ||
28 | struct mu_debug_locus locus; | ||
28 | 29 | ||
29 | if (getline (&buf, &s, fp) >= 0) | 30 | if (getline (&buf, &s, fp) >= 0) |
30 | { | 31 | { |
31 | int len = strlen (buf); | 32 | mu_rtrim_class (buf, MU_CTYPE_SPACE); |
32 | if (buf[len-1] == '\n') | 33 | |
33 | buf[len-1] = '\0'; | 34 | mu_diag_get_debug (&debug); |
35 | mu_debug_get_locus (debug, &locus); | ||
36 | mu_debug_set_locus (debug, locus.file, locus.line + 1); | ||
34 | return buf; | 37 | return buf; |
35 | } | 38 | } |
39 | |||
36 | return NULL; | 40 | return NULL; |
37 | } | 41 | } |
38 | 42 | ||
... | @@ -45,11 +49,12 @@ mail_source (int argc, char **argv) | ... | @@ -45,11 +49,12 @@ mail_source (int argc, char **argv) |
45 | { | 49 | { |
46 | FILE *fp; | 50 | FILE *fp; |
47 | int save_term; | 51 | int save_term; |
52 | mu_debug_t debug; | ||
48 | 53 | ||
49 | if (argc != 2) | 54 | if (argc != 2) |
50 | { | 55 | { |
51 | /* TRANSLATORS: 'source' is a command name. Do not translate it! */ | 56 | /* TRANSLATORS: 'source' is a command name. Do not translate it! */ |
52 | util_error (_("source requires an argument")); | 57 | util_error (_("source requires a single argument")); |
53 | return 1; | 58 | return 1; |
54 | } | 59 | } |
55 | 60 | ||
... | @@ -63,8 +68,11 @@ mail_source (int argc, char **argv) | ... | @@ -63,8 +68,11 @@ mail_source (int argc, char **argv) |
63 | 68 | ||
64 | save_term = interactive; | 69 | save_term = interactive; |
65 | interactive = 0; | 70 | interactive = 0; |
66 | mail_mainloop(source_readline, fp, 0); | 71 | mu_diag_get_debug (&debug); |
72 | mu_debug_set_locus (debug, argv[1], 0); | ||
73 | mail_mainloop (source_readline, fp, 0); | ||
67 | interactive = save_term; | 74 | interactive = save_term; |
75 | mu_debug_set_locus (debug, NULL, 0); | ||
68 | fclose (fp); | 76 | fclose (fp); |
69 | return 0; | 77 | return 0; |
70 | } | 78 | } | ... | ... |
-
Please register or sign in to post a comment