This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

RE: [PATCH]: Enable LC_TIME handling


The strftime.c documentation edits should be done consistently
in the manner that %r, %x, etc., were edited, which is to keep the
default locale information, but simply changing the words around them.
(Since many users likely know nothing about locale (and are better off
continuing to know nothing about it), keeping the info that is there is
better than deleting it; I can't, offhand, think of another place in
Newlib documentation where a user could go to get the information that
would be deleted.)
 
For example:
 
Extract from the patch:
 o %B
-The full name of the month, one of `<<January>>', `<<February>>',
-`<<March>>', `<<April>>', `<<May>>', `<<June>>', `<<July>>',
-`<<August>>', `<<September>>', `<<October>>', `<<November>>',
-`<<December>>'. [tm_mon]
+The full month name according to the current locale. [tm_mon]
...
 o %r
-The 12-hour time, to the second.  Equivalent to "%I:%M:%S %p". [tm_sec,
-tm_min, tm_hour]
+Replaced by the time in a.m. and p.m. notation.  In the POSIX locale
this
+is equivalent to "%I:%M:%S %p".  In locales which don't define
a.m./p.m.
+notations, the result is an empty string. [tm_sec, tm_min, tm_hour]
 
A possible alternative for %B, using the same paradigm as was used for
%r:
 o %B
+The full month name according to the current locale. [tm_mon]
-The full name of the month, one of `<<January>>', `<<February>>',
+In the default "C" locale, one of `<<January>>', `<<February>>',
 `<<March>>', `<<April>>', `<<May>>', `<<June>>', `<<July>>',
 `<<August>>', `<<September>>', `<<October>>', `<<November>>',
 `<<December>>'. [tm_mon]
 
Another alternative is to put the information in another place, and
refer to it so that users can find it--but the first alternative is
the least amount of work.
 
And a secondary comment:  when referring to locale, the patch generally
uses "POSIX".  Again, because many people likely don't know, it might
be better to talk about "C" locale or "'C' and POSIX" (or "'C'/POSIX,
etc.) locales.
 
And a question related to the coding, itself:  it appears that 256 has
been hard-coded in a couple of dependent places.  (I didn't take the
time to go completely through the call chains.  This just caught my
eye as maybe being something, but maybe it isn't.)
+     *len_ret = mbstowcs (buf, elem, 256);
...
+#ifdef MAKE_WCSFTIME
+  CHAR ctlocbuf[256];
+#endif
Are these two occurrences of the number 256 independent of each other?
If they are dependent, #define CTLOCBUFLEN 256 (or the like) should be
introduced.
 
Craig

-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
On Behalf Of Corinna Vinschen
Sent: Monday, January 18, 2010 12:17 PM
To: newlib@sourceware.org
Subject: [PATCH]: Enable LC_TIME handling

Hi,

the below patch enables LC_TIME handling.  The actual loading of the
localized LC_TIME data is restricted to Cygwin for now.  I was planning
to enable this for all targets, but I found that the __part_load_locale
function in ldpart.c is broken in terms of memory allocation and pointer
handling.  It's apparently a rather old implementation, which should
first be replaced by the latest from FreeBSD, for instance.  When we
have a new ldpart.c, we can easily enable this functionality for all
targets, if desired.

Although the actual localized data is only generated on Cygwin, the
generic functions strftime(3) and strptime(3) needed some work, since
they were using hardcoded formats as defined in the POSIX locale, rather
than accessing the locale specific data via the
__get_current_time_locale()
function.

...

Ok to apply?


Thanks,
Corinna


	...
	* libc/time/strftime.c: Change documentation to reflect changes
to
	strftime.  Remove locale constant strings in favor of access to
	locale-specifc data.
	(_ctloc): Define access method for locale-specifc data.
	(TOLOWER): Define for tolower conversion.
	(strftime): Throughout, convert locale-specific formats to use
	locale-specific data.  Add GNU-specific "%P" format.
	...


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