about summary refs log tree commit diff
path: root/manual
diff options
context:
space:
mode:
Diffstat (limited to 'manual')
-rw-r--r--manual/filesys.texi11
-rw-r--r--manual/string.texi50
-rw-r--r--manual/texinfo.tex18
3 files changed, 69 insertions, 10 deletions
diff --git a/manual/filesys.texi b/manual/filesys.texi
index afe072c594..5ddd8a20a7 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -455,8 +455,8 @@ value are selected.
 Finally the entries in the @var{namelist} are sorted using the user
 supplied function @var{cmp}.  The arguments of the @var{cmp} function
 are of type @code{struct dirent **}.  I.e., one cannot directly use the
-@code{strcmp} or @code{strcoll} function; see the function
-@code{alphasort} below.
+@code{strcmp} or @code{strcoll} function; see the functions
+@code{alphasort} and @code{versionsort} below.
 
 The return value of the function gives the number of entries placed in
 @var{namelist}.  If it is @code{-1} an error occurred and the global
@@ -465,7 +465,7 @@ variable @code{errno} contains more information on the error.
 
 As said above the fourth argument to the @code{scandir} function must be
 a pointer to a sorting function.  For the convenience of the programmer
-the GNU C library contains an implementation of a function which is very
+the GNU C library contains implementations of functions which are very
 helpful for this purpose.
 
 @deftypefun int alphasort (const void *@var{a}, const void *@var{b})
@@ -478,6 +478,11 @@ Return value of is less than, equal to, or greater than zero depending
 on the order of the two entries @var{a} and @var{b}.
 @end deftypefun
 
+@deftypefun int versionsort (const void *@var{a}, const void *@var{b})
+The @code{versionsort} function is like @code{alphasort}, excepted that it
+uses the @code{strverscmp} function internally.
+@end deftypefun
+
 @node Simple Directory Lister Mark II
 @subsection Simple Program to List a Directory, Mark II
 
diff --git a/manual/string.texi b/manual/string.texi
index 8f09ac9728..e358b2015f 100644
--- a/manual/string.texi
+++ b/manual/string.texi
@@ -609,6 +609,56 @@ strncmp ("hello, world", "hello, stupid world!!!", 5)
 @end smallexample
 
 @comment string.h
+@comment GNU
+@deftypefun int strverscmp (const char *@var{s1}, const char *@var{s2})
+The @code{strverscmp} function compares the string @var{s1} against
+@var{s2}, considering them as holding indices/version numbers.  Return
+value follows the same conventions as found in the @code{strverscmp}
+function.  In fact, if @var{s1} and @var{s2} contain no digits,
+@code{strverscmp} behaves like @code{strcmp}.
+
+Basically, we compare strings normaly (character by character), until
+we find a digit in each string - then we enter a special comparison
+mode, where each sequence of digit is taken as a whole.  If we reach the
+end of these two parts without noticing a difference, we return to the
+standard comparison mode.  There are two types of numeric parts:
+"integral" and "fractionnal" (these laters begins with a '0'). The types
+of the numeric parts affect the way we sort them:
+
+@itemize @bullet
+@item
+integral/integral: we compare values as you would expect.
+
+@item
+fractionnal/integral: the fractionnal part is less than the integral one.
+Again, no surprise.
+
+@item
+fractionnal/fractionnal: the things become a bit more complex.
+if the common prefix contains only leading zeroes, the longest part is less
+than the other one; else the comparison behaves normaly.
+@end itemize
+
+@smallexample
+strverscmp ("no digit", "no digit")
+    @result{} 0    /* @r{same behaviour as strverscmp.} */
+strverscmp ("item#99", "item#100")
+    @result{} <0   /* @r{same prefix, but 99 < 100.} */
+strverscmp ("alpha1", "alpha001")
+    @result{} >0   /* @r{fractionnal part inferior to integral one.} */
+strverscmp ("part1_f012", "part1_f01")
+    @result{} >0   /* @r{two fractionnal parts.} */
+strverscmp ("foo.009", "foo.0")
+    @result{} <0   /* @r{idem, but with leading zeroes only.} */
+@end smallexample
+
+This function is especially usefull when dealing with filename sorting,
+because filenames frequently hold indices/version numbers.
+
+@code{strverscmp} is a GNU extension.
+@end deftypefun
+
+@comment string.h
 @comment BSD
 @deftypefun int bcmp (const void *@var{a1}, const void *@var{a2}, size_t @var{size})
 This is an obsolete alias for @code{memcmp}, derived from BSD.
diff --git a/manual/texinfo.tex b/manual/texinfo.tex
index 72050b8e22..6bae66900a 100644
--- a/manual/texinfo.tex
+++ b/manual/texinfo.tex
@@ -1,5 +1,5 @@
 %% TeX macros to handle Texinfo files.
-%% $Id: texinfo.tex,v 2.198 1997/05/07 15:16:03 drepper Exp $
+%% $Id: texinfo.tex,v 2.199 1997/05/20 11:11:48 drepper Exp $
 
 %  Copyright (C) 1985, 86, 88, 90, 91, 92, 93,
 %                94, 95, 96, 97 Free Software Foundation, Inc.
@@ -36,7 +36,7 @@
 
 % This automatically updates the version number based on RCS.
 \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
-\deftexinfoversion$Revision: 2.198 $
+\deftexinfoversion$Revision: 2.199 $
 \message{Loading texinfo package [Version \texinfoversion]:}
 
 % If in a .fmt file, print the version number
@@ -1271,8 +1271,6 @@ where each line of input produces a line of output.}
 \def\ctrl #1{{\tt \rawbackslash \hat}#1}
 
 \let\file=\samp
-\let\url=\samp % perhaps include a hypertex \special eventually
-\def\email#1{$\langle${\tt #1}$\rangle$}
 
 % @code is a modification of @t,
 % which makes spaces the same size as normal in the surrounding text.
@@ -1325,7 +1323,7 @@ where each line of input produces a line of output.}
 
 \def\realdash{-}
 \def\codedash{-\discretionary{}{}{}}
-\def\codeunder{\normalunderscore\discretionary{}{}{}}
+\def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
 \def\codex #1{\tclose{#1}\endgroup}
 
 %\let\exp=\tclose  %Was temporary
@@ -1339,6 +1337,12 @@ where each line of input produces a line of output.}
 \else{\tclose{\ttsl\look}}\fi
 \else{\tclose{\ttsl\look}}\fi}
 
+% @url, @email.  Quotes do not seem necessary.
+\let\url=\code % perhaps include a hypertex \special eventually
+% rms does not like the angle brackets --karl, 17may97.
+%\def\email#1{$\langle${\tt #1}$\rangle$}
+\let\email=\code
+
 % Check if we are currently using a typewriter font.  Since all the
 % Computer Modern typewriter fonts have zero interword stretch (and
 % shrink), and it is reasonable to expect all typewriter fonts to have
@@ -3417,8 +3421,8 @@ width0pt\relax} \fi
 \let\.=\ptexdot
 \let\*=\ptexstar
 \let\dots=\ptexdots
-\def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}
-\def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}
+\def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
+\def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
 \def\@{@}%
 \let\bullet=\ptexbullet
 \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext