Commit Graph

17347 Commits

Author SHA1 Message Date
Corinna Vinschen 6f3943bca1 Reinstantiate Cygwin function called `__getreent'
This partially reverts commit 10a30e7 as far as the Cygwin version of
the __getreent function is concerned.  Remove _COMPILING_NEWLIB guard
only allowing to use __getreent inline function when building newlib,
since we wan to use it in Cygwin as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Stefan Assmann <sassmann@redhat.com>
2016-08-18 15:24:42 +02:00
Corinna Vinschen 3bbc40af2a Revert "Fix __getreent function for Cygwin"
This reverts commit 4de8596.  It worked around a problem which was
actually introduced by patch 10a30e7 a few weeks ago.  Rather than
adding special code to the newlib version of __getreent, the followup
patch reinstantiates the original, Cygwin-only implementation of
__getreent.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Stefan Assmann <sassmann@redhat.com>
2016-08-18 15:24:18 +02:00
Corinna Vinschen eb61113daf Workaround AzureAD shortcomings
No real domain, no DC, no infos via NetUserGetInfo... nothing.  Just nothing.

Use fixed uid 0x1000 (4096) for AzureAD user and gid 0x1001 (4097) for
AzureAD group.  Note that this group is part of the user token, but it's
not the primary group.  The primary group SID is, unfortunately, the
user's SID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-18 10:27:28 +02:00
Corinna Vinschen 4de8596b8e Fix __getreent function for Cygwin
So far the lib function __getreent always returned _impure_ptr.  On Cygwin
this is only correct after _impure_ptr got initialized.  The inline
function in include/cygwin/config.h always returns the right _reent ptr,
though.

After introducing per-thread locales, the __getreent function is called
prior to initialization of _impure_ptr (from dll_crt0_0) to access the
locale pointer, which leads to a crash.

Fix the __getreent lib function for Cygwin to return the correct _reent
pointer all the time.  Rename inline function to __inline_getreent
and introduce a macro __getreent calling the inline function.  Change
the lib function __getreent to call __inline_getreent on Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-18 10:27:14 +02:00
Thomas Preudhomme 0e2e3c958c Fix pdf build failure wrt documentation of is*_l functions
make pdf on arm-none-eabi targets fails to build after the reorganization in
baf0c9fcb5 to fold is*_l documentation in their
is* counterpart. This is due two issues:

1) newlib/libc/ctype/ctype.tex still including the def file for the long versions
2) missing angle brackets in .c files for some of is*_l functions

This patch fixes the issues and allows make pdf to succeeds.
2016-08-17 20:58:21 +02:00
Corinna Vinschen 8443fcd625 Add release message for commit c02ac89
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-17 11:17:26 +02:00
Corinna Vinschen c02ac89f28 Add -i/--input option to locale(1)
The default UI language returned by GetUserDefaultUILanguage does not
necessarily reflect what the user really wants.  E. g., the system could
be en_US, but the desired language is en_CA, without having a CA langpack
installed.

Changing the settings under "Languages" and changing the keyboard layout
is only affecting the so-called  "Input language", while what's returned
by GetUserDefaultUILanguage is the "Display language".  Changing the
latter requires installing MUI langpacks.

Thus, we introduce a way to fetch the "Input language" using the -i or
--input option.

Also clean up documentation of locale(1).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-17 10:58:04 +02:00
Corinna Vinschen b0d341442c Constify __locale_ctype_ptr and __locale_ctype_ptr_l
Remove _MB_CAPABLE-only _CONST in ctype.h

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-17 09:40:28 +02:00
Corinna Vinschen 1c25a777b3 Actually return pointers in locale categroy accessor functions
Commit 6e7ce50 was broken.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 16:23:51 +02:00
Corinna Vinschen 625a8a3f62 Always fall back to __ctype_ptr__ in isXXX_l functions.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 16:22:12 +02:00
Corinna Vinschen 042263cd83 Avoid "implicit declaration of function ‘strtold_l’" in wcstold.c
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 16:21:19 +02:00
Corinna Vinschen 1ec81984d8 Use era_info_t and alt_digits_t on _WANT_C99_TIME_FORMATS targets only
Using era_info_t and alt_digits_t indiscriminately in strftime and
strftime_l breaks targets not wanting C99 time formats.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 15:26:01 +02:00
Corinna Vinschen 6e7ce50e04 Expose locale category accessor functions to non-__HAVE_LOCALE_INFO__ targets.
These functions are used from, e.g., nl_langinfo or strftime, so
we need them for all targets.  Just return "C" locale category for
non-__HAVE_LOCALE_INFO__ targets.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 15:24:26 +02:00
Corinna Vinschen 7ef90f7f9d __localeconv_l: Always define locale variable lconv
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 13:54:32 +02:00
Corinna Vinschen 7964ad15c1 Don't use locale_t in internal header
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 13:51:46 +02:00
Corinna Vinschen a867598373 Rephrase release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 12:41:34 +02:00
Corinna Vinschen de09bb4d32 Fix typo in release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 11:22:26 +02:00
Corinna Vinschen 5dc306cf97 Add release text for Cygwin 2.6.0
Move release/2.5.3 to release/2.6.0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 21:26:01 +02:00
Corinna Vinschen 238455adfa Implement strto[dflu]_l/wcsto[dflu]_l
Implement GNU extensions strtod_l, strtof_l, strtol_l, strtold_l, strtoll_l,
strtoul_l, strtoull_l, wcstod_l, wcstof_l, wcstol_l, wcstold_l, wcstoll_l,
wcstoul_l, wcstoull_l.

Export from Cygwin, fix posix.xml.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 17:35:21 +02:00
Corinna Vinschen 5ef60b7e6a Add documentation for duplocale, freelocale, newlocale, and uselocale.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 17:34:40 +02:00
Corinna Vinschen baf0c9fcb5 Fold documentation of is*_l funcs into documentation of non-l is* funcs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 14:21:52 +02:00
Corinna Vinschen 5bdf8cfa49 setlocale/localeconv are *not* POSIX-1.2008
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:59 +02:00
Corinna Vinschen 1a5d08014b setlocale.h: Fix current locale handling for !__HAVE_LOCALE_INFO__ targets
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:59 +02:00
Corinna Vinschen beb721cf37 __loadlocale: Set missing val when evaluating CP874
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:59 +02:00
Corinna Vinschen 8f1378b19f Make sure alloca is called even when optimizing, fully init _REENT
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen d7281b92ab Fix multiple thinkos in newlocale
- Setting the categories strings in tmp_locale short-circuits
  __loadlocale.  Use a new_categories array instead, just as in
  _setlocale_r.

- If we have a base, copy over the *not* defined categories in
  category_mask in the first place.  Rearrange loop accordingly.

- Free base right in newlocale.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 659f4ca916 Fix _REENT_INIT initialization of _locale
Initializing a pointer to struct __locale_t to point to a string "C"
is not such a bright idea in the long run...

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 18f6750b95 Fix typo in isalnum_l doc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen ac7f1d5e93 Get rid of LCID, reformat type definitions in setlocale.h
Definition of LCID results in build problems on 32 bit Cygwin

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 7156bf842e Add sys/_locale.h header and fix up headers
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 91ebe04042 Bump CygwinAPI minor.
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 765d2c0bac Implement strfmon_l
Use latest code from FreeBSD

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 542b970d4e Rename __get_locale_XXX to __get_XXX_locale to use unified naming scheme
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen fb4fb921c6 Move lconv into struct __locale_t and implement __localeconv_l
Based on FreeBSD, just don't export symbol yet, unless required.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen c1b7d9d93d Implement per-locale string functions
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>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 8493c16316 Implement all per-locale ctype functions
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 956565be70 Move localeconv, duplocale, freelocale, newlocale, uselocale into separate files
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen a2ed50381e include/locale.h: Fix POSIX guards
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen cf2cd696da Remove non-working __part_load_locale function and any related code
Add TODO markers in case somebody wants to pick this up again

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen c402f0388f posix.xml: Note duplocale, freelocale, newlocale, uselocale as implemented
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 1afa0fe4b3 Fix memory handling in functions called from loadlocale
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen aefd8b5b51 Implement newlocale, freelocale, duplocale, uselocale
Add global const __C_locale for reference purposes.

Bump Cygwin API minor number and DLL major version number to 2.6.0.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen d4f6cae9cd Use __get_global_locale function where appropriate
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 53f84bb5ac Rearrange struct __locale_t pointers into an array
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>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 1498c79db8 Change loadlocale to fill a __locale_t given as parameter
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>
2016-08-15 10:56:57 +02:00
Corinna Vinschen d16a56306d Consolidate wctomb/mbtowc calls for POSIX-1.2008
- 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>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 88208d3735 POSIX-1.2008 per-thread locales, groundwork part 2
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>
2016-08-15 10:56:56 +02:00
Corinna Vinschen a6a477fa81 POSIX-1.2008 per-thread locales, groundwork part 1
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>
2016-08-15 10:56:56 +02:00
Yaakov Selkowitz 51b669f679 Do not include wctype.h in wchar.h with _GNU_SOURCE
_GNU_SOURCE generally enables all features, but in this case the POSIX
requirement to #include <wctype.h> for these is preferred.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-08-12 13:44:26 -05:00
Yaakov Selkowitz b14a1dbc86 Define va_list in stdio.h and wchar.h
This typedef, along with that of FILE in wchar.h, were XSI prior to
inclusion in POSIX.1-2008.

Fixes: https://sourceware.org/ml/newlib/2016/msg00640.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-08-12 11:43:14 -05:00