lint: Use early exit/continue

This commit is contained in:
Kurtis Rader 2016-10-30 12:38:56 -07:00
parent 2a5ad198bf
commit 49ed20c8cb
2 changed files with 81 additions and 79 deletions

View File

@ -381,7 +381,6 @@ int wgetopter_t::_wgetopt_internal(int argc, wchar_t **argv, const wchar_t *opts
}
// Look at and handle the next short option-character.
{
wchar_t c = *nextchar++;
wchar_t *temp = const_cast<wchar_t *>(my_index(optstring, c));
@ -395,17 +394,21 @@ int wgetopter_t::_wgetopt_internal(int argc, wchar_t **argv, const wchar_t *opts
woptopt = c;
if (*nextchar != '\0') woptind++;
return '?';
}
if (temp[1] == ':') {
if (temp[1] != ':') {
return c;
}
if (temp[2] == ':') {
// This is an option that accepts an argument optionally.
if (*nextchar != '\0') {
woptarg = nextchar;
woptind++;
} else
} else {
woptarg = NULL;
}
nextchar = NULL;
} else {
// This is an option that requires an argument.
@ -421,19 +424,19 @@ int wgetopter_t::_wgetopt_internal(int argc, wchar_t **argv, const wchar_t *opts
(wint_t)c);
}
woptopt = c;
if (optstring[0] == ':')
if (optstring[0] == ':') {
c = ':';
else
} else {
c = '?';
} else
}
} else {
// We already incremented `woptind' once; increment it again when taking next
// ARGV-elt as argument.
woptarg = argv[woptind++];
}
nextchar = NULL;
}
}
return c;
}
}
int wgetopter_t::wgetopt_long(int argc, wchar_t **argv, const wchar_t *options,

View File

@ -50,10 +50,10 @@ bool wreaddir_resolving(DIR *dir, const std::wstring &dir_path, std::wstring &ou
if (!d) return false;
out_name = str2wcstring(d->d_name);
if (out_is_dir) {
if (!out_is_dir) return true;
// The caller cares if this is a directory, so check.
bool is_dir = false;
// We may be able to skip stat, if the readdir can tell us the file type directly.
bool check_with_stat = true;
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
@ -83,7 +83,6 @@ bool wreaddir_resolving(DIR *dir, const std::wstring &dir_path, std::wstring &ou
}
}
*out_is_dir = is_dir;
}
return true;
}