diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-06-13 07:56:20 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-06-13 08:15:17 +0300 |
commit | 3a78309aa59c245c14e29d3e7eb953c6a2ea1035 (patch) | |
tree | c50b11921af9b4ea76c3128dbdd7d95eadc7b033 | |
parent | 16383a0184fd266e33c7d16ef55ce0d39dd1206e (diff) | |
download | mailutils-3a78309aa59c245c14e29d3e7eb953c6a2ea1035.tar.gz mailutils-3a78309aa59c245c14e29d3e7eb953c6a2ea1035.tar.bz2 |
Switch to new locus types
* include/mailutils/types.hin (mu_locus): Remove.
* include/mailutils/diag.h (mu_diag_at_locus): Remove.
(mu_diag_at_locus_point,mu_diag_at_locus_range): New protos.
* include/mailutils/mailutils.h: Include locus.h
* include/mailutils/stream.h (MU_IOCTL_LOGSTREAM_GET_LOCUS)
(MU_IOCTL_LOGSTREAM_SET_LOCUS): Remove.
* libmailutils/stream/logstream.c (_log_ctl): Reflect this.
* libmailutils/tests/logstr.at: Remove the related test.
* libmailutils/tests/logstr.c: Ditto.
* libmailutils/cfg/Makefile.am: Add new header.
* libmailutils/cfg/cfg.h: New file.
* libmailutils/cfg/format.c: Use mu_locus_range
* libmailutils/cfg/lexer.l: Use the mu_linetrack facility
* libmailutils/cfg/parser.y: LIkewise.
* libmailutils/diag/diag.c (mu_diag_at_locus): Remove.
(mu_diag_at_locus_point,mu_diag_at_locus_range): New protos.
* comsat/action.c: Use mu_locus_point and mu_locus_range
instead of the removed mu_locus.
* include/mailutils/auth.h: Likewise.
* include/mailutils/cfg.h: Likewise.
* include/mailutils/sieve.h: Likewise.
* libmailutils/base/wicket.c: Likewise.
* libmailutils/tests/wicket.c: Likewise.
* libmu_auth/radius.c: Likewise.
* libmu_sieve/actions.c: Likewise.
* libmu_sieve/comparator.c: Likewise.
* libmu_sieve/extensions/moderator.c: Likewise.
* libmu_sieve/mem.c: Likewise.
* libmu_sieve/prog.c: Likewise.
* libmu_sieve/require.c: Likewise.
* libmu_sieve/runtime.c: Likewise.
* libmu_sieve/sieve-priv.h: Likewise.
* libmu_sieve/sieve.l: Use the mu_linetrack facility.
* libmu_sieve/sieve.y: Likewise.
* libmu_sieve/util.c: Use mu_locus_point and mu_locus_range
instead of the removed mu_locus
* libmu_sieve/variables.c: Likewise.
* mail/source.c: Likewise.
* mu/libexec/dbm.c: Likewise.
* mu/libexec/logger.c: Likewise.
* mu/libexec/wicket.c: Likewise.
* sieve/sieve.c: Likewise.
* sieve/tests/i-numeric.at: Update expected locations
38 files changed, 493 insertions, 568 deletions
diff --git a/comsat/action.c b/comsat/action.c index 6ff766a82..24080a511 100644 --- a/comsat/action.c +++ b/comsat/action.c @@ -298,7 +298,7 @@ struct biffrc_environ mu_stream_t logstr; mu_message_t msg; mu_stream_t input; - struct mu_locus locus; + struct mu_locus_range locus; int use_default; char *errbuf; size_t errsize; @@ -523,16 +523,16 @@ eval_biffrc (struct biffrc_environ *env) ws.ws_comment = "#"; wsflags = MU_WRDSF_DEFFLAGS | MU_WRDSF_COMMENT; mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, - MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus); + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, &env->locus); mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM, - MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus); + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, &env->locus); while (mu_stream_getline (env->input, &stmt, &size, &n) == 0 && n > 0) { if (strncmp (stmt, "#line ", 6) == 0) { char *p; - env->locus.mu_line = strtoul (stmt + 6, &p, 10); + env->locus.beg.mu_line = strtoul (stmt + 6, &p, 10); if (*p != '\n') { report_error (env, _("malformed #line directive: %s")); @@ -541,10 +541,10 @@ eval_biffrc (struct biffrc_environ *env) { mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE, - &env->locus.mu_line); + &env->locus.beg.mu_line); mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE, - &env->locus.mu_line); + &env->locus.beg.mu_line); } continue; } @@ -600,9 +600,9 @@ eval_biffrc (struct biffrc_environ *env) free (stmt); mu_wordsplit_free (&ws); mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, - MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL); + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, NULL); mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM, - MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL); + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, NULL); } void @@ -645,13 +645,14 @@ run_user_action (const char *device, mu_message_t msg) if (!rcname) { mu_diag_funcall (MU_DIAG_ERROR, "mu_make_file_name", NULL, ENOMEM); - env.locus.mu_file = BIFF_RC; + env.locus.beg.mu_file = BIFF_RC; } else - env.locus.mu_file = rcname; + env.locus.beg.mu_file = rcname; - env.locus.mu_line = 1; - env.locus.mu_col = 0; + env.locus.beg.mu_line = 1; + env.locus.beg.mu_col = 0; + memset (&env.locus.end, 0, sizeof env.locus.end); env.use_default = 0; eval_biffrc (&env); mu_stream_destroy (&env.input); @@ -679,9 +680,9 @@ run_user_action (const char *device, mu_message_t msg) } else { - env.locus.mu_file = "<default>"; - env.locus.mu_line = 1; - env.locus.mu_col = 0; + env.locus.beg.mu_file = "<default>"; + env.locus.beg.mu_line = 1; + env.locus.beg.mu_col = 0; eval_biffrc (&env); mu_stream_destroy (&env.input); } diff --git a/include/mailutils/auth.h b/include/mailutils/auth.h index 04dbfd37c..998779b69 100644 --- a/include/mailutils/auth.h +++ b/include/mailutils/auth.h @@ -20,6 +20,7 @@ #define _MAILUTILS_AUTH_H #include <mailutils/types.h> +#include <mailutils/locus.h> #ifdef __cplusplus extern "C" { @@ -77,7 +78,7 @@ int mu_wicket_set_get_ticket (mu_wicket_t wicket, int mu_file_wicket_create (mu_wicket_t *pwicket, const char *filename); struct mu_debug_locus; -int mu_wicket_stream_match_url (mu_stream_t stream, struct mu_locus *loc, +int mu_wicket_stream_match_url (mu_stream_t stream, struct mu_locus_point *loc, mu_url_t url, int parse_flags, mu_url_t *pticket_url); int mu_wicket_file_match_url (const char *name, mu_url_t url, diff --git a/include/mailutils/cfg.h b/include/mailutils/cfg.h index 8ccd7f4eb..de84af6e1 100644 --- a/include/mailutils/cfg.h +++ b/include/mailutils/cfg.h @@ -23,6 +23,7 @@ #include <mailutils/debug.h> #include <mailutils/opool.h> #include <mailutils/util.h> +#include <mailutils/locus.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -64,7 +65,7 @@ enum mu_cfg_node_type struct mu_cfg_node { - struct mu_locus locus; + struct mu_locus_range locus; enum mu_cfg_node_type type; char *tag; mu_config_value_t *label; @@ -119,8 +120,6 @@ int mu_cfg_tree_union (mu_cfg_tree_t **pa, mu_cfg_tree_t **pb); int mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, struct mu_cfg_parse_hints *hints); -extern struct mu_locus mu_cfg_locus; - mu_opool_t mu_cfg_lexer_pool (void); #define MU_CFG_ITER_OK 0 @@ -285,7 +284,7 @@ int mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int mu_cfg_tree_create (struct mu_cfg_tree **ptree); mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree, enum mu_cfg_node_type type, - const struct mu_locus *loc, + const struct mu_locus_range *loc, const char *tag, const char *label, mu_list_t nodelist); diff --git a/include/mailutils/diag.h b/include/mailutils/diag.h index 3b57aae9d..03a0eacc2 100644 --- a/include/mailutils/diag.h +++ b/include/mailutils/diag.h @@ -24,6 +24,7 @@ #include <mailutils/types.h> #include <mailutils/log.h> #include <mailutils/debug.h> +#include <mailutils/locus.h> #ifdef __cplusplus extern "C" { @@ -51,8 +52,10 @@ void mu_diag_cont_printf (const char *fmt, ...) MU_PRINTFLIKE(1,2); void mu_diag_voutput (int, const char *, va_list); void mu_diag_output (int, const char *, ...) MU_PRINTFLIKE(2,3); -void mu_diag_at_locus (int level, struct mu_locus const *loc, - const char *fmt, ...); +void mu_diag_at_locus_point (int level, struct mu_locus_point const *loc, + const char *fmt, ...); +void mu_diag_at_locus_range (int level, struct mu_locus_range const *loc, + const char *fmt, ...); int mu_diag_level_to_syslog (int level); const char *mu_diag_level_to_string (int level); diff --git a/include/mailutils/mailutils.h b/include/mailutils/mailutils.h index 51cfe09c3..d5aadf85b 100644 --- a/include/mailutils/mailutils.h +++ b/include/mailutils/mailutils.h @@ -36,7 +36,7 @@ #include <mailutils/header.h> #include <mailutils/iterator.h> #include <mailutils/kwd.h> -/* FIXME #include <mailutils/locus.h> */ +#include <mailutils/locus.h> #include <mailutils/sieve.h> #include <mailutils/list.h> #include <mailutils/locker.h> diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h index 8d9c2c1a8..58a6037cb 100644 --- a/include/mailutils/sieve.h +++ b/include/mailutils/sieve.h @@ -23,6 +23,7 @@ #include <stdarg.h> #include <mailutils/mailutils.h> #include <mailutils/cli.h> +#include <mailutils/locus.h> #ifdef __cplusplus extern "C" { @@ -287,7 +288,7 @@ int mu_sieve_set_dry_run (mu_sieve_machine_t mach, int val); void mu_sieve_get_argc (mu_sieve_machine_t mach, size_t *args, size_t *tags); mu_mailer_t mu_sieve_get_mailer (mu_sieve_machine_t mach); -int mu_sieve_get_locus (mu_sieve_machine_t mach, struct mu_locus *); +int mu_sieve_get_locus (mu_sieve_machine_t mach, struct mu_locus_range *); char *mu_sieve_get_daemon_email (mu_sieve_machine_t mach); const char *mu_sieve_get_identifier (mu_sieve_machine_t mach); @@ -324,7 +325,7 @@ const char *mu_sieve_type_str (mu_sieve_data_type type); int mu_sieve_compile (mu_sieve_machine_t mach, const char *name); int mu_sieve_compile_buffer (mu_sieve_machine_t mach, const char *buf, int bufsize, - const char *fname, int line); + struct mu_locus_point const *pt); int mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox); int mu_sieve_message (mu_sieve_machine_t mach, mu_message_t message); int mu_sieve_disass (mu_sieve_machine_t mach); diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h index d200c2840..50cffc591 100644 --- a/include/mailutils/stream.h +++ b/include/mailutils/stream.h @@ -106,11 +106,9 @@ enum mu_buffer_type */ #define MU_IOCTL_LOGSTREAM_GET_SEVERITY 0 #define MU_IOCTL_LOGSTREAM_SET_SEVERITY 1 - /* Get or set locus. - Arg: struct mu_locus * - */ -#define MU_IOCTL_LOGSTREAM_GET_LOCUS 2 -#define MU_IOCTL_LOGSTREAM_SET_LOCUS 3 + + /* Codes 2 and 3 are reserved */ + /* Get or set log mode. Arg: int * */ diff --git a/include/mailutils/types.hin b/include/mailutils/types.hin index 2a0ee17fc..cc7709c9c 100644 --- a/include/mailutils/types.hin +++ b/include/mailutils/types.hin @@ -149,13 +149,6 @@ typedef unsigned int mu_debug_level_t; #define MU_DEFAULT_RECORD _MU_DEFAULT_RECORD_ -struct mu_locus -{ - char *mu_file; - unsigned mu_line; - unsigned mu_col; -}; - #ifdef __cplusplus } #endif diff --git a/libmailutils/base/wicket.c b/libmailutils/base/wicket.c index bb5ad2e7a..1acecff55 100644 --- a/libmailutils/base/wicket.c +++ b/libmailutils/base/wicket.c @@ -248,7 +248,7 @@ _file_wicket_get_ticket (mu_wicket_t wicket, void *data, } int -mu_wicket_stream_match_url (mu_stream_t stream, struct mu_locus *loc, +mu_wicket_stream_match_url (mu_stream_t stream, struct mu_locus_point *loc, mu_url_t url, int parse_flags, mu_url_t *pticket_url) { @@ -329,7 +329,7 @@ mu_wicket_file_match_url (const char *name, mu_url_t url, { mu_stream_t stream; int rc; - struct mu_locus loc; + struct mu_locus_point loc; rc = mu_file_stream_create (&stream, name, MU_STREAM_READ); if (rc) diff --git a/libmailutils/cfg/Makefile.am b/libmailutils/cfg/Makefile.am index 77aea6c61..51f67de6b 100644 --- a/libmailutils/cfg/Makefile.am +++ b/libmailutils/cfg/Makefile.am @@ -21,7 +21,8 @@ libcfg_la_SOURCES = \ driver.c\ format.c\ lexer.c\ - parser.c + parser.c\ + cfg.h localedir = $(datadir)/locale AM_CPPFLAGS = \ diff --git a/libmailutils/cfg/cfg.h b/libmailutils/cfg/cfg.h new file mode 100644 index 000000000..3b0ae34c3 --- /dev/null +++ b/libmailutils/cfg/cfg.h @@ -0,0 +1 @@ +#include <mailutils/yyloc.h> diff --git a/libmailutils/cfg/format.c b/libmailutils/cfg/format.c index a751c5793..78d84b1a0 100644 --- a/libmailutils/cfg/format.c +++ b/libmailutils/cfg/format.c @@ -152,10 +152,10 @@ format_node (const mu_cfg_node_t *node, void *data) { struct tree_print *tp = data; - if ((tp->flags & MU_CF_FMT_LOCUS) && node->locus.mu_file) + if ((tp->flags & MU_CF_FMT_LOCUS) && node->locus.beg.mu_file) mu_stream_printf (tp->stream, "# %lu \"%s\"\n", - (unsigned long) node->locus.mu_line, - node->locus.mu_file); + (unsigned long) node->locus.beg.mu_line, + node->locus.beg.mu_file); format_level (tp->stream, tp->level); switch (node->type) { diff --git a/libmailutils/cfg/lexer.l b/libmailutils/cfg/lexer.l index 88f24861a..d164a109f 100644 --- a/libmailutils/cfg/lexer.l +++ b/libmailutils/cfg/lexer.l @@ -38,7 +38,10 @@ #include <mailutils/cfg.h> #include <mailutils/list.h> #include <mailutils/util.h> - +#include <mailutils/locus.h> +#include <mailutils/stream.h> +#include <mailutils/stdstream.h> +#include "cfg.h" #include "parser.h" void _mu_line_begin (void); @@ -66,7 +69,16 @@ static int (*char_to_strip)(char); /* Strip matching characters of each static int isemptystr(int off); static mu_opool_t pool; - +static mu_linetrack_t trk; +static struct mu_locus_point string_beg; +#define YY_USER_ACTION \ + do \ + { \ + mu_linetrack_advance (trk, &yylloc, yytext, yyleng); \ + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, \ + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, &yylloc); \ + } \ + while (0); %} %option nounput @@ -83,7 +95,7 @@ P [1-9][0-9]* "/*" BEGIN(COMMENT); <COMMENT>[^*\n]* /* eat anything that's not a '*' */ <COMMENT>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ -<COMMENT>\n ++mu_cfg_locus.mu_line; +<COMMENT>\n ; <COMMENT>"*"+"/" BEGIN (INITIAL); /* End-of-line comments */ #debug=.*\n { @@ -91,9 +103,9 @@ P [1-9][0-9]* mu_cfg_set_debug (); mu_cfg_set_lex_debug (); } -#.*\n { mu_cfg_locus.mu_line++; } +#.*\n ; #.* /* end-of-file comment */; -"//".*\n { mu_cfg_locus.mu_line++; } +"//".*\n ; "//".* /* end-of-file comment */; /* Identifiers */ <INITIAL>{ID} { @@ -113,6 +125,7 @@ P [1-9][0-9]* return MU_TOK_QSTRING; } \"[^\\"\n]*\\. | \"[^\\"\n]*\\\n { BEGIN (STR); + mu_locus_point_copy (&string_beg, &yylloc.beg); _mu_line_begin (); _mu_line_add_unescape_last (yytext + 1, yyleng - 1); } <STR>[^\\"\n]*\\. | @@ -121,6 +134,10 @@ P [1-9][0-9]* if (yyleng > 1) _mu_line_add (yytext, yyleng - 1); yylval.string = _mu_line_finish (); + + mu_locus_point_copy (&yylloc.beg, &string_beg); + mu_locus_point_deinit (&string_beg); + return MU_TOK_QSTRING; } /* Multiline strings */ "<<"(-" "?)?\\?{ID}[ \t]*#.*\n | @@ -130,8 +147,8 @@ P [1-9][0-9]* "<<"(-" "?)?\"{ID}\"[ \t]*"//".*\n | "<<"(-" "?)?\"{ID}\"[ \t]*\n { BEGIN (ML); + mu_locus_point_copy (&string_beg, &yylloc.beg); multiline_begin (yytext+2); - mu_cfg_locus.mu_line++; } <ML>.*\n { char *p = multiline_strip_tabs (yytext); @@ -142,21 +159,21 @@ P [1-9][0-9]* multiline_delimiter = NULL; BEGIN (INITIAL); yylval.string = multiline_finish (); + + mu_locus_point_copy (&yylloc.beg, &string_beg); + mu_locus_point_deinit (&string_beg); + /* FIXME: Adjust yylloc.end without retreating trk */ return MU_TOK_MSTRING; } - mu_cfg_locus.mu_line++; multiline_add (p); } {WS} ; /* Other tokens */ -\n { mu_cfg_locus.mu_line++; } +\n ; [,;{}()] return yytext[0]; . { if (mu_isprint (yytext[0])) - mu_diag_at_locus (MU_LOG_ERROR, &mu_cfg_locus, - _("stray character %c"), yytext[0]); + mu_error (_("stray character %c"), yytext[0]); else - mu_diag_at_locus (MU_LOG_ERROR, &mu_cfg_locus, - _("stray character \\%03o"), - (unsigned char) yytext[0]); + mu_error (_("stray character \\%03o"), (unsigned char) yytext[0]); mu_cfg_error_count++; } %% @@ -175,8 +192,7 @@ unescape_to_line (int c) char t = mu_wordsplit_c_unquote_char (c); if (t == c && t != '\\' && t != '\"') { - mu_diag_at_locus (MU_LOG_ERROR, &mu_cfg_locus, - _("unknown escape sequence '\\%c'"), c); + mu_error (_("unknown escape sequence '\\%c'"), c); mu_cfg_error_count++; } mu_opool_append_char (pool, t); @@ -365,29 +381,24 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags) mu_cfg_set_lex_debug (); - /* Initialize locus: */ - /* 1. Save file name in the lexer object pool and point `file' member - to this copy. Free full_name: it is not used after that. */ - _mu_line_begin (); - _mu_line_add (full_name, strlen (full_name)); - mu_cfg_locus.mu_file = _mu_line_finish (); - free (full_name); - /* 2. Initialize line number */ - mu_cfg_locus.mu_line = 1; - + /* Initialize tracker */ + mu_linetrack_create (&trk, full_name, 2); + memset (&string_beg, 0, sizeof string_beg); /* Parse configuration */ yyrestart (fp); rc = mu_cfg_parse (return_tree); fclose (fp); if (flags & MU_CF_VERBOSE) - mu_diag_output (MU_DIAG_INFO, _("finished parsing file `%s'"), - mu_cfg_locus.mu_file); - + mu_diag_output (MU_DIAG_INFO, _("finished parsing file `%s'"), full_name); + free (full_name); + mu_linetrack_destroy (&trk); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, NULL); return rc == 0 ? 0 : MU_ERR_FAILURE; } mu_opool_t -mu_cfg_lexer_pool () +mu_cfg_lexer_pool (void) { mu_opool_t p = pool; pool = NULL; diff --git a/libmailutils/cfg/parser.y b/libmailutils/cfg/parser.y index 80b940f8a..b49dd0c11 100644 --- a/libmailutils/cfg/parser.y +++ b/libmailutils/cfg/parser.y @@ -40,10 +40,10 @@ #include <mailutils/stream.h> #include <mailutils/stdstream.h> #include <mailutils/cidr.h> +#include "cfg.h" int mu_cfg_parser_verbose; static mu_list_t /* of mu_cfg_node_t */ parse_node_list; -struct mu_locus mu_cfg_locus; size_t mu_cfg_error_count; static int _mu_cfg_errcnt; @@ -57,7 +57,7 @@ char *_mu_line_finish (void); static int yyerror (char *s) { - mu_diag_at_locus (MU_LOG_ERROR, &mu_cfg_locus, "%s", s); + mu_error ("%s", s); mu_cfg_error_count++; return 0; } @@ -85,7 +85,7 @@ _node_set_parent (void *item, void *data) } static mu_cfg_node_t * -mu_cfg_alloc_node (enum mu_cfg_node_type type, struct mu_locus *loc, +mu_cfg_alloc_node (enum mu_cfg_node_type type, struct mu_locus_range *loc, const char *tag, mu_config_value_t *label, mu_list_t nodelist) { @@ -94,7 +94,7 @@ mu_cfg_alloc_node (enum mu_cfg_node_type type, struct mu_locus *loc, size_t size = sizeof *np + strlen (tag) + 1; np = mu_alloc (size); np->type = type; - np->locus = *loc; + mu_locus_range_copy (&np->locus, loc); p = (char*) (np + 1); np->tag = p; strcpy (p, tag); @@ -121,17 +121,15 @@ debug_print_node (mu_cfg_node_t *node) if (node->type == mu_cfg_node_undefined) { /* Stay on the safe side */ - mu_diag_at_locus (MU_LOG_ERROR, &mu_cfg_locus, - _("unknown statement type!")); + mu_error (_("unknown statement type!")); mu_cfg_error_count++; } else { /* FIXME: How to print label? */ - mu_diag_at_locus (MU_LOG_DEBUG, &node->locus, - "statement: %s, id: %s", - node_type_str (node->type), - node->tag ? node->tag : "(null)"); + mu_error ("statement: %s, id: %s", + node_type_str (node->type), + node->tag ? node->tag : "(null)"); } } } @@ -170,6 +168,9 @@ mu_cfg_create_node_list (mu_list_t *plist) %} +%locations +%expect 1 + %union { mu_cfg_node_t node; mu_cfg_node_t *pnode; @@ -177,7 +178,6 @@ mu_cfg_create_node_list (mu_list_t *plist) char *string; mu_config_value_t value, *pvalue; mu_list_t list; - struct { const char *name; struct mu_locus locus; } ident; } %token <string> MU_TOK_IDENT MU_TOK_STRING MU_TOK_QSTRING MU_TOK_MSTRING @@ -186,7 +186,7 @@ mu_cfg_create_node_list (mu_list_t *plist) %type <value> value %type <pvalue> tag vallist %type <list> values list vlist -%type <ident> ident +%type <string> ident %type <nodelist> stmtlist %type <pnode> stmt simple block @@ -217,32 +217,32 @@ stmt : simple simple : ident vallist ';' { - $$ = mu_cfg_alloc_node (mu_cfg_node_param, &$1.locus, - $1.name, $2, - NULL); + struct mu_locus_range lr; + lr.beg = @1.beg; + lr.end = @3.end; + $$ = mu_cfg_alloc_node (mu_cfg_node_param, &lr, $1, $2, NULL); } ; block : ident tag '{' '}' opt_sc { - $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &$1.locus, - $1.name, $2, - NULL); + struct mu_locus_range lr; + lr.beg = @1.beg; + lr.end = @5.end; + $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &lr, $1, $2, NULL); } | ident tag '{' stmtlist '}' opt_sc { - $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &$1.locus, - $1.name, $2, $4); + struct mu_locus_range lr; + lr.beg = @1.beg; + lr.end = @6.end; + $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &lr, $1, $2, $4); mu_list_foreach ($4, _node_set_parent, $$); } ; ident : MU_TOK_IDENT - { - $$.name = $1; - $$.locus = mu_cfg_locus; - } - ; + ; tag : /* empty */ { @@ -270,8 +270,7 @@ vallist : vlist val.v.arg.v = mu_alloc (n * sizeof (val.v.arg.v[0])); if (!val.v.arg.v) { - mu_diag_at_locus (MU_LOG_ERROR, &mu_cfg_locus, - _("not enough memory")); + mu_error (_("not enough memory")); abort(); } @@ -292,9 +291,7 @@ vlist : value int rc = mu_list_create (&$$); if (rc) { - mu_diag_at_locus (MU_LOG_ERROR, &mu_cfg_locus, - _("cannot create list: %s"), - mu_strerror (rc)); + mu_error (_("cannot create list: %s"), mu_strerror (rc)); abort (); } mu_list_append ($$, config_value_dup (&$1)); /* FIXME */ @@ -401,14 +398,15 @@ mu_cfg_parse (mu_cfg_tree_t **ptree) mu_cfg_tree_t *tree; mu_opool_t pool; int save_mode = 0, mode; - struct mu_locus save_locus = { NULL, }; + struct mu_locus_range save_locus = MU_LOCUS_RANGE_INITIALIZER; mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_MODE, &save_mode); mode = save_mode | MU_LOGMODE_LOCUS; mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_MODE, &mode); - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_LOCUS, + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_GET_LOCUS_RANGE, &save_locus); mu_cfg_set_debug (); @@ -432,9 +430,10 @@ mu_cfg_parse (mu_cfg_tree_t **ptree) mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_MODE, &save_mode); - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS, + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, &save_locus); - free (save_locus.mu_file); + mu_locus_range_deinit (&save_locus); /* FIXME: refcount? */ return rc; } @@ -480,7 +479,7 @@ mu_cfg_tree_union (mu_cfg_tree_t **pa, mu_cfg_tree_t **pb) static mu_cfg_tree_t * do_include (const char *name, struct mu_cfg_parse_hints *hints, - struct mu_locus *loc) + struct mu_locus_range const *loc) { struct stat sb; char *tmpname = NULL; @@ -520,15 +519,15 @@ do_include (const char *name, struct mu_cfg_parse_hints *hints, } else if (errno == ENOENT) { - mu_diag_at_locus (MU_LOG_ERROR, loc, - _("include file or directory does not exist")); + mu_diag_at_locus_range (MU_LOG_ERROR, loc, + _("include file or directory does not exist")); mu_cfg_error_count++; } else { - mu_diag_at_locus (MU_LOG_ERROR, loc, - _("cannot stat include file or directory: %s"), - mu_strerror (errno)); + mu_diag_at_locus_range (MU_LOG_ERROR, loc, + _("cannot stat include file or directory: %s"), + mu_strerror (errno)); mu_cfg_error_count++; } |