Link to home
Start Free TrialLog in
Avatar of lhgarrett
lhgarrett

asked on

Source Code Reformatting Tool

Does anyone know where to find a shareware source code reformatting tool for C/C++?

So far I found the following for a fee:

  C-Clearly at
  http://www.mixsoftware.com/product/ccl.htm 

  Visual Source Format at
  http://www.SourceFormat.com 
Avatar of ozo
ozo
Flag of United States of America image

cb
Avatar of mliberi
mliberi

Did you ever try GNU indent?

http://www.gnu.org/software/indent/indent.html
Avatar of lhgarrett

ASKER

To ozo and mliberi:

I should have mentioned that I am doing my development on a PC. Both cb and indent look like they are Unix-based utilities. Do you folks know any formatter tools for DOS or Win98?
You can get the indent sources at
ftp://ftp.gnu.org/gnu/indent/
or from one of the mirrors listed at
http://www.gnu.org/order/ftp.html
and port it to your PC
if you are on VC there are some macros at codeguru.com

nil_dib
To ozo:

I found the source code for indent, and extracted the tar file to my PC. I unarchived the source code and shell scripts. I created a project in MS Visual C++, and tried to compile and link. I got 19 errors associated with the indent.exe executable.

I think I'm doing this the hard way! Is there a pre-compiled executable that I can download instead?

Thanks :-)
To nil dib:

Can you tell me where to find some specific macros at codeguru.com, or their names so I can do a search for them?

Thanks
Is there a C++ reformatting tool as customizable as indent (preferrably free)?
If you are using MSDev, just select the code and do Alt+F8.
I own a 'indent' DOS executable. I don't remember if I produced it by compiling the sources or I found it already compiled.

If you like I could send or POST it (uuencoded)
>> If you are using MSDev, just select the code and do Alt+F8.
Hardly "customizable"
Just in case you are using emacs -
do
M-x c-set-style
then type C programming style, there are a number available,e.g. I am using "ellemtel".
Then in any file mark a region and do
M-x indent-region

You can create your own customized style
read doc of c-style-alist variable (C-h v c-style-alist)

Hope that helps.
ASKER CERTIFIED SOLUTION
Avatar of Gyles
Gyles

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> http://www.codeguru.com/devstudio_macros/MakeCodeNicer.shtml 

This works to a point, but it is very slow since it is a macro that works in visual mode. Ideally, the code would be reformatted in a subprocess, and then redisplayed when the job is done.

Also, there are some inconsistencies and issues that the macro seems to overlook (lining up enumerated types, #ifdefs outside of the main() function, breaking-up onto multiple lines function signatures over 80 characters).
> Just in case you are using emacs
Actually, I'm using a combination of "improved vi" (www.vim.org) and MSDEV.

If there is a Vim function I'm unaware of, that would be slick!!!
> I own a 'indent' DOS executable...
I would like to try this out if possible (lhgarrett@hotmail.com).

> A simple but flexible one:
Gyles' suggestion seems to work pretty well, so I'm going to award points at this time.
I uploaded 'INDENT.EXE' to my home page.
Please download from http://www.geocities.com/mliberi/INDENT.ZIP