]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
syntax-check: fix violations and implement sc_useless_quotes_in_case.
authorGary V. Vaughan <gary@gnu.org>
Wed, 16 Nov 2011 08:00:47 +0000 (15:00 +0700)
committerGary V. Vaughan <gary@gnu.org>
Fri, 25 Nov 2011 07:53:41 +0000 (14:53 +0700)
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>
build-aux/ltmain.m4sh
cfg.mk
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

index 5e8fb252c631610f01f9bb63f8eb18440c1dc0a2..ee93a212b5218e17059313fbbec77d2f304517a3 100644 (file)
@@ -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 "*) ;;
diff --git a/cfg.mk b/cfg.mk
index 6a1748c1b81c86d40b2aa134c884303721880c7a..4bc32a73064d7ee511a29fbd26bc60412b7fee53 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -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 = \
index a9e20cfef7183f52d21ccc2f2d91cb37c579ccf1..ec00e8169ad114cdedde03ca517687c1ec771182 100644 (file)
@@ -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]) ;;
index 4e2fecc756caeec46c85fcc896bb4be168032b63..a3684a96cc225a89967e79a03d043b60555257fa 100644 (file)
@@ -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*)
     ;;
   *)
index 6eab4cdbc5aac699d715175da69c6418cc6b71b1..e2abe1a97ebdc08f76ef9e5a2a5e45bf89337901 100644 (file)
@@ -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
index 56f1ecc117fafbba9d7637a17609db8a473ca078..c09657f32f25a290cae7d21970af2cf1db613ce3 100644 (file)
@@ -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
index 31b2e1d7d1494e560f2af037dfe96086a6d4f47a..0e486904324f43144f8630315536e49a324ecc74 100755 (executable)
@@ -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"
index acceca69546d8d76efaaaa8c30a9a824a342c5ac..ab7c1aab9d3c867d70b0d245ea2c5b27adcd4424 100755 (executable)
@@ -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"
                                ;;
index 6c0f51921a6c5c1c0ded07eb62b27832151aa4e8..9c7c8c62c803b7e0d17aa343211b020173c47632 100755 (executable)
@@ -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"
   ;;
index 6a62dacdac06ff744b51204d763e65495bd14565..1b986d11f5d9784e45494a97080dc25faeff0455 100755 (executable)
@@ -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"
       ;;
index 2a271347a07418dd90c0d65f915ddc9872f914da..90aab6fe4e68cc6421bffe20bbe9753fb196427e 100644 (file)
@@ -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 ;;