increase visibility of highlighting the failed argument
This commit is contained in:
@ -132,7 +132,7 @@ void utils::missing_cmd_args(const std::string &file, int line, const std::strin
|
|||||||
if (error) error->all(file, line, "Illegal {} command: missing argument(s)", cmd);
|
if (error) error->all(file, line, "Illegal {} command: missing argument(s)", cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string utils::point_to_error(Input *input, int failedarg)
|
std::string utils::point_to_error(Input *input, int failed)
|
||||||
{
|
{
|
||||||
if (input) {
|
if (input) {
|
||||||
std::string cmdline = "Preprocessed: ";
|
std::string cmdline = "Preprocessed: ";
|
||||||
@ -142,14 +142,15 @@ std::string utils::point_to_error(Input *input, int failedarg)
|
|||||||
|
|
||||||
// assemble pre-processed command line and update error indicator position, if needed.
|
// assemble pre-processed command line and update error indicator position, if needed.
|
||||||
for (int i = 0; i < input->narg; ++i) {
|
for (int i = 0; i < input->narg; ++i) {
|
||||||
if (i == failedarg) indicator = cmdline.size();
|
if (i == failed) indicator = cmdline.size();
|
||||||
cmdline += input->arg[i];
|
cmdline += input->arg[i];
|
||||||
cmdline += ' ';
|
cmdline += ' ';
|
||||||
}
|
}
|
||||||
// construct and append error indicator line
|
// construct and append error indicator line
|
||||||
cmdline += '\n';
|
cmdline += '\n';
|
||||||
cmdline += std::string(indicator, ' ');
|
cmdline += std::string(indicator, ' ');
|
||||||
cmdline += "^\n";
|
cmdline += std::string(strlen(input->arg[failed]), '^');
|
||||||
|
cmdline += '\n';
|
||||||
return cmdline;
|
return cmdline;
|
||||||
} else return std::string("(Failed command line text not available)");
|
} else return std::string("(Failed command line text not available)");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,10 +64,10 @@ namespace utils {
|
|||||||
*
|
*
|
||||||
* This function is a helper function for error messages. It creates
|
* This function is a helper function for error messages. It creates
|
||||||
*
|
*
|
||||||
* \param input pointer to the Input class instance (for access to last command args)
|
* \param input pointer to the Input class instance (for access to last command args)
|
||||||
* \param failedarg index of the faulty argument (-1 to point to the command itself)
|
* \param faile index of the faulty argument (-1 to point to the command itself)
|
||||||
* \return string with two lines: the pre-processed command and a '^' pointing to the faulty argument */
|
* \return string with two lines: the pre-processed command and a '^' pointing to the faulty argument */
|
||||||
std::string point_to_error(Input *input, int failedarg);
|
std::string point_to_error(Input *input, int failed);
|
||||||
|
|
||||||
/*! Internal function handling the argument list for logmesg(). */
|
/*! Internal function handling the argument list for logmesg(). */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user