Commit e0bf3a5e e0bf3a5e4f6bbf1e500266e81bb2cc626f4ad19e by Sergey Poznyakoff

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.
1 parent d482c65e
......@@ -40,6 +40,8 @@ static struct argp_option options[] = {
"for. In this case the program prints those options from this list that "
"have been defined. It exits with zero status if all of the "
"specified options are defined. Otherwise, the exit status is 1."), 0},
{"verbose", 'v', NULL, 0,
N_("Increase output verbosity"), 0},
{0, 0, 0, 0}
};
......@@ -51,6 +53,7 @@ enum config_mode {
};
enum config_mode mode;
int verbose;
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
......@@ -69,6 +72,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
mode = MODE_INFO;
break;
case 'v':
verbose++;
break;
default:
return ARGP_ERR_UNKNOWN;
}
......@@ -269,7 +276,7 @@ main (int argc, char **argv)
case MODE_INFO:
if (argc == 0)
mu_print_options ();
mu_fprint_options (stdout, verbose);
else
{
int i, found = 0;
......@@ -280,7 +287,7 @@ main (int argc, char **argv)
if (opt)
{
found++;
mu_fprint_conf_option (stdout, opt);
mu_fprint_conf_option (stdout, opt, verbose);
}
}
return found == argc ? 0 : 1;
......
......@@ -33,8 +33,9 @@ struct mu_conf_option
extern char *mu_license_text;
extern void mu_print_options (void);
extern void mu_fprint_options (FILE *fp);
extern void mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt);
extern void mu_fprint_options (FILE *fp, int verbose);
extern void mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt,
int verbose);
extern const struct mu_conf_option *mu_check_option (char *name);
#ifdef __cplusplus
......
......@@ -40,6 +40,8 @@ dirname.c
dirname.h
dup-safer.c
dup2.c
errno.h
errno.in.h
error.c
error.h
exitfail.c
......@@ -138,6 +140,7 @@ stdbool.in.h
stdint.h
stdint.in.h
stdio-impl.h
stdio-write.c
stdio.h
stdio.in.h
stdlib.h
......
......@@ -19,6 +19,7 @@ dup2.m4
eealloc.m4
environ.m4
eoverflow.m4
errno_h.m4
error.m4
exitfail.m4
extensions.m4
......@@ -103,6 +104,7 @@ strnlen.m4
strtok_r.m4
sys_stat_h.m4
sysexits.m4
threadlib.m4
unistd-safer.m4
unistd_h.m4
vasnprintf.m4
......
......@@ -159,7 +159,7 @@ argcv_scan (struct argcv_info *ap)
return ap->save;
}
static char quote_transtab[] = "\\\\a\ab\bf\fn\nr\rt\t";
static char quote_transtab[] = "\\\\\"\"a\ab\bf\fn\nr\rt\t";
int
argcv_unquote_char (int c)
......
......@@ -693,6 +693,8 @@ mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val,
int (*fun) (mu_debug_t, const char *, void *),
void *data)
{
int rc = 0;
switch (val->type)
{
case MU_CFG_STRING:
......@@ -723,10 +725,14 @@ mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val,
mu_config_value_t *pval;
mu_iterator_current (itr, (void*) &pval);
if (mu_cfg_assert_value_type (pval, MU_CFG_STRING, debug))
{
rc = 1;
break;
}
fun (debug, pval->v.string, data);
}
mu_iterator_destroy (&itr);
}
}
return 0;
return rc;
}
......
......@@ -101,7 +101,7 @@ P [1-9][0-9]*
yylval.string = _mu_line_finish ();
return MU_TOK_IDENT; }
/* Strings */
[a-zA-Z0-9_\./:-]+ { _mu_line_begin ();
[a-zA-Z0-9_\./:\*=-]+ { _mu_line_begin ();
_mu_line_add (yytext, yyleng);
yylval.string = _mu_line_finish ();
return MU_TOK_STRING; }
......@@ -149,7 +149,14 @@ P [1-9][0-9]*
/* Other tokens */
\n { mu_cfg_locus.line++; }
[,;{}()] return yytext[0];
. mu_cfg_perror (&mu_cfg_locus, _("stray character \\%03o"), yytext[0]);
. { if (isascii (yytext[0]) && isprint (yytext[0]))
mu_cfg_perror (&mu_cfg_locus,
_("stray character %c"), yytext[0]);
else
mu_cfg_perror (&mu_cfg_locus,
_("stray character \\%03o"),
(unsigned char) yytext[0]);
}
%%
int
......@@ -164,7 +171,7 @@ unescape_to_line (int c)
if (c != '\n')
{
char t = mu_argcv_unquote_char (c);
if (t == c)
if (t == c && t != '\\' && t != '\"')
mu_cfg_perror (&mu_cfg_locus, _("unknown escape sequence '\\%c'"), c);
mu_opool_append_char (pool, t);
}
......
......@@ -127,27 +127,27 @@ static struct mu_conf_option mu_conf_option[] = {
};
void
mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt)
mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt, int verbose)
{
fprintf (fp, "%s", opt->name);
if (opt->descr)
fprintf (fp, "\t- %s", _(opt->descr));
if (verbose && opt->descr)
fprintf (fp, " \t- %s", _(opt->descr));
fputc('\n', fp);
}
void
mu_fprint_options (FILE *fp)
mu_fprint_options (FILE *fp, int verbose)
{
int i;
for (i = 0; mu_conf_option[i].name; i++)
mu_fprint_conf_option (fp, mu_conf_option + i);
mu_fprint_conf_option (fp, mu_conf_option + i, verbose);
}
void
mu_print_options ()
{
mu_fprint_options (stdout);
mu_fprint_options (stdout, 1);
}
const struct mu_conf_option *
......
......@@ -372,7 +372,7 @@ proc mu_version {} {
set output [remote_exec host "$MU_TOOL --show-config-options"]
set flg [split [lindex $output 1] "\n"]
for {set i 0} {$i < [llength $flg]} {incr i} {
regsub "(\t.*)?\r" [lindex $flg $i] "" string
regsub "( .*)?\r" [lindex $flg $i] "" string
if [regexp "(.*)=(.*)" $string var name value] {
set MU_CAPABILITY($name) $value
} elseif {$string != ""} {
......