Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
46
Task/Strip-block-comments/Ksh/strip-block-comments.ksh
Normal file
46
Task/Strip-block-comments/Ksh/strip-block-comments.ksh
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/ksh
|
||||
|
||||
# Strip block comments
|
||||
|
||||
# # Variables:
|
||||
#
|
||||
bd=${1:-'/*'}
|
||||
ed=${2:-'*/'}
|
||||
|
||||
testcase='/**
|
||||
* Some comments
|
||||
* longer comments here that we can parse.
|
||||
*
|
||||
* Rahoo
|
||||
*/
|
||||
function subroutine() {
|
||||
a = /* inline comment */ b + c ;
|
||||
}
|
||||
/*/ <-- tricky comments */
|
||||
|
||||
/**
|
||||
* Another comment.
|
||||
*/
|
||||
function something() {
|
||||
}'
|
||||
|
||||
######
|
||||
# main #
|
||||
######
|
||||
|
||||
testcase=${testcase%%"${bd}"*}
|
||||
while [[ -n ${.sh.match} ]]; do # .sh.match stores the most recent match
|
||||
if [[ -n ${testcase} ]]; then
|
||||
sm="${.sh.match}"
|
||||
sm="${sm/"${bd}"/}"
|
||||
buff="${testcase}"
|
||||
buff+="${sm#*"${ed}"}"
|
||||
testcase="${buff}"
|
||||
else
|
||||
testcase="${.sh.match}"
|
||||
testcase="${testcase#*"${ed}"}"
|
||||
fi
|
||||
testcase=${testcase%%"${bd}"*}
|
||||
done
|
||||
|
||||
echo "${testcase}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue