Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
##################################
# Validating The User Input
##################################
if test -z $SRC_PATH
then
echo "Path Not Entered!!!"
echo "Quitting..."
exit
else
if test -d $SRC_PATH
then
#echo "Do You Want To Scan Recursively?[Y/N]"
#read RECURSION
#if [ $RECURSION = y -o $RECURSION = Y -o $RECURSION = yes -o $RECURSION = YES -o $RECURSION = Yes ]
# then
# SEARCH="find $SRC_PATH
echo "Starting...."
echo
#echo
#echo
#fi
else
echo "Path Not Valid!!!"
echo "Quitting..."
exit
fi
fi
##################################
# Checking For Blank Lines
##################################
for Filename in $(find $SRC_PATH -iname "*.c")
do
echo Checking `basename $Filename`
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Rep:
There are programs available, but. . .
I would imagine that a way to do this (I haven't done it, but I've
got ideas) would be to keep an eye out for the begin multi-line
comment (/*), and hop in to a while loop, during which you look for
new lines (\n) and increment. The while loop will terminate
when you come to an end multi-line comment (*/).
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Rep:
Ok, Here's my little awk script (on its own, you'll have to modify it
somewhat to incorporate it into yours):
Code:
awk -F"\n"
'BEGIN
{RS=/\/\*/}
{RT=/\*\//}
{++MULTI}
END
{print MULTI}'
commented code:
Code:
awk
'BEGIN
{FS="\n"} # set the field separator to be a newline
{RS=/\/\*/} # set the Record separator to be the begin multiline comment
{RT=/\*\//} # set the Record terminator to be the end multiline comment
{++MULTI}
END
{print MULTI}'
Try this out, for more help read the awk man page. . .
[edit]:
Actually, there is a bug in here, but I haven't found it (them?) yet.
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Rep:
Here is a fixed version. I'm leaving the other one up there so
someone who knows more can look at it and tell me what's wrong
with it, if they care to. . .
Code:
awk '/\/\*/,/\*\// # Set the range pattern to be that of a multiline comment
{++MULTI} # Increment the multiline counter
END
{print MULTI}'
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.