development/c_count: Added (classify & count lines of C/C++ source)

Signed-off-by: bedlam <dave@slackbuilds.org>

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
B. Watson 2023-03-16 19:25:14 +00:00 committed by Willy Sudiarto Raharjo
parent c1a354d9fb
commit 9eb9c99558
No known key found for this signature in database
GPG key ID: 3F617144D7238786
4 changed files with 179 additions and 0 deletions

View file

@ -0,0 +1,43 @@
c_count (classify and count lines of C or C++ source)
c_count counts lines, statements, other simple measures of C/C++
source programs. It isn't lex/yacc based, and is easily portable to a
variety of systems.
Note: By default, the binary and man page are installed as C_count
(uppercase C), to prevent a conflict with /usr/bin/c_count from the
SBo sloccount package. If you really want, you can run this script
with LOWERCASE=yes in the environment to install as c_count... but if
you do this, don't install sloccount on the same system.
c_count gives more detailed statistics than sloccount, but does not
include sloccount's person-years and cost estimates.
Example output from c_count:
$ C_count filename.c
3656 1513 |filename.c
----------------
3656 1513 total lines/statements
881 lines had comments 24.1 %
47 comments are inline -1.3 %
537 lines were blank 14.7 %
197 lines for preprocessor 5.4 %
2088 lines containing code 57.1 %
3656 total lines 100.0 %
18053 comment-chars 22.8 %
4739 nontext-comment-chars 6.0 %
18594 whitespace-chars 23.5 %
2527 preprocessor-chars 3.2 %
35098 statement-chars 44.4 %
79011 total characters 100.0 %
3919 tokens, average length 6.99
0.48 ratio of comment:code
205 top-level blocks/statements
9 maximum blocklevel
2.93 ratio of blocklevel:code

View file

@ -0,0 +1,107 @@
#!/bin/bash
# Slackware build script for c_count
# Written by B. Watson (urchlay@slackware.uk)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# sloccount conflict is because both packages install /usr/bin/c_count.
# Upstream for c_count is aware of this but refuses to change (because
# his package is older). No idea if sloccount upstream knows or cares
# (it's been decades, so the problem isn't going to get solved). So
# install as C_count by default. Annnoyingly enough, there's no man
# page for sloccount's c_count, and our man command is case-insensitive
# by default, so "man c_count" will show the man page for C_count since
# there isn't one for sloccount c_count. Confusing. Hopefully whoever
# this happens to, figures it out pretty quick.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=c_count
VERSION=${VERSION:-7.22}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tgz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
\! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
# Avoid sloccount conflict. --program-transform-name fixes the
# filenames but not the file contents, hence the sed stuff.
if [ "${LOWERCASE:-no}" = "no" ]; then
PTN="--program-transform-name='s/^c/C/'"
sed -i '/"[^"]*c_count/s,c_count,C_count,g' $PRGNAM.c
sed -i 's,c_count,C_count,g' $PRGNAM.1
BIN="C_count"
else
BIN="c_count"
fi
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
$PTN \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/man \
--disable-static \
--build=$ARCH-slackware-linux
make
strip $PRGNAM
make install DESTDIR=$PKG
gzip $PKG/usr/man/man*/*
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a CHANGES COPYING README $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
mkdir -p $PKG/install
sed "s,@BIN@,$BIN,g" < $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE

View file

@ -0,0 +1,10 @@
PRGNAM="c_count"
VERSION="7.22"
HOMEPAGE="https://invisible-island.net/c_count/c_count.html"
DOWNLOAD="https://invisible-island.net/archives/c_count/c_count-7.22.tgz"
MD5SUM="1a876209c0d8a62a87b8bcd692dd13ea"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES=""
MAINTAINER="B. Watson"
EMAIL="urchlay@slackware.uk"

View file

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
c_count: c_count (classify and count lines of C or C++ source)
c_count:
c_count: c_count counts lines, statements, other simple measures of C/C++
c_count: source programs. It isn't lex/yacc based, and is easily portable to a
c_count: variety of systems.
c_count:
c_count: c_count gives more detailed statistics than sloccount, but does not
c_count: include sloccount's person-years and cost estimates.
c_count:
c_count: The binary is installed as /usr/bin/@BIN@
c_count: