Change names of variables and functions in multiple files?

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?

Reply to
Geek
Loading thread data ...

Found help here:

formatting link

:-)

Reply to
Geek

Geek escreveu:

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

formatting link

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.
 Click to see the full signature
Reply to
Cesar Rabak

Check your development system to see if it has a 'refactoring' tool - that is usually the most reliable way. Otherwise I recommend WinGrep:

formatting link

-- Chris Burrows CFB Software Armaide: ARM Integrated Development System

formatting link

Reply to
Chris Burrows

e

Try PERL

Reply to
Ed Prochak

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!

Reply to
Jason Taylor

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

Reply to
Theo Markettos

It may be a no complete solution, but certainly helps more than doing manually.

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'.

You use regular expressions that sed and Perl support.

Sure.

It depends what you call as 'decent' :-)

--
Cesar Rabak
GNU/Linux User 52247.
 Click to see the full signature
Reply to
Cesar Rabak

Hello again.

I have found Eclipse IDE for C/C++ Developers

formatting link
it does rename refactoring. :-)

Thank you all.

Reply to
Geek

Geek escreveu:

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.
 Click to see the full signature
Reply to
Cesar Rabak

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).

--------------------------------------- This message was sent using the comp.arch.embedded web interface on

formatting link

Reply to
Geek

Geek escreveu:

If you don't mind a command line utility, I suggest you check indent

formatting link

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.
 Click to see the full signature
Reply to
Cesar Rabak

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.