Topic: Need indent (cb) for C++
Author: Jim Johnson <75300.3270@CompuServe.COM>
Date: 6 Jan 1995 06:41:36 GMT Raw View
Hi all.
Anyone know of an FTP site or other source for a C++ version of
indent, (the famous C beautifier) or some other similar tool?
Source code, please, (or something with a really sharp Windows
front-end, failing that).
Thanks muchly.
--
Jim
Author: rtrigg@netcom.com (Roger Trigg)
Date: Fri, 6 Jan 1995 10:11:19 GMT Raw View
Jim Johnson (75300.3270@CompuServe.COM) wrote:
: Hi all.
: Anyone know of an FTP site or other source for a C++ version of
: indent, (the famous C beautifier) or some other similar tool?
: Source code, please, (or something with a really sharp Windows
: front-end, failing that).
The oak.oakland.edu site has source and executable for this. It's named
indentx.zip and indent.zip (not sure of the exact name of the second one)
and can by found in the SimTel directory.
Regards,
Roger Trigg (rtrigg@symantec.com)
Author: scalio@hogpf.ho.att.com (-J.SCALIO)
Date: Fri, 6 Jan 1995 15:50:21 GMT Raw View
For those that are familiar with and have access to cb, I provide a
script (cb++) that ``beautifies'' C++ source. Some of this may look
familiar, that is because some of it has been posted to comp.*.c++
news groups. I take no credit (or responsibility) for the provided
code. However, I use it all the time and it works great! ``cb++''
even appears to handle C++ templates!
There are two things that ``cb'' doesn't handle properly with respect
to C++ source: the C++ comment ``//'' and ``::''. This is were ``sed''
works beautifully for our purposes.
The cb++ script uses ``sed'' to prefilter the source code into a form
that ``cb'' can handle. This filtered text is piped into ``cb'' whose
output is piped to ``sed''. The final call to ``sed'' post-filters the
source to replace the aforementioned C++ pieces back to their original
form.
The cb++ script that I provide supports the same command line options
as the ``cb'' command.
---------------------------------------------------------------------
| James Scalio | Whose word is it? That's right; mine! |
| james.scalio@att.com | |
---------------------------------------------------------------------
------------------------------ begin script --------------------------
#!/bin/sh
#
# cb++ - a companion to ``cb'' for C++ source files.
#
USAGE="usage: `basename $0` [-s] [-j] [-l length] [filename ...]"
#
OPTS=
#
while getopts jl:s flag
do
case $flag in
j|s) OPTS="${OPTS} -${flag}";;
l) OPTS="${OPTS} -${flag} ${OPTARG}";;
\?) echo ${USAGE}; exit 1;;
esac
done
shift `expr ${OPTIND} - 1`
#
sed -e 's,::,__CC__,g' -e 's,//,/*@@,g' -e '\x/*@@x a\
@@*/' $@ | cb $OPTS | sed -e '\x@@\*/x d' -e 's,/\*@@,//,g' -e 's,__CC__,::,g'
#
exit 0
#
------------------------------ end script ----------------------------
Author: Jim Johnson <75300.3270@CompuServe.COM>
Date: 6 Jan 1995 20:33:05 GMT Raw View
Many thanks, Roger. I' knew this Internet stuff would be good for
something! (I've been looking for this on CompuServe for over a
year (on and off)).
--
Jim