Last active
August 29, 2015 14:05
-
-
Save raimusyndrome/068649ead687b4952a73 to your computer and use it in GitHub Desktop.
後からnamespaceを追加するためのスクリプト。使用条件としては(ヘッダファイル名は~.h、ソースファイル名は~.cpp)(ヘッダファイルはifndefを用いた二重インクルード防止処置を使用している)(#includeをファイル前方にまとめている)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NAME=SAMPLE | |
for f in `ls *.h` | |
do | |
TOP=`grep -n "#include" $f | cut -f 1 -d : | tail -n 1` | |
TOP=`expr $TOP + 1` | |
sed -e "$TOP inamespace $NAME \{" -i.bak $f | |
BOTTOM=`grep -n "#endif" $f | cut -f 1 -d : | tail -n 1` | |
sed -e "$BOTTOM i\}" -i $f | |
done | |
for f in `ls *.cpp` | |
do | |
TOP=`grep -n "#include" $f | cut -f 1 -d : | tail -n 1` | |
TOP=`expr $TOP + 1` | |
sed -e "$TOP inamespace $NAME \{" -i.bak $f | |
BOTTOM=`wc -l $f | cut -f 1 -d ' '` | |
sed -e "$BOTTOM i\}" -i $f | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for f in `ls *.bak` | |
do | |
UNDOFILE=`echo $f | sed -e 's/.bak//'` | |
cp $f $UNDOFILE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment