- 论坛徽章:
- 0
|
本帖最后由 junhengwoo 于 2016-03-03 14:49 编辑
谢谢你提供的建议,我会再查一下。
我已经写了一个简单的Shell,基本实现了这个功能。
#!/bin/bash
SrcFile="bb.c"
TargetFuncName="DoA"
for LineNumItem in `grep -n ${TargetFuncName} ${SrcFile}| awk -F":" '{print $1}'`
do
FuncName=""
FuncLineNum=1
echo ""
for CtagItem in `ctags -x --c-kinds=f ${SrcFile} | awk '{printf("%s-%s\n", $3, $1)}' | sort -t- -nk 1`
do
CtagFuncName=`echo ${CtagItem} | awk -F"-" '{print $2}'`
CtagBeginLineNum=`echo ${CtagItem} | awk -F"-" '{print $1}'`
if [ ${LineNumItem} -lt ${CtagBeginLineNum} ] ; then
echo "${TargetFuncName} is found: ${FuncName} ${FuncLineNum}"
break
elif [ ${LineNumItem} -eq ${CtagBeginLineNum} ] ; then
echo "${TargetFuncName} definition is found: ${CtagFuncName} ${CtagBeginLineNum}"
break
else
FuncName=${CtagFuncName}
FuncLineNum=${CtagBeginLineNum}
fi
done
done
回复 10# yjh777
|
|