[1/2] fix conflicting types (wint_t)

Message ID 20190723121548.20384-1-uchan0+newlib@gmail.com
State New
Headers show
Series
  • [1/2] fix conflicting types (wint_t)
Related show

Commit Message

Kota Uchida July 23, 2019, 12:15 p.m.
From: uchan-nos <uchan0@gmail.com>


---
 newlib/libc/string/wcwidth.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

-- 
2.17.1

Comments

Corinna Vinschen July 24, 2019, 7:22 a.m. | #1
On Jul 23 21:15, uchan0+newlib@gmail.com wrote:
> From: uchan-nos <uchan0@gmail.com>

> 

> ---

>  newlib/libc/string/wcwidth.c | 10 ++++++++--

>  1 file changed, 8 insertions(+), 2 deletions(-)

> 

> diff --git a/newlib/libc/string/wcwidth.c b/newlib/libc/string/wcwidth.c

> index 62e76edc3..a4b520bbe 100644

> --- a/newlib/libc/string/wcwidth.c

> +++ b/newlib/libc/string/wcwidth.c

> @@ -225,10 +225,16 @@ __wcwidth (const wint_t ucs)

>  #endif /* _MB_CAPABLE */

>  }

>  

> +#ifdef __CYGWIN__

> +#define WCHAR_TYPE wint_t

> +#else

> +#define WCHAR_TYPE wchar_t

> +#endif

> +

>  int

> -wcwidth (const wint_t wc)

> +wcwidth (const WCHAR_TYPE wc)

>  {

> -  wint_t wi = wc;

> +  WCHAR_TYPE wi = wc;


This is incorrect.  _jp2uc() as well as __wcwidth always take a wint_t
argument.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

Patch

diff --git a/newlib/libc/string/wcwidth.c b/newlib/libc/string/wcwidth.c
index 62e76edc3..a4b520bbe 100644
--- a/newlib/libc/string/wcwidth.c
+++ b/newlib/libc/string/wcwidth.c
@@ -225,10 +225,16 @@  __wcwidth (const wint_t ucs)
 #endif /* _MB_CAPABLE */
 }
 
+#ifdef __CYGWIN__
+#define WCHAR_TYPE wint_t
+#else
+#define WCHAR_TYPE wchar_t
+#endif
+
 int
-wcwidth (const wint_t wc)
+wcwidth (const WCHAR_TYPE wc)
 {
-  wint_t wi = wc;
+  WCHAR_TYPE wi = wc;
 
 #ifdef _MB_CAPABLE
   wi = _jp2uc (wi);