help:text processing needed when porting

Z

Zhenhuan Du

Hello!
I was porting some files writing by others in C language.
Due to bad naming ,I found many
typedefs disagreement and macro definition conflicts.
That was really annoying.

My first solutions are :

So for clearance and portability, I want to do following actions.
1)Add a prefix like "CCC_" before every macro definition ,typedef
,functions name and global variable.
2)Add a prefix like "CCC_" in every ".c" file name and ".h" file name.
I there any

For example:
file1.c contains
#define define1 0x0
becomes
CCC_file1.c
#define CCC_define1 0x0

But I can't find any software capable of doing this job.

I know this kind of work is more like common text batch processing .

But I'm not good at this kind of programming.Maybe someone has done a
good job like this. Can anybody give some advice here? Thanks !

Also, if any other kind of solution is available, share with me please.




Du Zhenhuan <[email protected]>
 
J

John Bokma

Jim Gibson said:
I would start by putting all of the files to convert in a directory
tree, using the File::Find module to find each C source file. use open
and <> to read each file line-by-line, use mkdir, open, and print to
create a modified copy in a parallel directory tree,

How about checking the whole thing into a version control system? Way
easier.
file names and #define statements using regular expressions and the
s/// operator. You want to keep the original files untouched so you can
inspect the modified versions of your files and compare them to the
originals (e.g. with the Unix diff utility).

I am sure there are visual diffs for *nix as well that come with a version
control system. With Windows, TortoiseSVN would this part (checking in,
comparing, etc) make a piece of cake.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top