diff options
author | Gary V. Vaughan <gary@gnu.org> | 2011-11-16 15:00:47 +0700 |
---|---|---|
committer | Gary V. Vaughan <gary@gnu.org> | 2011-11-25 14:53:41 +0700 |
commit | 59e09030ae0f79108745dd527b2fd03f0f149696 (patch) | |
tree | 1a7384a4dbed08fa8d389ea4c122ebf981476d07 | |
parent | 11d16ab06c36948c053c507f5f9e06ff3de221c7 (diff) | |
download | libtool-59e09030ae0f79108745dd527b2fd03f0f149696.tar.gz |
syntax-check: fix violations and implement sc_useless_quotes_in_case.
Contrary to popular belief, Bourne shell does not resplit case
expressions after expansion, so if there are no unquoted shell
metacharacters or whitespace, the quotes are useless.
* cfg.mk (sc_useless_quotes_in_case): New syntax-check rule to
ensure we don't reintroduce useless quoted case expressions.
* build-aux/ltmain.m4sh, m4/libtool.m4, tests/bindir.at,
tests/darwin.at, tests/defs.m4sh, tests/demo-hardcode.test,
tests/demo-nopic.test, tests/link-2.test, tests/quote.test,
tests/sysroot.at: Remove spurious quotes.
Signed-off-by: Gary V. Vaughan <gary@gnu.org>
-rw-r--r-- | build-aux/ltmain.m4sh | 12 | ||||
-rw-r--r-- | cfg.mk | 8 | ||||
-rw-r--r-- | m4/libtool.m4 | 2 | ||||
-rw-r--r-- | tests/bindir.at | 4 | ||||
-rw-r--r-- | tests/darwin.at | 2 | ||||
-rw-r--r-- | tests/defs.m4sh | 2 | ||||
-rwxr-xr-x | tests/demo-hardcode.test | 4 | ||||
-rwxr-xr-x | tests/demo-nopic.test | 6 | ||||
-rwxr-xr-x | tests/link-2.test | 2 | ||||
-rwxr-xr-x | tests/quote.test | 8 | ||||
-rw-r--r-- | tests/sysroot.at | 2 |
11 files changed, 30 insertions, 22 deletions
diff --git a/build-aux/ltmain.m4sh b/build-aux/ltmain.m4sh index 5e8fb252..ee93a212 100644 --- a/build-aux/ltmain.m4sh +++ b/build-aux/ltmain.m4sh @@ -461,7 +461,7 @@ func_lalib_unsafe_p () for lalib_p_l in 1 2 3 4 do read lalib_p_line - case "$lalib_p_line" in + case $lalib_p_line in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done @@ -568,7 +568,7 @@ func_resolve_sysroot () # store the result into func_replace_sysroot_result. func_replace_sysroot () { - case "$lt_sysroot:$1" in + case $lt_sysroot:$1 in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" @@ -3625,7 +3625,7 @@ main (int argc, char *argv[]) if (STREQ (argv[i], dumpscript_opt)) { EOF - case "$host" in + case $host in *mingw* | *cygwin* ) # make stdout use "unix" line endings echo " setmode(1,_O_BINARY);" @@ -5796,7 +5796,7 @@ func_mode_link () if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi - case "$host" in + case $host in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both @@ -5896,7 +5896,7 @@ func_mode_link () # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. - case "$temp_rpath:" in + case $temp_rpath: in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac @@ -8765,7 +8765,7 @@ func_mode_uninstall () done test -n "$old_library" && func_append rmfiles " $odir/$old_library" - case "$opt_mode" in + case $opt_mode in clean) case " $library_names " in *" $dlname "*) ;; @@ -60,6 +60,14 @@ sc_trailing_blank-non-rfc3676: halt='found trailing blank(s)' \ $(_sc_search_regexp) +# Avoid useless quotes around case arguments such as: +# case "$foo" in ... +exclude_file_name_regexp--sc_useless_quotes_in_case = ^cfg.mk$$ +sc_useless_quotes_in_case: + @prohibit='case "[^ "]*"[ ][ ]*in' \ + halt='found spurious quotes around case argument' \ + $(_sc_search_regexp) + # List syntax-check exempted files. exclude_file_name_regexp--sc_bindtextdomain = ^tests/.*demo[0-9]*/.*\.c$$ exclude_file_name_regexp--sc_error_message_uppercase = \ diff --git a/m4/libtool.m4 b/m4/libtool.m4 index a9e20cfe..ec00e816 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1198,7 +1198,7 @@ func_echo_all () $ECHO "$*" } -case "$ECHO" in +case $ECHO in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; diff --git a/tests/bindir.at b/tests/bindir.at index 4e2fecc7..a3684a96 100644 --- a/tests/bindir.at +++ b/tests/bindir.at @@ -64,7 +64,7 @@ AT_SETUP([bindir basic lib test]) bindirneeded=: -case "$host_os" in +case $host_os in cygwin*|mingw*|cegcc*) ;; *) @@ -173,7 +173,7 @@ AT_CLEANUP AT_SETUP([bindir install tests]) bindirneeded=: -case "$host_os" in +case $host_os in cygwin*|mingw*|cegcc*) ;; *) diff --git a/tests/darwin.at b/tests/darwin.at index 6eab4cdb..e2abe1a9 100644 --- a/tests/darwin.at +++ b/tests/darwin.at @@ -25,7 +25,7 @@ AT_BANNER([Mac OS X tests]) AT_SETUP([darwin fat compile]) noskip=: -case "$host_os" in +case $host_os in darwin*) ;; *) noskip=false ;; esac diff --git a/tests/defs.m4sh b/tests/defs.m4sh index 56f1ecc1..c09657f3 100644 --- a/tests/defs.m4sh +++ b/tests/defs.m4sh @@ -45,7 +45,7 @@ fi # How verbose should we be? Default is test output in log file. # Setting VERBOSE=debug puts the shell in debug mode. debug_cmd=: -case "$VERBOSE" in +case $VERBOSE in DEBUG | debug ) debug_cmd='set -x' $debug_cmd diff --git a/tests/demo-hardcode.test b/tests/demo-hardcode.test index 31b2e1d7..0e486904 100755 --- a/tests/demo-hardcode.test +++ b/tests/demo-hardcode.test @@ -49,7 +49,7 @@ hardcode_libdir_flag_spec' "./libtool --config" ": fatal" echo "= Searching for hardcoded library directories in each program" for file in hc-*; do - case "$file" in + case $file in hc-direct) expected="$hardcode_direct" ;; hc-libpath) expected="$hardcode_shlibpath_var" ;; hc-minusL) expected="$hardcode_minus_L" ;; @@ -96,7 +96,7 @@ for file in hc-*; do fi # Check the result. - case "$hardcoded" in + case $hardcoded in yes) if test $expected = yes; then echo "$objdir was hardcoded in \`$file', as libtool expected" diff --git a/tests/demo-nopic.test b/tests/demo-nopic.test index acceca69..ab7c1aab 100755 --- a/tests/demo-nopic.test +++ b/tests/demo-nopic.test @@ -25,7 +25,7 @@ . tests/defs || exit 1 -case "$host" in +case $host in hppa*|x86_64*|s390*) func_skip "$host doesn't like non-PIC shared libs" ;; @@ -36,10 +36,10 @@ esac if test "$build" = "$host" && test -d "/etc/selinux"; then _selinux=`getenforce 2>/dev/null || echo "Disabled"` - case "${_selinux}" in + case ${_selinux} in *Enforcing) _sebool_allow_execmod=`getsebool allow_execmod 2>/dev/null` - case "${_sebool_allow_execmod}" in + case ${_sebool_allow_execmod} in *off) func_skip "SELinux policy disallows" ;; diff --git a/tests/link-2.test b/tests/link-2.test index 6c0f5192..9c7c8c62 100755 --- a/tests/link-2.test +++ b/tests/link-2.test @@ -41,7 +41,7 @@ rm -f hell.lo test $res -eq 0 || exit $EXIT_FAILURE echo "$linkresult" -case "$linkresult" in +case $linkresult in *".lo "*) func_fail "$progname: .lo files should not be linked into programs" ;; diff --git a/tests/quote.test b/tests/quote.test index 6a62dacd..1b986d11 100755 --- a/tests/quote.test +++ b/tests/quote.test @@ -47,7 +47,7 @@ for mode in compile link install; do # try metacharacters in the options it needs to pass to other programs. # preargs and postargs need to go through libtool unmodified. - case "$mode" in + case $mode in compile) preargs="$CC -c" preflag= @@ -83,7 +83,7 @@ for mode in compile link install; do # may modify them. For example, on Cygwin, ``libtool --mode=link gcc -o # foo foo.o'' becomes ``gcc -o foo.exe foo.o''. match="${match_preflag}${flag}test " - case "$result" in + case $result in *"$match"*) $ECHO "= passed: $result" ;; @@ -99,7 +99,7 @@ for mode in compile link install; do result=`$LIBTOOL -n --mode=$mode $preargs ${preflag}"${flag}${mchar}test${mchar}" $postargs` || status=$EXIT_FAILURE match="${match_preflag}${flag}\\${mchar}test\\${mchar} " alt_match="${match_preflag}\"${flag}\\${mchar}test\\${mchar}\" " - case "$result" in + case $result in *"$match"*) $ECHO "= passed: $result" ;; @@ -120,7 +120,7 @@ for mode in compile link install; do $ECHO "= trying: \"$mchar\" quoting" result=`$LIBTOOL -n --mode=$mode $preargs ${preflag}"${flag}${mchar}test${mchar}" $postargs` || status=$EXIT_FAILURE match="${match_preflag}\"${flag}${mchar}test${mchar}\" " - case "$result" in + case $result in *"$match"*) $ECHO "= passed: $result" ;; diff --git a/tests/sysroot.at b/tests/sysroot.at index 2a271347..90aab6fe 100644 --- a/tests/sysroot.at +++ b/tests/sysroot.at @@ -37,7 +37,7 @@ prefix= for i in crt0.o crt1.o crt2.o crti.o; do j=`$CC --print-file-name $i 2> /dev/null` test $? = 0 || continue - case "$j" in + case $j in $gcc_sysroot*/lib/$i) prefix=`echo "$j" | sed "s,^$gcc_sysroot\\(.*\\)/lib/$i\$,\\1,"` break ;; |