From: Andreas Schwab Date: Sat, 11 May 2002 16:00:10 +0000 (+0000) Subject: (intersection): Keep the elements of the returned list X-Git-Tag: ttn-vms-21-2-B4~15101 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=eef762fc0f8608ace52913b8dca6263a88e02f6d;p=emacs.git (intersection): Keep the elements of the returned list in the same order as in the first list. --- diff --git a/src/ChangeLog b/src/ChangeLog index c92e4b5cff4..570c82c9628 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-05-11 Andreas Schwab + + * coding.c (intersection): Keep the elements of the returned list + in the same order as in the first list. + 2002-05-11 Kim F. Storm * keymap.c (current_minor_maps): Fixed resizing of cmm_maps; diff --git a/src/coding.c b/src/coding.c index 8c54f86e531..baf6acf08af 100644 --- a/src/coding.c +++ b/src/coding.c @@ -6324,14 +6324,17 @@ static Lisp_Object intersection (l1, l2) Lisp_Object l1, l2; { - Lisp_Object val; + Lisp_Object val = Fcons (Qnil, Qnil), tail; - for (val = Qnil; CONSP (l1); l1 = XCDR (l1)) + for (tail = val; CONSP (l1); l1 = XCDR (l1)) { if (!NILP (Fmemq (XCAR (l1), l2))) - val = Fcons (XCAR (l1), val); + { + XSETCDR (tail, Fcons (XCAR (l1), Qnil)); + tail = XCDR (tail); + } } - return val; + return XCDR (val); }