1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
Last updated (02/24/2005)
Simple Refactoring Tools for C/C++
These tools help in performing simple refactoring tasks like renaming of
identifiers in source files or any other type of ASCII text file.
Important!!!! In order for some of these scripts to be used, the directory
where these scripts are located must be added to the PATH environment
variable. Some of the scripts have been updated to not require this.
update-copyright-header.py --copyright-header=COPYRIGHTFILE --file=FILE
Updates a given source file's copyright header info. This will replace a
the files current copyright header if it already has one and will add it if
the file does not already have one.
token-replace.pl old_token new_token old_file new_file
Replaces all occurrences of 'old_token' from the file 'old_file' with
'new_token' and puts the modified text into the file 'new_file'.
Note that this function will only replace tokens and not strings
in the middle of tokens. The file 'new_file' can be the same as 'old_file'
and if 'new_file' and 'old_file' are the same and no replacement is performed
then the file is not modifed. The greatly helps with CVS.
token-replace-r old_token new_token
Replaces all occurrences of 'old_token' with 'new_token' in all the files
starting with the current directory and then extending into all
of the children subdirectories. Note that files in directories with
the name 'CVS' are not searched or replaced. The files that are modified
are modified in place. This script calls 'token-replace.pl' as its
workhorse.
token-replace-list.pl token_list old_file new_file
Performs all token replacements specified in the file 'token_list' (note,
this file must be specified using its absolute path, not its relative path)
by replacing tokens in the file 'old_file' and putting the modified
text into the file 'new_file'. The file token_list must take the
form:
old-token-1 new-token-1
old-token-2 new-token-2
...
old-token-n new-token-n
The file 'new_file' can be the same as 'old_file' and if 'new_file' and
'old_file' are the same and no replacement is performed then the file is not
modifed. The greatly helps with CVS.
token-replace-list-r token_list
Performs all token replacements specified in the file 'token_list'
(see 'token-replace-list.pl') by replacing tokens in the all the files
starting with the current directory and then extending into all of the
children subdirectories. Note that files in directories with the
name 'CVS' are not searched or replaced. The files are modified in
place. If no text is replaced in the file then the file's timestamp
is not modifed. This greatly helps CVS. This script calls
'token-replace-list.pl' as its workhorse.
string-replace.pl old_string new_string old_file new_file
Replaces all occurrences of 'old_string' from the file 'old_file'
with 'new_string' and puts the modified text into the file
'new_file'. Note that this function does not respect tokens and will
replace strings in the middle of tokens. When this utility is called,
the 'old_string' is interpreted as a regular expression so remember
to escape characters such as '#' with '\#' etc. The file 'new_file' can be
the same as 'old_file' and if 'new_file' and 'old_file' are the same and no
replacement is performed then the file is not modifed. The greatly helps
with CVS.
string-replace-r old_string new_string
Replaces all occurrences of 'old_string' with 'new_string' in all the
files starting with the current directory and then extending into
all of the children subdirectories. Note that files in directories
with the name CVS are not searched or replaced. The files are
modified in place. If no text is replaced in the file then the file's
time stamp is not modifed. This script calls 'string-replace.pl' as
its workhorse.
string-replace-list.pl string_file old_file new_file
Replaces all occurrences of a list of strings in the file 'string_file'
(note, this file must use it's absolute path and not a relative path). Each
pair of replacements is on seperate lines with a newline in between them.
It is necessary to have a newline in between strings since we can
not use a space as a seperator (as we did with a token replacement
since strings can not have spaces. This makes the string replacement
file a little harder to read but is more general. Specifically, the
file string_file must take the form:
old-string-1
new-string-1
old-string-2
new-string-2
...
old-string-n
new-sting-n
This script has the same behavior as 'string-replace.pl' except it
operates on a list of strings.
string-replace-list-r string_file
Replaces all occurrences of a list strings from the file 'string_file' in
all the files starting with the current directory and then extending into
all of the children subdirectories. Note that files in directories
with the name 'CVS' are not searched or replaced. The files are
modified in place. This script calls the script 'string-replace-list.pl'
as its workhorse.
fix-dos-text-file.pl file_in file_out
Fixes dos files by removing the ^M from the ends. The file 'file_in' and
'file_out' can be the same files. If the files are the same and no text is
modified then the file's time stamp is not modifed. This is useful for CVS.
fix-dos-text-file-r
Calls 'fix-dos-text-file.pl' on all files starting with the current
directory and then extending into all of the children subdirectories. Note
that files in directories with the name CVS are not touched. The files are
modified in place. If no text is replaced in the file then the file's
time stamp is not modifed.
replace-tabs-with-spaces.pl spaces_per_tab file_in file_out
Replaces leading tabs with 'spaces_per_tab' spaces. The files
'file_in' and 'file_out' can be the same file. If the files are
the same and no tabs are replaced, the the file's time stamp is not
changed.
replace-tabs-with-spaces-r spaces_per_tab
Calls 'fix-dos-text-file.pl spaces_per_tab' on all files starting with the
current directory and then extending into all of the children
subdirectories. Note that files in directories with the name CVS are not
touched. The files are modified in place. If no text is replaced in the
file then the file's time stamp is not modifed.
copy-files-list.py old_dir new_dir old_to_new_file_list
Script reads a set of files and copies them from on directory to another and
renames them given a list of names. The file old_to_new_file_list contains rows
of the form:
file1_oldname file1_newname
file2_oldname file2_newname
...
filen_oldname filen_newname
|