bug-gnu-utils
[Top][All Lists]
Advanced

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

address@hidden: Re: test10-pre7]


From: Ingo Oeser
Subject: address@hidden: Re: test10-pre7]
Date: Sat, 4 Nov 2000 18:58:18 +0100
User-agent: Mutt/1.2i

Dear maintainers,

Since we need _such_ hackary (see attachment) for building the
Linux kernel, isn't it time to implement $(unique LIST) ?

This should have been implemented since the beginning, because
sorting and removing duplicates are orthogonal funcions.

I would even try to do a patch, but would like to know, whether
it would be accepted.

Thanks & Regards

Ingo Oeser
-- 
Feel the power of the penguin - run address@hidden
<esc>:x
--- Begin Message --- Subject: Re: test10-pre7 Date: Fri, 03 Nov 2000 11:26:06 -0500
Hi, Peter

> [Vladislav Malyshkin <address@hidden>]
> > Also, the function remove_duplicates can be written using make rules
> > and functions.  Using functions "foreach" "if" from make and
> > comparison you can easily build a function remove_duplicates in make,
> > no shell involved.
>
> Could you please write me this function?  I am curious to see how you
> do it.
>
> I am also a bit skeptical.  About 3 months ago, I thought it would be
> possible to do this, so I spent a few hours fiddling around and reading
> documentation.  I failed; nothing I tried worked.
>
> > so instead of $(sort) your will have $(remove_duplicates) written
> > entirely in make.
>
> That would make me happy.

Absense of recursive macros in make makes the problem not that clear.
An alternative may be if to put \n into variable value,
so the make commands will be automatically generated
---- like this
remove_duplicates = $(2) := ; $(foreach tmpvar1,$(1),$(2) += $$(if
$$(findstring $(tmpvar1),$$($(2))),,$(tmpvar1)); )
$(call remove_duplicates, x y a a c c a b c,ABCD)
--- in this example the variable ABCD is set to the string without
duplicates
but make seems does not allow \n as a value and does not understand
several assignments in one line, so
A = B ; C = D
does not work as expected.

So the best what we can get without using shell is below (the code and
usage example)
The function $(call remove_duplicates,string with duplicates)
removes the duplicates from the string.

# joins four strings
join4 = $(join $(join $(1),$(2)),$(join $(3),$(4)))
# generates indexes
numbers = $(foreach x4,0 1 2 3 4 5 6 7 8 9,\
$(strip $(foreach x3,0 1 2 3 4 5 6 7 8 9,\
$(strip $(foreach x2,0 1 2 3 4 5 6 7 8 9,\
$(strip $(foreach x1,0 1 2 3 4 5 6 7 8 9,\
$(strip $(if $(findstring $(call join4,$(x4),$(x3),$(x2),$(x1)),0000),,\
$(if $(word $(call join4,$(x4),$(x3),$(x2),$(x1)),$(1)),\
$(call join4,$(x4),$(x3),$(x2),$(x1)))))))))))))
# generates indexes
numbers1 = $(wordlist 1,$(words $(wordlist 2,$(words $(1)),$(1))),\
$(call numbers,$(1)))
# Remove duplicates from a line of up to 10000 words
remove_duplicates = $(strip $(firstword $(1)) \
$(foreach tmpvar,$(call numbers1,$(1)),\
$(if $(findstring \
$(word $(tmpvar),$(wordlist 2,$(words $(1)),$(1))),\
$(wordlist 1,$(tmpvar),$(1))),,\
$(word $(tmpvar),$(wordlist 2,$(words $(1)),$(1))))))

f := x x y a b c d x e y jj jj j2 j2 j2 j7
all:
    echo '$(call remove_duplicates,$(f))'



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to address@hidden
Please read the FAQ at http://www.tux.org/lkml/

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]