Bug 54391

Summary: Document that glob(3) respects LC_COLLATE
Product: Documentation Reporter: Thomas-Martin Seck <tmseck>
Component: Books & ArticlesAssignee: freebsd-doc (Nobody) <doc>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Thomas-Martin Seck 2003-07-11 18:50:14 UTC
	glob(3)'s description of GLOB_NOSORT claims that glob(3) always
	sorts in alphabetical order as specified by ASCII.
	This is not true if LC_COLLATE (or LANG, resp.) are set.

Fix: 

Reword glob(3) like this:

	Index: glob.3
	===================================================================
	RCS file: /home/ncvs/src/lib/libc/gen/glob.3,v
	retrieving revision 1.23
	diff -u -r1.23 glob.3
	--- glob.3	4 Feb 2003 16:27:42 -0000	1.23
	+++ glob.3	11 Jul 2003 17:05:58 -0000
	@@ -197,10 +197,10 @@
	 .Dv GLOB_NOESCAPE
	 is set, backslash escaping is disabled.
	 .It Dv GLOB_NOSORT
	-By default, the pathnames are sorted in ascending
	-.Tn ASCII
	-order;
	-this flag prevents that sorting (speeding up
	+By default, the pathnames are sorted in locale specific ascending order
	+as specified by
	+.Ev LC_COLLATE .
	+This flag prevents that sorting (speeding up
	 .Fn glob ) .
	 .El
	 .Pp
	@@ -421,7 +421,8 @@
	 .Sh SEE ALSO
	 .Xr sh 1 ,
	 .Xr fnmatch 3 ,
	-.Xr regexp 3
	+.Xr regexp 3 ,
	+.Xr setlocale 3
	 .Sh STANDARDS
	 The
	 .Fn glob
How-To-Repeat: 	Create the files a.test, b.test and <aumlaut>.test with <aumlaut>
	being the "a with dots" present in ISO8859-1.
	Then compare the output of
	env LC_COLLATE=en_US.US-ASCII ls *.test
	(<aumlaut>.test ist sorted last)
	with
	env LC_COLLATE=en_US.ISO8859-1 ls *.test
	(<aumlaut is sorted between a and b).
Comment 1 Tom Rhodes freebsd_committer freebsd_triage 2003-07-11 18:50:47 UTC
On 11 Jul 2003 17:41:02 -0000
Thomas Seck <tmseck@netcologne.de> wrote:

> 
> 	Index: glob.3
> 	===================================================================
> 	RCS file: /home/ncvs/src/lib/libc/gen/glob.3,v
> 	retrieving revision 1.23
> 	diff -u -r1.23 glob.3
> 	--- glob.3	4 Feb 2003 16:27:42 -0000	1.23
> 	+++ glob.3	11 Jul 2003 17:05:58 -0000
> 	@@ -197,10 +197,10 @@
> 	 .Dv GLOB_NOESCAPE
> 	 is set, backslash escaping is disabled.
> 	 .It Dv GLOB_NOSORT
> 	-By default, the pathnames are sorted in ascending
> 	-.Tn ASCII
> 	-order;
> 	-this flag prevents that sorting (speeding up
> 	+By default, the pathnames are sorted in locale specific ascending order


"sorted by locale in ascending order"?


--
Tom Rhodes
Comment 2 Thomas-Martin Seck 2003-07-11 19:20:44 UTC
* Tom Rhodes (trhodes@FreeBSD.org):

> On 11 Jul 2003 17:41:02 -0000
> Thomas Seck <tmseck@netcologne.de> wrote:
> 
> > 
> > 	+By default, the pathnames are sorted in locale specific ascending order
> 
> 
> "sorted by locale in ascending order"?

Hm, I am not a native speaker but this does not sound right to me. SUSv3
uses "...according to the current setting of the LC_COLLATE
category..." and it is qsort(3) that actually does the sorting. But I
admit that my suggestion sounds a bit awkward.

Regards,
-- 
Thomas Seck
Comment 3 Tim Robbins freebsd_committer freebsd_triage 2004-08-23 13:11:26 UTC
State Changed
From-To: open->patched

A similar patch has been committed to -current and will be MFC'd in 7 days.
Comment 4 Tim Robbins freebsd_committer freebsd_triage 2004-09-01 12:03:53 UTC
State Changed
From-To: patched->closed

glob() does not actually respect LC_COLLATE, and the change to the manual 
page has been backed out in -current. Your shell must not be using glob() 
from libc.