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. // Look at and handle the next short option-character.
{
wchar_t c = *nextchar++; wchar_t c = *nextchar++;
wchar_t *temp = const_cast<wchar_t *>(my_index(optstring, c)); 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; woptopt = c;
if (*nextchar != '\0') woptind++; if (*nextchar != '\0') woptind++;
return '?'; return '?';
} }
if (temp[1] == ':') {
if (temp[1] != ':') {
return c;
}
if (temp[2] == ':') { if (temp[2] == ':') {
// This is an option that accepts an argument optionally. // This is an option that accepts an argument optionally.
if (*nextchar != '\0') { if (*nextchar != '\0') {
woptarg = nextchar; woptarg = nextchar;
woptind++; woptind++;
} else } else {
woptarg = NULL; woptarg = NULL;
}
nextchar = NULL; nextchar = NULL;
} else { } else {
// This is an option that requires an argument. // 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); (wint_t)c);
} }
woptopt = c; woptopt = c;
if (optstring[0] == ':') if (optstring[0] == ':') {
c = ':'; c = ':';
else } else {
c = '?'; c = '?';
} else }
} else {
// We already incremented `woptind' once; increment it again when taking next // We already incremented `woptind' once; increment it again when taking next
// ARGV-elt as argument. // ARGV-elt as argument.
woptarg = argv[woptind++]; woptarg = argv[woptind++];
}
nextchar = NULL; nextchar = NULL;
} }
}
return c; return c;
}
} }
int wgetopter_t::wgetopt_long(int argc, wchar_t **argv, const wchar_t *options, 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; if (!d) return false;
out_name = str2wcstring(d->d_name); 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. // The caller cares if this is a directory, so check.
bool is_dir = false; bool is_dir = false;
// We may be able to skip stat, if the readdir can tell us the file type directly. // We may be able to skip stat, if the readdir can tell us the file type directly.
bool check_with_stat = true; bool check_with_stat = true;
#ifdef HAVE_STRUCT_DIRENT_D_TYPE #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; *out_is_dir = is_dir;
}
return true; return true;
} }