summaryrefslogtreecommitdiffstats
path: root/tools/pragmaonce
diff options
context:
space:
mode:
Diffstat (limited to 'tools/pragmaonce')
-rwxr-xr-x[-rw-r--r--]tools/pragmaonce/pragmaonce.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/pragmaonce/pragmaonce.py b/tools/pragmaonce/pragmaonce.py
index 15224c4..22f22a8 100644..100755
--- a/tools/pragmaonce/pragmaonce.py
+++ b/tools/pragmaonce/pragmaonce.py
@@ -1,13 +1,17 @@
-# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+#!/usr/bin/env python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+"""Tool to add "#pragma once" lines to files that don't have it yet.
+
+Usage:
+ find chrome -name '*.h' -exec tools/pragmaonce/pragmaonce.py {} \;
+"""
+
import re
import sys
-# A tool to add "#pragma once" lines to files that don't have it yet.
-# Intended usage:
-# find chrome -name '*.h' -exec python tools/pragmaonce/pragmaonce.py {} \;
# Some files have absurdly long comments at the top
NUM_LINES_TO_SCAN_FOR_GUARD = 250
@@ -34,16 +38,17 @@ def main(filename):
if index < len(lines) and re.match(r'#pragma once', lines[index]):
# The pragma is already there.
- return
+ return 0
lines.insert(index, "#pragma once\n")
f = open(filename, 'w')
f.write(''.join(lines))
f.close()
+ return 0
if __name__ == '__main__':
if len(sys.argv) != 2:
print >>sys.stderr, "Usage: %s inputfile" % sys.argv[0]
sys.exit(1)
- main(sys.argv[1])
+ sys.exit(main(sys.argv[1]))