Skip to content
Snippets Groups Projects
Commit b43a3a58 authored by Ximin Luo's avatar Ximin Luo
Browse files

Set limits to inf when parsing args, instead of checking for "> 0" everywhere

parent 341be077
No related branches found
No related tags found
No related merge requests found
......@@ -110,7 +110,7 @@ class DiffParser(object):
if line[0] in ('-', '+') and line[0] == self._direction:
self._block_len += 1
max_lines = Config.general.max_diff_block_lines
if max_lines > 0 and self._block_len >= max_lines:
if self._block_len >= max_lines:
return self.skip_block
else:
self._block_len = 1
......@@ -229,14 +229,14 @@ def make_feeder_from_raw_reader(in_file, filter=lambda buf: buf):
line_count = 0
end_nl = False
h = None
if max_lines > 0:
if max_lines < float("inf"):
h = hashlib.sha1()
for buf in in_file:
line_count += 1
out = filter(buf)
if h:
h.update(out)
if max_lines == 0 or line_count < max_lines:
if line_count < max_lines:
out_file.write(out)
end_nl = buf[-1] == '\n'
if h and line_count >= max_lines:
......
......@@ -165,9 +165,9 @@ class ListToolsAction(argparse.Action):
def maybe_set_limit(config, parsed_args, key):
v = getattr(parsed_args, key)
if v is not None:
setattr(config, key, v)
setattr(config, key, float("inf") if v == 0 else v)
elif parsed_args.no_max_limits:
setattr(config, key, 0)
setattr(config, key, float("inf"))
def run_diffoscope(parsed_args):
......
......@@ -190,7 +190,7 @@ def create_limited_print_func(print_func, max_page_size):
limited_print_func.char_count = 0
print_func(s)
limited_print_func.char_count += len(s)
if not force and max_page_size > 0 and limited_print_func.char_count >= max_page_size:
if not force and limited_print_func.char_count >= max_page_size:
raise PrintLimitReached()
return limited_print_func
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment