pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/buildlink3 Use a stack instead of the broken implem...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/72eac2af910c
branches:  trunk
changeset: 467325:72eac2af910c
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Thu Jan 29 07:14:30 2004 +0000

description:
Use a stack instead of the broken implementation of a circular list for the
argument buffer.

diffstat:

 mk/buildlink3/buffer     |  52 ++++++++++++++++-------------------------------
 mk/buildlink3/libtool.sh |   8 +++---
 mk/buildlink3/wrapper.sh |   8 +++---
 3 files changed, 26 insertions(+), 42 deletions(-)

diffs (139 lines):

diff -r 4be1ca0aeaa1 -r 72eac2af910c mk/buildlink3/buffer
--- a/mk/buildlink3/buffer      Thu Jan 29 06:37:56 2004 +0000
+++ b/mk/buildlink3/buffer      Thu Jan 29 07:14:30 2004 +0000
@@ -1,12 +1,10 @@
-# $NetBSD: buffer,v 1.4 2004/01/27 08:23:45 jlam Exp $
+# $NetBSD: buffer,v 1.5 2004/01/29 07:14:30 jlam Exp $
 #
-# Fill the buffer if it's empty, and shift the arguments.  The next
-# argument checked by the cache and logic files is taken from the
-# first non-empty buffer.  We avoid using "eval" so that we can skip
-# having to specially quote the argument using "sed".
+# Push arguments onto the argument stack and shift the arguments.  The
+# next argument checked by the cache and logic files is take from the
+# the top of the stack.
 #
-case ${buf1}${buf2}${buf3}${buf4}${buf5} in
-"")
+if $test -z "$depth"; then
        arg="$1"; shift
        #
        # Marshall any group of consecutive arguments into a single
@@ -41,16 +39,8 @@
                while $test $# -gt 0; do
                        case "$dirlist" in
                        "$1"|"$1 "*) ;;
-                       *" $1 "*|*" $1") ;;
-                       *)      dirlist="$dirlist $1"
-                               if   $test -z "$buf1"; then buf1="$R$1"
-                               elif $test -z "$buf2"; then buf2="$R$1"
-                               elif $test -z "$buf3"; then buf3="$R$1"
-                               elif $test -z "$buf4"; then buf4="$R$1"
-                               elif $test -z "$buf5"; then buf5="$R$1"
-                               else exit 2
-                               fi
-                               ;;
+                       *" $1 "*|*" $1")         ;;
+                       *) dirlist="$1 $dirlist" ;;
                        esac
                        shift
                done
@@ -58,25 +48,19 @@
                if $test -n "$allargs"; then
                        set -- $allargs
                fi
+               for dir in $dirlist; do
+                       depth=${depth}0
+                       eval stack${depth}="\$R\$dir"
+               done
                ;;
        *)
-               if   $test -z "$buf1"; then buf1="$arg"
-               elif $test -z "$buf2"; then buf2="$arg"
-               elif $test -z "$buf3"; then buf3="$arg"
-               elif $test -z "$buf4"; then buf4="$arg"
-               elif $test -z "$buf5"; then buf5="$arg"
-               else exit 2
-               fi
+               depth=${depth}0
+               eval stack${depth}="\$arg"
                ;;
        esac
-       ;;
-esac
-#
-# Re-fetch $arg from the first non-empty buffer.
+fi
 #
-if   $test -n "$buf1"; then arg="$buf1"; buf1=
-elif $test -n "$buf2"; then arg="$buf2"; buf2=
-elif $test -n "$buf3"; then arg="$buf3"; buf3=
-elif $test -n "$buf4"; then arg="$buf4"; buf4=
-elif $test -n "$buf5"; then arg="$buf5"; buf5=
-fi
+# Re-fetch $arg from the top of the stack.
+#
+eval arg="\$stack${depth}"
+depth=${depth%0}
diff -r 4be1ca0aeaa1 -r 72eac2af910c mk/buildlink3/libtool.sh
--- a/mk/buildlink3/libtool.sh  Thu Jan 29 06:37:56 2004 +0000
+++ b/mk/buildlink3/libtool.sh  Thu Jan 29 07:14:30 2004 +0000
@@ -1,6 +1,6 @@
 #!@BUILDLINK_SHELL@
 #
-# $NetBSD: libtool.sh,v 1.12 2004/01/29 06:06:41 jlam Exp $
+# $NetBSD: libtool.sh,v 1.13 2004/01/29 07:14:30 jlam Exp $
 
 Xsed='@SED@ -e 1s/^X//'
 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
@@ -37,8 +37,8 @@
 WRKDIR="@WRKDIR@"
 WRKSRC="@WRKSRC@"
 
-# Argument buffers
-buf1=; buf2=; buf3=; buf4=; buf5=
+# Argument stack depth
+depth=
 
 original_cmd="$0 $@"
 $echo [*] $original_cmd >> $wrapperlog
@@ -112,7 +112,7 @@
        done    
        ;;
 *)
-       while $test $# -gt 0 -o -n "${buf1}${buf2}${buf3}${buf4}${buf5}"; do
+       while $test $# -gt 0 -o -n "$depth"; do
                skipargs=0
                #
                # Get the next argument from the buffer.
diff -r 4be1ca0aeaa1 -r 72eac2af910c mk/buildlink3/wrapper.sh
--- a/mk/buildlink3/wrapper.sh  Thu Jan 29 06:37:56 2004 +0000
+++ b/mk/buildlink3/wrapper.sh  Thu Jan 29 07:14:30 2004 +0000
@@ -1,6 +1,6 @@
 #!@BUILDLINK_SHELL@
 #
-# $NetBSD: wrapper.sh,v 1.8 2004/01/29 06:06:41 jlam Exp $
+# $NetBSD: wrapper.sh,v 1.9 2004/01/29 07:14:30 jlam Exp $
 
 Xsed='@SED@ -e 1s/^X//'
 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
@@ -34,8 +34,8 @@
 WRKDIR="@WRKDIR@"
 WRKSRC="@WRKSRC@"
 
-# Argument buffers
-buf1=; buf2=; buf3=; buf4=; buf5=
+# Argument stack depth
+depth=
 
 original_cmd="$0 $@"
 $echo [*] $original_cmd >> $wrapperlog
@@ -44,7 +44,7 @@
 ldflags=
 libs=
 set -- "$@" @_BLNK_WRAP_EXTRA_FLAGS@
-while $test $# -gt 0 -o -n "${buf1}${buf2}${buf3}${buf4}${buf5}"; do
+while $test $# -gt 0 -o -n "$depth"; do
        cachehit=no
        skipcache=no
        skipargs=0



Home | Main Index | Thread Index | Old Index