Bugfixes.
* config/mailutils-config.c (main): Do not print flag descriptions on --info, this breaks existing scripts. New option --verbose makes --info print verbose descriptions. * include/mailutils/version.h (mu_fprint_options) (mu_fprint_conf_option): Take additional argument. * mailbox/argcv.c (quote_transtab): Handle \". * mailbox/cfg_driver.c (mu_cfg_string_value_cb): Bugfix * mailbox/cfg_lexer.l: Allow * and = in non-quoted words. Improve 'stray character' diagnostics'. (unescape_to_line): Handle \\ and \". * mailbox/version.c (mu_fprint_options) (mu_fprint_conf_option): New argument `verbose' instructs whether to print textual descriptions. (mu_fprint_conf_option): Print single space after the flag to facilitate writing parser scripts. * testsuite/lib/mailutils.exp: Reflect this change.
Showing
9 changed files
with
43 additions
and
17 deletions
... | @@ -40,6 +40,8 @@ static struct argp_option options[] = { | ... | @@ -40,6 +40,8 @@ static struct argp_option options[] = { |
40 | "for. In this case the program prints those options from this list that " | 40 | "for. In this case the program prints those options from this list that " |
41 | "have been defined. It exits with zero status if all of the " | 41 | "have been defined. It exits with zero status if all of the " |
42 | "specified options are defined. Otherwise, the exit status is 1."), 0}, | 42 | "specified options are defined. Otherwise, the exit status is 1."), 0}, |
43 | {"verbose", 'v', NULL, 0, | ||
44 | N_("Increase output verbosity"), 0}, | ||
43 | {0, 0, 0, 0} | 45 | {0, 0, 0, 0} |
44 | }; | 46 | }; |
45 | 47 | ||
... | @@ -51,6 +53,7 @@ enum config_mode { | ... | @@ -51,6 +53,7 @@ enum config_mode { |
51 | }; | 53 | }; |
52 | 54 | ||
53 | enum config_mode mode; | 55 | enum config_mode mode; |
56 | int verbose; | ||
54 | 57 | ||
55 | static error_t | 58 | static error_t |
56 | parse_opt (int key, char *arg, struct argp_state *state) | 59 | parse_opt (int key, char *arg, struct argp_state *state) |
... | @@ -68,6 +71,10 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -68,6 +71,10 @@ parse_opt (int key, char *arg, struct argp_state *state) |
68 | case 'i': | 71 | case 'i': |
69 | mode = MODE_INFO; | 72 | mode = MODE_INFO; |
70 | break; | 73 | break; |
74 | |||
75 | case 'v': | ||
76 | verbose++; | ||
77 | break; | ||
71 | 78 | ||
72 | default: | 79 | default: |
73 | return ARGP_ERR_UNKNOWN; | 80 | return ARGP_ERR_UNKNOWN; |
... | @@ -269,7 +276,7 @@ main (int argc, char **argv) | ... | @@ -269,7 +276,7 @@ main (int argc, char **argv) |
269 | 276 | ||
270 | case MODE_INFO: | 277 | case MODE_INFO: |
271 | if (argc == 0) | 278 | if (argc == 0) |
272 | mu_print_options (); | 279 | mu_fprint_options (stdout, verbose); |
273 | else | 280 | else |
274 | { | 281 | { |
275 | int i, found = 0; | 282 | int i, found = 0; |
... | @@ -280,7 +287,7 @@ main (int argc, char **argv) | ... | @@ -280,7 +287,7 @@ main (int argc, char **argv) |
280 | if (opt) | 287 | if (opt) |
281 | { | 288 | { |
282 | found++; | 289 | found++; |
283 | mu_fprint_conf_option (stdout, opt); | 290 | mu_fprint_conf_option (stdout, opt, verbose); |
284 | } | 291 | } |
285 | } | 292 | } |
286 | return found == argc ? 0 : 1; | 293 | return found == argc ? 0 : 1; | ... | ... |
... | @@ -33,8 +33,9 @@ struct mu_conf_option | ... | @@ -33,8 +33,9 @@ struct mu_conf_option |
33 | 33 | ||
34 | extern char *mu_license_text; | 34 | extern char *mu_license_text; |
35 | extern void mu_print_options (void); | 35 | extern void mu_print_options (void); |
36 | extern void mu_fprint_options (FILE *fp); | 36 | extern void mu_fprint_options (FILE *fp, int verbose); |
37 | extern void mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt); | 37 | extern void mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt, |
38 | int verbose); | ||
38 | extern const struct mu_conf_option *mu_check_option (char *name); | 39 | extern const struct mu_conf_option *mu_check_option (char *name); |
39 | 40 | ||
40 | #ifdef __cplusplus | 41 | #ifdef __cplusplus | ... | ... |
... | @@ -40,6 +40,8 @@ dirname.c | ... | @@ -40,6 +40,8 @@ dirname.c |
40 | dirname.h | 40 | dirname.h |
41 | dup-safer.c | 41 | dup-safer.c |
42 | dup2.c | 42 | dup2.c |
43 | errno.h | ||
44 | errno.in.h | ||
43 | error.c | 45 | error.c |
44 | error.h | 46 | error.h |
45 | exitfail.c | 47 | exitfail.c |
... | @@ -138,6 +140,7 @@ stdbool.in.h | ... | @@ -138,6 +140,7 @@ stdbool.in.h |
138 | stdint.h | 140 | stdint.h |
139 | stdint.in.h | 141 | stdint.in.h |
140 | stdio-impl.h | 142 | stdio-impl.h |
143 | stdio-write.c | ||
141 | stdio.h | 144 | stdio.h |
142 | stdio.in.h | 145 | stdio.in.h |
143 | stdlib.h | 146 | stdlib.h | ... | ... |
... | @@ -19,6 +19,7 @@ dup2.m4 | ... | @@ -19,6 +19,7 @@ dup2.m4 |
19 | eealloc.m4 | 19 | eealloc.m4 |
20 | environ.m4 | 20 | environ.m4 |
21 | eoverflow.m4 | 21 | eoverflow.m4 |
22 | errno_h.m4 | ||
22 | error.m4 | 23 | error.m4 |
23 | exitfail.m4 | 24 | exitfail.m4 |
24 | extensions.m4 | 25 | extensions.m4 |
... | @@ -103,6 +104,7 @@ strnlen.m4 | ... | @@ -103,6 +104,7 @@ strnlen.m4 |
103 | strtok_r.m4 | 104 | strtok_r.m4 |
104 | sys_stat_h.m4 | 105 | sys_stat_h.m4 |
105 | sysexits.m4 | 106 | sysexits.m4 |
107 | threadlib.m4 | ||
106 | unistd-safer.m4 | 108 | unistd-safer.m4 |
107 | unistd_h.m4 | 109 | unistd_h.m4 |
108 | vasnprintf.m4 | 110 | vasnprintf.m4 | ... | ... |
... | @@ -159,7 +159,7 @@ argcv_scan (struct argcv_info *ap) | ... | @@ -159,7 +159,7 @@ argcv_scan (struct argcv_info *ap) |
159 | return ap->save; | 159 | return ap->save; |
160 | } | 160 | } |
161 | 161 | ||
162 | static char quote_transtab[] = "\\\\a\ab\bf\fn\nr\rt\t"; | 162 | static char quote_transtab[] = "\\\\\"\"a\ab\bf\fn\nr\rt\t"; |
163 | 163 | ||
164 | int | 164 | int |
165 | argcv_unquote_char (int c) | 165 | argcv_unquote_char (int c) | ... | ... |
... | @@ -693,6 +693,8 @@ mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val, | ... | @@ -693,6 +693,8 @@ mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val, |
693 | int (*fun) (mu_debug_t, const char *, void *), | 693 | int (*fun) (mu_debug_t, const char *, void *), |
694 | void *data) | 694 | void *data) |
695 | { | 695 | { |
696 | int rc = 0; | ||
697 | |||
696 | switch (val->type) | 698 | switch (val->type) |
697 | { | 699 | { |
698 | case MU_CFG_STRING: | 700 | case MU_CFG_STRING: |
... | @@ -723,10 +725,14 @@ mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val, | ... | @@ -723,10 +725,14 @@ mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val, |
723 | mu_config_value_t *pval; | 725 | mu_config_value_t *pval; |
724 | mu_iterator_current (itr, (void*) &pval); | 726 | mu_iterator_current (itr, (void*) &pval); |
725 | if (mu_cfg_assert_value_type (pval, MU_CFG_STRING, debug)) | 727 | if (mu_cfg_assert_value_type (pval, MU_CFG_STRING, debug)) |
726 | fun (debug, pval->v.string, data); | 728 | { |
729 | rc = 1; | ||
730 | break; | ||
731 | } | ||
732 | fun (debug, pval->v.string, data); | ||
727 | } | 733 | } |
728 | mu_iterator_destroy (&itr); | 734 | mu_iterator_destroy (&itr); |
729 | } | 735 | } |
730 | } | 736 | } |
731 | return 0; | 737 | return rc; |
732 | } | 738 | } | ... | ... |
... | @@ -101,7 +101,7 @@ P [1-9][0-9]* | ... | @@ -101,7 +101,7 @@ P [1-9][0-9]* |
101 | yylval.string = _mu_line_finish (); | 101 | yylval.string = _mu_line_finish (); |
102 | return MU_TOK_IDENT; } | 102 | return MU_TOK_IDENT; } |
103 | /* Strings */ | 103 | /* Strings */ |
104 | [a-zA-Z0-9_\./:-]+ { _mu_line_begin (); | 104 | [a-zA-Z0-9_\./:\*=-]+ { _mu_line_begin (); |
105 | _mu_line_add (yytext, yyleng); | 105 | _mu_line_add (yytext, yyleng); |
106 | yylval.string = _mu_line_finish (); | 106 | yylval.string = _mu_line_finish (); |
107 | return MU_TOK_STRING; } | 107 | return MU_TOK_STRING; } |
... | @@ -149,7 +149,14 @@ P [1-9][0-9]* | ... | @@ -149,7 +149,14 @@ P [1-9][0-9]* |
149 | /* Other tokens */ | 149 | /* Other tokens */ |
150 | \n { mu_cfg_locus.line++; } | 150 | \n { mu_cfg_locus.line++; } |
151 | [,;{}()] return yytext[0]; | 151 | [,;{}()] return yytext[0]; |
152 | . mu_cfg_perror (&mu_cfg_locus, _("stray character \\%03o"), yytext[0]); | 152 | . { if (isascii (yytext[0]) && isprint (yytext[0])) |
153 | mu_cfg_perror (&mu_cfg_locus, | ||
154 | _("stray character %c"), yytext[0]); | ||
155 | else | ||
156 | mu_cfg_perror (&mu_cfg_locus, | ||
157 | _("stray character \\%03o"), | ||
158 | (unsigned char) yytext[0]); | ||
159 | } | ||
153 | %% | 160 | %% |
154 | 161 | ||
155 | int | 162 | int |
... | @@ -164,7 +171,7 @@ unescape_to_line (int c) | ... | @@ -164,7 +171,7 @@ unescape_to_line (int c) |
164 | if (c != '\n') | 171 | if (c != '\n') |
165 | { | 172 | { |
166 | char t = mu_argcv_unquote_char (c); | 173 | char t = mu_argcv_unquote_char (c); |
167 | if (t == c) | 174 | if (t == c && t != '\\' && t != '\"') |
168 | mu_cfg_perror (&mu_cfg_locus, _("unknown escape sequence '\\%c'"), c); | 175 | mu_cfg_perror (&mu_cfg_locus, _("unknown escape sequence '\\%c'"), c); |
169 | mu_opool_append_char (pool, t); | 176 | mu_opool_append_char (pool, t); |
170 | } | 177 | } | ... | ... |
... | @@ -127,27 +127,27 @@ static struct mu_conf_option mu_conf_option[] = { | ... | @@ -127,27 +127,27 @@ static struct mu_conf_option mu_conf_option[] = { |
127 | }; | 127 | }; |
128 | 128 | ||
129 | void | 129 | void |
130 | mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt) | 130 | mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt, int verbose) |
131 | { | 131 | { |
132 | fprintf (fp, "%s", opt->name); | 132 | fprintf (fp, "%s", opt->name); |
133 | if (opt->descr) | 133 | if (verbose && opt->descr) |
134 | fprintf (fp, "\t- %s", _(opt->descr)); | 134 | fprintf (fp, " \t- %s", _(opt->descr)); |
135 | fputc('\n', fp); | 135 | fputc('\n', fp); |
136 | } | 136 | } |
137 | 137 | ||
138 | void | 138 | void |
139 | mu_fprint_options (FILE *fp) | 139 | mu_fprint_options (FILE *fp, int verbose) |
140 | { | 140 | { |
141 | int i; | 141 | int i; |
142 | 142 | ||
143 | for (i = 0; mu_conf_option[i].name; i++) | 143 | for (i = 0; mu_conf_option[i].name; i++) |
144 | mu_fprint_conf_option (fp, mu_conf_option + i); | 144 | mu_fprint_conf_option (fp, mu_conf_option + i, verbose); |
145 | } | 145 | } |
146 | 146 | ||
147 | void | 147 | void |
148 | mu_print_options () | 148 | mu_print_options () |
149 | { | 149 | { |
150 | mu_fprint_options (stdout); | 150 | mu_fprint_options (stdout, 1); |
151 | } | 151 | } |
152 | 152 | ||
153 | const struct mu_conf_option * | 153 | const struct mu_conf_option * | ... | ... |
... | @@ -372,7 +372,7 @@ proc mu_version {} { | ... | @@ -372,7 +372,7 @@ proc mu_version {} { |
372 | set output [remote_exec host "$MU_TOOL --show-config-options"] | 372 | set output [remote_exec host "$MU_TOOL --show-config-options"] |
373 | set flg [split [lindex $output 1] "\n"] | 373 | set flg [split [lindex $output 1] "\n"] |
374 | for {set i 0} {$i < [llength $flg]} {incr i} { | 374 | for {set i 0} {$i < [llength $flg]} {incr i} { |
375 | regsub "(\t.*)?\r" [lindex $flg $i] "" string | 375 | regsub "( .*)?\r" [lindex $flg $i] "" string |
376 | if [regexp "(.*)=(.*)" $string var name value] { | 376 | if [regexp "(.*)=(.*)" $string var name value] { |
377 | set MU_CAPABILITY($name) $value | 377 | set MU_CAPABILITY($name) $value |
378 | } elseif {$string != ""} { | 378 | } elseif {$string != ""} { | ... | ... |
-
Please register or sign in to post a comment