public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] <wchar.h>: Make wmempcy, wcwidth, wcswidth available by default
@ 2022-12-06  9:31 Florian Weimer
  2022-12-06  9:42 ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2022-12-06  9:31 UTC (permalink / raw)
  To: libc-alpha

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(-)

diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index c1321c7518..203ef9ac1d 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -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'

base-commit: 8fb923ddc38dd5f4bfac4869d70fd80483fdb87a


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] <wchar.h>: Make wmempcy, wcwidth, wcswidth available by default
  2022-12-06  9:31 [PATCH] <wchar.h>: Make wmempcy, wcwidth, wcswidth available by default Florian Weimer
@ 2022-12-06  9:42 ` Andreas Schwab
  2022-12-06 10:25   ` Florian Weimer
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2022-12-06  9:42 UTC (permalink / raw)
  To: Florian Weimer via Libc-alpha; +Cc: Florian Weimer

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, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] <wchar.h>: Make wmempcy, wcwidth, wcswidth available by default
  2022-12-06  9:42 ` Andreas Schwab
@ 2022-12-06 10:25   ` Florian Weimer
  2022-12-08 17:21     ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2022-12-06 10:25 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Florian Weimer via Libc-alpha

* 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] <wchar.h>: Make wmempcy, wcwidth, wcswidth available by default
  2022-12-06 10:25   ` Florian Weimer
@ 2022-12-08 17:21     ` Adhemerval Zanella Netto
  2022-12-08 18:14       ` Florian Weimer
  0 siblings, 1 reply; 5+ messages in thread
From: Adhemerval Zanella Netto @ 2022-12-08 17:21 UTC (permalink / raw)
  To: Florian Weimer, Andreas Schwab; +Cc: Florian Weimer via Libc-alpha



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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] <wchar.h>: Make wmempcy, wcwidth, wcswidth available by default
  2022-12-08 17:21     ` Adhemerval Zanella Netto
@ 2022-12-08 18:14       ` Florian Weimer
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Weimer @ 2022-12-08 18:14 UTC (permalink / raw)
  To: Adhemerval Zanella Netto; +Cc: Andreas Schwab, Florian Weimer via Libc-alpha

* 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-08 18:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06  9:31 [PATCH] <wchar.h>: Make wmempcy, wcwidth, wcswidth available by default Florian Weimer
2022-12-06  9:42 ` Andreas Schwab
2022-12-06 10:25   ` Florian Weimer
2022-12-08 17:21     ` Adhemerval Zanella Netto
2022-12-08 18:14       ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).