1__SKIP__=77 2 3skip() 4{ 5 echo "$@" 6 exit ${__SKIP__} 7} 8 9remove_commit_id() 10{ 11 # Remove a commit id embedded in tags file 12 sed -i -e '/!_TAG_PROGRAM_VERSION.*/s#/[^/]*/#//#' $1 13} 14 15filesize() 16{ 17 wc -c < "$1" 18} 19 20is_feature_available() 21{ 22 local ctags=$1 23 local tmp=$2 24 local o="--quiet --options=NONE" 25 local neg 26 local feat 27 28 if [ "${tmp}" = '!' ]; then 29 neg=1 30 feat=$3 31 else 32 feat=$2 33 fi 34 35 if [ "${neg}" = 1 ]; then 36 if ${ctags} $o --with-list-header=no --list-features | grep -q "$feat"; then 37 skip "feature \"$feat\" is available in $ctags" 38 fi 39 else 40 if ! ${ctags} $o --with-list-header=no --list-features | grep -q "$feat"; then 41 skip "feature \"$feat\" is not available in $ctags" 42 fi 43 fi 44} 45 46skip_if_user_has_dot_ctags_d() 47{ 48 if [ -d ~/.ctags.d ]; then 49 skip "this test case doesn't work well if you have ~/.ctags.d" 50 fi 51} 52 53exit_if_win32() 54{ 55 is_feature_available $1 '!' win32 56} 57 58exit_unless_win32() 59{ 60 is_feature_available $1 win32 61} 62 63exit_if_no_case_insensitive_filenames() 64{ 65 is_feature_available $1 case-insensitive-filenames 66} 67 68run_with_format() 69{ 70 echo '#' $* 71 local format=$1 72 shift 73 ${CTAGS} --quiet --options=NONE --output-format=$format "$@" -o - input.* 74} 75 76exit_status_for_input_c() 77{ 78 local ctags=$1 79 shift 80 81 local remove_file=$1 82 shift 83 84 printf "%s => " "$(echo "$*" | sed -e 's#[^ ][^ ]*/\([^ ]*\)#\1#g')" 85 ${ctags} --quiet --options=NONE "$@" input.c > /dev/null 86 local result_local=$? 87 88 if [ "$remove_file" != "none" ]; then 89 rm -f "$remove_file" 90 fi 91 92 if [ "$result_local" = 0 ]; then 93 echo "ok" 94 else 95 echo "failed" 96 fi 97} 98 99get_column_index() 100{ 101 local index=0 102 local ctags=$1 103 local option=$2 104 local column=$3 105 106 for x in $($ctags --quiet --options=NONE --with-list-header "$option" | sed -ne 's/^#\(.*\)$/\1/p'); do 107 if [ "$x" = "$column" ]; then 108 echo $index 109 return 0 110 fi 111 index=$(expr $index + 1) 112 done 113 114 echo -1 115 return 1 116} 117 118filter_by_column_index() 119{ 120 local index=$1 121 122 awk '{print $'$(expr $index + 1)'}' 123} 124 125echo2() 126{ 127 # use a external echo command here. 128 # built-in echo suppresses \1. 129 /bin/echo "$@" 130 /bin/echo "$@" 1>&2 131} 132 133direq_maybe () 134{ 135 [ "$(cd ${1} && pwd)" = "$(cd ${2} && pwd)" ] 136 return $? 137} 138 139check_encoding() 140{ 141 if iconv -l | grep -qi "$1"; then 142 return 0 143 fi 144 skip "iconv doesn't know about the encoding: $1" 145} 146