<wchar.h>: Make wmempcy, wcwidth, wcswidth available by default
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
This matches what FreeBSD does. This helps to port software from
BSD using a C99 compiler that does not accept implicit function
declarations.
Tested on x86_64-linux-gnu.
---
wcsmbs/wchar.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
base-commit: 8fb923ddc38dd5f4bfac4869d70fd80483fdb87a
Comments
On Dez 06 2022, Florian Weimer via Libc-alpha wrote:
> @@ -363,14 +363,14 @@ extern size_t wcsnrtombs (char *__restrict __dst,
>
>
> /* The following functions are extensions found in X/Open CAE. */
> -#ifdef __USE_XOPEN
> +#if defined __USE_XOPEN || defined __USE_MISC
> /* Determine number of column positions required for C. */
> extern int wcwidth (wchar_t __c) __THROW;
>
> /* Determine number of column positions required for first N wide
> characters (or fewer if S ends before this) in S. */
> extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
> -#endif /* Use X/Open. */
> +#endif /* __USE_XOPEN || __USE_MISC. */
Again, I do not see how that matches what FreeBSD does. Both
definitions are protected by __XSI_VISIBLE there.
* Andreas Schwab:
> On Dez 06 2022, Florian Weimer via Libc-alpha wrote:
>
>> @@ -363,14 +363,14 @@ extern size_t wcsnrtombs (char *__restrict __dst,
>>
>>
>> /* The following functions are extensions found in X/Open CAE. */
>> -#ifdef __USE_XOPEN
>> +#if defined __USE_XOPEN || defined __USE_MISC
>> /* Determine number of column positions required for C. */
>> extern int wcwidth (wchar_t __c) __THROW;
>>
>> /* Determine number of column positions required for first N wide
>> characters (or fewer if S ends before this) in S. */
>> extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
>> -#endif /* Use X/Open. */
>> +#endif /* __USE_XOPEN || __USE_MISC. */
>
> Again, I do not see how that matches what FreeBSD does. Both
> definitions are protected by __XSI_VISIBLE there.
Should we do this instead?
diff --git a/include/features.h b/include/features.h
index 123de9fd47..40d10a0fb5 100644
--- a/include/features.h
+++ b/include/features.h
@@ -393,6 +393,7 @@
#if defined _DEFAULT_SOURCE
# define __USE_MISC 1
+# define __USE_XOPEN 1
#endif
#ifdef _ATFILE_SOURCE
Should we also define __USE_XOPEN_EXTENDED and __USE_XOPEN2K8 in this
case? This would allow us to simplify a lot of conditionals involving
__USE_MISC.
Thanks,
Florian
On 06/12/22 07:25, Florian Weimer via Libc-alpha wrote:
> * Andreas Schwab:
>
>> On Dez 06 2022, Florian Weimer via Libc-alpha wrote:
>>
>>> @@ -363,14 +363,14 @@ extern size_t wcsnrtombs (char *__restrict __dst,
>>>
>>>
>>> /* The following functions are extensions found in X/Open CAE. */
>>> -#ifdef __USE_XOPEN
>>> +#if defined __USE_XOPEN || defined __USE_MISC
>>> /* Determine number of column positions required for C. */
>>> extern int wcwidth (wchar_t __c) __THROW;
>>>
>>> /* Determine number of column positions required for first N wide
>>> characters (or fewer if S ends before this) in S. */
>>> extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
>>> -#endif /* Use X/Open. */
>>> +#endif /* __USE_XOPEN || __USE_MISC. */
>>
>> Again, I do not see how that matches what FreeBSD does. Both
>> definitions are protected by __XSI_VISIBLE there.
>
> Should we do this instead?
>
> diff --git a/include/features.h b/include/features.h
> index 123de9fd47..40d10a0fb5 100644
> --- a/include/features.h
> +++ b/include/features.h
> @@ -393,6 +393,7 @@
>
> #if defined _DEFAULT_SOURCE
> # define __USE_MISC 1
> +# define __USE_XOPEN 1
> #endif
>
> #ifdef _ATFILE_SOURCE
>
> Should we also define __USE_XOPEN_EXTENDED and __USE_XOPEN2K8 in this
> case? This would allow us to simplify a lot of conditionals involving
> __USE_MISC.
What is the define flags used by this old programs? I don't see much trouble
adding __USE_XOPEN for _DEFAULT_SOURCE.
* Adhemerval Zanella Netto:
> On 06/12/22 07:25, Florian Weimer via Libc-alpha wrote:
>> * Andreas Schwab:
>>
>>> On Dez 06 2022, Florian Weimer via Libc-alpha wrote:
>>>
>>>> @@ -363,14 +363,14 @@ extern size_t wcsnrtombs (char *__restrict __dst,
>>>>
>>>>
>>>> /* The following functions are extensions found in X/Open CAE. */
>>>> -#ifdef __USE_XOPEN
>>>> +#if defined __USE_XOPEN || defined __USE_MISC
>>>> /* Determine number of column positions required for C. */
>>>> extern int wcwidth (wchar_t __c) __THROW;
>>>>
>>>> /* Determine number of column positions required for first N wide
>>>> characters (or fewer if S ends before this) in S. */
>>>> extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
>>>> -#endif /* Use X/Open. */
>>>> +#endif /* __USE_XOPEN || __USE_MISC. */
>>>
>>> Again, I do not see how that matches what FreeBSD does. Both
>>> definitions are protected by __XSI_VISIBLE there.
>>
>> Should we do this instead?
>>
>> diff --git a/include/features.h b/include/features.h
>> index 123de9fd47..40d10a0fb5 100644
>> --- a/include/features.h
>> +++ b/include/features.h
>> @@ -393,6 +393,7 @@
>>
>> #if defined _DEFAULT_SOURCE
>> # define __USE_MISC 1
>> +# define __USE_XOPEN 1
>> #endif
>>
>> #ifdef _ATFILE_SOURCE
>>
>> Should we also define __USE_XOPEN_EXTENDED and __USE_XOPEN2K8 in this
>> case? This would allow us to simplify a lot of conditionals involving
>> __USE_MISC.
>
>
> What is the define flags used by this old programs? I don't see much trouble
> adding __USE_XOPEN for _DEFAULT_SOURCE.
The program doesn't know anything about feature macros, so it uses
implicit _DEFAULT_SOURCE by default.
Thanks,
Florian
@@ -271,7 +271,7 @@ extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
/* Set N wide characters of S to C. */
extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
-#ifdef __USE_GNU
+#ifdef __USE_MISC
/* Copy N wide characters of SRC to DEST and return pointer to following
wide character. */
extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
@@ -363,14 +363,14 @@ extern size_t wcsnrtombs (char *__restrict __dst,
/* The following functions are extensions found in X/Open CAE. */
-#ifdef __USE_XOPEN
+#if defined __USE_XOPEN || defined __USE_MISC
/* Determine number of column positions required for C. */
extern int wcwidth (wchar_t __c) __THROW;
/* Determine number of column positions required for first N wide
characters (or fewer if S ends before this) in S. */
extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
-#endif /* Use X/Open. */
+#endif /* __USE_XOPEN || __USE_MISC. */
/* Convert initial portion of the wide string NPTR to `double'