mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 12:11:20 -03:00
Rename things to avoid conflicts with headers
Was breaking builds * ncurses.h: can declare `char *const key_name'. * netbsd term.h: has `newline', `lines' macros.
This commit is contained in:
@@ -50,8 +50,8 @@ static bool should_exit(wchar_t wc) {
|
||||
memcmp(recent_chars + 2, "\x4\x4", 2) == 0); // ctrl-D, ctrl-D
|
||||
}
|
||||
|
||||
/// Return the key name if the recent sequence of characters matches a known terminfo sequence.
|
||||
static char *const key_name(wchar_t wc) {
|
||||
/// Return the name if the recent sequence of characters matches a known terminfo sequence.
|
||||
static char *const sequence_name(wchar_t wc) {
|
||||
unsigned char c = wc < 0x80 ? wc : 0;
|
||||
static char recent_chars[8] = {0};
|
||||
|
||||
@@ -159,7 +159,7 @@ static void output_info_about_char(wchar_t wc) {
|
||||
}
|
||||
|
||||
static bool output_matching_key_name(wchar_t wc) {
|
||||
char *name = key_name(wc);
|
||||
char *name = sequence_name(wc);
|
||||
if (name) {
|
||||
printf("bind -k %s 'do something'\n", name);
|
||||
free(name);
|
||||
|
||||
@@ -3005,10 +3005,10 @@ void history_tests_t::test_history_races_pound_on_history()
|
||||
/* Called in child process to modify history */
|
||||
history_t *hist = new history_t(L"race_test");
|
||||
hist->chaos_mode = true;
|
||||
const wcstring_list_t lines = generate_history_lines(getpid());
|
||||
for (size_t idx = 0; idx < lines.size(); idx++)
|
||||
const wcstring_list_t hist_lines = generate_history_lines(getpid());
|
||||
for (size_t idx = 0; idx < hist_lines.size(); idx++)
|
||||
{
|
||||
const wcstring &line = lines.at(idx);
|
||||
const wcstring &line = hist_lines.at(idx);
|
||||
hist->add(line);
|
||||
hist->save();
|
||||
}
|
||||
@@ -3053,17 +3053,17 @@ void history_tests_t::test_history_races(void)
|
||||
}
|
||||
|
||||
// Compute the expected lines
|
||||
wcstring_list_t lines[RACE_COUNT];
|
||||
wcstring_list_t expected_lines[RACE_COUNT];
|
||||
for (size_t i=0; i < RACE_COUNT; i++)
|
||||
{
|
||||
lines[i] = generate_history_lines(children[i]);
|
||||
expected_lines[i] = generate_history_lines(children[i]);
|
||||
}
|
||||
|
||||
// Count total lines
|
||||
size_t line_count = 0;
|
||||
for (size_t i=0; i < RACE_COUNT; i++)
|
||||
for (size_t i = 0; i < RACE_COUNT; i++)
|
||||
{
|
||||
line_count += lines[i].size();
|
||||
line_count += expected_lines[i].size();
|
||||
}
|
||||
|
||||
// Ensure we consider the lines that have been outputted as part of our history
|
||||
@@ -3082,13 +3082,13 @@ void history_tests_t::test_history_races(void)
|
||||
// The item must be present in one of our 'lines' arrays
|
||||
// If it is present, then every item after it is assumed to be missed
|
||||
size_t i;
|
||||
for (i=0; i < RACE_COUNT; i++)
|
||||
for (i = 0; i < RACE_COUNT; i++)
|
||||
{
|
||||
wcstring_list_t::iterator where = std::find(lines[i].begin(), lines[i].end(), item.str());
|
||||
if (where != lines[i].end())
|
||||
wcstring_list_t::iterator where = std::find(expected_lines[i].begin(), expected_lines[i].end(), item.str());
|
||||
if (where != expected_lines[i].end())
|
||||
{
|
||||
// Delete everything from the found location onwards
|
||||
lines[i].resize(where - lines[i].begin());
|
||||
expected_lines[i].resize(where - expected_lines[i].begin());
|
||||
|
||||
// Break because we found it
|
||||
break;
|
||||
|
||||
@@ -393,19 +393,19 @@ static size_t offset_of_next_item_fish_2_0(const char *begin, size_t mmap_length
|
||||
const char *line_start = begin + cursor;
|
||||
|
||||
/* Advance the cursor to the next line */
|
||||
const char *newline = (const char *)memchr(line_start, '\n', mmap_length - cursor);
|
||||
if (newline == NULL)
|
||||
const char *a_newline = (const char *)memchr(line_start, '\n', mmap_length - cursor);
|
||||
if (a_newline == NULL)
|
||||
break;
|
||||
|
||||
/* Advance the cursor past this line. +1 is for the newline */
|
||||
cursor = newline - begin + 1;
|
||||
cursor = a_newline - begin + 1;
|
||||
|
||||
/* Skip lines with a leading space, since these are in the interior of one of our items */
|
||||
if (line_start[0] == ' ')
|
||||
continue;
|
||||
|
||||
/* Skip very short lines to make one of the checks below easier */
|
||||
if (newline - line_start < 3)
|
||||
if (a_newline - line_start < 3)
|
||||
continue;
|
||||
|
||||
/* Try to be a little YAML compatible. Skip lines with leading %, ---, or ... */
|
||||
@@ -418,7 +418,7 @@ static size_t offset_of_next_item_fish_2_0(const char *begin, size_t mmap_length
|
||||
/* Hackish: fish 1.x rewriting a fish 2.0 history file can produce lines with lots of leading "- cmd: - cmd: - cmd:". Trim all but one leading "- cmd:". */
|
||||
const char *double_cmd = "- cmd: - cmd: ";
|
||||
const size_t double_cmd_len = strlen(double_cmd);
|
||||
while (newline - line_start > double_cmd_len && ! memcmp(line_start, double_cmd, double_cmd_len))
|
||||
while (a_newline - line_start > double_cmd_len && ! memcmp(line_start, double_cmd, double_cmd_len))
|
||||
{
|
||||
/* Skip over just one of the - cmd. In the end there will be just one left. */
|
||||
line_start += strlen("- cmd: ");
|
||||
@@ -427,7 +427,7 @@ static size_t offset_of_next_item_fish_2_0(const char *begin, size_t mmap_length
|
||||
/* Hackish: fish 1.x rewriting a fish 2.0 history file can produce commands like "when: 123456". Ignore those. */
|
||||
const char *cmd_when = "- cmd: when:";
|
||||
const size_t cmd_when_len = strlen(cmd_when);
|
||||
if (newline - line_start >= cmd_when_len && ! memcmp(line_start, cmd_when, cmd_when_len))
|
||||
if (a_newline - line_start >= cmd_when_len && ! memcmp(line_start, cmd_when, cmd_when_len))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -1800,9 +1800,9 @@ void history_t::populate_from_bash(FILE *stream)
|
||||
{
|
||||
/* Skip the newline */
|
||||
char *newline = strchr(buff, '\n');
|
||||
if (newline) *newline = '\0';
|
||||
has_newline = (newline != NULL);
|
||||
|
||||
if (a_newline) *a_newline = '\0';
|
||||
has_newline = (a_newline != NULL);
|
||||
|
||||
/* Append what we've got */
|
||||
line.append(buff);
|
||||
}
|
||||
|
||||
@@ -712,31 +712,31 @@ public:
|
||||
void parse_ll_t::dump_stack(void) const
|
||||
{
|
||||
// Walk backwards from the top, looking for parents
|
||||
wcstring_list_t lines;
|
||||
wcstring_list_t stack_lines;
|
||||
if (symbol_stack.empty())
|
||||
{
|
||||
lines.push_back(L"(empty)");
|
||||
stack_lines.push_back(L"(empty)");
|
||||
}
|
||||
else
|
||||
{
|
||||
node_offset_t child = symbol_stack.back().node_idx;
|
||||
node_offset_t cursor = child;
|
||||
lines.push_back(nodes.at(cursor).describe());
|
||||
stack_lines.push_back(nodes.at(cursor).describe());
|
||||
while (cursor--)
|
||||
{
|
||||
const parse_node_t &node = nodes.at(cursor);
|
||||
if (node.child_start <= child && node.child_start + node.child_count > child)
|
||||
{
|
||||
lines.push_back(node.describe());
|
||||
stack_lines.push_back(node.describe());
|
||||
child = cursor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "Stack dump (%zu elements):\n", symbol_stack.size());
|
||||
for (size_t idx = 0; idx < lines.size(); idx++)
|
||||
for (size_t idx = 0; idx < stack_lines.size(); idx++)
|
||||
{
|
||||
fprintf(stderr, " %ls\n", lines.at(idx).c_str());
|
||||
fprintf(stderr, " %ls\n", stack_lines.at(idx).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user