mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-24 11:53:09 +00:00
implement our own assert()
function
I recently upgraded the software on my macOS server and was dismayed to see that cppcheck reported a huge number of format string errors due to mismatches between the format string and its arguments from calls to `assert()`. It turns out they are due to the macOS header using `%lu` for the line number which is obviously wrong since it is using the C preprocessor `__LINE__` symbol which evaluates to a signed int. I also noticed that the macOS implementation writes to stdout, rather than stderr. It also uses `printf()` which can be a problem on some platforms if the stream is already in wide mode which is the normal case for fish. So implement our own `assert()` implementation. This also eliminates double-negative warnings that we get from some of our calls to `assert()` on some platforms by oclint. Also reimplement the `DIE()` macro in terms of our internal implementation. Rewrite `assert(0 && msg)` statements to `DIE(msg)` for clarity and to eliminate oclint warnings about constant expressions. Fixes #3276, albeit not in the fashion I originally envisioned.
This commit is contained in:
parent
7fc1994339
commit
509ee64fc9
69 changed files with 119 additions and 117 deletions
|
@ -1,7 +1,6 @@
|
||||||
// The classes responsible for autoloading functions and completions.
|
// The classes responsible for autoloading functions and completions.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -17,18 +17,18 @@
|
||||||
// 4). Use 'git add doc_src/NAME.txt' to start tracking changes to the documentation file.
|
// 4). Use 'git add doc_src/NAME.txt' to start tracking changes to the documentation file.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_BUILTIN_H
|
#define FISH_BUILTIN_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Functions used for implementing the commandline builtin.
|
// Functions used for implementing the commandline builtin.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_BUILTIN_COMPLETE_H
|
#define FISH_BUILTIN_COMPLETE_H
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_BUILTIN_JOBS_H
|
#define FISH_BUILTIN_JOBS_H
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_BUILTIN_PRINTF_H
|
#define FISH_BUILTIN_PRINTF_H
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
|
@ -453,9 +453,8 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
wchar_t *arg = argv[i];
|
wchar_t *arg = argv[i];
|
||||||
int slice = 0;
|
int slice = 0;
|
||||||
|
|
||||||
if (!(dest = wcsdup(arg))) {
|
dest = wcsdup(arg);
|
||||||
DIE_MEM();
|
assert(dest);
|
||||||
}
|
|
||||||
|
|
||||||
if (wcschr(dest, L'[')) {
|
if (wcschr(dest, L'[')) {
|
||||||
slice = 1;
|
slice = 1;
|
||||||
|
@ -512,9 +511,8 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dest = wcsdup(argv[w.woptind]))) {
|
dest = wcsdup(argv[w.woptind]);
|
||||||
DIE_MEM();
|
assert(dest);
|
||||||
}
|
|
||||||
|
|
||||||
if (wcschr(dest, L'[')) {
|
if (wcschr(dest, L'[')) {
|
||||||
slice = 1;
|
slice = 1;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_BUILTIN_SET_H
|
#define FISH_BUILTIN_SET_H
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
// Functions used for implementing the set_color builtin.
|
// Functions used for implementing the set_color builtin.
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#if HAVE_NCURSES_H
|
#if HAVE_NCURSES_H
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#elif HAVE_NCURSES_CURSES_H
|
#elif HAVE_NCURSES_CURSES_H
|
||||||
|
@ -14,10 +18,6 @@
|
||||||
#include <ncurses/term.h>
|
#include <ncurses/term.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_BUILTIN_SET_COLOR_H
|
#define FISH_BUILTIN_SET_COLOR_H
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define PCRE2_STATIC
|
#define PCRE2_STATIC
|
||||||
#endif
|
#endif
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -370,9 +369,7 @@ struct compiled_regex_t {
|
||||||
}
|
}
|
||||||
|
|
||||||
match = pcre2_match_data_create_from_pattern(code, 0);
|
match = pcre2_match_data_create_from_pattern(code, 0);
|
||||||
if (match == 0) {
|
assert(match);
|
||||||
DIE_MEM();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~compiled_regex_t() {
|
~compiled_regex_t() {
|
||||||
|
@ -705,9 +702,8 @@ bool regex_replacer_t::replace_matches(const wchar_t *arg) {
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while (!done) {
|
while (!done) {
|
||||||
if (output == NULL) {
|
assert(output);
|
||||||
DIE_MEM();
|
|
||||||
}
|
|
||||||
PCRE2_SIZE outlen = bufsize;
|
PCRE2_SIZE outlen = bufsize;
|
||||||
pcre2_rc = pcre2_substitute(regex.code, PCRE2_SPTR(arg), arglen,
|
pcre2_rc = pcre2_substitute(regex.code, PCRE2_SPTR(arg), arglen,
|
||||||
0, // start offset
|
0, // start offset
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_BUILTIN_STRING_H
|
#define FISH_BUILTIN_STRING_H
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
// Implemented from scratch (yes, really) by way of IEEE 1003.1 as reference.
|
// Implemented from scratch (yes, really) by way of IEEE 1003.1 as reference.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_BUILTIN_ULIMIT_H
|
#define FISH_BUILTIN_ULIMIT_H
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Color class implementation.
|
// Color class implementation.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -298,7 +297,7 @@ color24_t rgb_color_t::to_color24() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char rgb_color_t::to_name_index() const {
|
unsigned char rgb_color_t::to_name_index() const {
|
||||||
// XXX this should look for the nearest color
|
// TODO: This should look for the nearest color.
|
||||||
assert(type == type_named || type == type_rgb);
|
assert(type == type_named || type == type_rgb);
|
||||||
if (type == type_named) return data.name_idx;
|
if (type == type_named) return data.name_idx;
|
||||||
if (type == type_rgb) return term16_color_for_rgb(data.color.rgb);
|
if (type == type_rgb) return term16_color_for_rgb(data.color.rgb);
|
||||||
|
@ -342,8 +341,7 @@ wcstring rgb_color_t::description() const {
|
||||||
return L"normal";
|
return L"normal";
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
abort();
|
DIE("unknown color type");
|
||||||
return L"";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_COLOR_H
|
#define FISH_COLOR_H
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Various functions, mostly string utilities, that are used by most parts of fish.
|
// Various functions, mostly string utilities, that are used by most parts of fish.
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -28,6 +27,7 @@
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory> // IWYU pragma: keep
|
#include <memory> // IWYU pragma: keep
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
@ -266,14 +266,14 @@ char *wcs2str(const wchar_t *in) {
|
||||||
if (result) {
|
if (result) {
|
||||||
// It converted into the local buffer, so copy it.
|
// It converted into the local buffer, so copy it.
|
||||||
result = strdup(result);
|
result = strdup(result);
|
||||||
if (!result) DIE_MEM();
|
assert(result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here we probably allocate a buffer probably much larger than necessary.
|
// Here we probably allocate a buffer probably much larger than necessary.
|
||||||
char *out = (char *)malloc(MAX_UTF8_BYTES * wcslen(in) + 1);
|
char *out = (char *)malloc(MAX_UTF8_BYTES * wcslen(in) + 1);
|
||||||
if (!out) DIE_MEM();
|
assert(out);
|
||||||
return wcs2str_internal(in, out);
|
return wcs2str_internal(in, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,9 +400,7 @@ void append_formatv(wcstring &target, const wchar_t *format, va_list va_orig) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buff = (wchar_t *)realloc((buff == static_buff ? NULL : buff), size);
|
buff = (wchar_t *)realloc((buff == static_buff ? NULL : buff), size);
|
||||||
if (buff == NULL) {
|
assert(buff != NULL);
|
||||||
DIE_MEM();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try printing.
|
// Try printing.
|
||||||
|
@ -2031,3 +2029,10 @@ void redirect_tty_output() {
|
||||||
if (tcgetattr(STDERR_FILENO, &t) == -1 && errno == EIO) dup2(fd, STDERR_FILENO);
|
if (tcgetattr(STDERR_FILENO, &t) == -1 && errno == EIO) dup2(fd, STDERR_FILENO);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Display a failed assertion message, dump a stack trace if possible, then die.
|
||||||
|
[[noreturn]] void __assert(const char *msg, const char *file, size_t line) {
|
||||||
|
debug(0, L"%s:%zu: failed assertion: %s", file, line, msg);
|
||||||
|
show_stackframe(L'E', 99, 1);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
45
src/common.h
45
src/common.h
|
@ -12,6 +12,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -125,25 +126,6 @@ enum selection_direction_t {
|
||||||
direction_deselect
|
direction_deselect
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool selection_direction_is_cardinal(selection_direction_t dir) {
|
|
||||||
switch (dir) {
|
|
||||||
case direction_north:
|
|
||||||
case direction_east:
|
|
||||||
case direction_south:
|
|
||||||
case direction_west:
|
|
||||||
case direction_page_north:
|
|
||||||
case direction_page_south: {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case direction_next:
|
|
||||||
case direction_prev:
|
|
||||||
case direction_deselect: {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
default: { abort(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Issue a debug message with printf-style string formating and automatic line breaking. The string
|
/// Issue a debug message with printf-style string formating and automatic line breaking. The string
|
||||||
/// will begin with the string \c program_name, followed by a colon and a whitespace.
|
/// will begin with the string \c program_name, followed by a colon and a whitespace.
|
||||||
///
|
///
|
||||||
|
@ -244,20 +226,17 @@ extern bool has_working_tty_timestamps;
|
||||||
exit_without_destructors(1); \
|
exit_without_destructors(1); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Exit program at once after emitting an error message.
|
/// Exit the program at once after emitting an error message and stack trace if possible.
|
||||||
#define DIE(msg) \
|
/// We use our own private implementation of `assert()` for two reasons. First, some implementations
|
||||||
{ \
|
/// are subtly broken. For example, using `printf()` which can cause problems when mixed with wide
|
||||||
debug(0, "%s on line %ld of file %s, shutting down fish", msg, (long)__LINE__, __FILE__); \
|
/// stdio functions and should be writing the message to stderr rather than stdout. Second, if
|
||||||
FATAL_EXIT(); \
|
/// possible it is useful to provide additional context such as a stack backtrace.
|
||||||
}
|
#undef assert
|
||||||
|
#undef __assert
|
||||||
/// Exit program at once, leaving an error message about running out of memory.
|
//#define assert(e) do {(void)((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__)); } while(false)
|
||||||
#define DIE_MEM() \
|
#define assert(e) (e) ? ((void)0) : __assert(#e, __FILE__, __LINE__)
|
||||||
{ \
|
#define DIE(msg) __assert(msg, __FILE__, __LINE__)
|
||||||
fwprintf(stderr, L"fish: Out of memory on line %ld of file %s, shutting down fish\n", \
|
[[noreturn]] void __assert(const char *msg, const char *file, size_t line);
|
||||||
(long)__LINE__, __FILE__); \
|
|
||||||
FATAL_EXIT(); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if signals are blocked. If so, print an error message and return from the function
|
/// Check if signals are blocked. If so, print an error message and return from the function
|
||||||
/// performing this check.
|
/// performing this check.
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
///
|
///
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define FISH_COMPLETE_H
|
#define FISH_COMPLETE_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Functions for setting and getting environment variables.
|
// Functions for setting and getting environment variables.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <arpa/inet.h> // IWYU pragma: keep
|
#include <arpa/inet.h> // IWYU pragma: keep
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
// We need the sys/file.h for the flock() declaration on Linux but not OS X.
|
// We need the sys/file.h for the flock() declaration on Linux but not OS X.
|
||||||
#include <sys/file.h> // IWYU pragma: keep
|
#include <sys/file.h> // IWYU pragma: keep
|
||||||
// We need the ioctl.h header so we can check if SIOCGIFHWADDR is defined by it so we know if we're
|
// We need the ioctl.h header so we can check if SIOCGIFHWADDR is defined by it so we know if we're
|
||||||
// on a Linux system.
|
// on a Linux system.
|
||||||
#include <sys/ioctl.h> // IWYU pragma: keep
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <netinet/in.h> // IWYU pragma: keep
|
#include <netinet/in.h> // IWYU pragma: keep
|
||||||
|
#include <sys/ioctl.h> // IWYU pragma: keep
|
||||||
#if !defined(__APPLE__) && !defined(__CYGWIN__)
|
#if !defined(__APPLE__) && !defined(__CYGWIN__)
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,7 +25,7 @@
|
||||||
#include <sys/select.h> // IWYU pragma: keep
|
#include <sys/select.h> // IWYU pragma: keep
|
||||||
#endif
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h> // IWYU pragma: keep
|
#include <sys/time.h> // IWYU pragma: keep
|
||||||
#include <sys/types.h> // IWYU pragma: keep
|
#include <sys/types.h> // IWYU pragma: keep
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#define FISH_EVENT_H
|
#define FISH_EVENT_H
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
// performed have been massive.
|
// performed have been massive.
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifdef HAVE_SIGINFO_H
|
#ifdef HAVE_SIGINFO_H
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_EXEC_H
|
#define FISH_EXEC_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
// IWYU pragma: no_include <cstddef>
|
// IWYU pragma: no_include <cstddef>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
// IWYU likes to recommend adding term.h when we want ncurses.h.
|
// IWYU likes to recommend adding term.h when we want ncurses.h.
|
||||||
// IWYU pragma: no_include term.h
|
// IWYU pragma: no_include term.h
|
||||||
#include <assert.h> // IWYU pragma: keep
|
|
||||||
#include <dirent.h> // IWYU pragma: keep
|
#include <dirent.h> // IWYU pragma: keep
|
||||||
#include <errno.h> // IWYU pragma: keep
|
#include <errno.h> // IWYU pragma: keep
|
||||||
#include <fcntl.h> // IWYU pragma: keep
|
#include <fcntl.h> // IWYU pragma: keep
|
||||||
|
|
|
@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -454,9 +455,9 @@ int main(int argc, char **argv) {
|
||||||
res = reader_read(fd, empty_ios);
|
res = reader_read(fd, empty_ios);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
debug(1, _(L"Error while reading file %ls\n"), reader_current_filename()
|
debug(1, _(L"Error while reading file %ls\n"),
|
||||||
? reader_current_filename()
|
reader_current_filename() ? reader_current_filename()
|
||||||
: _(L"Standard input"));
|
: _(L"Standard input"));
|
||||||
}
|
}
|
||||||
reader_pop_current_filename();
|
reader_pop_current_filename();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
@ -27,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
// IWYU pragma: no_include <cstring>
|
// IWYU pragma: no_include <cstring>
|
||||||
// IWYU pragma: no_include <cstddef>
|
// IWYU pragma: no_include <cstddef>
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#ifndef FISH_HIGHLIGHT_H
|
#ifndef FISH_HIGHLIGHT_H
|
||||||
#define FISH_HIGHLIGHT_H
|
#define FISH_HIGHLIGHT_H
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// History functions, part of the user interface.
|
// History functions, part of the user interface.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Functions for reading a character of input from stdin.
|
// Functions for reading a character of input from stdin.
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#define FISH_INPUT_H
|
#define FISH_INPUT_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define INPUT_COMMON_H
|
#define INPUT_COMMON_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Utilities for io redirection.
|
// Utilities for io redirection.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
1
src/io.h
1
src/io.h
|
@ -4,6 +4,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
// Note that we have to include something to get any _LIBCPP_VERSION defined so we can detect libc++
|
// Note that we have to include something to get any _LIBCPP_VERSION defined so we can detect libc++
|
||||||
// So it's key that vector go above. If we didn't need vector for other reasons, we might include
|
// So it's key that vector go above. If we didn't need vector for other reasons, we might include
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
@ -9,6 +8,7 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -40,8 +40,7 @@ struct spawn_request_t {
|
||||||
|
|
||||||
spawn_request_t() {}
|
spawn_request_t() {}
|
||||||
|
|
||||||
spawn_request_t(void_function_t &&f, void_function_t &&comp)
|
spawn_request_t(void_function_t &&f, void_function_t &&comp) : handler(f), completion(comp) {}
|
||||||
: handler(f), completion(comp) {}
|
|
||||||
|
|
||||||
// Move-only
|
// Move-only
|
||||||
spawn_request_t &operator=(const spawn_request_t &) = delete;
|
spawn_request_t &operator=(const spawn_request_t &) = delete;
|
||||||
|
|
12
src/lru.h
12
src/lru.h
|
@ -2,8 +2,8 @@
|
||||||
#ifndef FISH_LRU_H
|
#ifndef FISH_LRU_H
|
||||||
#define FISH_LRU_H
|
#define FISH_LRU_H
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -303,19 +303,19 @@ class lru_cache_t {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
while (cursor != &mouth) {
|
while (cursor != &mouth) {
|
||||||
if (cursor->prev != prev) {
|
if (cursor->prev != prev) {
|
||||||
assert(0 && "Node busted previous link");
|
DIE("node busted previous link");
|
||||||
}
|
}
|
||||||
prev = cursor;
|
prev = cursor;
|
||||||
cursor = cursor->next;
|
cursor = cursor->next;
|
||||||
if (count++ > max) {
|
if (count++ > max) {
|
||||||
assert(0 && "LRU cache unable to re-reach the mouth - not circularly linked?");
|
DIE("LRU cache unable to re-reach the mouth - not circularly linked?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mouth.prev != prev) {
|
if (mouth.prev != prev) {
|
||||||
assert(0 && "mouth.prev does not connect to last node");
|
DIE("mouth.prev does not connect to last node");
|
||||||
}
|
}
|
||||||
if (count != expected_count) {
|
if (count != expected_count) {
|
||||||
assert(0 && "Linked list count mismatch from map count");
|
DIE("linked list count mismatch from map count");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count iterators
|
// Count iterators
|
||||||
|
@ -325,7 +325,7 @@ class lru_cache_t {
|
||||||
iter_dist++;
|
iter_dist++;
|
||||||
}
|
}
|
||||||
if (iter_dist != count) {
|
if (iter_dist != count) {
|
||||||
assert(0 && "Linked list iterator mismatch from map count");
|
DIE("linked list iterator mismatch from map count");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define FISH_OUTPUT_H
|
#define FISH_OUTPUT_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
// IWYU pragma: no_include <cstddef>
|
// IWYU pragma: no_include <cstddef>
|
||||||
#include <assert.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
@ -40,6 +39,24 @@ typedef std::vector<comp_t> comp_info_list_t;
|
||||||
/// Text we use for the search field.
|
/// Text we use for the search field.
|
||||||
#define SEARCH_FIELD_PROMPT _(L"search: ")
|
#define SEARCH_FIELD_PROMPT _(L"search: ")
|
||||||
|
|
||||||
|
inline bool selection_direction_is_cardinal(selection_direction_t dir) {
|
||||||
|
switch (dir) {
|
||||||
|
case direction_north:
|
||||||
|
case direction_east:
|
||||||
|
case direction_south:
|
||||||
|
case direction_west:
|
||||||
|
case direction_page_north:
|
||||||
|
case direction_page_south: {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case direction_next:
|
||||||
|
case direction_prev:
|
||||||
|
case direction_deselect: {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns numer / denom, rounding up. As a "courtesy" 0/0 is 0.
|
/// Returns numer / denom, rounding up. As a "courtesy" 0/0 is 0.
|
||||||
static size_t divide_round_up(size_t numer, size_t denom) {
|
static size_t divide_round_up(size_t numer, size_t denom) {
|
||||||
if (numer == 0) return 0;
|
if (numer == 0) return 0;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_PAGER_H
|
#define FISH_PAGER_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
// for the execution to finish to see them.
|
// for the execution to finish to see them.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Programmatic representation of fish code.
|
// Programmatic representation of fish code.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#ifndef FISH_PARSE_PRODUCTIONS_H
|
#ifndef FISH_PARSE_PRODUCTIONS_H
|
||||||
#define FISH_PARSE_PRODUCTIONS_H
|
#define FISH_PARSE_PRODUCTIONS_H
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
// that are somehow related to parsing the code.
|
// that are somehow related to parsing the code.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
@ -300,9 +299,7 @@ static void job_or_process_extent(const wchar_t *buff, size_t cursor_pos, const
|
||||||
if (a) *a = begin;
|
if (a) *a = begin;
|
||||||
if (b) *b = end;
|
if (b) *b = end;
|
||||||
buffcpy = wcsndup(begin, end - begin);
|
buffcpy = wcsndup(begin, end - begin);
|
||||||
if (!buffcpy) {
|
assert(buffcpy != NULL);
|
||||||
DIE_MEM();
|
|
||||||
}
|
|
||||||
|
|
||||||
tokenizer_t tok(buffcpy, TOK_ACCEPT_UNFINISHED);
|
tokenizer_t tok(buffcpy, TOK_ACCEPT_UNFINISHED);
|
||||||
tok_t token;
|
tok_t token;
|
||||||
|
@ -659,8 +656,9 @@ std::vector<int> parse_util_compute_indents(const wcstring &src) {
|
||||||
// foo ; cas', we get an invalid parse tree (since 'cas' is not valid) but we indent it as if it
|
// foo ; cas', we get an invalid parse tree (since 'cas' is not valid) but we indent it as if it
|
||||||
// were a case item list.
|
// were a case item list.
|
||||||
parse_node_tree_t tree;
|
parse_node_tree_t tree;
|
||||||
parse_tree_from_string(src, parse_flag_continue_after_error | parse_flag_include_comments |
|
parse_tree_from_string(src,
|
||||||
parse_flag_accept_incomplete_tokens,
|
parse_flag_continue_after_error | parse_flag_include_comments |
|
||||||
|
parse_flag_accept_incomplete_tokens,
|
||||||
&tree, NULL /* errors */);
|
&tree, NULL /* errors */);
|
||||||
|
|
||||||
// Start indenting at the first node. If we have a parse error, we'll have to start indenting
|
// Start indenting at the first node. If we have a parse error, we'll have to start indenting
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define FISH_PARSE_UTIL_H
|
#define FISH_PARSE_UTIL_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// The fish parser. Contains functions for parsing and evaluating code.
|
// The fish parser. Contains functions for parsing and evaluating code.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// issues.
|
// issues.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#if HAVE_TERM_H
|
#if HAVE_TERM_H
|
||||||
#include <term.h>
|
#include <term.h>
|
||||||
#elif HAVE_NCURSES_TERM_H
|
#elif HAVE_NCURSES_TERM_H
|
||||||
|
@ -29,7 +28,10 @@
|
||||||
#endif
|
#endif
|
||||||
#include <sys/time.h> // IWYU pragma: keep
|
#include <sys/time.h> // IWYU pragma: keep
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <algorithm> // IWYU pragma: keep
|
#include <algorithm> // IWYU pragma: keep
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#define FISH_PROC_H
|
#define FISH_PROC_H
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/time.h> // IWYU pragma: keep
|
#include <sys/time.h> // IWYU pragma: keep
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
// IWYU pragma: no_include <type_traits>
|
// IWYU pragma: no_include <type_traits>
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#define FISH_READER_H
|
#define FISH_READER_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
#if HAVE_NCURSES_H
|
#if HAVE_NCURSES_H
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#elif HAVE_NCURSES_CURSES_H
|
#elif HAVE_NCURSES_CURSES_H
|
||||||
|
@ -23,9 +26,7 @@
|
||||||
#elif HAVE_NCURSES_TERM_H
|
#elif HAVE_NCURSES_TERM_H
|
||||||
#include <ncurses/term.h>
|
#include <ncurses/term.h>
|
||||||
#endif
|
#endif
|
||||||
#include <assert.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -10,12 +10,10 @@
|
||||||
#define FISH_SCREEN_H
|
#define FISH_SCREEN_H
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstddef>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
// extended to support marks, tokenizing multiple strings and disposing of unused string segments.
|
// extended to support marks, tokenizing multiple strings and disposing of unused string segments.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <stdint.h> // IWYU pragma: keep
|
#include <stdint.h> // IWYU pragma: keep
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#define _UTF8_H_
|
#define _UTF8_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define UTF8_IGNORE_ERROR 0x01
|
#define UTF8_IGNORE_ERROR 0x01
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
// provides recursive wildcards using **.
|
// provides recursive wildcards using **.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -294,7 +293,7 @@ static bool wildcard_complete_internal(const wchar_t *str, const wchar_t *wc,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("Unreachable code reached");
|
DIE("unreachable code reached");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define FISH_NO_ISW_WRAPPERS
|
#define FISH_NO_ISW_WRAPPERS
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -353,7 +352,7 @@ wchar_t *wrealpath(const wcstring &pathname, wchar_t *resolved_path) {
|
||||||
if (pathsep_idx == cstring::npos) {
|
if (pathsep_idx == cstring::npos) {
|
||||||
// No pathsep means a single path component relative to pwd.
|
// No pathsep means a single path component relative to pwd.
|
||||||
narrow_res = realpath(".", NULL);
|
narrow_res = realpath(".", NULL);
|
||||||
if (!narrow_res) DIE("unexpected realpath(\".\") failure");
|
assert(narrow_res != NULL);
|
||||||
pathsep_idx = 0;
|
pathsep_idx = 0;
|
||||||
} else {
|
} else {
|
||||||
// Only call realpath() on the portion up to the last component.
|
// Only call realpath() on the portion up to the last component.
|
||||||
|
|
Loading…
Reference in a new issue