summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-09-18 10:46:47 -0400
committerNick Mathewson <nickm@torproject.org>2019-09-23 08:48:53 -0400
commitf36e743e5de92cecee81a64d2e78ce5ca3070f98 (patch)
tree607ef654289aa3def706f3258559df6550ff262e /scripts
parent0b367f3386b0ec25f85716001690c95ae2e78c4d (diff)
downloadtor-f36e743e5de92cecee81a64d2e78ce5ca3070f98.tar.gz
tor-f36e743e5de92cecee81a64d2e78ce5ca3070f98.zip
annotate_ifdef_directives: introduce a function to make commented lines
No functional change in this commit.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/maint/annotate_ifdef_directives15
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/maint/annotate_ifdef_directives b/scripts/maint/annotate_ifdef_directives
index 15121652d7..fcd96aeb38 100755
--- a/scripts/maint/annotate_ifdef_directives
+++ b/scripts/maint/annotate_ifdef_directives
@@ -29,6 +29,12 @@ LINE_OBVIOUSNESS_LIMIT = 4
class Problem(Exception):
pass
+def commented_line(fmt, argument):
+ """
+ Return fmt%argument, for use as a commented line.
+ """
+ return fmt % argument
+
def uncomment(s):
"""
Remove existing trailing comments from an #else or #endif line.
@@ -83,7 +89,8 @@ def translate(f_in, f_out):
raise Problem("Unexpected #%s on %d"% (command,lineno))
if (len(cur_level) == 1 and command == 'else' and
lineno > cur_level[0][2] + LINE_OBVIOUSNESS_LIMIT):
- f_out.write("#else /* !(%s) */\n"%cur_level[0][1])
+ f_out.write(commented_line("#else /* !(%s) */\n",
+ cur_level[0][1]))
else:
f_out.write(line)
cur_level.append((command, rest, lineno))
@@ -96,9 +103,11 @@ def translate(f_in, f_out):
f_out.write(line)
elif len(cur_level) == 1 or (
len(cur_level) == 2 and cur_level[1][0] == 'else'):
- f_out.write("#endif /* %s */\n"%cur_level[0][1])
+ f_out.write(commented_line("#endif /* %s */\n",
+ cur_level[0][1]))
else:
- f_out.write("#endif /* %s || ... */\n"%cur_level[0][1])
+ f_out.write(commented_line("#endif /* %s || ... */\n",
+ cur_level[0][1]))
cur_level = stack.pop()
if len(stack) or cur_level != whole_file:
raise Problem("Missing #endif")