LDP/LDP/howto/docbook/C-C++Beautifier-HOWTO.xml

1878 lines
59 KiB
XML

<?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY version "0.01">
]>
<article id="C-C--Beautifier-HOWTO">
<articleinfo>
<title>
C-C++ Beautifier HOW-TO
</title>
<author>
<firstname>
Al Dev (Alavoor Vasudevan)
</firstname>
<authorblurb>
<para>
<ulink url="mailto:alavoor[AT]yahoo.com">
alavoor[AT]yahoo.com
</ulink>
</para>
</authorblurb>
<affiliation>
<address format="linespecific">
<email>
alavoor[AT]yahoo.com
</email>
</address>
</affiliation>
</author>
<pubdate>
v16.7, 2 Nov 2003
</pubdate>
<abstract>
<para>
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, Apple Macintosh, Windows
95/NT/2000, BeOS, OS/2, IBM OSes, all flavors of Unix like Solaris,
HPUX, AIX, SCO, Sinix, BSD, UnixWare, etc.. and to all other operating
systems which support "C" compiler (it means almost all the operating
systems on this planet!).
</para>
</abstract>
</articleinfo>
<sect1 id="introduction">
<title>
Introduction
</title>
<para>
<emphasis remap="bf">
(The latest version of this document is at
<ulink url="http://www.milkywaygalaxy.freeservers.com">
"http://www.milkywaygalaxy.freeservers.com"
</ulink>
. You may want to check there for changes).
</emphasis>
</para>
<para>
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
<emphasis remap="bf">
productivity
</emphasis>
of programmers by
<emphasis remap="bf">
2 times
</emphasis>
!!
</para>
<para>
On Linux/Unixes there is a command called
<emphasis remap="bf">
"indent"
</emphasis>
and
<emphasis remap="bf">
"cb"
</emphasis>
. Refer to 'man indent' and 'man cb'. Note that
<emphasis remap="bf">
indent
</emphasis>
and
<emphasis remap="bf">
cb
</emphasis>
work for only "C" programs. For "C++" programs use
<emphasis remap="bf">
"bcpp"
</emphasis>
.
</para>
<para>
<emphasis remap="bf">
Important NOTE:
</emphasis>
<emphasis remap="it">
To compile bcpp under unix, unpack bcpp.tar.gz and you
<emphasis remap="bf">
MUST
</emphasis>
change directory to "code" and give a make. Do not change to "unix"
directory and give a make. That will give lots of errors.
</emphasis>
</para>
<para>
Download the beautifier program from one of the following
<itemizedlist>
<listitem>
<para>
If you are having trouble downloading software from any of the
sites below, then download for a small cost from my site at
<ulink url="http://www.milkywaygalaxy.freeservers.com">
"http://www.milkywaygalaxy.freeservers.com"
</ulink>
. The cost is very small to maintain this web site. Some of the
free sites below are not maintained properly.
</para>
</listitem>
<listitem>
<para>
C++ : BCPP site is at
<ulink url="http://dickey.his.com/bcpp/bcpp.html">
"http://dickey.his.com/bcpp/bcpp.html"
</ulink>
or at
<ulink url="http://www.clark.net/pub/dickey">
"http://www.clark.net/pub/dickey"
</ulink>
. BCPP ftp site is at
<ulink url="ftp://dickey.his.com/bcpp/bcpp.tar.gz">
"ftp://dickey.his.com/bcpp/bcpp.tar.gz"
</ulink>
</para>
</listitem>
<listitem>
<para>
C++ :
<ulink url="http://www.consultix-inc.com/c++b.html">
"http://www.consultix-inc.com/c++b.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
C :
<ulink url="http://www.chips.navy.mil/oasys/c/">
"http://www.chips.navy.mil/oasys/c/"
</ulink>
and mirror at
<ulink url="http://oasys.nctamslant.navy.mil/oasys/c">
Oasys
</ulink>
</para>
</listitem>
<listitem>
<para>
C++ :
<ulink url="http://www.semdesigns.com/Products/DMS/DMSToolkit.html">
"http://www.semdesigns.com/Products/DMS/DMSToolkit.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
C++, C, Java and Oracle Pro-C Beautifier
<ulink url="http://www.geocities.com/~starkville/main.html">
"http://www.geocities.com/~starkville/main.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
C++, C beautifier
<ulink url="http://users.erols.com/astronaut/vim/ccb-1.07.tar.gz">
"http://users.erols.com/astronaut/vim/ccb-1.07.tar.gz"
</ulink>
and site at
<ulink url="http://users.erols.com/astronaut/vim/#vimlinks_src">
"http://users.erols.com/astronaut/vim/#vimlinks_src"
</ulink>
</para>
</listitem>
<listitem>
<para>
C++, C, Java, Perl beautifier CBP
<ulink url="http://www.prismtk.de/docs/cbp">
"http://www.prismtk.de/docs/cbp"
</ulink>
</para>
</listitem>
<listitem>
<para>
GC! GreatCode! is a powerful C/C++ source code beautifier Windows
95/98/NT/2000
<ulink url="http://perso.club-internet.fr/cbeaudet">
"http://perso.club-internet.fr/cbeaudet"
</ulink>
</para>
</listitem>
<listitem>
<para>
CbVan for C, C++ and Java at
<ulink url="http://www.geocities.com/~starkville/main.html">
"http://www.geocities.com/~starkville/main.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
Artistic Style beautifier for C, C++, Java at
<ulink url="http://sourceforge.net/projects/astyle">
"http://sourceforge.net/projects/astyle"
</ulink>
<ulink url="http://astyle.sourceforge.net">
"http://astyle.sourceforge.net"
</ulink>
.
</para>
</listitem>
</itemizedlist>
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.
</para>
<para>
BCPP was written by Steven De Toni at
<ulink url="mailto: steve@alpha.ocbbs.gen.nz ">
steve@alpha.ocbbs.gen.nz
</ulink>
</para>
</sect1>
<sect1 id="installing_bcpp">
<title>
Installing BCPP
</title>
<para>
To install
<ulink url="http://dickey.his.com/bcpp/bcpp.html">
BCPP
</ulink>
<programlisting format="linespecific">
Unpacking bcpp:
tar zxvf bcpp.tar.gz
Building bcpp:
cd code
make
cp bcpp ~/local/bin/
cp bcpp.cfg ~/local/bin
Usage:
bcpp -h or bcpp -?
Recommended: Always use spaces instead of tabs in indenting during beautifying.
Use the option -s so that the code looks the same in all types of editors like vi,
emacs, MS DOS edit, Notepad, Wordpad etc..
bcpp -s *.cpp
In Solaris, you can also use:
ls *.cpp | xargs -I{} -t bcpp -s {}
in Linux, you can also use:
ls *.cpp | xargs -i{} -t bcpp -s {}
</programlisting>
</para>
</sect1>
<sect1 id="trust_beautifier">
<title>
How can I trust Beautifier programs??!!
</title>
<para>
For 100[percnt] assurance you need a
<emphasis remap="bf">
SCIENTIFIC
</emphasis>
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.
</para>
<para>
In order to verify that beautifier programs like
<emphasis remap="bf">
bcpp
</emphasis>
,
<emphasis remap="bf">
indent
</emphasis>
or
<emphasis remap="bf">
cb
</emphasis>
is not damaging or changing the input source-code after formatting, you
can use one of the following technique -
</para>
<sect2 id="verifycpp1">
<title>
Method 1: Verfication Program for C++/C
</title>
<para>
<programlisting format="linespecific">
bash$ man diff
bash$ diff -b --ignore-all-space originalfile formattedfile
</programlisting>
</para>
</sect2>
<sect2 id="verifycpp2">
<title>
Method 2: Verfication Program for C++/C
</title>
<para>
Generate the object code from the original input source code using the
compiler -
<programlisting format="linespecific">
g++ -c myprogram.cpp
</programlisting>
Here g++ is GNU C++ compiler. This will create object output
myprogram.o
</para>
<para>
Save this file -
<programlisting format="linespecific">
mv myprogram.o myprogram_orig.o
</programlisting>
</para>
<para>
Now run bcpp -
<programlisting format="linespecific">
bcpp myprogram.cpp
</programlisting>
This will create the formatted output program file myprogram.cpp and
move the original file to myprogram.cpp.orig. Compile the new file
with -
<programlisting format="linespecific">
g++ -c myprogram.cpp
</programlisting>
</para>
<para>
Now use the unix 'diff' command to compare the two object files -
<programlisting format="linespecific">
diff myprogram.o myprogram_orig.o
</programlisting>
Both these files
<emphasis remap="bf">
MUST BE IDENTICAL
</emphasis>
. This verifies that bcpp is working perfectly. On DOS or Windows 95
you may want to use the free
<ulink url="http://www.cygnus.com">
Cygnus
</ulink>
Cygwin 'diff' or 'MKS' utilities.
</para>
<para>
<emphasis remap="bf">
<emphasis remap="it">
If for some reason you are not able to diff the object files then
you MUST use the assembly output as described below.
</emphasis>
</emphasis>
</para>
<para>
You can use the assembler output instead of object output from the C++
compiler for doing the comparison. Like -
<programlisting format="linespecific">
g++ -S myprogram.cpp
</programlisting>
This creates myprogram.s. Verify with -
<programlisting format="linespecific">
diff myprogram.s myprogram_orig.s
</programlisting>
This step gives 100[percnt] 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[percnt]
quality assurance and life term or long term
<emphasis remap="bf">
WARRANTY
</emphasis>
on beautifier programs like 'bcpp', 'cb' or 'indent'.
</para>
<para>
It is strongly recommended that you do these two steps every time you
run beautifier programs like
<emphasis remap="bf">
bcpp
</emphasis>
,
<emphasis remap="bf">
indent
</emphasis>
or
<emphasis remap="bf">
cb
</emphasis>
.
</para>
</sect2>
<sect2 id="verify_program">
<title>
Method 3: Verfication Program for Java/C++/Others
</title>
<para>
Since you cannot compile the Java source code to machine code and you
can compile Java source to byte-codes you cannot use the technique
given in Method 2 above. When you do diff on Java class files it will
always be different.
</para>
<para>
In this method, a different technique will be given which can be used
to validate any beautifier program for Java. Also this method is quite
powerful and can be used to validate any beautifier program for any
language like C, C++, PERL, SQL, HTML or Java. Since all beautifier
program simply rearrange or insert whitespaces , you can strip all the
whitespaces from original source file and dump it to a file called
verify1.out and strip all the whitespaces from beautified source file
and dump it to a file called verify2.out. Now, do a diff on
verify1.out and verify2.out. If there is no difference, then
beautifier program is working properly. The method is not 100[percnt]
perfect and can catch atleast 98[percnt] of the errors/bugs in the
beautifier program. Use this method in conjunction with other methods.
But this method is better than not having a verification at all and
blindly trusting the beautifier program!!
</para>
<para>
Note: A whitespace can be one of following - blank space ' ',
form-feed '\f', newline '\n', carriage return '\r', horizontal tab
'\t' or vertical tab '\v'.
</para>
<para>
<programlisting format="linespecific">
bash$ java StripWhitespaces sample.java &gt; verify1.out
bash$ java StripWhitespaces sample_beutified.java &gt; verify2.out
bash$ diff verify1.out verify2.out
bash$ java StripWhitespaces sample.cpp &gt; verify1.out
bash$ java StripWhitespaces sample_beutified.cpp &gt; verify2.out
bash$ diff verify1.out verify2.out
bash$ java StripWhitespaces sample.sql &gt; verify1.out
bash$ java StripWhitespaces sample_beutified.sql &gt; verify2.out
bash$ diff verify1.out verify2.out
</programlisting>
The source code of StripWhitespaces Java program is not given here. It
is left as an exercise for students (you) to write a small program in
Java which will simply strip whitespaces from the input text file and
output to standard console output. Students are also urged to write
this small program (StripWhitespaces) in C, PERL, Unix shell script
(Korn, Bourne) and AWK script. Students can see howto the same task
can be accomplished in these five different languages and can do
comparison of ease of programing. You should
<emphasis remap="it">
<emphasis remap="bf">
put a newline '\n' character after every 50 characters
</emphasis>
</emphasis>
while generating verify1.out and verify2.out so that when you do a
diff you can see on which lines differences are coming up. Otherwise,
verify*.out files will just contain one line and it will be difficult
to pin-point where exactly the beautifier program is failing (got this
point ???).
</para>
</sect2>
<sect2 id="verifycpp3">
<title>
Method 4: Shell script: Verfication Program for C++/C
</title>
<para>
This is a Korn shell script to verify beautifier program. Requires
"pdksh*.rpm" from Linux 'contrib' cdrom. Save this file as 'text' file
and chmod a+rx on it. You can re-write this shell script in PERL so
that you can use it on Window 95/NT or MSDOS. Uncomment the PRGM
variable to point to
<emphasis remap="bf">
bcpp
</emphasis>
,
<emphasis remap="bf">
cb
</emphasis>
or
<emphasis remap="bf">
indent
</emphasis>
<programlisting format="linespecific">
#!/bin/ksh
# Verification program to check C++ Beautifiers 'bcpp', 'indent' or cb
############################################################
# Copyright
# The copyright policy is GNU/GPL.
# Author: Al Dev (Alavoor Vasudevan) alavoor[AT]yahoo.com
############################################################
check_beautify_now()
{
# Remove all the temp files....
\rm -f ${TMP_FILE}
\rm -f ${TMP_CPPFILE}*.*
FNAME=$1
if [ ! -f ${FNAME} ]; then
print "\nError: The file ${FNAME} does not exist!!. Aborting now ...."
exit
fi
\cp -f ${FNAME} ${TMP_CPPFILE}.cpp
${COMPILER} -c ${TMP_CPPFILE}.cpp
if [ ! -f ${TMP_CPPFILE}.o ]; then
print "Fatal Error: Failed to compile ${FNAME}. Aborting now... "
exit
fi
\mv -f ${TMP_CPPFILE}.o ${TMP_CPPFILE}_orig.o
aa=`basename $PRGM`
print "\nRunning, verifying $aa on ${FNAME}"
${PRGM} ${TMP_CPPFILE}.cpp
${COMPILER} -c ${TMP_CPPFILE}.cpp
\rm -f $TMP_FILE
diff ${TMP_CPPFILE}.o ${TMP_CPPFILE}_orig.o 1&gt; $TMP_FILE 2&gt;&gt; $TMP_FILE
result=""
result=`wc -c $TMP_FILE | awk '{print $1}' `
if [ "$result" = "0" ]; then
print "Success!! Beautifier $aa is working properly!!\n"
else
print "Fatal Error: Something wrong!! Beautifier is not working!!"
exit
fi
# ${COMPILER} -S ${TMP_CPPFILE}.cpp
# diff ${TMP_CPPFILE}.s ${TMP_CPPFILE}_orig.s
# Remove all the temp files....
\rm -f ${TMP_FILE}
\rm -f ${TMP_CPPFILE}*.*
}
########## Main of program begins here ##################3
#PRGM=/usr/bin/bcpp
#PRGM=/usr/bin/cb
PRGM=/usr/bin/indent
COMPILER=/usr/bin/g++
TMP_FILE=beautify.tmp
TMP_CPPFILE=beautify-tmp_cppfile
print -n "Enter the C++ file name &lt;default is *.cpp&gt; : "
read ans
if [ "$ans" = "" -o "$ans" = " " ]; then
ans="ALL"
else
FILENAME=$ans
fi
# Remove all the temp files....
\rm -f ${TMP_FILE}
\rm -f ${TMP_CPPFILE}*.*
if [ "$ans" != "ALL" ]; then
check_beautify_now ${FILENAME}
else
ls *.cpp |
while read FILENAME
do
check_beautify_now ${FILENAME}
done
fi
</programlisting>
</para>
</sect2>
</sect1>
<sect1 id="html_beautifier">
<title>
HTML Beautifier
</title>
<para>
Since all the documents in the world are getting converted to HTML
format (or being in the process), the HTML beautifier is immensely
important. Each and every document, book, articles, news and papers
about science, technology, medicine, politics and others are already
available or in the process of getting converted to HTML documents. So
HTML deservers a separate chapter like this one.
<itemizedlist>
<listitem>
<para>
HTML :
<ulink url="http://www.digital-mines.com/htb/">
"http://www.digital-mines.com/htb/"
</ulink>
</para>
</listitem>
<listitem>
<para>
HTML : Clean up HTML and fix mistakes with Tidy
<ulink url="http://tidy.sourceforge.net">
http://tidy.sourceforge.net
</ulink>
See also validate HTML files
<itemizedlist>
<listitem>
<para>
<ulink url="http://directory.google.com/Top/Computers/Data_Formats/Markup_Languages/HTML/Tools/Validators_and_Lints/?il=1">
Google directory : HTML Validators_and_Lints
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink url="http://www.htmlhelp.com/tools/validator/offline">
HTMLHelp.com Validator
</ulink>
</para>
</listitem>
<listitem>
<para>
Apache Module HTML validator:
<ulink url="http://home.snafu.de/tusk/mod_tidy/">
Apache: mod_tidy
</ulink>
</para>
</listitem>
<listitem>
<para>
Perl HTML::Validator at
<ulink url="http://www.hut.fi/~samzait/HTML-Validator">
HTMl::Validator
</ulink>
. Download this module and build the 'validate' command with
'make install'.
</para>
</listitem>
<listitem>
<para>
The WebLint PERL HTML validator at
<ulink url="http://sourceforge.net/projects/html-lint">
HTML::Lint</ulink>
and at
<ulink url="http://rpmfind.net//linux/RPM/contrib/noarch/noarch/weblint-1.9.3-2.rh6.2.noarch.html">
WebLint HTML Validator
</ulink>
</para>
</listitem>
<listitem>
<para>
CSE HTML Validator at
<ulink url="http://www.htmlvalidator.com">
HTML Validator
</ulink>
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>
HTML :
<ulink url="http://www.datacomm.ch/mwoog/software/perl/beautifier.html">
"http://www.datacomm.ch/mwoog/software/perl/beautifier.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
HTML :
<ulink url="http://www.watson-net.com/free/perl/s_fhtml.asp">
"http://www.watson-net.com/free/perl/s_fhtml.asp"
</ulink>
</para>
</listitem>
<listitem>
<para>
HTML :
<ulink url="http://www.firstpage.com">
"http://www.firstpage.com"
</ulink>
</para>
</listitem>
<listitem>
<para>
HTML :
<ulink url="http://www.trita.com">
"http://www.trita.com"
</ulink>
</para>
</listitem>
</itemizedlist>
</para>
</sect1>
<sect1 id="beautifier_for_others">
<title>
Beautifiers for other Languages
</title>
<para>
Visit the following sites to get beautifiers for other languages like
HTML, SQL, Java, Perl, Fortran.
<itemizedlist>
<listitem>
<para>
For HTML beautifiers refer to
<xref linkend="html_beautifier"/>
.
</para>
</listitem>
<listitem>
<para>
JSP : For JSP files you can use the HTML editors to beautify which
have the option of skipping/formatting the JSP lines.
<ulink url="http://www.beautifier.org">
http://www.beautifier.org
</ulink>
This beautifier highlights and indents source code using highlight
configuration files (which are similar to Ultraedit highlighting
files). As such, it supports C, C#, Java, Perl, PHP, Pascal, Lisp,
Mumps, Eiffel, Euphoria, and x86 Assembler, amongst others.
Beautifier handles line/block comments, keyword highlighting,
correct indentation, and string highlighting, as well as the
harvesting of comment text to allow for easy source code indexing.
</para>
</listitem>
<listitem>
<para>
SQL :
<ulink url="http://www.netbula.com/products/sqlb">
"http://www.netbula.com/products/sqlb"
</ulink>
</para>
</listitem>
<listitem>
<para>
Oracle PLSQL :
<ulink url="http://www.revealnet.com/Products/Formatter_Plus/formatter_plus.htm">
http://www.revealnet.com
</ulink>
</para>
</listitem>
<listitem>
<para>
GPL
<ulink url="http://www.geocities.com/~starkville/vancbj.html">
"http://www.geocities.com/~starkville/vancbj.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
GPL
<ulink url="http://kevinkelley.mystarband.net/java/dent.html">
"http://kevinkelley.mystarband.net/java/dent.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
Free
<ulink url="http://www.tiobe.com/jacobe.htm">
"http://www.tiobe.com/jacobe.htm"
</ulink>
</para>
</listitem>
<listitem>
<para>
Free
<ulink url="http://www.mmsindia.com/JPretty.html">
"http://www.mmsindia.com/JPretty.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
Free
<ulink url="http://members.magnet.at/johann.langhofer/products/jxbeauty/overview.html">
"http://members.magnet.at/johann.langhofer/products/jxbeauty/overview.html"
</ulink>
(has JBuilder support)
</para>
</listitem>
<listitem>
<para>
Free
<ulink url="http://www.semdesigns.com/Products/Formatters/JavaFormatter.html">
"http://www.semdesigns.com/Products/Formatters/JavaFormatter.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
Commercial $24.99
<ulink url="http://smartbeautify.com">
"http://smartbeautify.com"
</ulink>
</para>
</listitem>
<listitem>
<para>
Commercial $129
<ulink url="http://www.jindent.com">
"http://www.jindent.com"
</ulink>
</para>
</listitem>
<listitem>
<para>
Google
<ulink url="http://directory.google.com/Top/Computers/Programming/Languages/Java/Development_Tools/Code_Beautifiers/?tc=1">
"http://directory.google.com/Top/Computers/Programming/Languages/Java/Development_Tools/Code_Beautifiers/?tc=1"
</ulink>
</para>
</listitem>
<listitem>
<para>
Java, SQL, HTML, C++ :
<ulink url="http://www.semdesigns.com/Products/DMS/DMSToolkit.html">
"http://www.semdesigns.com/Products/DMS/DMSToolkit.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
Java JIndent
<ulink url="http://home.wtal.de/software-solutions/jindent">
"http://home.wtal.de/software-solutions/jindent"
</ulink>
</para>
</listitem>
<listitem>
<para>
Java Pat
<ulink url="http://javaregex.com/cgi-bin/pat/jbeaut.asp">
"http://javaregex.com/cgi-bin/pat/jbeaut.asp"
</ulink>
</para>
</listitem>
<listitem>
<para>
Java JStyle
<ulink url="http://www.redrival.com/greenrd/java/jstyle">
"http://www.redrival.com/greenrd/java/jstyle"
</ulink>
</para>
</listitem>
<listitem>
<para>
Java JPrettyPrinter
<ulink url="http://www.epoch.com.tw/download/ms/java/java.htm">
"http://www.epoch.com.tw/download/ms/java/java.htm"
</ulink>
</para>
</listitem>
<listitem>
<para>
Java JxBeauty
<ulink url="http://members.nextra.at/johann.langhofer/download/jxbeauty">
"http://members.nextra.at/johann.langhofer/download/jxbeauty"
</ulink>
and the
<ulink url="http://members.magnet.at/johann.langhofer/products/jxbeauty/overview.html">
JxBeauty Home
</ulink>
</para>
</listitem>
<listitem>
<para>
Java beautify
<ulink url="http://www2.blaze.ca/~jspeton/percolator">
percolator
</ulink>
</para>
</listitem>
<listitem>
<para>
Java list
<ulink url="http://www.java.about.com/compute/java/library/weekly/aa102499.htm">
"http://www.java.about.com/compute/java/library/weekly/aa102499.htm"
</ulink>
</para>
</listitem>
<listitem>
<para>
Java html present
<ulink url="http://www.chez.com/vasile/java2/VasJava2HTML.html">
VasJava2HTML
</ulink>
</para>
</listitem>
<listitem>
<para>
Java code colorifier and beautifier
<ulink url="http://www.mycgiserver.com/~lisali/jccb">
"http://www.mycgiserver.com/~lisali/jccb"
</ulink>
</para>
</listitem>
<listitem>
<para>
Perl :
<ulink url="http://www.consultix-inc.com/www.consultix-inc.com/talk.htm">
"http://www.consultix-inc.com/www.consultix-inc.com/talk.htm"
</ulink>
</para>
</listitem>
<listitem>
<para>
Perl :
<ulink url="http://www.consultix-inc.com/www.consultix-inc.com/perl_beautifier.html">
"http://www.consultix-inc.com/www.consultix-inc.com/perl_beautifier.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
Fortran beautifier :
<ulink url="http://www.aeem.iastate.edu/Fortran/tools.html">
"http://www.aeem.iastate.edu/Fortran/tools.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
C++ : BCPP site is at
<ulink url="http://dickey.his.com/bcpp/bcpp.html">
"http://dickey.his.com/bcpp/bcpp.html"
</ulink>
or at
<ulink url="http://www.clark.net/pub/dickey">
"http://www.clark.net/pub/dickey"
</ulink>
. BCPP ftp site is at
<ulink url="ftp://dickey.his.com/bcpp/bcpp.tar.gz">
"ftp://dickey.his.com/bcpp/bcpp.tar.gz"
</ulink>
</para>
</listitem>
<listitem>
<para>
C++ :
<ulink url="http://www.consultix-inc.com/c++b.html">
"http://www.consultix-inc.com/c++b.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
C :
<ulink url="http://www.chips.navy.mil/oasys/c/">
"http://www.chips.navy.mil/oasys/c/"
</ulink>
and mirror at
<ulink url="http://oasys.nctamslant.navy.mil/oasys/c">
Oasys
</ulink>
</para>
</listitem>
<listitem>
<para>
C++, C, Java, Oracle Pro-C Beautifier
<ulink url="http://www.geocities.com/~starkville/main.html">
"http://www.geocities.com/~starkville/main.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
C++, C beautifier
<ulink url="http://users.erols.com/astronaut/vim/ccb-1.07.tar.gz">
"http://users.erols.com/astronaut/vim/ccb-1.07.tar.gz"
</ulink>
and site at
<ulink url="http://users.erols.com/astronaut/vim/#vimlinks_src">
"http://users.erols.com/astronaut/vim/#vimlinks_src"
</ulink>
</para>
</listitem>
<listitem>
<para>
GC! GreatCode! is a powerful C/C++ source code beautifier Windows
95/98/NT/2000
<ulink url="http://perso.club-internet.fr/cbeaudet">
"http://perso.club-internet.fr/cbeaudet"
</ulink>
</para>
</listitem>
<listitem>
<para>
C++ beautifier 'SourceStyler'
<ulink url="http://www.ochre.com.au">
"http://www.ochre.com.au"
</ulink>
</para>
</listitem>
</itemizedlist>
</para>
<para>
<itemizedlist>
<listitem>
<para>
White paper on beautifier :
<ulink url="http://www.consultix-inc.com/www.consultix-inc.com/talk.htm">
"http://www.consultix-inc.com/www.consultix-inc.com/talk.htm"
</ulink>
</para>
</listitem>
</itemizedlist>
</para>
<para>
To create presentation of codes to display using HTML -
<itemizedlist>
<listitem>
<para>
Presentation (C,C++,Java) to html :
<ulink url="http://www.perlstudio.de/cbindex.html">
"http://www.perlstudio.de/cbindex.html"
</ulink>
</para>
</listitem>
<listitem>
<para>
The GNU project: Source-Highlight:
<ulink url="http://www.gnu.org/software/src-highlite">
"http://www.gnu.org/software/src-highlite"
</ulink>
and its KDE frontend Ksrc2html
<ulink url="http://murphy.netsolution-net.de/Ksrc2.html">
"http://murphy.netsolution-net.de/Ksrc2.html"
</ulink>
</para>
</listitem>
</itemizedlist>
Also search the search engines like
<ulink url="http://www.yahoo.com">
"http://www.yahoo.com"
</ulink>
or
<ulink url="http://www.lycos.com">
"http://www.lycos.com"
</ulink>
and search for keyword "beautfier".
</para>
</sect1>
<sect1 id="beautifier_sgml">
<title>
Beautifiers For SGML and XML
</title>
<para>
To beautify SGML and XML use one of these perl scripts. I used perl
script from Kevin and it works fine for me.
</para>
<sect2 id="sgml_indenter_kevin">
<title>
SGML Auto-Indenter By Kevin
</title>
<para>
This script was originally written by Kevin M. Dunn
<ulink url="mailto: kdunn@hsc.edu ">
kdunn@hsc.edu
</ulink>
Department of Chemistry Hampden-Sydney College HSC, VA 23943 (804)
223-6181 (804) 223-6374 (Fax). And this script here was modified and
enhanced by Al Dev alavoor[AT]yahoo.com.
</para>
<para>
Several people have discussed the use of Tidy to indent sgml and xml
sources, but does not work for SGML documents, as Tidy did not
recognize the entities. Rather than fix Tidy, here is the perl script
to indent anything with sgml-type tags. Only non-empty tags are
indented, and text is justified at 80 characters/line (easily
changed).
</para>
<para>
Known problems: will break line-specific enviroments. So far, the
script is quite general--it does not recognize specific tags and so
could be used for any xml or sgml, not just docbook. Is there any way
to recognize literal text independent of DTD? Leading whitespace, for
example? Trailing whitespace? Or I could indent tags only, and leave
all non-tag text unjustified and unindented.
</para>
<para>
<programlisting format="linespecific">
#!/usr/bin/perl -w
#
# sb: the sgml beautifier
# indents non-empty sgml tags
# usage: sb filename or sb &lt; filename or | sb
# author: Kevin M. Dunn (kdunn@hsc.edu), Modified by Al Dev (alavoor[AT]yahoo.com)
# license: anyone is free to use this for any purpose whatever
#
use strict;
use diagnostics;
sub separate_tags
{
@_ &lt; 1 ? die "\nInsufficient args .. " : 0 ;
my ($tmpfile) = @_;
my ($current_line);
open(FILETMP, "&gt;$tmpfile");
while (&lt;&gt;)
{
$current_line = $_;
#if ($current_line =~ /^\s+$/)
if ($current_line eq "\n")
{
# Pad spaces to distinguish/identify this line with other newlines
# so that this line is printed and not bypassed in indent_tags()
$current_line = "\t " . $current_line; # Prepend with spaces
#print "\ndone padding\n";
#sleep 5;
}
#$_ =~ s/^\s+//; # Left trim the leading white spaces - ltrim
#$_ =~ s/\s+$//; # Right trim the trailing white spaces - rtrim
$current_line =~ s/&lt;/\n&lt;/g; # Put newline before start of tag "&lt;"
$current_line =~ s/&gt;/&gt;\n/g; # Put newline after end of tag "&gt;"
print FILETMP "$current_line";
}
close(FILETMP);
}
sub get_tags
{
@_ &lt; 1 ? die "\nInsufficient args .. " : 0 ;
my ($tmpfile) = @_;
open(FILETMP, "$tmpfile");
my ($word);
while (&lt;FILETMP&gt;)
{
$word = $_;
$word =~ s/[&gt; ].*//;
chomp($word);
if ( $word =~ /^&lt;\/.*/ )
{
$sgb::tag2{$word} = 1; # here the word has something like '&lt;/TITLE'
$word =~ s/\///;
$sgb::tag1{$word} = 1; # here the word has something like '&lt;TITLE'
}
}
}
sub indent_tags
{
@_ &lt; 1 ? die "\nInsufficient args .. " : 0 ;
my ($tmpfile) = @_;
my $jl = 80; #text will be justified to 80 characters/line
my $nl = 0;
my $sp = 0;
my @space;
$space[0] = "";
my $newline = ""; # hack to prevent extraneous blank first line
open(FILETMP, "$tmpfile");
my ($current_line, $word, $saveword);
while (&lt;FILETMP&gt;)
{
chomp($_); # avoid \n on last field
$current_line = $_;
$word = $current_line;
$word =~ s/[&gt; ].*//; # truncate trailing "&gt; " and spaces therafter
if ( $sgb::tag1{$word} )
{
$saveword = $word;
print "\n$space[$sp]$current_line";
$nl = $jl; # force new line on next line of input
$sp++;
if ( ! $space[$sp] )
{
$space[$sp] = $space[$sp-1] . " ";
}
}
elsif ( $sgb::tag2{$word} )
{
$saveword = $word;
$sp--;
# If the tag is &lt;ProgramListing&gt; then do not justify...
if (lc($word) eq "&lt;/programlisting")
{
print "$current_line";
}
else
{
print "\n$space[$sp]$current_line";
}
$nl = $jl; # force new line on next line of input
}
elsif ( $word =~ /&lt;.*/ )
{
$saveword = $word;
print "$newline$space[$sp]$current_line";
$newline = "\n"; # hack to prevent extraneous blank first line
$nl = $jl; # force new line on next line of input
}
elsif ( length($current_line) &gt; 0 )
{
# If the tag is &lt;ProgramListing&gt; then do not justify...
if (lc($saveword) eq "&lt;programlisting")
{
#print "\nthe tag1 word is $saveword----eof \n";
#print "$newline$space[$sp]$current_line";
# DO NOT put any tabs or spaces, because repeated running of this program
# on same file will keep putting tabs or spaces.
print "$newline$current_line";
$newline = "\n"; # hack to prevent extraneous blank first line
$nl = $jl; # force new line on next line of input
}
else
{
$nl = justify($jl, $nl, $sp, $current_line, @space);
}
}
}
}
sub justify
{
@_ &lt; 4 ? die "\nInsufficient args .. " : 0 ;
my ($jl, $nl, $sp, $current_line, @space) = @_;
my @words = split;
my $nw = @words;
for (my $i = 0; $i &lt; $nw; $i++ )
{
$sgb::ll += length($words[$i]) + 1 + $nl; # line length if this word is added
if ($sgb::ll &lt; $jl) # if short enough, print it
{
print "$words[$i] ";
$nl = 0;
}
else # if line is too long, start a new one
{
print "\n$space[$sp]$words[$i] ";
$nl = 0;
$sgb::ll = length($space[$sp] . $words[$i]) + 1;
}
}
return $nl;
}
$sgb::ll = 0; # global var
my $tmpfile = "$$.tmp";
separate_tags($tmpfile);
get_tags($tmpfile);
indent_tags($tmpfile);
unlink ("$tmpfile"); # remove temporary file
print "\n"; # add final line to output
</programlisting>
</para>
</sect2>
<sect2 id="sgml_indenter_hector">
<title>
SGML Auto-Indenter By Hector
</title>
<para>
Download from
<ulink url="http://www.olea.org/tmp/indent-sgml-xml">
"http://www.olea.org/tmp/indent-sgml-xml"
</ulink>
. The author is at
<ulink url="mailto: hector@debian.org ">
hector@debian.org
</ulink>
And this script here was modified and enhanced by Al Dev
alavoor[AT]yahoo.com.
</para>
<para>
The program below uses the XML::Parser. Read the online manual page
with 'man XML::Parser::Expat' and also 'man XML::Parser'.
</para>
<para>
</para>
<para>
<programlisting format="linespecific">
#!/usr/bin/perl -w
#
# Author: Hector (hector@debian.org). Modified by Al Dev (alavoor[AT]yahoo.com)
# For documentation please see 'man XML::Parser::Expat' and
# also see 'man XML::Parser'
use diagnostics;
use XML::Parser::Expat;
$|=1;
if ( !$ARGV[0] )
{
print "Argument missing\n";
exit 1;
}
$inline_tags = "acronym|ulink|link|citetitle|firstname|surname|application|guimenu|guisubmenu|guimenuitem|menuchoice|interface|guilabel|guibutton|glossterm|systemitem|filename|xref|emphasis|keycap|markup|email|command|inlinegraphic|entry|email|screeninfo|graphic";
$one_line = "title|member";
$todo = "";
$temp = "";
$ancho = " ";
$indentacion = 0;
#open IN , "&lt;$ARGV[0]";
#my $todo = join ('', &lt;IN&gt;);
#close (IN);
$parser = new XML::Parser::Expat;
$parser-&gt;setHandlers('Start' =&gt; \&amp;inicio,
'End' =&gt; \&amp;fin,
'Char' =&gt; \&amp;cadena,
'Comment' =&gt; \&amp;comentario);
open(FOO, "$ARGV[0]") or die "Couldn't open";
# If you get this type of error:
# syntax error at line 1, column 0, byte 0 at ../sgml-beautifier-indentar.pl line 37
# Then edit input file $ARGV[0] and change put this line -
# &lt;?xml version="1.0" encoding="utf-8"?&gt;
$parser-&gt;parse(*FOO);
close(FOO);
$todo =~ s/\n+/\n/gm;
$todo =~ s/\n *\n/\n/gm;
print "$todo\n";
exit 1;
sub inicio
{
my ($p, $el, %atts) = @_;
my $tag = "&lt;$el";
foreach my $key ( sort %atts)
{
if ( $atts{$key} )
{
$tag .= " $key=\"$atts{$key}\"";
}
}
$tag .= "&gt;";
if ( !($el =~ /$inline_tags|$one_line/) )
{
$temp = &amp;indentar ($temp, $indentacion);
if ( $temp ) {
$todo .= "$temp\n";
}
my $pad = $ancho x $indentacion;
$todo .= "$pad$tag\n";
$temp = "";
$indentacion++;
}
else
{
$temp .= $tag;
}
}
sub fin
{
my ($p, $el) = @_;
my $tag = "&lt;/$el&gt;";
if ( !($el =~ /$inline_tags/) )
{
$temp = &amp;indentar ($temp, $indentacion);
$temp =~ s/\n$// ;
$todo .= "$temp";
if ( !($el =~ /$one_line/) )
{
$indentacion--;
if ( !($todo =~ /\n$/) ) {
$todo .= "\n";
}
my $pad = $ancho x $indentacion;
$todo .= "$pad";
#$indentacion--;
}
$todo .= "$tag\n";
$temp = "";
# $indentacion++;
}
else
{
$temp .= "$tag";
}
}
sub cadena
{
my ($p, $str) = @_;
$str =~ s/ +/ /g;
#$str =~ s/^ //;
#$str =~ s/ $//;
$temp .= "$str";
}
sub comentario
{
my ($p, $str) = @_;
$todo .= "&lt;!--\n $str \n--&gt;\n";
}
sub indentar ()
{
my $linea = $_[0] ;
# print ("Indentacion es $_[1]\nLinea $_[0]\n");
my $indentacion = $_[1];
my $cantidad = 75 - ( $indentacion * length($ancho));
my $pad = $ancho x $indentacion;
my $temp = &amp;cortar_linea ( $linea, $cantidad);
$temp =~ s/\n/\n$pad/g;
$temp =~ s/^ //;
my $resultado = "$pad$temp\n";
return $resultado;
}
sub cortar_linea ()
{
my $linea = $_[0];
#$linea =~ s/\n/ \n/;
$linea .= " ";
my $cantidad = $_[1];
$temp = "";
$temp2 = "";
#print "Llega $linea\n";
while ( $linea =~ /(.+?) / )
{
if ( (length ($temp) + length ($+)) &lt;= $cantidad )
{
$temp .= "$+ ";
$linea = $';
}
elsif ( length ($+) &gt;= $cantidad )
{
$linea = $';
$temp2 .= "$temp\n$+";
$temp = "";
}
else
{
$temp2 .= "$temp\n";
$temp = "$+ ";
$linea = $';
}
}
$temp2 .= "$temp\n";
$temp2 =~ s/\n$//;
$temp2 =~ s/ $//;
# print "Sale\n##$temp2##\n";
return $temp2;
}
</programlisting>
</para>
</sect2>
</sect1>
<sect1 id="related_urls">
<title>
Related URLs
</title>
<para>
Visit following locators which are related to C, C++ -
<itemizedlist>
<listitem>
<para>
<ulink url="http://metalab.unc.edu/LDP/HOWTO/Vim-HOWTO.html">
Vim color text editor for C++, C
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink url="http://metalab.unc.edu/LDP/HOWTO/C++Programming-HOWTO.html">
C++ Programming HOWTO
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink url="http://metalab.unc.edu/LDP/HOWTO/CVS-HOWTO.html">
CVS HOWTO for C++ programs
</ulink>
</para>
</listitem>
<listitem>
<para>
Linux goodies
<ulink url="http://www.milkywaygalaxy.freeservers.com">
"http://www.milkywaygalaxy.freeservers.com"
</ulink>
and mirrors at
<ulink url="http://aldev0.webjump.com">
"http://aldev0.webjump.com"
</ulink>
,
<ulink url="http://www.angelfire.com/country/aldev0">
angelfire
</ulink>
,
<ulink url="http://www.geocities.com/alavoor/index.html">
geocities
</ulink>
,
<ulink url="http://aldev0.virtualave.net">
virtualave
</ulink>
,
<ulink url="http://aldev0.50megs.com">
50megs
</ulink>
,
<ulink url="http://members.theglobe.com/aldev1/index.html">
theglobe
</ulink>
,
<ulink url="http://members.nbci.com/alavoor">
NBCi
</ulink>
,
<ulink url="http://aldev.terrashare.com">
Terrashare
</ulink>
,
<ulink url="http://members.fortunecity.com/aldev">
Fortunecity
</ulink>
,
<ulink url="http://aldev.freewebsites.com">
Freewebsites
</ulink>
,
<ulink url="http://members.tripod.lycos.com/aldev">
Tripod
</ulink>
,
<ulink url="http://members.spree.com/technology/aldev">
Spree
</ulink>
,
<ulink url="http://www.escalix.com/freepage/aldev">
Escalix
</ulink>
,
<ulink url="http://www.httpcity.com/aldev/index.html">
Httpcity
</ulink>
,
<ulink url="http://aldev.freeservers.com">
Freeservers
</ulink>
.
</para>
</listitem>
</itemizedlist>
</para>
</sect1>
<sect1 id="other_formats">
<title>
Other Formats of this Document
</title>
<para>
This document is published in 14 different formats namely - DVI,
Postscript, Latex, Adobe Acrobat PDF, LyX, GNU-info, HTML, RTF(Rich Text
Format), Plain-text, Unix man pages, single HTML file, SGML (Linuxdoc
format), SGML (Docbook format), MS WinHelp format.
</para>
<para>
This howto document is located at -
<itemizedlist>
<listitem>
<para>
<ulink url="http://www.linuxdoc.org">
"http://www.linuxdoc.org"
</ulink>
and click on HOWTOs and search for howto document name using
CTRL+f or ALT+f within the web-browser.
</para>
</listitem>
</itemizedlist>
</para>
<para>
You can also find this document at the following mirrors sites -
<itemizedlist>
<listitem>
<para>
<ulink url="http://www.caldera.com/LDP/HOWTO">
"http://www.caldera.com/LDP/HOWTO"
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink url="http://www.linux.ucla.edu/LDP">
"http://www.linux.ucla.edu/LDP"
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink url="http://www.cc.gatech.edu/linux/LDP">
"http://www.cc.gatech.edu/linux/LDP"
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink url="http://www.redhat.com/mirrors/LDP">
"http://www.redhat.com/mirrors/LDP"
</ulink>
</para>
</listitem>
<listitem>
<para>
Other mirror sites near you (network-address-wise) can be found at
<ulink url="http://www.linuxdoc.org/mirrors.html">
"http://www.linuxdoc.org/mirrors.html"
</ulink>
select a site and go to directory /LDP/HOWTO/xxxxx-HOWTO.html
</para>
</listitem>
</itemizedlist>
</para>
<para>
<itemizedlist>
<listitem>
<para>
You can get this HOWTO document as a single file tar ball in HTML,
DVI, Postscript or SGML formats from -
<ulink url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO/other-formats/">
"ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO/other-formats/"
</ulink>
and
<ulink url="http://www.linuxdoc.org/docs.html#howto">
"http://www.linuxdoc.org/docs.html#howto"
</ulink>
</para>
</listitem>
<listitem>
<para>
Plain text format is in:
<ulink url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO">
"ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO"
</ulink>
and
<ulink url="http://www.linuxdoc.org/docs.html#howto">
"http://www.linuxdoc.org/docs.html#howto"
</ulink>
</para>
</listitem>
<listitem>
<para>
Single HTML file format is in:
<ulink url="http://www.linuxdoc.org/docs.html#howto">
"http://www.linuxdoc.org/docs.html#howto"
</ulink>
Single HTML file can be created with command (see man sgml2html) -
sgml2html -split 0 xxxxhowto.sgml
</para>
</listitem>
<listitem>
<para>
Translations to other languages like French, German, Spanish,
Chinese, Japanese are in
<ulink url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO">
"ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO"
</ulink>
and
<ulink url="http://www.linuxdoc.org/docs.html#howto">
"http://www.linuxdoc.org/docs.html#howto"
</ulink>
Any help from you to translate to other languages is welcome.
</para>
</listitem>
</itemizedlist>
The document is written using a tool called "SGML-Tools" which can be
got from -
<ulink url="http://www.sgmltools.org">
"http://www.sgmltools.org"
</ulink>
Compiling the source you will get the following commands like
<itemizedlist>
<listitem>
<para>
sgml2html xxxxhowto.sgml (to generate html file)
</para>
</listitem>
<listitem>
<para>
sgml2html -split 0 xxxxhowto.sgml (to generate a single page html
file)
</para>
</listitem>
<listitem>
<para>
sgml2rtf xxxxhowto.sgml (to generate RTF file)
</para>
</listitem>
<listitem>
<para>
sgml2latex xxxxhowto.sgml (to generate latex file)
</para>
</listitem>
</itemizedlist>
</para>
<sect2 id="acrobatpdf">
<title>
Acrobat PDF format
</title>
<para>
PDF file can be generated from postscript file using either acrobat
<emphasis remap="bf">
distill
</emphasis>
or
<emphasis remap="bf">
Ghostscript
</emphasis>
. And postscript file is generated from DVI which in turn is generated
from LaTex file. You can download distill software from
<ulink url="http://www.adobe.com">
"http://www.adobe.com"
</ulink>
. Given below is a sample session:
<programlisting format="linespecific">
bash$ man sgml2latex
bash$ sgml2latex filename.sgml
bash$ man dvips
bash$ dvips -o filename.ps filename.dvi
bash$ distill filename.ps
bash$ man ghostscript
bash$ man ps2pdf
bash$ ps2pdf input.ps output.pdf
bash$ acroread output.pdf &amp;
</programlisting>
Or you can use Ghostscript command
<emphasis remap="bf">
ps2pdf
</emphasis>
. ps2pdf is a work-alike for nearly all the functionality of Adobe's
Acrobat Distiller product: it converts PostScript files to Portable
Document Format (PDF) files.
<emphasis remap="bf">
ps2pdf
</emphasis>
is implemented as a very small command script (batch file) that
invokes Ghostscript, selecting a special "output device" called
<emphasis remap="bf">
pdfwrite
</emphasis>
. In order to use ps2pdf, the pdfwrite device must be included in the
makefile when Ghostscript was compiled; see the documentation on
building Ghostscript for details.
</para>
</sect2>
<sect2 id="linuxdoc2docbook">
<title>
Convert Linuxdoc to Docbook format
</title>
<para>
This document is written in linuxdoc SGML format. The Docbook SGML
format supercedes the linuxdoc format and has lot more features than
linuxdoc. The linuxdoc is very simple and is easy to use. To convert
linuxdoc SGML file to Docbook SGML use the program
<emphasis remap="bf">
ld2db.sh
</emphasis>
and some perl scripts. The ld2db output is not 100[percnt] clean and
you need to use the
<emphasis remap="bf">
clean[lowbar]ld2db.pl
</emphasis>
perl script. You may need to manually correct few lines in the
document.
<itemizedlist>
<listitem>
<para>
Download ld2db program from
<ulink url="http://www.dcs.gla.ac.uk/~rrt/docbook.html">
"http://www.dcs.gla.ac.uk/~rrt/docbook.html"
</ulink>
or from
<ulink url="http://www.milkywaygalaxy.freeservers.com">
Milkyway Galaxy site
</ulink>
</para>
</listitem>
<listitem>
<para>
Download the cleanup[lowbar]ld2db.pl perl script from
<ulink url="http://www.milkywaygalaxy.freeservers.com">
Milkyway Galaxy
</ulink>
</para>
</listitem>
</itemizedlist>
The ld2db.sh is not 100[percnt] clean, you will get lots of errors
when you run
<programlisting format="linespecific">
bash$ ld2db.sh file-linuxdoc.sgml db.sgml
bash$ cleanup.pl db.sgml &gt; db_clean.sgml
bash$ gvim db_clean.sgml
bash$ docbook2html db.sgml
</programlisting>
And you may have to manually edit some of the minor errors after
running the perl script. For e.g. you may need to put closing tag &lt;
/Para&gt; for each &lt; Listitem&gt;
</para>
</sect2>
<sect2 id="mswinhelp">
<title>
Convert to MS WinHelp format
</title>
<para>
You can convert the SGML howto document to Microsoft Windows Help
file, first convert the sgml to html using:
<programlisting format="linespecific">
bash$ sgml2html xxxxhowto.sgml (to generate html file)
bash$ sgml2html -split 0 xxxxhowto.sgml (to generate a single page html file)
</programlisting>
Then use the tool
<ulink url="http://javadocs.planetmirror.com/htmltohlpe.html">
HtmlToHlp
</ulink>
. You can also use sgml2rtf and then use the RTF files for generating
winhelp files.
</para>
</sect2>
<sect2 id="readformats">
<title>
Reading various formats
</title>
<para>
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 [verbar] Applications
[verbar] Publishing [verbar] TeX menu buttons. To read dvi document
give the command -
<screen format="linespecific">
xdvi -geometry 80x90 howto.dvi man xdvi
</screen>
And resize the window with mouse. 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'.
</para>
<para>
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 [verbar] Applications [verbar] Graphics
menu buttons. The gv program is much more user friendly than
ghostscript. Also ghostscript and gv are available on other platforms
like OS/2, Windows 95 and NT, you view this document even on those
platforms.
</para>
<para>
<itemizedlist>
<listitem>
<para>
Get ghostscript for Windows 95, OS/2, and for all OSes from
<ulink url="http://www.cs.wisc.edu/~ghost">
"http://www.cs.wisc.edu/~ghost"
</ulink>
</para>
</listitem>
</itemizedlist>
</para>
<para>
To read postscript document give the command -
<screen format="linespecific">
gv howto.ps ghostscript howto.ps
</screen>
</para>
<para>
You can read HTML format document using Netscape Navigator, Microsoft
Internet explorer, Redhat Baron Web browser or any of the 10 other web
browsers.
</para>
<para>
You can read the latex, LyX output using LyX a X-Windows front end to
latex.
</para>
</sect2>
</sect1>
<sect1 id="copyright">
<title>
Copyright
</title>
<para>
Copyright policy is GNU/GPL as per LDP (Linux Documentation project).
LDP is a GNU/GPL project. Additional restrictions are - you must retain
the author's name, email address and this copyright notice on all the
copies. If you make any changes or additions to this document then you
should intimate all the authors of this document.
</para>
</sect1>
</article>