2018-05-21 16:40:32 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
echo 'find_msgs.sh'
|
|
|
|
|
2018-05-22 00:42:07 +00:00
|
|
|
#list all source files from source folder except *language* files
|
2018-05-21 16:40:32 +00:00
|
|
|
files=$(ls ../Firmware/*.c* | grep -v 'language'; ls ../Firmware/*.h | grep -v 'language'; )
|
|
|
|
|
2018-05-22 00:42:07 +00:00
|
|
|
echo ' processing msgs_en.txt and msgs_common.txt...'
|
2018-05-21 16:40:32 +00:00
|
|
|
#msgs=$(cat msgs_en.txt | cut -f 1 -d' ')
|
|
|
|
msgs=$(cat msgs_en.txt msgs_common.txt | cut -f 1 -d' ')
|
|
|
|
#msgs=$(cat msgs_common.txt | cut -f 1 -d' ')
|
|
|
|
echo "$msgs" | while read msg; do
|
|
|
|
echo -n "$msg "
|
2018-05-22 00:42:07 +00:00
|
|
|
found=$(grep -c -E "\b$msg\b" $files | sed "/:0$/d;s/.*:/+/g")
|
2018-05-21 16:40:32 +00:00
|
|
|
echo $(("0"$found))
|
2018-05-22 00:42:07 +00:00
|
|
|
done | tee msgs_usage.txt_0
|
2018-05-21 16:40:32 +00:00
|
|
|
cat msgs_usage.txt_0 | sort -k2 -n >msgs_usage.txt
|
|
|
|
rm msgs_usage.txt_0
|
|
|
|
|
2018-05-22 00:42:07 +00:00
|
|
|
#list messages that are not used
|
|
|
|
msgs=$(cat msgs_usage.txt | grep " 0$" | cut -f1 -d' ')
|
|
|
|
#make regular expression from the list - replace spaces with '\b|\b' (match whole words)
|
|
|
|
msgs='\b'$(echo $msgs | sed "s/ /\\\b\\\|\\\b/g")'\b'
|
|
|
|
#grep unused messages
|
|
|
|
cat msgs_en.txt | grep "$msgs" > msgs_en_unused.txt
|
|
|
|
cat msgs_common.txt | grep "$msgs" > msgs_common_unused.txt
|
|
|
|
|
|
|
|
#list messages used once
|
|
|
|
msgs=$(cat msgs_usage.txt | grep " 1$" | cut -f1 -d' ')
|
|
|
|
#make regular expression from the list - replace spaces with '\b|\b' (match whole words)
|
|
|
|
msgs='\b'$(echo $msgs | sed "s/ /\\\b\\\|\\\b/g")'\b'
|
|
|
|
#grep unused messages
|
|
|
|
cat msgs_en.txt | grep "$msgs" > msgs_en_used_once.txt
|
|
|
|
cat msgs_common.txt | grep "$msgs" > msgs_common_used_once.txt
|
|
|
|
|
|
|
|
#list messages used once more (exclude unused and used once)
|
|
|
|
msgs=$(cat msgs_usage.txt | grep -v " 0$" | grep -v " 1$" | cut -f1 -d' ')
|
|
|
|
#make regular expression from the list - replace spaces with '\b|\b' (match whole words)
|
|
|
|
msgs='\b'$(echo $msgs | sed "s/ /\\\b\\\|\\\b/g")'\b'
|
|
|
|
#grep unused messages
|
|
|
|
cat msgs_en.txt | grep "$msgs" > msgs_en_used_more.txt
|
|
|
|
cat msgs_common.txt | grep "$msgs" > msgs_common_used_more.txt
|
|
|
|
|
|
|
|
echo "step2 finished... press key"
|
2018-05-21 16:40:32 +00:00
|
|
|
|
|
|
|
read
|
|
|
|
exit
|