Skip to content

Instantly share code, notes, and snippets.

@skyscribe
Created March 3, 2012 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyscribe/1964161 to your computer and use it in GitHub Desktop.
Save skyscribe/1964161 to your computer and use it in GitHub Desktop.
generate gcc tags from header
#!/bin/bash
if [ $# -eq 0 ];then
dir=.
else
dir=$1
fi
#Substitute scripts
cat > .edit.sed <<- EOF
s/\b_GLIBCXX_BEGIN_NAMESPACE\b\s*\(\s*(\w+)\s*\)/namespace \1{/g
s/_GLIBCXX_BEGIN_NESTED_NAMESPACE\s*\(\s*std\s*,\s*_GLIBCXX_STD_[DP]\s*\)/namespace std{/g
s/\b_GLIBCXX_END_NAMESPACE\b/}/g
s/\b_GLIBCXX_END_(NESTED_\?NAMESPACE\b/}/g
EOF
count=0
cols=`tput cols`
cols=`echo "$cols - 8"|bc`
for file in `find $dir -type f`;do
if [ "T"$file != "T"$0 ];then
sed -nf ".edit.sed" $file
count=`echo "$count+1"|bc`
echo -ne "="
if [ `echo "$count%$cols"|bc` -eq 0 ];then
echo " $count"
fi
fi
done
echo "Processed $count files!"
rm -fr .edit.sed
# Generate ctag file
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q
echo "generated tag file!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment