diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-06-29 16:15:25 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-06-29 16:18:14 +0300 |
commit | 7dbe959d8394c5c9336370cc0772989802989d8a (patch) | |
tree | fb75532e2817cc91ccc515f8281a2ae002915848 | |
parent | 0a55a54a348c76828a345c1b9cd815be84969f62 (diff) | |
download | mailutils-7dbe959d8394c5c9336370cc0772989802989d8a.tar.gz mailutils-7dbe959d8394c5c9336370cc0772989802989d8a.tar.bz2 |
Add special flag for debugging MH format parser
* mh/mh.h (MH_FMT_PARSE_DEBUG): New flag.
* mh/fmtcheck.c: Pass the MH_FMT_PARSE_DEBUG flag, if
required.
* mh/mh_fmtgram.y (mh_format_debug): Remove.
(format_parse): Enable debugging if MH_FMT_PARSE_DEBUG flag is set
-rw-r--r-- | mh/fmtcheck.c | 12 | ||||
-rw-r--r-- | mh/mh.h | 2 | ||||
-rw-r--r-- | mh/mh_fmtgram.y | 10 |
3 files changed, 8 insertions, 16 deletions
diff --git a/mh/fmtcheck.c b/mh/fmtcheck.c index 89eb9c993..3a90c8b9b 100644 --- a/mh/fmtcheck.c +++ b/mh/fmtcheck.c @@ -103,18 +103,16 @@ main (int argc, char **argv) return 1; } - mh_format_debug (debug_option); if (!format_str) { mu_error (_("Format string not specified")); return 1; } - if (mh_format_string_parse (&format, format_str, &locus, MH_FMT_PARSE_TREE)) - { - mu_error (_("Bad format string")); - exit (1); - } - + if (mh_format_string_parse (&format, format_str, &locus, + MH_FMT_PARSE_TREE + | (debug_option ? MH_FMT_PARSE_DEBUG : 0))) + return 1; + if (dump_option) mh_format_dump_code (format); if (disass_option) @@ -179,6 +179,7 @@ void mh_format_dump_disass (mh_format_t fmt); #define MH_FMT_PARSE_DEFAULT 0 #define MH_FMT_PARSE_TREE 0x01 +#define MH_FMT_PARSE_DEBUG 0x02 int mh_format_string_parse (mh_format_t *retfmt, char const *format_str, struct mu_locus_point const *locus, int flags); @@ -187,7 +188,6 @@ int mh_format_file_parse (mh_format_t *retfmt, char const *formfile, mh_format_t mh_scan_format (void); -void mh_format_debug (int val); void mh_format_free (mh_format_t fmt); void mh_format_destroy (mh_format_t *fmt); diff --git a/mh/mh_fmtgram.y b/mh/mh_fmtgram.y index c1011cf3e..084445d3f 100644 --- a/mh/mh_fmtgram.y +++ b/mh/mh_fmtgram.y @@ -834,12 +834,6 @@ yylex_func (void) return ARGUMENT; } -void -mh_format_debug (int val) -{ - yydebug = val; -} - static int format_parse (mh_format_t *fmtptr, char *format_str, struct mu_locus_point const *locus, @@ -848,7 +842,7 @@ format_parse (mh_format_t *fmtptr, char *format_str, int rc; char *p = getenv ("MHFORMAT_DEBUG"); - if (p || mu_debug_level_p (MU_DEBCAT_APP, MU_DEBUG_TRACE2)) + if (p || (flags & MH_FMT_PARSE_DEBUG)) yydebug = 1; start = tok_start = curp = format_str; mu_opool_create (&tokpool, MU_OPOOL_ENOMEMABRT); @@ -1112,7 +1106,7 @@ dump_node_pretty (struct node *node, int level) printf(", %d, ", node->v.prt.fmtspec & MH_WIDTH_MASK); } else - printf ("PRINT(%d,", node->v.prt.fmtspec); + printf ("PRINT("); dump_statement (node->v.prt.arg, INLINE); printf (")"); break; |