0% found this document useful (0 votes)
10 views7 pages

C C++Beautifier HOWTO

Uploaded by

cthung.photos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views7 pages

C C++Beautifier HOWTO

Uploaded by

cthung.photos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

C−C++ Beautifier HOW−TO

C−C++ Beautifier HOW−TO

Table of Contents
C−C++ Beautifier HOW−TO.............................................................................................................................1
Al Dev (Alavoor Vasudevan) alavoor@yahoo.com................................................................................1
1.Introduction...........................................................................................................................................1
2.How can I trust Beautifier programs??!!..............................................................................................1
3.Beautifiers for other Languages............................................................................................................1
4.Other Formats of this Document...........................................................................................................1
5.Copyright..............................................................................................................................................1
1. Introduction..........................................................................................................................................1
2. How can I trust Beautifier programs??!!.............................................................................................2
3. Beautifiers for other Languages...........................................................................................................3
4. Other Formats of this Document..........................................................................................................4
5. Copyright.............................................................................................................................................5

i
C−C++ Beautifier HOW−TO

Al Dev (Alavoor Vasudevan) [email protected]


v1.0, 7 February 2000

This document will help you to format (beautify) the C/C++ programs so that it is more readable and
confirms to your site C/C++ coding standards. The information in this document applies to all the operating
sytems that is − Linux, MS DOS, Windows 95/NT, all flavors of Unix like Solaris, HPUX, AIX, SCO, Sinix,
BSD, SCO, etc.. and to all other operating systems which support "C" compiler.

1.Introduction

2.How can I trust Beautifier programs??!!

3.Beautifiers for other Languages

4.Other Formats of this Document

5.Copyright
Next Previous Contents Next Previous Contents

1. Introduction
Coding standards for C/C++ or any language is required in order to make the programs more
readable/understandable by programmers. There are C/C++ beautifiers (formating tools) to accomplish this
goal. Formatted (beautified) code improves the productivity of programmers by 2 times!!

On Linux/Unixes there is a command called "indent" and "cb" . Refer to 'man indent' and 'man cb'. Note
that indent and cb work for only "C" programs. For "C++" programs use "bcpp". Download the beautifier

C−C++ Beautifier HOW−TO 1


C−C++ Beautifier HOW−TO

program from one of the following

• C++ : BCPP site is at http://www.clark.net/pub/dickey/bcpp/bcpp.html


• C++ : http://www.consultix−inc.com/www.consultix−inc.com/c++b.html
• C : http://www.chips.navy.mil/oasys/c/

I used BCPP to format the C++ programs and it worked fine for me. You may want to check other tools and
use the one which you may like the most.

Next Previous ContentsNextPreviousContents

2. How can I trust Beautifier programs??!!


For 100% assurance you need a SCIENTIFIC way to validate and trust a beautifier program. The method
described in this section will enable the beautifier program to be accepted as "trust−worthy" and reliable.

In order to verify that beautifier programs like bcpp, indent or cb is not damaging or changing the input
source−code after formatting, use the following technique −

Generate the object code from the original input source code using the compiler −

g++ −c myprogram.cpp

Here g++ is GNU C++ compiler. This will create object output myprogram.o

Save this file −

mv myprogram.o myprogram_orig.o

Now run bcpp −

bcpp myprogram.cpp

This will create the formatted output program file myprogram.cpp and move the original file to
myprogram.cpp.orig. Compile the new file with −

g++ −c myprogram.cpp

Now use the unix 'diff' command to compare the two object files −

diff myprogram.o myprogram_orig.o

Both these files MUST BE IDENTICAL. This verifies that bcpp is working perfectly. On DOS or Windows
95 you may want to use the free Cygnus Cygwin 'diff' or 'MKS' utilities.

2. How can I trust Beautifier programs??!! 2


C−C++ Beautifier HOW−TO

Also you can use the assembler output instead of object output in compiler. Like −

g++ −S myprogram.cpp

This creates myprogram.s. Verify with −

diff myprogram.s myprogram_orig.s

This step gives 100% guarantee that your valuable source code is intact and bcpp is JUST doing ONLY
formatting and is NOT changing or damaging your code in any way. This method gives you 100% quality
assurance and long term WARRANTY on beautifier programs like 'bcpp', 'cb' or 'indent'.

It is strongly recommended that you do these two steps every time you run beautifier programs like bcpp,
indent or cb.

NextPreviousContentsNextPreviousContents

3. Beautifiers for other Languages


Visit the following sites to get beautifiers for other languages like HTML, SQL, Java, Perl, Fortran.

