| 1 |
# Copyright: 2016 Masatake YAMATO |
| 2 |
# License: GPL-2 |
| 3 |
|
| 4 |
CTAGS=$1 |
| 5 |
O="--quiet --options=NONE -o - -x " |
| 6 |
P=$(pwd) |
| 7 |
|
| 8 |
if type realpath > /dev/null 2>&1; then |
| 9 |
P=$(realpath "$P") |
| 10 |
cd "$P" |
| 11 |
fi |
| 12 |
|
| 13 |
. ../utils.sh |
| 14 |
|
| 15 |
if ! ${CTAGS} $O --help | grep -e --tag-relative | grep --quiet -e always; then |
| 16 |
echo "--tag-relative=always|never is not available on this platform" |
| 17 |
exit ${__SKIP__} |
| 18 |
fi |
| 19 |
|
| 20 |
{ |
| 21 |
F=./input.c |
| 22 |
${CTAGS} $O --_xformat="default: $F -> %F" $F |
| 23 |
${CTAGS} $O --_xformat="never: $F -> %F" --tag-relative=never $F |
| 24 |
${CTAGS} $O --_xformat="no: $F -> %F" --tag-relative=no $F |
| 25 |
${CTAGS} $O --_xformat="yes: $F -> %F" --tag-relative=yes $F |
| 26 |
${CTAGS} $O --_xformat="always: $F -> %F" --tag-relative=always $F |
| 27 |
|
| 28 |
F=input.c |
| 29 |
${CTAGS} $O --_xformat="default: $F -> %F" $F |
| 30 |
${CTAGS} $O --_xformat="never: $F -> %F" --tag-relative=never $F |
| 31 |
${CTAGS} $O --_xformat="no: $F -> %F" --tag-relative=no $F |
| 32 |
${CTAGS} $O --_xformat="yes: $F -> %F" --tag-relative=yes $F |
| 33 |
${CTAGS} $O --_xformat="always: $F -> %F" --tag-relative=always $F |
| 34 |
|
| 35 |
F=${P}/input.c |
| 36 |
${CTAGS} $O --_xformat="default: $F -> %F" $F |
| 37 |
${CTAGS} $O --_xformat="never: $F -> %F" --tag-relative=never $F |
| 38 |
${CTAGS} $O --_xformat="no: $F -> %F" --tag-relative=no $F |
| 39 |
${CTAGS} $O --_xformat="yes: $F -> %F" --tag-relative=yes $F |
| 40 |
${CTAGS} $O --_xformat="always: $F -> %F" --tag-relative=always $F |
| 41 |
} | { |
| 42 |
# Normalize Windows driver letter |
| 43 |
# |
| 44 |
# comment time: Sat Feb 6 13:11:44 UTC 2021 |
| 45 |
# comment author: [email protected] |
| 46 |
# |
| 47 |
# as far as I know, the most widely used unix-like POSIX-compatible environments on Windows are Cygwin and MSYS2. Actually, MSYS2 is a modified fork of Cygwin. They both provide a command-line tool called cygpath which can be used to convert Windows PATH to UNIX path. There exists other unix-like POSIX-compatible environments on Windows, git-for-windows as an example, but they all based on Cygwin or MSYS2. |
| 48 |
if command -v cygpath > /dev/null && command -v awk > /dev/null ; then |
| 49 |
awk '{if ($NF ~ /^[A-Z]:/) { "cygpath "$NF | getline newpath; sub($NF,newpath) } print}' |
| 50 |
else |
| 51 |
# \l is a GNU extension. But only Windows's path match [A-Z]: pattern, Cygwin and MSYS2 use GNU sed. |
| 52 |
sed 's|\([A-Z]\):|/\l\1|' |
| 53 |
fi |
| 54 |
} | { |
| 55 |
# Unescape |
| 56 |
sed -e 's|\\\\|\\|g' |
| 57 |
} | { |
| 58 |
# Convert to / |
| 59 |
sed -e 's|\\|/|g' |
| 60 |
} | { |
| 61 |
# Convert pwd test environment neutral |
| 62 |
sed -e "s|${P}|/abs|g" |
| 63 |
} |