decrease scope of a couple variables, prefix incr non-primitives

This commit is contained in:
Aaron Gyes 2022-04-07 09:24:39 -07:00
parent 5861358238
commit 8ea2be2648
3 changed files with 5 additions and 5 deletions

View file

@ -536,9 +536,8 @@ static int handle_flag_V(const wchar_t **argv, parser_t &parser, io_streams_t &s
static int handle_flag_w(const wchar_t **argv, parser_t &parser, io_streams_t &streams,
const wgetopter_t &w, options_t *opts) {
long width = 0;
if (opts->width_valid) {
width = fish_wcstol(w.woptarg);
long width = fish_wcstol(w.woptarg);
if (width < 0) {
string_error(streams, _(L"%ls: Invalid width value '%ls'\n"), argv[0], w.woptarg);
return STATUS_INVALID_ARGS;

View file

@ -681,12 +681,13 @@ void narrow_string_safe(char buff[64], const wchar_t *s) {
wcstring reformat_for_screen(const wcstring &msg, const termsize_t &termsize) {
wcstring buff;
int line_width = 0;
int screen_width = termsize.width;
if (screen_width) {
const wchar_t *start = msg.c_str();
const wchar_t *pos = start;
int line_width = 0;
while (true) {
int overflow = 0;

View file

@ -427,7 +427,7 @@ static launch_result_t fork_child_for_process(const std::shared_ptr<job_t> &job,
DIE("Child process returned control to fork_child lambda!");
}
s_fork_count++;
++s_fork_count;
FLOGF(exec_fork, L"Fork #%d, pid %d: %s for '%ls'", int(s_fork_count), pid, fork_type,
p->argv0());
return launch_result_t::ok;
@ -527,7 +527,7 @@ static launch_result_t exec_external_command(parser_t &parser, const std::shared
#if FISH_USE_POSIX_SPAWN
// Prefer to use posix_spawn, since it's faster on some systems like OS X.
if (can_use_posix_spawn_for_job(j, dup2s)) {
s_fork_count++; // spawn counts as a fork+exec
++s_fork_count; // spawn counts as a fork+exec
posix_spawner_t spawner(j.get(), dup2s);
maybe_t<pid_t> pid = spawner.spawn(actual_cmd, const_cast<char *const *>(argv),