Skip to content
Snippets Groups Projects
Commit 21cc9d13 authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

annotate_ifdef_directives: clarify situation with newlines

Our line limit is 80 characters, assuming that there is a single
terminating newline character that counts towards the limit.  On
Windows, this might go as high as 81 characters, if we count CRLF as
two characters.
parent 194dbea2
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,10 @@ import re
# Any block with fewer than this many lines does not need annotations.
LINE_OBVIOUSNESS_LIMIT = 4
# Maximum line width.
# Maximum line width. This includes a terminating newline character.
#
# (This is the maximum before encoding, so that if the the operating system
# uses multiple characers to encode newline, that's still okay.)
LINE_WIDTH=80
class Problem(Exception):
......@@ -38,7 +41,10 @@ def commented_line(fmt, argument, maxwidth=LINE_WIDTH):
be longer than maxwidth, truncate argument.
Requires that fmt%"..." will fit into maxwidth characters.
Requires that fmt ends with a newline.
"""
assert fmt.endswith("\n")
result = fmt % argument
if len(result) <= maxwidth:
return result
......
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