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:
Kurtis Rader 2017-02-13 20:37:27 -08:00
parent 7fc1994339
commit 509ee64fc9
69 changed files with 119 additions and 117 deletions

View file

@ -1,7 +1,6 @@
// The classes responsible for autoloading functions and completions.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stddef.h>

View file

@ -4,6 +4,7 @@
#include <pthread.h>
#include <time.h>
#include <set>
#include "common.h"

View file

@ -17,18 +17,18 @@
// 4). Use 'git add doc_src/NAME.txt' to start tracking changes to the documentation file.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <wchar.h>
#include <algorithm>
#include <map>
#include <memory>

View file

@ -3,6 +3,7 @@
#define FISH_BUILTIN_H
#include <stddef.h>
#include <vector>
#include "common.h"

View file

@ -1,7 +1,6 @@
// Functions used for implementing the commandline builtin.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>

View file

@ -3,6 +3,7 @@
#define FISH_BUILTIN_COMPLETE_H
#include <wchar.h>
#include <cstring>
class parser_t;

View file

@ -3,6 +3,7 @@
#define FISH_BUILTIN_JOBS_H
#include <wchar.h>
#include <cstring>
class parser_t;

View file

@ -3,6 +3,7 @@
#define FISH_BUILTIN_PRINTF_H
#include <wchar.h>
#include <cstring>
class parser_t;

View file

@ -453,9 +453,8 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
wchar_t *arg = argv[i];
int slice = 0;
if (!(dest = wcsdup(arg))) {
DIE_MEM();
}
dest = wcsdup(arg);
assert(dest);
if (wcschr(dest, L'[')) {
slice = 1;
@ -512,9 +511,8 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
return retcode;
}
if (!(dest = wcsdup(argv[w.woptind]))) {
DIE_MEM();
}
dest = wcsdup(argv[w.woptind]);
assert(dest);
if (wcschr(dest, L'[')) {
slice = 1;

View file

@ -3,6 +3,7 @@
#define FISH_BUILTIN_SET_H
#include <wchar.h>
#include <cstring>
class parser_t;

View file

@ -1,6 +1,10 @@
// Functions used for implementing the set_color builtin.
#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#if HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_CURSES_H
@ -14,10 +18,6 @@
#include <ncurses/term.h>
#endif
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory>
#include <string>
#include <vector>

View file

@ -3,6 +3,7 @@
#define FISH_BUILTIN_SET_COLOR_H
#include <wchar.h>
#include <cstring>
class parser_t;

View file

@ -5,7 +5,6 @@
#ifdef _WIN32
#define PCRE2_STATIC
#endif
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
@ -370,9 +369,7 @@ struct compiled_regex_t {
}
match = pcre2_match_data_create_from_pattern(code, 0);
if (match == 0) {
DIE_MEM();
}
assert(match);
}
~compiled_regex_t() {
@ -705,9 +702,8 @@ bool regex_replacer_t::replace_matches(const wchar_t *arg) {
bool done = false;
while (!done) {
if (output == NULL) {
DIE_MEM();
}
assert(output);
PCRE2_SIZE outlen = bufsize;
pcre2_rc = pcre2_substitute(regex.code, PCRE2_SPTR(arg), arglen,
0, // start offset

View file

@ -3,6 +3,7 @@
#define FISH_BUILTIN_STRING_H
#include <wchar.h>
#include <cstring>
class parser_t;

View file

@ -3,13 +3,13 @@
// Implemented from scratch (yes, really) by way of IEEE 1003.1 as reference.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <wchar.h>
#include <memory>
#include <string>
#include <type_traits>

View file

@ -3,6 +3,7 @@
#define FISH_BUILTIN_ULIMIT_H
#include <wchar.h>
#include <cstring>
class parser_t;

View file

@ -1,7 +1,6 @@
// Color class implementation.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <stddef.h>
#include <stdint.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 {
// XXX this should look for the nearest color
// TODO: This should look for the nearest color.
assert(type == type_named || type == type_rgb);
if (type == type_named) return data.name_idx;
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";
}
default: {
abort();
return L"";
DIE("unknown color type");
}
}
}

View file

@ -3,6 +3,7 @@
#define FISH_COLOR_H
#include <string.h>
#include <string>
#include "common.h"

View file

@ -1,7 +1,6 @@
// Various functions, mostly string utilities, that are used by most parts of fish.
#include "config.h"
#include <assert.h>
#include <cxxabi.h>
#include <dlfcn.h>
#include <errno.h>
@ -28,6 +27,7 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <algorithm>
#include <memory> // IWYU pragma: keep
#include <type_traits>
@ -266,14 +266,14 @@ char *wcs2str(const wchar_t *in) {
if (result) {
// It converted into the local buffer, so copy it.
result = strdup(result);
if (!result) DIE_MEM();
assert(result);
}
return result;
}
// Here we probably allocate a buffer probably much larger than necessary.
char *out = (char *)malloc(MAX_UTF8_BYTES * wcslen(in) + 1);
if (!out) DIE_MEM();
assert(out);
return wcs2str_internal(in, out);
}
@ -400,9 +400,7 @@ void append_formatv(wcstring &target, const wchar_t *format, va_list va_orig) {
break;
}
buff = (wchar_t *)realloc((buff == static_buff ? NULL : buff), size);
if (buff == NULL) {
DIE_MEM();
}
assert(buff != NULL);
}
// Try printing.
@ -2031,3 +2029,10 @@ void redirect_tty_output() {
if (tcgetattr(STDERR_FILENO, &t) == -1 && errno == EIO) dup2(fd, STDERR_FILENO);
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();
}

