This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.20-401-g98fe149


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  98fe149e34b48d0c4d69105315cc7c61be8276ec (commit)
      from  d12455f59679faee885809258ae4f10449b1f2cf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=98fe149e34b48d0c4d69105315cc7c61be8276ec

commit 98fe149e34b48d0c4d69105315cc7c61be8276ec
Author: Anders Kaseorg <andersk@mit.edu>
Date:   Thu Dec 11 05:33:22 2014 -0500

    manual: Correct guarantee about pointers compared by qsort()
    
    C99, C11, POSIX, and the glibc implementation do guarantee that the
    pointers passed to the qsort comparison function lie within the array.
    
    Signed-off-by: Anders Kaseorg <andersk@mit.edu>

diff --git a/ChangeLog b/ChangeLog
index 642f84d..eaaff71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-21  Anders Kaseorg  <andersk@mit.edu>
+
+	* manual/search.texi: (Array Sort Function): Clarify stable sorting
+	guarantees.
+
 2014-12-20  Chris Metcalf  <cmetcalf@ezchip.com>
 
 	* sysdeps/unix/sysv/linux/tile/localplt.data: New file.
diff --git a/manual/search.texi b/manual/search.texi
index 8aff574..662527f 100644
--- a/manual/search.texi
+++ b/manual/search.texi
@@ -164,8 +164,8 @@ To sort an array using an arbitrary comparison function, use the
 @comment ISO
 @deftypefun void qsort (void *@var{array}, size_t @var{count}, size_t @var{size}, comparison_fn_t @var{compare})
 @safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
-The @var{qsort} function sorts the array @var{array}.  The array contains
-@var{count} elements, each of which is of size @var{size}.
+The @code{qsort} function sorts the array @var{array}.  The array
+contains @var{count} elements, each of which is of size @var{size}.
 
 The @var{compare} function is used to perform the comparison on the
 array elements.  This function is called with two pointer arguments and
@@ -180,10 +180,12 @@ This can make a difference when the comparison considers only part of
 the elements.  Two elements with the same sort key may differ in other
 respects.
 
-The addresses passed to the comparison function need not correspond with
-the original location of the objects, and need not even lie within the
-original array.  The only way to perform a stable sort with @var{qsort}
-is to first augment the objects with a monotonic counter of some kind.
+Although the object addresses passed to the comparison function lie
+within the array, they need not correspond with the original locations
+of those objects because the sorting algorithm may swap around objects
+in the array before making some comparisons.  The only way to perform
+a stable sort with @code{qsort} is to first augment the objects with a
+monotonic counter of some kind.
 
 Here is a simple example of sorting an array of doubles in numerical
 order, using the comparison function defined above (@pxref{Comparison

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |    5 +++++
 manual/search.texi |   14 ++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]