[comp.lang.c] Looking to C conversion utility

stevem@hpvcfs1.HP.COM (Steve Miller) (07/27/89)

I'm looking for a shell script, C program, or anything that will do the
following conversions on a large number of C source files:

1) Convert all variables spelled "my_var" to "myVar"
2) Convert all procedures named "My_Procedure" to "MyProcedure"
3) Convert all variable types to a custome typedef:              
   (Example:  convert "char" to "UBYTE" or convert "short" to "UINT")
4) Leave constants alone (MY_CONSTANT)

The script/program must work reliably enough that minimal or no editing needs
to be done to correct mistakes since many source files are involved.  I
expect these types of things have been done before and it would be nice to
take advantage of existing solutions of this problem.

Thanks in Advance.

Steven Miller  stevem@hpvcfs1
Vancouver Division
Hewlett Packard 

acs60222@zach.fit.edu ( ENRIQUEZ) (07/27/89)

In article <700001@hpvcfs1.HP.COM> stevem@hpvcfs1.HP.COM (Steve Miller) writes:
>
>I'm looking for a shell script, C program, or anything that will do the
>following conversions on a large number of C source files:
>
>1) Convert all variables spelled "my_var" to "myVar"
>2) Convert all procedures named "My_Procedure" to "MyProcedure"
>3) Convert all variable types to a custome typedef:              
>   (Example:  convert "char" to "UBYTE" or convert "short" to "UINT")
>4) Leave constants alone (MY_CONSTANT)
>

It seems an easy way to do this would be to load the file into 
a word processor and use a "find/replace/global" command to do all
the switching at once.

Also, if you are using UNIX, the vi editor has the same feature.
I think the syntax is:

    :g/old_string/s//new_string

I attempted to mail this, but it was bounced...

    Good Luck!

    mark enriquez  acs60222@zach.UUCP
  

stevem@hpvcfs1.HP.COM (Steve Miller) (07/27/89)

My base note stated:

>1) Convert all variables spelled "my_var" to "myVar"
>2) Convert all procedures named "My_Procedure" to "MyProcedure"

I realize that my original posting was not very clear.  I should have said:

1) Convert all variables spelled with an underscore to be spelled without the
   underscore but with the word following the underscore capitalized.
   (Example:  my_var becomes myVar  and string_ptr becomes stringPtr)

2) Eliminate all underscores from procedure names.
   (Examples: My_Procedure becomes MyProcedure and A_Big_Proc becomes ABigProc)

Sorry,

Steven Miller  stevem@hpvcfs1
Vancouver Division
Hewlett Packard