summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/nlsfuncs.cc
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* * nlsfuncs.cc (has_modifier): MOve up in file to use inCorinna Vinschen2010-02-061-27/+50
| | | | | | | | | | __get_lcid_from_locale as well. (__get_lcid_from_locale): Handle no_NO locale as alias for nn_NO. Default all sr_XY locales to Cyrillic script. Change lcid to Latin script if "@latin" modifier has been specified. (__set_charset_from_locale): Handle Serbian in codepage 1251 case as well. Also check for sr_BA lcid. Restrict "@euro" modifier to locales otherwise defaulting to ISO-8859-1.
* * nlsfuncs.cc (__set_charset_from_locale): Set default charset forCorinna Vinschen2010-02-061-0/+4
| | | | "ka_GE" locale to GEORGIAN-PS, for "kk_KZ" to PT154.
* * nlsfuncs.cc (__set_charset_from_locale): Set default locale forCorinna Vinschen2010-02-051-2/+3
| | | | "uz_UZ" locale to ISO-8859-1, with the "@cyrillic" modifier to UTF-8.
* Replace regex files with multibyte-aware version from FreeBSD.Corinna Vinschen2010-02-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.in (install-headers): Remove extra command to install regex.h. (uninstall-headers): Remove extra command to uninstall regex.h. * nlsfuncs.cc (collate_lcid): Make externally available to allow access to collation internals from regex functions. (collate_charset): Ditto. * wchar.h: Add __cplusplus guards to make C-clean. * include/regex.h: New file, replacing regex/regex.h. Remove UCB advertising clause. * regex/COPYRIGHT: Accommodate BSD license. Remove UCB advertising clause. * regex/cclass.h: Remove. * regex/cname.h: New file from FreeBSD. * regex/engine.c: Ditto. (NONCHAR): Tweak for Cygwin. * regex/engine.ih: Remove. * regex/mkh: Remove. * regex/regcomp.c: New file from FreeBSD. Tweak slightly for Cygwin. Import required collate internals from nlsfunc.cc. (p_ere_exp): Add GNU-specific \< and \> handling for word boundaries. (p_simp_re): Ditto. (__collate_range_cmp): Define. (p_b_term): Use Cygwin-specific collate internals. (findmust): Ditto. * regex/regcomp.ih: Remove. * regex/regerror.c: New file from FreeBSD. Fix a few compiler warnings. * regex/regerror.ih: Remove. * regex/regex.7: New file from FreeBSD. Remove UCB advertising clause. * regex/regex.h: Remove. Replaced by include/regex.h. * regex/regexec.c: New file from FreeBSD. Fix a few compiler warnings. * regex/regfree.c: New file from FreeBSD. * regex/tests: Remove. * regex/utils.h: New file from FreeBSD.
* * nlsfuncs.cc (__get_lcid_from_locale): Add comments. Fix typos inCorinna Vinschen2010-01-251-12/+26
| | | | | | | | comments. Make sure to set last_lcid every time. Return locale without territory part as invalid. Handle modern serbian territory names per ISO 3166 on older systems as well. Add appropriate comment. (__set_charset_from_locale): Handle LCID for sr_CS as well to make older systems happy.
* * nlsfuncs.cc (__set_charset_from_locale): Rearrange to set charsetCorinna Vinschen2010-01-251-28/+89
| | | | more closely aligned to Glibc.
* * nlsfuncs.cc (__get_lcid_from_locale): Fix a comment. Handle specialCorinna Vinschen2010-01-251-3/+63
| | | | language/TERRITORY combinations explicitely. Explain why.
* * nlsfuncs.cc (__set_charset_from_locale): Fix comment.Corinna Vinschen2010-01-241-3/+1
|
* * nlsfuncs.cc (check_codepage): Move from syscalls.cc here.Corinna Vinschen2010-01-241-1/+109
| | | | | | | | | (internal_setlocale): Ditto. (initial_setlocale): Ditto. (setlocale): Ditto. * strfuncs.cc (__sjis_wctomb): Revert previous patch. (__sjis_mbtowc): Ditto. * syscalls.cc: Move setlocale-related functions to nlsfuncs.cc.
* * nlsfuncs.cc (wcsxfrm): Call LCMapStringW with LCMAP_BYTEREV flag toCorinna Vinschen2010-01-231-1/+1
| | | | allow correct comparison using wcscmp.
* * Makefile.in (DLL_OFILES): Add nlsfunc.o and strfmon.o.Corinna Vinschen2010-01-221-0/+764
* autoload.cc (LocaleNameToLCID): Define. * cygwin.din (strfmon): Export. * nlsfuncs.cc: New file. Define a lot of internal functions called from setlocale. (wcscoll): Implement locale-aware here, using CompareStringW function. (strcoll): Ditto. (wcsxfrm): Implement locale-aware here, usingLCMapStringW function. (strxfrm): Ditto. (__set_charset_from_locale): Replace __set_charset_from_codepage. Return Linux-compatible charset. * strfuncs.cc (__set_charset_from_codepage): Remove. * wchar.h (__set_charset_from_codepage): Drop definition. * wincap.h (wincaps::has_localenames): New element. * wincap.cc: Implement above element throughout. * libc/strfmon.c: New file. * libc/strptime.cc: Remove locale constant strings in favor of access to locale-specifc data. (strptime): Point _CurrentTimeLocale to locale-specific data. Throughout use correct locale-specific format fields for all locale-specific formats. * include/monetary.h: New file. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.