Permalink
Browse files

Fix to stop reporting config.fish execution as coming from "standard

input" within backtraces
  • Loading branch information...
1 parent 3ab9546 commit adf5b036d646561dbcd7d3d5d04ab7a0e6827a87 @ridiculousfish ridiculousfish committed Feb 20, 2014
Showing with 29 additions and 10 deletions.
  1. +2 −0 fish.cpp
  2. +21 −10 parser.cpp
  3. +6 −0 parser.h
View
@@ -227,7 +227,9 @@ static void source_config_in_directory(const wcstring &dir)
const wcstring escaped_dir = escape_string(dir, ESCAPE_ALL);
const wcstring cmd = L"builtin source " + escaped_dir + L"/config.fish 2>/dev/null";
parser_t &parser = parser_t::principal_parser();
+ parser.set_is_within_fish_initialization(true);
parser.eval(cmd, io_chain_t(), TOP);
+ parser.set_is_within_fish_initialization(false);
}
/**
View
@@ -299,6 +299,7 @@ parser_t::parser_t(enum parser_type_t type, bool errors) :
error_code(0),
err_pos(0),
cancellation_requested(false),
+ is_within_fish_initialization(false),
current_tokenizer(NULL),
current_tokenizer_pos(0),
job_start_pos(0),
@@ -322,6 +323,11 @@ parser_t &parser_t::principal_parser(void)
return parser;
}
+void parser_t::set_is_within_fish_initialization(bool flag)
+{
+ is_within_fish_initialization = flag;
+}
+
void parser_t::skip_all_blocks(void)
{
/* Tell all blocks to skip */
@@ -858,10 +864,13 @@ void parser_t::stack_trace(size_t block_idx, wcstring &buff) const
b->src_lineno,
user_presentable_path(file).c_str());
}
+ else if (is_within_fish_initialization)
+ {
+ append_format(buff, _(L"\tcalled during startup\n"));
+ }
else
{
- append_format(buff,
- _(L"\tcalled on standard input\n"));
+ append_format(buff, _(L"\tcalled on standard input\n"));
}
if (b->type() == FUNCTION_CALL)
@@ -1064,15 +1073,17 @@ const wchar_t *parser_t::current_line()
{
int prev_width = my_wcswidth(lineinfo.c_str());
if (file)
- append_format(lineinfo,
- _(L"%ls (line %d): "),
- file,
- lineno);
+ {
+ append_format(lineinfo, _(L"%ls (line %d): "), file, lineno);
+ }
+ else if (is_within_fish_initialization)
+ {
+ append_format(lineinfo, L"%ls: ", _(L"Startup"), lineno);
+ }
else
- append_format(lineinfo,
- L"%ls: ",
- _(L"Standard input"),
- lineno);
+ {
+ append_format(lineinfo, L"%ls: ", _(L"Standard input"), lineno);
+ }
offset = my_wcswidth(lineinfo.c_str()) - prev_width;
}
else
View
@@ -283,6 +283,9 @@ class parser_t
/** Indication that we should skip all blocks */
bool cancellation_requested;
+
+ /** Indicates that we are within the process of initializing fish */
+ bool is_within_fish_initialization;
/** Stack of execution contexts. We own these pointers and must delete them */
std::vector<parse_execution_context_t *> execution_contexts;
@@ -447,6 +450,9 @@ class parser_t
{
return my_job_list;
}
+
+ /* Hackish. In order to correctly report the origin of code with no associated file, we need to know whether it's run during initialization or not. */
+ void set_is_within_fish_initialization(bool flag);
/** Pushes the block. pop_block will call delete on it. */
void push_block(block_t *newv);

0 comments on commit adf5b03

Please sign in to comment.