diff options
author | 2013-04-28 14:35:00 -0700 | |
---|---|---|
committer | 2013-04-28 14:35:00 -0700 | |
commit | 0f12f2b6b144001b4b47a0655d276a92fc192195 (patch) | |
tree | 56e6ba429404247d7bf1024652a6cd2b5c9a645b /builtin.cpp | |
parent | 32c1d50887d915bbdbd08cb5e3d8e654743a63b6 (diff) |
Formatting cleanup of builtin_contains
Diffstat (limited to 'builtin.cpp')
-rw-r--r-- | builtin.cpp | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/builtin.cpp b/builtin.cpp index 861d355d..890784a3 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -2904,28 +2904,17 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv) { int argc; argc = builtin_count_args(argv); - int i; wchar_t *needle; - int index=0; + bool should_output_index = false; woptind=0; - const struct woption - long_options[] = + const struct woption long_options[] = { - { - L"help", no_argument, 0, 'h' - } - , - { - L"index", no_argument, 0, 'i' - } - , - { - 0, 0, 0, 0 - } - } - ; + { L"help", no_argument, 0, 'h' } , + { L"index", no_argument, 0, 'i' }, + { 0, 0, 0, 0 } + }; while (1) { @@ -2967,14 +2956,12 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv) return STATUS_BUILTIN_ERROR; case 'i': - index=1; + should_output_index = true; break; } } - - needle = argv[woptind]; if (!needle) { @@ -2982,12 +2969,12 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv) } - for (i=woptind+1; i<argc; i++) + for (int i=woptind+1; i<argc; i++) { if (!wcscmp(needle, argv[i])) { - if (index) append_format(stdout_buffer, L"%d\n", i-woptind); + if (should_output_index) append_format(stdout_buffer, L"%d\n", i-woptind); return 0; } } |