1#!/bin/bash 2 3# This script will recursively search all |FILES| from the current 4# directory and replace all |TYPES| according to the list below. 5 6# NOTE 1: 7# If this script is run from .../packages/modules/Bluetooth/system (as it's intended to be), 8# please edit stack/include/bt_types.h next and remove the typedef's 9# near the top and restore the definitions of TRUE and FALSE. These 10# are still used in the vnd_* files and device specific repositories. 11 12# NOTE 2: 13# The list of files to be modified also includes "*.patch", which means 14# this script can be used to help cherry-picking changes from older 15# branches. Follow this workflow outline: 16# 1. git format-patch [-1] <your sha1> 17# 2. Run change_type script on patch[es] 18# 3. git apply / git am 19 20 21# Regular expression matching the file name 22FILES="\.h$|\.c$|\.cpp$|\.cc$|\.patch$" 23 24# Search/replace terms, separated by ":" 25TYPES=( 26 "UINT8 :uint8_t " 27 "UINT16 :uint16_t " 28 "UINT32 :uint32_t " 29 "UINT64 :uint64_t " 30 "INT8 :int8_t " 31 "INT16 :int16_t " 32 "INT32 :int32_t " 33 "INT64 :int64_t " 34 "UINT8:uint8_t" 35 "UINT16:uint16_t" 36 "UINT32:uint32_t" 37 "UINT64:uint64_t" 38 "INT8:int8_t" 39 "INT16:int16_t" 40 "INT32:int32_t" 41 "INT64:int64_t" 42 "BOOLEAN:bool " 43 "TRUE:true" 44 "FALSE:false" 45 "__FUNCTION__:__func__" 46) 47 48function process_file 49{ 50 echo -n "Processing file $1 " 51 52 for tt in "${TYPES[@]}" ; 53 do 54 before=${tt%%:*} 55 after=${tt#*:} 56 57 echo -n "." 58 sed -i -e "s/\b${before}/${after}/g; s/${after}_/${before}_/g;" "$1" 59 done 60 echo 61} 62 63function process_files 64{ 65 until [ -z "$1" ] 66 do 67 process_file "$1" 68 shift 69 done 70} 71 72 73# Let's do this ... 74process_files `find ./ | grep -E "${FILES}"` 75 76# All done ... 77echo 78echo "All done." 79 80# Try to be helpful ... 81PWD=`pwd` 82if [[ "${PWD}" == */packages/modules/Bluetooth/system ]] 83then 84 echo "Please edit ${PWD}/stack/include/bt_types.h next." 85fi 86