diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-12-16 10:57:30 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-12-16 10:57:30 +0000 |
commit | 58c3231b55918324adf92c6fee152d7825e67236 (patch) | |
tree | 21aefdb1d8012ba952714e18ef8b3495ea10e37a /tools/clang-format | |
parent | 3817e4bbaa8753beb43887343a50b494aec6a745 (diff) | |
download | clang-58c3231b55918324adf92c6fee152d7825e67236.tar.gz clang-58c3231b55918324adf92c6fee152d7825e67236.tar.bz2 clang-58c3231b55918324adf92c6fee152d7825e67236.tar.xz |
Added -iregex for case-insensitive regex to filter file names.
Summary:
-regex and -iregex both mimic options of the find utility.
Made the default list of extensions case-insensitive, so that it's not only C
and CPP extensions are accepted in upper case.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2415
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197378 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-format')
-rwxr-xr-x | tools/clang-format/clang-format-diff.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/clang-format/clang-format-diff.py b/tools/clang-format/clang-format-diff.py index f8fceeb4fc..b914c37795 100755 --- a/tools/clang-format/clang-format-diff.py +++ b/tools/clang-format/clang-format-diff.py @@ -43,9 +43,13 @@ def main(): help='apply edits to files instead of displaying a diff') parser.add_argument('-p', metavar='NUM', default=0, help='strip the smallest prefix containing P slashes') - parser.add_argument('-regex', metavar='PATTERN', default= - r'.*\.(cpp|cc|CPP|C|c\+\+|cxx|c|h|hpp|m|mm|inc|js)', - help='custom pattern selecting file paths to reformat') + parser.add_argument('-regex', metavar='PATTERN', default='', + help='custom pattern selecting file paths to reformat ' + '(case sensitive, override -iregex)') + parser.add_argument('-iregex', metavar='PATTERN', default= + r'.*\.(cpp|cc|c\+\+|cxx|c|h|hpp|m|mm|inc|js)', + help='custom pattern selecting file paths to reformat ' + '(case insensitive, override -regex)') parser.add_argument( '-style', help= @@ -62,8 +66,12 @@ def main(): if filename == None: continue - if not re.match(args.regex, filename): - continue + if args.regex != '': + if not re.match(args.regex, filename): + continue + else: + if not re.match(args.iregex, filename, re.IGNORECASE): + continue match = re.search('^@@.*\+(\d+)(,(\d+))?', line) if match: |