When splicing a source list before a position in a target list,
the items must be spliced in order from first to last; otherwise,
(splicing from last to first) the items become reversed as they
are moved to the target.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-03  Matthew Heaney  <hea...@adacore.com>

        * a-cbdlli.adb (Splice): move source items from first to last

Index: a-cbdlli.adb
===================================================================
--- a-cbdlli.adb        (revision 176998)
+++ a-cbdlli.adb        (working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2004-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 2004-2011, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -1486,10 +1486,9 @@
            "attempt to tamper with cursors of Source (list is busy)";
       end if;
 
-      loop
-         Insert (Target, Before, Source.Nodes (Source.Last).Element);
-         Delete_Last (Source);
-         exit when Is_Empty (Source);
+      while not Is_Empty (Source) loop
+         Insert (Target, Before, Source.Nodes (Source.First).Element);
+         Delete_First (Source);
       end loop;
    end Splice;
 

Reply via email to