3 # finds all the resource ids in resource headers (only those named the
4 # canonical resource.h name) and discovers any duplicates. the duplicates
5 # are shown with their symbolic names and file locations.
7 TEMP_RESOURCE_HEADERS=/tmp/resrc_headers_$USER.txt
9 sp='[ ]' # space and tab.
11 # find all the resource headers so we can look at their contents.
12 find "$BUILD_TOP" -type f -iname "resource.h" | \
14 grep -vi admin_items | \
15 grep -v app >"$TEMP_RESOURCE_HEADERS"
16 #hmmm: above ignores *anything* with app in the name.
17 # grep -v app_src >"$TEMP_RESOURCE_HEADERS"
19 FULLDEFS=/tmp/full_definition_list_$USER.txt
20 # clean up prior versions.
23 # iterate through all the resource headers we found.
26 # find any lines that define a resource id. remove any that are part of
27 # visual studio's tracking system for next id to assign (_APS_NEXT crud).
28 chop_line="$(echo $line | sed -e 's/[\\\/]/+/g')"
29 grep "^$sp*#define$sp*[_A-Za-z0-9][_A-Za-z0-9]*$sp*[0-9][0-9]*$sp*$" <"$line" | \
30 grep -v "_APS_NEXT" | \
32 grep -v "$sp*\/\/.*" | \
33 sed -e "s/^$sp*#define$sp*\([_A-Za-z0-9][_A-Za-z0-9]*\)$sp*\([0-9][0-9]*\)$sp*$/\1=\2#$chop_line/" >>"$FULLDEFS"
34 done <"$TEMP_RESOURCE_HEADERS"
36 # our accumulated lists of names and ids (in order per list).
37 declare -a resource_names=()
38 declare -a resource_ids=()
39 declare -a resource_files=()
41 # iterate through the definitions list and compile the set of known ids.
43 name=$(echo $line | sed -e 's/\([^=]*\)=[^#]*#.*/\1/')
44 id=$(echo $line | sed -e 's/[^=]*=\([^#]*\)#.*/\1/')
45 file=$(echo $line | sed -e 's/[^=]*=[^#]*#\(.*\)/\1/')
50 next_index=${#resource_names[*]}
51 #echo next ind is $next_index
52 resource_names[${next_index}]=$name
53 resource_ids[${next_index}]=$id
54 resource_files[${next_index}]=$id
58 echo done reading all definitions.
60 JUST_IDS=/tmp/ids_list_$USER.txt
64 while [[ i -le $next_index ]]; do
65 echo ${resource_ids[$i]} >>"$JUST_IDS"
69 echo done accumulating list of integer ids.
71 id_size=$(wc "$JUST_IDS")
73 JUST_IDS_TEMP=/tmp/ids_list_temp_$USER.txt
75 sort "$JUST_IDS" | uniq >"$JUST_IDS_TEMP"
76 id_temp_size=$(wc "$JUST_IDS_TEMP")
77 if [ "$id_size" == "$id_temp_size" ]; then
78 echo "Your IDs are all unique! Ending analysis."
82 echo "Your ids are *NOT* all unique; the repeated ones are:"
83 sort "$JUST_IDS" | uniq -d >"$JUST_IDS_TEMP"
87 echo "=== identifier $id ==="
88 grep "=$line#" "$FULLDEFS" | sed -e 's/\+/\//g' | sed -e 's/#/\
90 done <"$JUST_IDS_TEMP"