| Computers Forum Index » Computer Architecture - Embedded » Change names of variables and functions in multiple... |
|
Page 1 of 1 |
|
| Author |
Message |
| Geek... |
Posted: Thu Oct 15, 2009 9:11 pm |
|
|
|
Guest
|
Hello
I would like to have a program that allows me to change a word in multiple
files.
I need to change multiple variable and function names (to comply with a
coding standard).
Any tips? |
|
|
| Back to top |
|
|
|
| Geek... |
Posted: Thu Oct 15, 2009 9:16 pm |
|
|
|
Guest
|
|
| Back to top |
|
|
|
| Cesar Rabak... |
Posted: Thu Oct 15, 2009 10:40 pm |
|
|
|
Guest
|
Geek escreveu:
Quote: Hello
I would like to have a program that allows me to change a word in
multiple files.
I need to change multiple variable and function names (to comply with a
coding standard).
Any tips?
As you seem to be posting from a Microsoft Windows platform, maybe
you're less acquainted with a Unix utility called 'sed' that allows to
do that. It is available for Windows as a port of GNU utils at
http://gnuwin32.sourceforge.net/packages/sed.htm
As an advantage in relation to the alternative of using an editor, you
can write scripts, and if you like put a lot of then in a batch file and
have the conversion done while you go have a coffee or if your
environment requires it, at night and collect the result the other day.
--
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/ |
|
|
| Back to top |
|
|
|
| Ed Prochak... |
Posted: Fri Oct 16, 2009 3:25 am |
|
|
|
Guest
|
On Oct 15, 1:11 pm, "Geek" <g... at (no spam) gik.ze> wrote:
Quote: Hello
I would like to have a program that allows me to change a word in multiple
files.
I need to change multiple variable and function names (to comply with a
coding standard).
Any tips?
Try PERL |
|
|
| Back to top |
|
|
|
| Jason Taylor... |
Posted: Fri Oct 16, 2009 4:54 am |
|
|
|
Guest
|
On 15 Oct, 13:11, "Geek" <g... at (no spam) gik.ze> wrote:
Quote: Hello
I would like to have a program that allows me to change a word in multiple
files.
I need to change multiple variable and function names (to comply with a
coding standard).
Any tips?
Try Crystal REVS from sgvsarc
It can find and replace the names of variables and functions in
mutliple files. It searches as per lexical scope rules; other
similarly spelled words in the files are left untouched.
It can check for compliance with naming convention as well.
You can examine the use of variables via its DataFlow and Rich Tree
features. It's neat tool! |
|
|
| Back to top |
|
|
|
| Chris Burrows... |
Posted: Fri Oct 16, 2009 5:03 am |
|
|
|
Guest
|
"Geek" <gik at (no spam) gik.ze> wrote in message
news:4ad757d3$0$288$14726298 at (no spam) news.sunsite.dk...
Quote:
I would like to have a program that allows me to change a word in multiple
files.
I need to change multiple variable and function names (to comply with a
coding standard).
Check your development system to see if it has a 'refactoring' tool - that
is usually the most reliable way. Otherwise I recommend WinGrep:
http://www.wingrep.com/features.htm
--
Chris Burrows
CFB Software
Armaide: ARM Integrated Development System
http://www.cfbsoftware.com/armaide |
|
|
| Back to top |
|
|
|
| Theo Markettos... |
Posted: Fri Oct 16, 2009 5:44 pm |
|
|
|
Guest
|
Ed Prochak <edprochak at (no spam) gmail.com> wrote:
Text processing sometimes doesn't help. Consider:
struct foo {
int x;
}
int x(int x, char *s)
{
struct foo bill;
bill.x = strlen(s);
x=bar(x,bill);
return x;
}
There are three separate scopes of the identifier 'x' there. Without
writing a C compiler, how does your perl script tell the difference?
'Refactoring' is indeed the term to search for.
(Are there any decent open source options out there?)
Theo |
|
|
| Back to top |
|
|
|
| Cesar Rabak... |
Posted: Fri Oct 16, 2009 10:07 pm |
|
|
|
Guest
|
Theo Markettos escreveu:
Quote: Ed Prochak <edprochak at (no spam) gmail.com> wrote:
Try PERL
Text processing sometimes doesn't help.
It may be a no complete solution, but certainly helps more than doing
manually.
Quote: Consider:
struct foo {
int x;
}
int x(int x, char *s)
{
struct foo bill;
bill.x = strlen(s);
x=bar(x,bill);
return x;
}
Very interesting pathological case! It remains to the OP to see how it
pertains to the his problem. Given he posted that an editor that allows
manually edition of several files would cut, I surmise the answer is
'not too much'.
Quote: There are three separate scopes of the identifier 'x' there. Without
writing a C compiler, how does your perl script tell the difference?
You use regular expressions that sed and Perl support.
Quote:
'Refactoring' is indeed the term to search for.
Sure.
Quote: (Are there any decent open source options out there?)
It depends what you call as 'decent' :-)
--
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/ |
|
|
| Back to top |
|
|
|
| Geek... |
Posted: Sat Oct 17, 2009 8:25 pm |
|
|
|
Guest
|
Hello again.
I have found Eclipse IDE for C/C++ Developers
(http://www.eclipse.org/downloads/), it does rename refactoring. :-)
Thank you all. |
|
|
| Back to top |
|
|
|
| Cesar Rabak... |
Posted: Sat Oct 17, 2009 8:46 pm |
|
|
|
Guest
|
Geek escreveu:
Quote: Hello again.
I have found Eclipse IDE for C/C++ Developers
(http://www.eclipse.org/downloads/), it does rename refactoring. :-)
Thank you all.
Interesting! Does Eclipse IDE for C/C++ refactor in batch mode or you
have to set up a project in order all the dependencies are accounted for?
--
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/ |
|
|
| Back to top |
|
|
|
| Cesar Rabak... |
Posted: Wed Oct 21, 2009 11:17 pm |
|
|
|
Guest
|
Geek escreveu:
Quote: Interesting! Does Eclipse IDE for C/C++ refactor in batch mode or you
have to set up a project in order all the dependencies are accounted for?
I think you must make a new project and import all your C and H files so it
can find all dependencies.
I tried it out yesterday with files from an old PIC24 project.
It would also be nice to apply some kind of code formatting at a press of a
button (code beautifier).
If you don't mind a command line utility, I suggest you check indent
http://gnuwin32.sourceforge.net/packages/indent.htm
Otherwise, the c-mode of Emacs is powerful and you can get almost the
same effect with a key combination :-)
--
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/ |
|
|
| Back to top |
|
|
|
|