| Index: tools/pragmaonce/pragmaonce.py
|
| diff --git a/tools/pragmaonce/pragmaonce.py b/tools/pragmaonce/pragmaonce.py
|
| old mode 100644
|
| new mode 100755
|
| index 15224c49edbf149c6a7781e961b8beafb5885b64..22f22a8eff437f88a32bd9e1e0e27c59d55f68a5
|
| --- 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]))
|
|
|