diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -547,20 +547,21 @@ parse_opt(int key, char *arg, struct argp_state *state) need_script = 1; break; case 'v': { char *p; + struct locus locus = { "<command line>", 1, 0 }; p = strchr(arg, '='); if (!p) argp_error(state, _("expected assignment, but found `%s'"), arg); *p++ = 0; - defer_initialize_variable(arg, p); + defer_initialize_variable(arg, p, &locus); break; } case OPTION_DAEMON: mode = MAILFROMD_DAEMON; need_script = 1; @@ -713,13 +714,15 @@ cb_timeout(void *data, mu_config_value_t *arg) static int cb_set_variable(void *data, mu_config_value_t *arg) { const char *value; char *alloc_str = NULL; - + struct mu_locus mloc; + struct locus locus; + if (mu_cfg_assert_value_type(arg, MU_CFG_ARRAY)) return 1; if (arg->v.arg.c < 2) { mu_error(_("not enough arguments")); return 1; } else if (arg->v.arg.c > 2) { @@ -746,14 +749,31 @@ cb_set_variable(void *data, mu_config_value_t *arg) default: mu_error (_("INTERNAL ERROR at %s:%d: please report"), __FILE__, __LINE__); abort(); } - - defer_initialize_variable(arg->v.arg.v[0].v.string, value); + + locus.leng = 0; + if (mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_GET_LOCUS, &mloc)) { + locus.file = "<unknown>"; + locus.line = 0; + locus.point = 0; + } else { + if (mloc.mu_file) { + struct literal *lit = string_alloc(mloc.mu_file, + strlen(mloc.mu_file)); + free(mloc.mu_file); + locus.file = lit->text; + } else + locus.file = "<unknown>"; + locus.line = mloc.mu_line; + locus.point = mloc.mu_col; + } + defer_initialize_variable(arg->v.arg.v[0].v.string, value, &locus); free(alloc_str); return 0; } static int cb_include_path(void *data, mu_config_value_t *val) |