- const char *file_name = fh_get_name (f->handle);
- struct string s = DS_EMPTY_INITIALIZER;
- ds_put_format (&s,
- _("Variable %s in file %s has different "
- "type or width from the same variable in "
- "earlier file."),
- var_name, file_name);
- ds_put_cstr (&s, " ");
- if (var_is_numeric (dv))
- ds_put_format (&s, _("In file %s, %s is numeric."),
- file_name, var_name);
- else
- ds_put_format (&s, _("In file %s, %s is a string variable "
- "with width %d."),
- file_name, var_name, var_get_width (dv));
- ds_put_cstr (&s, " ");
- if (var_is_numeric (mv))
- ds_put_format (&s, _("In an earlier file, %s was numeric."),
- var_name);
- else
- ds_put_format (&s, _("In an earlier file, %s was a string "
- "variable with width %d."),
- var_name, var_get_width (mv));
- msg (SE, ds_cstr (&s));
- ds_destroy (&s);
+ msg (SE, _("Variable %s has different type or width in different "
+ "files."), var_name);
+
+ for (size_t j = 0; j < 2; j++)
+ {
+ const struct variable *ev = !j ? mv : dv;
+ const struct comb_file *ef
+ = !j ? &proc->files[proc->var_sources[var_get_dict_index (mv)]] : f;
+ const char *fn = ef->handle ? fh_get_name (ef->handle) : "*";
+
+ if (var_is_numeric (ev))
+ lex_ofs_msg (lexer, SN, ef->start_ofs, ef->end_ofs,
+ _("In file %s, %s is numeric."),
+ fn, var_name);
+ else
+ lex_ofs_msg (lexer, SN, ef->start_ofs, ef->end_ofs,
+ _("In file %s, %s is a string with width %d."),
+ fn, var_name, var_get_width (ev));
+ }
+