summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/nlsfuncs.cc
Commit message (Collapse)AuthorAgeFilesLines
* cygwin wcsxfrm: byte swap result ourselvesCorinna Vinschen2017-06-061-8/+13
| | | | | | | | | | | | | | | | | | | | | Workaround a bug (or undocumented behaviour) in LCMapStringW: It's documented(*) that the cchDest parameter is a byte count with LCMAP_SORTKEY, but a character count otherwise. But the docs don't state what happens if you combine LCMAP_SORTKEY with LCMAP_BYTEREV. Tests indicate that LCMAP_SORTKEY treats cchDest as byte count, but then LCMAP_BYTEREV treats it as char count in the same call. So the latter swaps twice as much bytes in the destination buffer than the byte count it returns, which potentially results in writing past the end of the given output buffer. Solution: Don't specify LCMAP_BYTEREV in the LCMapStringW(LCMAP_SORTKEY) call, rather byte swap afterwards. (*) https://msdn.microsoft.com/en-us/library/windows/desktop/dd318702(v=vs.85).aspx Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Reference __global_locale only via __get_global_locale.Corinna Vinschen2016-08-231-3/+3
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Introduce __current_locale_charset/__locale_charsetCorinna Vinschen2016-08-201-1/+2
| | | | | | | | | The former __locale_charset always fetched the current locale's charset. We need the per-locale charset, too, in future. Rename __locale_charset to __current_locale_charset and change __locale_charset to take a locale_t as parameter. Accommodate througout. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Rename __get_locale_XXX to __get_XXX_locale to use unified naming schemeCorinna Vinschen2016-08-151-6/+6
| | | | Signed-off by: Corinna Vinschen <corinna@vinschen.de>
* Implement per-locale string functionsCorinna Vinschen2016-08-151-10/+38
| | | | | | | | | | | | strcasecmp_l, strcoll_l, strncasecmp_l, strxfrm_l, wcscasecmp_l, wcscoll_l, wcstrncasecmp_l, wcstrxfrm_l, strftime_l. Add missing CHEWOUT_FILES from previous patch. TODO: strfmon_l. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
* Fix memory handling in functions called from loadlocaleCorinna Vinschen2016-08-151-20/+24
| | | | Signed-off by: Corinna Vinschen <corinna@vinschen.de>
* Rearrange struct __locale_t pointers into an arrayCorinna Vinschen2016-08-151-9/+9
| | | | | | | This allows looping through the structs and buffers. Also rearrange definitions to follow order of LC_xxx values. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
* Change loadlocale to fill a __locale_t given as parameterCorinna Vinschen2016-08-151-1/+1
| | | | | | | | | | | | Don't use global variables. This allows to call loadlocale from the yet to be created newlocale(). Rename _thr_locale_t to __locale_t (these locales are not restricted to threads so the name is misleading). Along these lines, fix _set_ctype to take a __locale_t as parameter. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
* Consolidate wctomb/mbtowc calls for POSIX-1.2008Corinna Vinschen2016-08-151-57/+38
| | | | | | | | | | | | | | | | | | | | | - Remove charset parameter from low level __foo_wctomb/__foo_mbtowc calls. - Instead, create array of function for ISO and Windows codepages to point to function which does not require to evaluate the charset string on each call. Create matching helper functions. I.e., __iso_wctomb, __iso_mbtowc, __cp_wctomb and __cp_mbtowc are functions returning the right function pointer now. - Create __WCTOMB/__MBTOWC macros utilizing per-reent locale and replace calls to __wctomb/__mbtowc with calls to __WCTOMB/__MBTOWC. - Drop global __wctomb/__mbtowc vars. - Utilize aforementioned changes in Cygwin to get rid of charset in other, calling functions and simplify the code. - In Cygwin restrict global cygheap locale info to the job performed by internal_setlocale. Use UTF-8 instead of ASCII on the fly in internal conversion functions. - In Cygwin dll_entry, make sure to initialize a TLS area with a NULL _REENT->_locale pointer. Add comment to explain why. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
* POSIX-1.2008 per-thread locales, groundwork part 2Corinna Vinschen2016-08-151-40/+32
| | | | | | | | | Move all locale category structure definitions into setlocale.h and remove other headers in locale subdir. Create inline accessor functions for current category struct pointers and use throughout. Use pointers to "C" locale category structs by default in __global_locale. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
* POSIX-1.2008 per-thread locales, groundwork part 1Corinna Vinschen2016-08-151-24/+43
| | | | | | | | | | | | | | | | Introduce first cut of struct _thr_locale_t used for the locale_t definition. Introduce global instance called __global_locale used by default. Introduce internal inline functions __get_global_locale, __get_locale_r, __get_current_locale. Remove usage of global variables in favor of accessor functions pointing to __global_locale for now. Include all local headers in locale subdir from setlocale.h to get single include for internal locale access. Introduce __CTYPE_PTR macro to replace direct access to __ctype_ptr__ and use throughout in isxxx functions. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
* Add support for certain newer locales only available with ScriptCorinna Vinschen2016-06-241-1/+5
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Drop has_localenames flagCorinna Vinschen2016-06-231-150/+64
|
* Drop has_always_all_codepages flagCorinna Vinschen2016-06-231-46/+1
|
* Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout optioncygwin-2_5_2-releaseCorinna Vinschen2016-06-231-2/+0
| | | | | | | | | | | | | | Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause. Everything else stays under GPLv3+. New Linking Exception exempts resulting executables from LGPLv3 section 4. Add CONTRIBUTORS file to keep track of licensing. Remove 'Copyright Red Hat Inc' comments. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* strxfrm/wcsxfrm: Always return length of the transformed stringCorinna Vinschen2016-04-121-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | Cygwin's strxfrm/wcsfrm treated a too short output buffer as an error condition and always returned the size value provided as third parameter. This is not as it's documented in POSIX.1-2008. Rather, the only error condition is an invalid input string(*). Other than that, the functions are supposed to return the length of the resulting sort key, even if the output buffer is too small. In the latter case the content of the output array is unspecified, but it's the job of the application to check that the return value is greater or equal to the provided buffer size. (*) We have to make an exception in Cygwin: strxfrm has to call the UNICODE function LCMapStringW for reasons outlined in a source comment. If the incoming multibyte string is so large that we fail to malloc the space required to convert it to a wchar_t string, we have to ser errno as well since we have nothing to call LCMapStringW with. * nlsfuncs.cc (wcsxfrm): Fix expression computing offset of trailing wchar_t NUL. Compute correct return value even if output buffer is too small. (strxfrm): Handle failing malloc. Compute correct return value even if output buffer is too small. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix numeric and monetary decimal point and thousands separator in fa_IR and ↵Corinna Vinschen2015-11-211-10/+56
| | | | | | | | | | | | | ps_AF locales * nlsfuncs.cc (setlocaleinfo): New macro calling __setlocaleinfo. (__setlocaleinfo): New function to set a locale-specific character to an explicit wchar_t value. (__set_lc_numeric_from_win): Handle fa_IR and ps_AF locales to return same decimal point and thousands separator characters as on Linux. (__set_lc_monetary_from_win): Ditto for monetary characters. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Workaround bug in LocaleNameToLCID on Windows 10Corinna Vinschen2015-10-301-6/+13
| | | | | | | | * nlsfuncs.cc (__get_lcid_from_locale): Handle LocaleNameToLCID returning LOCALE_CUSTOM_UNSPECIFIED instead of failing in case of an unsupported locale on Windows 10. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* * nlsfuncs.cc (wcscoll): Add "__restrict" to definition.Corinna Vinschen2013-11-261-2/+2
| | | | (wcsxfrm): Ditto.
* * nlsfuncs.cc (strcoll): Add "__restrict" to definition.Corinna Vinschen2013-11-261-2/+2
| | | | (strxfrm): Ditto.
* Throughout, drop unnecessary explicit includes of windows header filesCorinna Vinschen2013-11-241-1/+0
| | | | | | | | | | | | included by default. * winlean.h: Add long comment to explain why we have to define certain symbols. (_NORMALIZE_): Define. (_WINNLS_): Drop definition and subsequent undef. (_WINNETWK_): Ditto. (_WINSVC_): Ditto. 2013-11-23 Eric Blake <eblake@redhat.com>
* * lc_msg.h: Regenerate.Corinna Vinschen2013-08-191-5/+29
| | | | | | | * nlsfuncs.cc (__get_lcid_from_locale): Update list of Script-only locales to Windows 8. (__set_charset_from_locale): Take locales added with Windows 8 and 8.1 into account.
* * nlsfuncs.cc (__collate_range_cmp): Convert input to wchar_t and callCorinna Vinschen2013-06-191-4/+6
| | | | | wcscoll since all calling functions are using wide chars. Explain in preceeding comment.
* * Merge in cygwin-64bit-branch.Corinna Vinschen2013-04-231-11/+6
|
* Throughout, update copyrights to reflect dates which correspond to main-branchChristopher Faylor2013-01-211-1/+1
| | | | checkins. Regularize copyright format.
* * Makefile.in (clean): Remove non-existant regexp dir.Corinna Vinschen2012-02-131-0/+9
| | | | | | | | | | | | | | | | | * collate.h: New header. (__collate_range_cmp): Declare. (__collate_load_error): Define. * glob.cc: Pull in latest version from FreeBSD. Simplify and reduce Cygwin-specific changes. * regex/regcomp.c: Include collate.h on Cygwin as well. (__collate_range_cmp): Move from here... * nlsfuncs.cc (__collate_range_cmp): ...to here. * miscfuncs.cc (thread_wrapper): Fix typo in comment. (CygwinCreateThread): Take dead zone of Windows stack into account. Change the way how the stack is commited and how to handle guardpages. Explain how and why. * thread.h (PTHREAD_DEFAULT_STACKSIZE): Change definition. Explain why.
* Clean up whitespace.Christopher Faylor2011-12-171-1/+1
|
* whitespace eliminationChristopher Faylor2011-06-061-25/+25
|
* * exceptions.cc (open_stackdumpfile): Correctly append .stackdumpCorinna Vinschen2010-06-011-15/+15
| | | | | | | | suffix. * nlsfuncs.cc (rebase_locale_buf): Reorder arguments. Accommodate throughout. Add pointer to end of buffer and avoid changing pointers not pointing into the buffer.
* * nlsfuncs.cc (__set_lc_time_from_win): Use LOCALE_SMONTHNAME1Corinna Vinschen2010-05-261-2/+12
| | | | | instead of LOCALE_SABBREVMONTHNAME1 in Japanese and Korean locales to get abbreviated month names. Explain why.
* * cygwin.din (__locale_mb_cur_max): Export.Corinna Vinschen2010-04-281-325/+527
| | | | | | | | | | | | | | | | | | * nlsfuncs.cc (__getlocaleinfo): Drop conversion to multibyte. (__charfromwchar): New function to convert to multibyte. (__eval_datetimefmt): Convert to return wchar_t pointer. Work on wide char string. (__set_lc_time_from_win): Take additional pointer to "C" category info to accommodate C.foo locales. Rework to fill wide char members in category info. (__set_lc_ctype_from_win): New function. (__set_lc_numeric_from_win): Take additional pointer to "C" category info to accommodate C.foo locales. Rework to fill wide char members in category info. (__set_lc_monetary_from_win): Ditto. (__set_lc_messages_from_win): Ditto. (__get_current_collate_codeset): New function, called from nl_langinfo. * include/cygwin/config.h (__HAVE_LOCALE_INFO_EXTENDED__): Define.
* * nlsfuncs.cc (__set_lc_time_from_win): Actually setCorinna Vinschen2010-04-091-0/+1
| | | | _time_locale->md_order to the D_MD_ORDER value written to the buffer.
* * nlsfuncs.cc: Fix indentation.Corinna Vinschen2010-04-011-4/+4
|
* * nlsfuncs.cc (rebase_locale_buf): New helper function to rebaseCorinna Vinschen2010-04-011-0/+27
| | | | | | | function pointers in locale structures. Explain why this is necessary. (__set_lc_time_from_win): Use rebase_locale_buf after realloc. (__set_lc_numeric_from_win): Ditto. (__set_lc_monetary_from_win): Ditto.
* * nlsfuncs.cc (__set_charset_from_locale): Set default charset forCorinna Vinschen2010-03-271-1/+1
| | | | locales defaulting to codepage 936 to GB2312.
* * lc_era.h: Redefine lc_era_t to keepCorinna Vinschen2010-02-221-72/+106
| | | | | | | | | | default date and time formats as well to workaround YA Windows shortcoming. Refresh with latest data. * lc_msg.h: Refresh with latest data. * nlsfuncs.cc (__eval_datetimefmt): Revert latest change. (__set_lc_time_from_win): Rename res to era. Prefer default date and time formats from era array if available. (__set_lc_messages_from_win): Rename res to msg.
* * lc_era.h (lc_era): Fix "ja_JP" era_t_fmt entry to use traditionalCorinna Vinschen2010-02-201-3/+12
| | | | | | | | | format. * nlsfuncs.cc (dt_flags): Remove DT_ERACAL since crippled era data in Windows makes it useless. (__eval_datetimefmt): Check if locale's default calender has non-gregorian start year. Use era year also in default date entries, if so.
* * lc_era.h: New file.Corinna Vinschen2010-02-191-23/+92
| | | | | | | * nlsfuncs.cc: Include lc_era.h. (locale_cmp): convert arguments to char** to be usable for both types, lc_msg_t and lc_era_t. (__set_lc_time_from_win): Handle era-related data
* * nlsfuncs.cc (eval_datetimefmt): Rename force to flags.Corinna Vinschen2010-02-181-16/+42
| | | | | | | | (enum dt_flags): Define. (__eval_datetimefmt): Change force to flags and change type to dt_flags. Accommodate throughout. (__set_lc_time_from_win): Accommodate above change. Set era-related values to empty strings for now.
* * nlsfuncs.cc (initial_setlocale): Move check whether charset hasCorinna Vinschen2010-02-111-3/+7
| | | | | | changed from here... (internal_setlocale): ...to here, to avoid unnecessary work when invoked via CW_INT_SETLOCALE.
* * nlsfuncs.cc (__set_charset_from_locale): Allow "@euro" modifier onlyCorinna Vinschen2010-02-101-1/+4
| | | | for locales which use EUR as currency.
* * nlsfuncs.cc (__get_lcid_from_locale): Convert iu_CA to iu-Latn-CACorinna Vinschen2010-02-101-2/+3
| | | | | rather than iu-Cans-CA on Vista and later. (__set_charset_from_locale): Set default charset for iu_CA to UTF-8.
* * nlsfuncs.cc (lc_wcstombs): Add `return_invalid' flag to specifyCorinna Vinschen2010-02-091-23/+18
| | | | | | | | whether invalid chars should be ignored or not. Change comment. (__set_lc_monetary_from_win): Call lc_wcstombs with return_invalid flag set. (__set_lc_messages_from_win): Simplify to accommodate the fact that lc_wcstombs just ignores invalid chars. Explain why.
* * nlsfuncs.cc (__set_lc_messages_from_win): Fix typo.Corinna Vinschen2010-02-091-1/+1
|
* * lc_msg.h: New file, autogenerated from CLDR data.Corinna Vinschen2010-02-091-17/+98
| | | | | | | | | | | | | | * nlsfuncs.cc: Include lc_msg.h. (lc_time_buf): Remove. (lc_numeric_buf): Remove. (lc_monetary_buf): Remove. (lc_mbstowcs): Fix previous fix. (__set_lc_time_from_win): Take additional pointer to buffer pointer, defined in newlib. (__set_lc_numeric_from_win): Ditto. (__set_lc_monetary_from_win): Ditto. (locale_cmp): New static function. (__set_lc_messages_from_win): New function to be called from newlib.
* Now *really* check in what should have been checked in 12 hours ago.Corinna Vinschen2010-02-081-2/+10
|
* This patch got lost in the previous checkin, accidentally:Corinna Vinschen2010-02-081-1/+1
| | | | * nlsfuncs.cc (lc_mbstowcs): Fix call to f_mbtowc.
* * nlsfuncs.cc (__get_lcid_from_locale): Handle "@cyrillic" modifierCorinna Vinschen2010-02-071-3/+16
| | | | | for uz_UZ locale here. (__set_charset_from_locale): Accommodate above change.
* * nlsfuncs.cc (__set_locale_from_locale_alias): New function to readCorinna Vinschen2010-02-071-0/+63
| | | | locale aliases from /usr/share/locale/locale.alias.
* * nlsfuncs.cc (__get_lcid_from_locale): Handle no_NO as nb_NO, ratherCorinna Vinschen2010-02-061-5/+5
| | | | than nn_NO.