View file

@ -12,6 +12,7 @@
#include <string.h>
#include <termios.h>
#include <wchar.h>
#include <memory>
#include <sstream>
#include <string>
@ -125,25 +126,6 @@ enum selection_direction_t {
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
/// 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 program at once after emitting an error message.
#define DIE(msg) \
{ \
debug(0, "%s on line %ld of file %s, shutting down fish", msg, (long)__LINE__, __FILE__); \
FATAL_EXIT(); \
}
/// Exit program at once, leaving an error message about running out of memory.
#define DIE_MEM() \
{ \
fwprintf(stderr, L"fish: Out of memory on line %ld of file %s, shutting down fish\n", \
(long)__LINE__, __FILE__); \
FATAL_EXIT(); \
}
/// Exit the program at once after emitting an error message and stack trace if possible.
/// 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
/// stdio functions and should be writing the message to stderr rather than stdout. Second, if
/// possible it is useful to provide additional context such as a stack backtrace.
#undef assert
#undef __assert
//#define assert(e) do {(void)((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__)); } while(false)
#define assert(e) (e) ? ((void)0) : __assert(#e, __FILE__, __LINE__)
#define DIE(msg) __assert(msg, __FILE__, __LINE__)
[[noreturn]] void __assert(const char *msg, const char *file, size_t line);
/// Check if signals are blocked. If so, print an error message and return from the function
/// performing this check.

View file

@ -5,12 +5,12 @@
///
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <pthread.h>
#include <pwd.h>
#include <stddef.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <functional>
#include <list>

View file

@ -6,6 +6,7 @@
#define FISH_COMPLETE_H
#include <stdint.h>
#include <vector>
#include "common.h"

View file

@ -1,7 +1,6 @@
// Functions for setting and getting environment variables.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <locale.h>
#include <pthread.h>

View file

@ -4,6 +4,7 @@
#include <stddef.h>
#include <stdint.h>
#include <map>
#include <memory>
#include <string>

View file

@ -2,16 +2,15 @@
#include "config.h" // IWYU pragma: keep
#include <arpa/inet.h> // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
// We need the sys/file.h for the flock() declaration on Linux but not OS X.
#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
// on a Linux system.
#include <sys/ioctl.h> // IWYU pragma: keep
#include <limits.h>
#include <netinet/in.h> // IWYU pragma: keep
#include <sys/ioctl.h> // IWYU pragma: keep
#if !defined(__APPLE__) && !defined(__CYGWIN__)
#include <pwd.h>
#endif
@ -26,7 +25,7 @@
#include <sys/select.h> // IWYU pragma: keep
#endif
#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 <unistd.h>
#include <wchar.h>

View file

@ -4,6 +4,7 @@
#include <pthread.h>
#include <stdio.h>
#include <memory>
#include <set>
#include <vector>

View file

@ -7,6 +7,7 @@
#define FISH_EVENT_H
#include <unistd.h>
#include <memory>
#include <vector>

View file

@ -4,7 +4,6 @@
// performed have been massive.
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_SIGINFO_H

View file

@ -3,6 +3,7 @@
#define FISH_EXEC_H
#include <stddef.h>
#include <vector>
#include "common.h"

View file

@ -2,7 +2,6 @@
// IWYU pragma: no_include <cstddef>
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <pwd.h>
#include <stdarg.h>

View file

@ -8,6 +8,7 @@
#include "config.h"
#include <stddef.h>
#include <string>
#include <vector>

View file

@ -7,7 +7,6 @@
// IWYU likes to recommend adding term.h when we want ncurses.h.
// IWYU pragma: no_include term.h
#include <assert.h> // IWYU pragma: keep
#include <dirent.h> // IWYU pragma: keep
#include <errno.h> // IWYU pragma: keep
#include <fcntl.h> // IWYU pragma: keep

View file

@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include <sys/stat.h>
#include <unistd.h>
#include <wchar.h>
#include <memory>
#include <string>
#include <vector>
@ -454,9 +455,9 @@ int main(int argc, char **argv) {
res = reader_read(fd, empty_ios);
if (res) {
debug(1, _(L"Error while reading file %ls\n"), reader_current_filename()
? reader_current_filename()
: _(L"Standard input"));
debug(1, _(L"Error while reading file %ls\n"),
reader_current_filename() ? reader_current_filename()
: _(L"Standard input"));
}
reader_pop_current_filename();
}

View file

@ -17,7 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <getopt.h>
#include <locale.h>
@ -27,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#include <memory>
#include <string>
#include <vector>

View file

@ -3,7 +3,6 @@
// IWYU pragma: no_include <cstring>
// IWYU pragma: no_include <cstddef>
#include <assert.h>
#include <errno.h>
#include <libgen.h>
#include <limits.h>

View file

@ -10,6 +10,7 @@
#include <pthread.h>
#include <stddef.h>
#include <wchar.h>
#include <map>
#include <memory>
#include <set>

View file

@ -2,9 +2,9 @@
#ifndef FISH_HIGHLIGHT_H
#define FISH_HIGHLIGHT_H
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "color.h"

View file

@ -1,7 +1,6 @@
// History functions, part of the user interface.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>

View file

@ -9,6 +9,7 @@
#include <stdio.h>
#include <time.h>
#include <wctype.h>
#include <deque>
#include <memory>
#include <set>

View file

@ -1,7 +1,6 @@
// Functions for reading a character of input from stdin.
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

View file

@ -4,6 +4,7 @@
#define FISH_INPUT_H
#include <stddef.h>
#include <vector>
#include "common.h"

View file

@ -3,6 +3,7 @@
#define INPUT_COMMON_H
#include <stddef.h>
#include <functional>
#include "common.h"

View file

@ -3,6 +3,7 @@
#include <stddef.h>
#include <wchar.h>
#include <algorithm>
#include <memory>
#include <vector>

View file

@ -1,7 +1,6 @@
// Utilities for io redirection.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>

View file

@ -4,6 +4,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <vector>
// 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

View file

@ -1,6 +1,5 @@
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <pthread.h>
@ -9,6 +8,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <queue>
#include "common.h"
@ -40,8 +40,7 @@ struct spawn_request_t {
spawn_request_t() {}
spawn_request_t(void_function_t &&f, void_function_t &&comp)
: handler(f), completion(comp) {}
spawn_request_t(void_function_t &&f, void_function_t &&comp) : handler(f), completion(comp) {}
// Move-only
spawn_request_t &operator=(const spawn_request_t &) = delete;

View file

@ -2,8 +2,8 @@
#ifndef FISH_LRU_H
#define FISH_LRU_H
#include <assert.h>
#include <wchar.h>
#include <map>
#include "common.h"
@ -303,19 +303,19 @@ class lru_cache_t {
size_t count = 0;
while (cursor != &mouth) {
if (cursor->prev != prev) {
assert(0 && "Node busted previous link");
DIE("node busted previous link");
}
prev = cursor;
cursor = cursor->next;
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) {
assert(0 && "mouth.prev does not connect to last node");
DIE("mouth.prev does not connect to last node");
}
if (count != expected_count) {
assert(0 && "Linked list count mismatch from map count");
DIE("linked list count mismatch from map count");
}
// Count iterators
@ -325,7 +325,7 @@ class lru_cache_t {
iter_dist++;
}
if (iter_dist != count) {
assert(0 && "Linked list iterator mismatch from map count");
DIE("linked list iterator mismatch from map count");
}
}
};

View file

@ -18,6 +18,7 @@
#endif
#include <limits.h>
#include <wchar.h>
#include <memory>
#include <string>
#include <vector>

View file

@ -6,6 +6,7 @@
#define FISH_OUTPUT_H
#include <stddef.h>
#include <vector>
#include "color.h"

View file

@ -1,7 +1,6 @@
#include "config.h" // IWYU pragma: keep
// IWYU pragma: no_include <cstddef>
#include <assert.h>
#include <stddef.h>
#include <wchar.h>
#include <wctype.h>
@ -40,6 +39,24 @@ typedef std::vector<comp_t> comp_info_list_t;
/// Text we use for the search field.
#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.
static size_t divide_round_up(size_t numer, size_t denom) {
if (numer == 0) return 0;

View file

@ -3,6 +3,7 @@
#define FISH_PAGER_H
#include <stddef.h>
#include <memory>
#include <string>
#include <vector>

View file

@ -8,7 +8,6 @@
// for the execution to finish to see them.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>

View file

@ -1,7 +1,6 @@
// Programmatic representation of fish code.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>

View file

@ -2,10 +2,10 @@
#ifndef FISH_PARSE_PRODUCTIONS_H
#define FISH_PARSE_PRODUCTIONS_H
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <memory>
#include <vector>

View file

@ -4,7 +4,6 @@
// that are somehow related to parsing the code.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <stdarg.h>
#include <stdlib.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 (b) *b = end;
buffcpy = wcsndup(begin, end - begin);
if (!buffcpy) {
DIE_MEM();
}
assert(buffcpy != NULL);
tokenizer_t tok(buffcpy, TOK_ACCEPT_UNFINISHED);
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
// were a case item list.
parse_node_tree_t tree;
parse_tree_from_string(src, parse_flag_continue_after_error | parse_flag_include_comments |
parse_flag_accept_incomplete_tokens,
parse_tree_from_string(src,
parse_flag_continue_after_error | parse_flag_include_comments |
parse_flag_accept_incomplete_tokens,
&tree, NULL /* errors */);
// Start indenting at the first node. If we have a parse error, we'll have to start indenting

View file

@ -3,6 +3,7 @@
#define FISH_PARSE_UTIL_H
#include <stddef.h>
#include <vector>
#include "common.h"

View file

@ -1,9 +1,9 @@
// The fish parser. Contains functions for parsing and evaluating code.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <stdio.h>
#include <wchar.h>
#include <algorithm>
#include <memory>

View file

@ -3,7 +3,6 @@
// issues.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

View file

@ -14,8 +14,7 @@
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <memory>
#include <vector>
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_NCURSES_TERM_H
@ -29,7 +28,10 @@
#endif
#include <sys/time.h> // IWYU pragma: keep
#include <sys/types.h>
#include <algorithm> // IWYU pragma: keep
#include <memory>
#include <vector>
#include "common.h"
#include "event.h"

View file

@ -5,7 +5,6 @@
#define FISH_PROC_H
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <signal.h>
#include <stddef.h>
#include <sys/time.h> // IWYU pragma: keep

View file

@ -14,7 +14,6 @@
#include "config.h"
// IWYU pragma: no_include <type_traits>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>

View file

@ -5,6 +5,7 @@
#define FISH_READER_H
#include <stddef.h>
#include <string>
#include <vector>

View file

@ -10,7 +10,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <wchar.h>
#if HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_CURSES_H
@ -23,9 +26,7 @@
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#endif
#include <assert.h>
#include <time.h>
#include <wchar.h>
#include <algorithm>
#include <string>
#include <vector>

View file

@ -10,12 +10,10 @@
#define FISH_SCREEN_H
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <stddef.h>
#include <sys/stat.h>
#include <algorithm>
#include <cstddef>
#include <map>
#include <memory>
#include <set>

View file

@ -2,7 +2,6 @@
// extended to support marks, tokenizing multiple strings and disposing of unused string segments.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <fcntl.h>
#include <limits.h>
#include <unistd.h>

View file

@ -17,6 +17,7 @@
#include <stdint.h> // IWYU pragma: keep
#include <sys/types.h>
#include <limits>
#include <string>

View file

@ -19,6 +19,7 @@
#define _UTF8_H_
#include <stddef.h>
#include <string>
#define UTF8_IGNORE_ERROR 0x01

View file

@ -2,7 +2,6 @@
// provides recursive wildcards using **.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <stddef.h>
@ -294,7 +293,7 @@ static bool wildcard_complete_internal(const wchar_t *str, const wchar_t *wc,
return false;
}
default: {
DIE("Unreachable code reached");
DIE("unreachable code reached");
break;
}
}

View file

@ -2,7 +2,6 @@
#define FISH_NO_ISW_WRAPPERS
#include "config.h"
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
@ -353,7 +352,7 @@ wchar_t *wrealpath(const wcstring &pathname, wchar_t *resolved_path) {
if (pathsep_idx == cstring::npos) {
// No pathsep means a single path component relative to pwd.
narrow_res = realpath(".", NULL);
if (!narrow_res) DIE("unexpected realpath(\".\") failure");
assert(narrow_res != NULL);
pathsep_idx = 0;
} else {
// Only call realpath() on the portion up to the last component.