]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
annotate_ifdef_directives: clarify situation with newlines
authorNick Mathewson <nickm@torproject.org>
Thu, 26 Sep 2019 01:13:30 +0000 (21:13 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 26 Sep 2019 19:52:45 +0000 (15:52 -0400)
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.

scripts/maint/annotate_ifdef_directives

index 4463d8382838da42b79f6958f90c57e87d773928..b6bb147ce29f434a735d6a69c7733ad7e901ae5f 100755 (executable)
@@ -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