mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 08:56:10 +08:00
Fix some miscellaneous warnings
This commit is contained in:
parent
67c4da9dbf
commit
2a680ebd12
@ -907,18 +907,17 @@ class literal_replacer_t : public string_replacer_t {
|
||||
|
||||
static wcstring interpret_escapes(const wcstring &arg) {
|
||||
wcstring result;
|
||||
|
||||
const wchar_t *orig = arg.c_str();
|
||||
const wchar_t *start = arg.c_str();
|
||||
while (orig - start < arg.size()) {
|
||||
if (*orig == L'\\') {
|
||||
orig += read_unquoted_escape(orig, &result, true, false);
|
||||
result.reserve(arg.size());
|
||||
const wchar_t *cursor = arg.c_str();
|
||||
const wchar_t *end = cursor + arg.size();
|
||||
while (cursor < end) {
|
||||
if (*cursor == L'\\') {
|
||||
cursor += read_unquoted_escape(cursor, &result, true, false);
|
||||
} else {
|
||||
result += *orig;
|
||||
orig++;
|
||||
result.push_back(*cursor);
|
||||
cursor++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -948,15 +947,15 @@ bool literal_replacer_t::replace_matches(const wcstring &arg) {
|
||||
} else {
|
||||
auto &cmp_func = opts.ignore_case ? wcsncasecmp : wcsncmp;
|
||||
const wchar_t *cur = arg.c_str();
|
||||
const wchar_t *start = arg.c_str();
|
||||
while (cur - start < arg.size()) {
|
||||
const wchar_t *end = cur + arg.size();
|
||||
while (cur < end) {
|
||||
if ((opts.all || !replacement_occurred) && cmp_func(cur, pattern.c_str(), patlen) == 0) {
|
||||
result += replacement;
|
||||
cur += patlen;
|
||||
replacement_occurred = true;
|
||||
total_replaced++;
|
||||
} else {
|
||||
result += *cur;
|
||||
result.push_back(*cur);
|
||||
cur++;
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ class history_file_contents_t {
|
||||
static std::unique_ptr<history_file_contents_t> create(int fd) {
|
||||
// Check that the file is seekable, and its size.
|
||||
off_t len = lseek(fd, 0, SEEK_END);
|
||||
if (len <= 0 || len >= SIZE_MAX) return nullptr;
|
||||
if (len <= 0 || static_cast<unsigned long>(len) >= SIZE_MAX) return nullptr;
|
||||
if (lseek(fd, 0, SEEK_SET) != 0) return nullptr;
|
||||
|
||||
// Read the file, possibly ussing mmap.
|
||||
|
@ -278,8 +278,7 @@ class reader_history_search_t {
|
||||
bool add_skip(const wcstring &str) { return skips_.insert(str).second; }
|
||||
|
||||
/// Reset, beginning a new line or token mode search.
|
||||
void reset_to_mode(const wcstring &text, history_t *hist, mode_t mode,
|
||||
wcstring_list_t skip_list = {}) {
|
||||
void reset_to_mode(const wcstring &text, history_t *hist, mode_t mode) {
|
||||
assert(mode != inactive && "mode cannot be inactive in this setter");
|
||||
skips_ = {text};
|
||||
matches_ = {text};
|
||||
|
Loading…
x
Reference in New Issue
Block a user