diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-07-29 13:01:38 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-07-29 13:01:38 +0000 |
commit | b1b65de9604dab4824664f091f7884c2b48bfdf7 (patch) | |
tree | e84c7f2a36f932c4b62a8408a34bbb64b3c2c6cc | |
parent | d85aa8088a5cd4bc27b7d2d568242e5c84a758a0 (diff) | |
download | portage-b1b65de9604dab4824664f091f7884c2b48bfdf7.tar.gz portage-b1b65de9604dab4824664f091f7884c2b48bfdf7.tar.bz2 portage-b1b65de9604dab4824664f091f7884c2b48bfdf7.zip |
Fix slightly broken loop logic in insert_optional_args() by converting it to
pop args off of a stack.
svn path=/main/trunk/; revision=11262
-rw-r--r-- | pym/_emerge/__init__.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 205111999..a9f28a79d 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -12737,7 +12737,10 @@ def insert_optional_args(args): new_args = [] jobs_opts = ("-j", "--jobs") - for i, arg in enumerate(args): + arg_stack = args[:] + arg_stack.reverse() + while arg_stack: + arg = arg_stack.pop() short_job_opt = bool("j" in arg and arg[:1] == "-" and arg[:2] != "--") if not (short_job_opt or arg in jobs_opts): @@ -12760,16 +12763,15 @@ def insert_optional_args(args): job_count = "True" saved_opts = arg[1:].replace("j", "") - if job_count is None and \ - i < len(args) - 1: + if job_count is None and arg_stack: try: - job_count = int(args[i+1]) + job_count = int(arg_stack[-1]) except ValueError: pass else: - # The next loop iteration will append - # the validated job count to new_args. - continue + # Discard the job count from the stack + # since we're consuming it here. + arg_stack.pop() if job_count is None: # unlimited number of jobs |