From 8a160cc42b8db21fcbc5a9e92f28bef1c726f3ec Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Thu, 2 Jun 2011 16:58:33 +0000 Subject: Reverts the Tooling changes as requested by Chris. llvm-svn: 132462 --- clang/examples/Tooling/replace.py | 50 --------------------------------------- 1 file changed, 50 deletions(-) delete mode 100755 clang/examples/Tooling/replace.py (limited to 'clang/examples/Tooling/replace.py') diff --git a/clang/examples/Tooling/replace.py b/clang/examples/Tooling/replace.py deleted file mode 100755 index a738dea70c0..00000000000 --- a/clang/examples/Tooling/replace.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python - -#===- replace.py - Applying code rewrites --------------------*- python -*--===# -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -#===------------------------------------------------------------------------===# -# -# This script applies the rewrites generated by replace-cstr-calls on a source -# tree. -# -# Usage: -# ./replace.py < /path/to/replace-cstr-calls-output -# -#===------------------------------------------------------------------------===# - -import fileinput -import re -import sys - -for line in sys.stdin.readlines(): - # The format is: - # ::::: - # FIXME: This currently does not support files with colons, we'll need to - # figure out a format when we implement more refactoring support. - match = re.match(r'(.*):(\d+):(\d+):(\d+):(\d+):(.*)$', line) - if match is not None: - file_name = match.group(1) - start_line, start_column = int(match.group(2)), int(match.group(3)) - end_line, end_column = int(match.group(4)), int(match.group(5)) - replacement = match.group(6) - if start_line != end_line: - print ('Skipping match "%s": only single line ' + - 'replacements are supported') % line.strip() - continue - try: - replace_file = fileinput.input(file_name, inplace=1) - for replace_line in replace_file: - # FIXME: Looping over the file for each replacement is both inefficient - # and incorrect if replacements add or remove lines. - if replace_file.lineno() == start_line: - sys.stdout.write(replace_line[:start_column-1] + replacement + - replace_line[end_column:]) - else: - sys.stdout.write(replace_line) - except OSError, e: - print 'Cannot open %s for editing' % file_name -- cgit v1.2.3