From f4d1657c22c81a7720a91026f915b80d2d6aa6e8 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 25 Jul 2015 18:16:00 -0700 Subject: Eliminate wgetopt global variables Replace them with a new struct wgetopter_t that uses instance variables instead. --- src/builtin_jobs.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/builtin_jobs.cpp') diff --git a/src/builtin_jobs.cpp b/src/builtin_jobs.cpp index 02bf94f2..32079287 100644 --- a/src/builtin_jobs.cpp +++ b/src/builtin_jobs.cpp @@ -160,13 +160,14 @@ static void builtin_jobs_print(const job_t *j, int mode, int header) */ static int builtin_jobs(parser_t &parser, wchar_t **argv) { + wgetopter_t w; int argc=0; int found=0; int mode=JOBS_DEFAULT; int print_last = 0; argc = builtin_count_args(argv); - woptind=0; + w.woptind=0; while (1) { @@ -201,11 +202,11 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv) int opt_index = 0; - int opt = wgetopt_long(argc, - argv, - L"pclgh", - long_options, - &opt_index); + int opt = w.wgetopt_long(argc, + argv, + L"pclgh", + long_options, + &opt_index); if (opt == -1) break; @@ -248,7 +249,7 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv) return 0; case '?': - builtin_unknown_option(parser, argv[0], argv[woptind-1]); + builtin_unknown_option(parser, argv[0], argv[w.woptind-1]); return 1; } @@ -283,13 +284,13 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv) } else { - if (woptind < argc) + if (w.woptind < argc) { int i; found = 1; - for (i=woptind; i