mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:03:57 +08: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:
parent
47fbfdca3e
commit
0045b46af8
|
@ -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);
|
||||
|
|
|
@ -2582,9 +2582,9 @@ 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 &line = lines.at(idx);
|
||||
const wcstring_list_t hist_lines = generate_history_lines(getpid());
|
||||
for (size_t idx = 0; idx < hist_lines.size(); idx++) {
|
||||
const wcstring &line = hist_lines.at(idx);
|
||||
hist->add(line);
|
||||
hist->save();
|
||||
}
|
||||
|
@ -2623,15 +2623,15 @@ 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++) {
|
||||
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.
|
||||
|
@ -2650,10 +2650,10 @@ void history_tests_t::test_history_races(void) {
|
|||
size_t 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()) {
|
||||
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;
|
||||
|
|
|
@ -204,11 +204,11 @@ static size_t read_line(const char *base, size_t cursor, size_t len, std::string
|
|||
// Locate the newline.
|
||||
assert(cursor <= len);
|
||||
const char *start = base + cursor;
|
||||
const char *newline = (char *)memchr(start, '\n', len - cursor);
|
||||
if (newline != NULL) { // we found a newline
|
||||
result.assign(start, newline - start);
|
||||
const char *a_newline = (char *)memchr(start, '\n', len - cursor);
|
||||
if (a_newline != NULL) { // we found a newline
|
||||
result.assign(start, a_newline - start);
|
||||
// Return the amount to advance the cursor; skip over the newline.
|
||||
return newline - start + 1;
|
||||
return a_newline - start + 1;
|
||||
}
|
||||
|
||||
// We ran off the end.
|
||||
|
@ -543,17 +543,17 @@ 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) break;
|
||||
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) continue;
|
||||
if (a_newline - line_start < 3) continue;
|
||||
|
||||
// Try to be a little YAML compatible. Skip lines with leading %, ---, or ...
|
||||
if (!memcmp(line_start, "%", 1) || !memcmp(line_start, "---", 3) ||
|
||||
|
@ -564,7 +564,7 @@ static size_t offset_of_next_item_fish_2_0(const char *begin, size_t mmap_length
|
|||
// 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 &&
|
||||
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: ");
|
||||
|
@ -574,7 +574,7 @@ static size_t offset_of_next_item_fish_2_0(const char *begin, size_t mmap_length
|
|||
// 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;
|
||||
|
||||
// At this point, we know line_start is at the beginning of an item. But maybe we want to
|
||||
|
@ -1516,9 +1516,9 @@ void history_t::populate_from_bash(FILE *stream) {
|
|||
success = (bool)fgets(buff, sizeof buff, stream);
|
||||
if (success) {
|
||||
// Skip the newline.
|
||||
char *newline = strchr(buff, '\n');
|
||||
if (newline) *newline = '\0';
|
||||
has_newline = (newline != NULL);
|
||||
char *a_newline = strchr(buff, '\n');
|
||||
if (a_newline) *a_newline = '\0';
|
||||
has_newline = (a_newline != NULL);
|
||||
|
||||
// Append what we've got.
|
||||
line.append(buff);
|
||||
|
|
|
@ -593,25 +593,25 @@ class parse_ll_t {
|
|||
#if 0
|
||||
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++) {
|
||||
fprintf(stderr, " %ls\n", lines.at(idx).c_str());
|
||||
for (size_t idx = 0; idx < stack_lines.size(); idx++) {
|
||||
fprintf(stderr, " %ls\n", stack_lines.at(idx).c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user