2012-06-26 23:27:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Script to automatically replace patterns in all source files
|
|
|
|
# Example usage
|
|
|
|
# (in main directory colobot):
|
|
|
|
# $ tools/sed-replace.sh src/app/d3dengine.cpp ...
|
|
|
|
# $ tools/sed-replace.sh `find . -name '*.cpp' -o -name '*.h'`
|
|
|
|
|
|
|
|
# List of sed commands (replacements)
|
|
|
|
replacements=( \
|
2012-06-26 23:47:07 +00:00
|
|
|
's/\bSetProfileString\b/SetLocalProfileString/g' \
|
|
|
|
's/\bGetProfileString\b/GetLocalProfileString/g' \
|
|
|
|
's/\bSetProfileInt\b/SetLocalProfileInt/g' \
|
|
|
|
's/\bGetProfileInt\b/GetLocalProfileInt/g' \
|
|
|
|
's/\bSetProfileFloat\b/SetLocalProfileFloat/g' \
|
|
|
|
's/\bGetProfileFloat\b/GetLocalProfileFloat/g' \
|
2012-06-26 23:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Loop over arguments
|
2012-06-26 23:47:07 +00:00
|
|
|
find -type f \( -name '*.cpp' -o -name '*.h' \) -print0 | while read -d $'\0' file; do
|
|
|
|
echo "Processing file '$file'..."
|
|
|
|
# Loop over replacements
|
|
|
|
for what in "${replacements[@]}"; do
|
|
|
|
sed -i "$what" "$file"
|
|
|
|
done
|
2012-06-26 23:27:42 +00:00
|
|
|
done
|