scripts: recognize the "q", "s" and "S" actions/modifiers in ar-lib
authorPeter Rosin <peda@lysator.liu.se>
Thu, 1 Mar 2012 08:30:45 +0000 (09:30 +0100)
committerPeter Rosin <peda@lysator.liu.se>
Thu, 1 Mar 2012 08:30:45 +0000 (09:30 +0100)
* lib/ar-lib: Implement the "q" (quick) action as a synonym
for "r" (replace).  Ignore "s" (symbol index) and "S" (no symbol
index) when used as modifiers and "s" when used as a command,
there is simply no way for Microsoft lib to not update the
symbol table index in the archive.
(scriptversion): Update.
* tests/ar-lib.test: Check the added behavior.  Also add checks
for the recently added "u" (update) and "v" (verbose) modifiers.

lib/ar-lib
tests/ar-lib.test

index c698ac5..67f5f36 100755 (executable)
@@ -2,7 +2,7 @@
 # Wrapper for Microsoft lib.exe
 
 me=ar-lib
-scriptversion=2012-01-30.22; # UTC
+scriptversion=2012-03-01.08; # UTC
 
 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
 # Written by Peter Rosin <peda@lysator.liu.se>.
@@ -153,7 +153,9 @@ action=${action#-}
 delete=
 extract=
 list=
+quick=
 replace=
+index=
 create=
 
 while test -n "$action"
@@ -162,7 +164,10 @@ do
     d*) delete=yes  ;;
     x*) extract=yes ;;
     t*) list=yes    ;;
+    q*) quick=yes   ;;
     r*) replace=yes ;;
+    s*) index=yes   ;;
+    S*)             ;; # the index is always updated implicitly
     c*) create=yes  ;;
     u*)             ;; # TODO: don't ignore the update modifier
     v*)             ;; # TODO: don't ignore the verbose modifier
@@ -173,8 +178,8 @@ do
   action=${action#?}
 done
 
-case $delete$extract$list$replace in
-  yes)
+case $delete$extract$list$quick$replace,$index in
+  yes,* | ,yes)
     ;;
   yesyes*)
     func_error "more than one action specified"
@@ -225,7 +230,7 @@ elif test -n "$extract"; then
     done
   fi
 
-elif test -n "$replace"; then
+elif test -n "$quick$replace"; then
   if test ! -f "$orig_archive"; then
     if test -z "$create"; then
       echo "$me: creating $orig_archive"
index 0350645..1ddec64 100755 (executable)
@@ -45,6 +45,23 @@ touch foo.lib
 opts=`./ar-lib ./lib r foo.lib foo.obj`
 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
 
+# Check if ar-lib can update an existing archive with "q".
+opts=`./ar-lib ./lib q foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
+# Check if ar-lib accepts "u" as a modifier.
+# NOTE: "u" should have an effect, but currently doesn't.
+opts=`./ar-lib ./lib ru foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
+# Check if ar-lib accepts "s" as a modifier.
+opts=`./ar-lib ./lib rs foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
+# Check if ar-lib accepts "S" as a modifier.
+opts=`./ar-lib ./lib rS foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
 # Check if ar-lib passes on @FILE with "r"
 opts=`./ar-lib ./lib r foo.lib @list`
 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib @list"
@@ -62,6 +79,11 @@ test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
 opts=`./ar-lib ./lib t foo.lib`
 test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
 
+# Check if ar-lib accepts "v" as a modifier.
+# NOTE: "v" should have an effect, but currently doesn't.
+opts=`./ar-lib ./lib tv foo.lib`
+test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
+
 # Check if ar-lib can extract archive members with "x".
 touch fake.lib
 opts=`./ar-lib ./lib x fake.lib`
@@ -84,4 +106,8 @@ touch fake2.lib
 opts=`./ar-lib ./lib x fake2.lib`
 test x"$opts" = x"lib -NOLOGO -EXTRACT:dir\\fake2.obj fake2.lib"
 
+# Check if ar-lib accepts "s" as an action.
+opts=`./ar-lib ./lib s foo.lib`
+test x"$opts" = x
+
 :