• HTML : http://www.digital−mines.com/htb/
• HTML : http://www.datacomm.ch/mwoog/software/perl/beautifier.html
• HTML : http://www.watson−net.com/free/perl/s_fhtml.asp
• SQL : http://www.netbula.com/products/sqlb
• Java : http://home.wtal.de/software−solutions/jindent/frameset.html
• Perl : http://www.consultix−inc.com/www.consultix−inc.com/talk.htm
• Perl : http://www.consultix−inc.com/www.consultix−inc.com/perl_beautifier.html
• Fortran beautifier : http://www.aeem.iastate.edu/Fortran/tools.html
• C++ : BCPP site is at http://www.clark.net/pub/dickey/bcpp/bcpp.html
• C++ : http://www.consultix−inc.com/www.consultix−inc.com/c++b.html
• C : http://www.chips.navy.mil/oasys/c/

• White paper on beautifier : http://www.consultix−inc.com/www.consultix−inc.com/talk.htm

To create presentation of codes to display using HTML −

• Presentation (C,C++,Java) to html : http://www.perlstudio.de/cbindex.html

Also search the search engines like http://www.yahoo.com or http://www.lycos.com and search for keyword
"beautfier".

NextPreviousContentsNextPreviousContents

3. Beautifiers for other Languages 3


C−C++ Beautifier HOW−TO

4. Other Formats of this Document


This document is published in 10 different formats namely − DVI, Postscript, Latex, LyX, GNU−info,
HTML, RTF(Rich Text Format), Plain−text, Unix man pages and SGML.

• You can get this HOWTO document as a single file tar ball in HTML, DVI, Postscript or SGML
formats from − ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/other−formats/ or
ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/other−formats/
• Plain text format is in: ftp://metalab.unc.edu/pub/Linux/docs/HOWTO or
ftp://metalab.unc.edu/pub/Linux/docs/HOWTO
• Translations to other languages like French, German, Spanish, Chinese, Japanese are in
ftp://metalab.unc.edu/pub/Linux/docs/HOWTO or
ftp://metalab.unc.edu/pub/Linux/docs/HOWTO Any help from you to translate to other languages is
welcome.

The document is written using a tool called "SGML tool" which can be got from −
http://www.xs4all.nl/~cg/sgmltools/ Compiling the source you will get the following commands like

• sgml2html C−C++Beautifier−howto.sgml (to generate html file)


• sgml2rtf C−C++Beautifier−howto.sgml (to generate RTF file)
• sgml2latex C−C++Beautifier−howto.sgml (to generate latex file)

This document is located at −

• http://metalab.unc.edu/LDP/HOWTO/C−C++Beautifier−HOWTO.html

Also you can find this document at the following mirrors sites −

• http://www.caldera.com/LDP/HOWTO/C−C++Beautifier−HOWTO.html
• http://www.WGS.com/LDP/HOWTO/C−C++Beautifier−HOWTO.html
• http://www.cc.gatech.edu/linux/LDP/HOWTO/C−C++Beautifier−HOWTO.html
• http://www.redhat.com/linux−info/ldp/HOWTO/C−C++Beautifier−HOWTO.html
• Other mirror sites near you (network−address−wise) can be found at
http://metalab.unc.edu/LDP/hmirrors.html select a site and go to directory
/LDP/HOWTO/C−C++Beautifier−HOWTO.html

In order to view the document in dvi format, use the xdvi program. The xdvi program is located in
tetex−xdvi*.rpm package in Redhat Linux which can be located through ControlPanel | Applications |
Publishing | TeX menu buttons.

To read dvi document give the command −


xdvi −geometry 80x90 howto.dvi
And resize the window with mouse. See man page on xdvi.
To navigate use Arrow keys, Page Up, Page Down keys, also
you can use 'f', 'd', 'u', 'c', 'l', 'r', 'p', 'n' letter
keys to move up, down, center, next page, previous page etc.
To turn off expert menu press 'x'.

4. Other Formats of this Document 4


C−C++ Beautifier HOW−TO

You can read postscript file using the program 'gv' (ghostview) or 'ghostscript'. The ghostscript program is in
ghostscript*.rpm package and gv program is in gv*.rpm package in Redhat Linux which can be located
through ControlPanel | Applications | Graphics menu buttons. The gv program is much more user friendly
than ghostscript. Ghostscript and gv are also available on other platforms like OS/2, Windows 95 and NT.

To read postscript document give the command −


gv howto.ps

To use ghostscript give −


ghostscript howto.ps

You can read HTML format document using Netscape Navigator, Microsoft Internet explorer, Redhat Baron
Web browser or any other web browsers.

You can read the latex, LyX output using LyX a "X−Windows" front end to latex.

NextPreviousContents Next PreviousContents

5. Copyright
Copyright is GNU GPL but it is requested that you retain the author's name and email on all copies.

Next PreviousContents

5. Copyright 5

You might also like