Skip to content

Commit

Permalink
GNUIndentBear.py Fix max_line_length=0
Browse files Browse the repository at this point in the history
Add infinite length when
max_line_length is set to 0

Fixes coala#2669
  • Loading branch information
srivama committed Aug 16, 2018
1 parent d07dde4 commit d309cbc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bears/c_languages/GNUIndentBear.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import platform
import shlex
import sys

from coalib.bearlib import deprecate_settings
from coalib.bearlib.abstractions.Linter import linter
Expand Down Expand Up @@ -155,6 +156,10 @@ def create_arguments(filename, file, config_file,
Any command line options the indent binary understands. They
will be simply passed through.
"""
# The limit is set to an arbitrary high value
if not max_line_length:
max_line_length = sys.maxsize

indent_options = ('--no-tabs' if use_spaces else '--use-tabs',
'--line-length', str(max_line_length),
'--indent-level', str(indent_size),
Expand Down Expand Up @@ -191,10 +196,6 @@ def create_arguments(filename, file, config_file,
if linux_style and indent_style_option is ()
else ())

# The limit is set to a number which equals to int max in C
if not max_line_length:
max_line_length = 2147483647

# If a style is chosen the other configs aren't passed to `indent`
return (indent_style_option if indent_style_option is not ()
else indent_options) + tuple(shlex.split(indent_cli_options))

0 comments on commit d309cbc

Please sign in to comment.