Skip to content

Commit

Permalink
Merge pull request universal-ctags#256 from vhda/units/sed-r
Browse files Browse the repository at this point in the history
units: Don't use extended regular expressions in sed
  • Loading branch information
masatake committed Mar 1, 2015
2 parents cc8e8f0 + e4b28d8 commit ee66264
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Units/php-simple.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ add_item input.php /^ function add_item ($artnr, $num)$/;" f class:Cart signa
foo input.php /^function foo ($arg_1, $arg_2, ..., $arg_n)$/;" f signature:($arg_1, $arg_2, ..., $arg_n)
items input.php /^ var $items; \/\/ Items in our shopping cart$/;" v class:Cart access:public
remove_item input.php /^ function remove_item ($artnr, $num)$/;" f class:Cart signature:($artnr, $num)
t�yte Units/php-simple.d/input.php /^$t�yte = 'mansikka'; \/\/ valid; '�' is ASCII 228.$/;" v
t�yte input.php /^$t�yte = 'mansikka'; \/\/ valid; '�' is ASCII 228.$/;" v
var input.php /^$var = "Bob";$/;" v
2 changes: 1 addition & 1 deletion Units/simple.php.t/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ add_item input.php /^ function add_item ($artnr, $num)$/;" f class:Cart
foo input.php /^function foo ($arg_1, $arg_2, ..., $arg_n)$/;" f
items input.php /^ var $items; \/\/ Items in our shopping cart$/;" v class:Cart
remove_item input.php /^ function remove_item ($artnr, $num)$/;" f class:Cart
t�yte Units/simple.php.t/input.php /^$t�yte = 'mansikka'; \/\/ valid; '�' is ASCII 228.$/;" v
t�yte input.php /^$t�yte = 'mansikka'; \/\/ valid; '�' is ASCII 228.$/;" v
var input.php /^$var = "Bob";$/;" v
19 changes: 14 additions & 5 deletions misc/units
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ run_shrink ()
}

# filters out the directory prefix in a ctags input
tags_basename_filter_regex='s%(^[^\t]+\t)([^/\t]+/)*%\1%'
tags_basename_filter_regex='s%\(^[^ ]\{1,\} \)\([^/ ]\{1,\}/\)*%\1%'
tags_basename_filter()
{
sed -r "${tags_basename_filter_regex}"
sed "${tags_basename_filter_regex}"
}

run_record_cmdline ()
Expand All @@ -304,7 +304,7 @@ run_record_cmdline ()

printf "%s \\\\\n| %s \\\\\n| %s\n" \
"${_CMDLINE}" \
"sed -r '${tags_basename_filter_regex}'" \
"sed '${tags_basename_filter_regex}'" \
"${ffilter}" \
> "${ocmdline}"
}
Expand Down Expand Up @@ -363,7 +363,7 @@ run_tcase ()
#
# Filtered by LANGUAGES
#
guessed_lang=$( ${_CMDLINE} --print-language "$input" 2>/dev/null | sed -nr 's/^.*: (.+)$/\1/p')
guessed_lang=$( ${_CMDLINE} --print-language "$input" 2>/dev/null | sed -n 's/^.*: //p')
if [ -n "${LANGUAGES}" ]; then
member_p "${guessed_lang}" ${LANGUAGES} || return 1
fi
Expand Down Expand Up @@ -1459,7 +1459,7 @@ noise_lang_file ()
local offset
local guessed_lang

guessed_lang=$( ${_CMDLINE_FOR_SHRINKING} --print-language "${input}" 2>/dev/null | sed -nr 's/^.*: (.+)$/\1/p')
guessed_lang=$( ${_CMDLINE_FOR_SHRINKING} --print-language "${input}" 2>/dev/null | sed -n 's/^.*: //p')
if [ "${lang}" != "${guessed_lang}" ]; then
return 0
fi
Expand Down Expand Up @@ -1549,6 +1549,14 @@ $0 noise [OPTIONS] UNITS-DIR
EOF
}

# Avoid issues between sed and the locale settings by overriding it using
# LC_ALL, which takes precedence over all other locale configurations:
# https://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html
prepare_environment ()
{
LC_ALL="C"; export LC_ALL
}

main ()
{
if [ $# = 0 ]; then
Expand Down Expand Up @@ -1587,5 +1595,6 @@ main ()
esac
}

prepare_environment
main "$@"
exit $?

0 comments on commit ee66264

Please sign in to comment.