[PATCH 1/2] fix conflicting types (wint_t)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] fix conflicting types (wint_t)

uchan0+newlib
From: uchan-nos <[hidden email]>

---
 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;
 
 #ifdef _MB_CAPABLE
   wi = _jp2uc (wi);
--
2.17.1

Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] fix compile errors for efgcvt.c

uchan0+newlib
From: uchan-nos <[hidden email]>

---
 newlib/libc/stdlib/efgcvt.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/newlib/libc/stdlib/efgcvt.c b/newlib/libc/stdlib/efgcvt.c
index 9314bf361..3cdb9c420 100644
--- a/newlib/libc/stdlib/efgcvt.c
+++ b/newlib/libc/stdlib/efgcvt.c
@@ -102,6 +102,9 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
 #include <stdlib.h>
 #include "local.h"
 
+char * ecvtbuf (double, int, int*, int*, char *);
+char * fcvtbuf (double, int, int*, int*, char *);
+
 char *
 fcvt (double d,
  int ndigit,
@@ -121,6 +124,21 @@ fcvtf (float d,
 }
 
 
+char *
+gcvt (double d,
+ int ndigit,
+ char *buf)
+{
+  char *tbuf = buf;
+  if (d < 0) {
+    *buf = '-';
+    buf++;
+    ndigit--;
+  }
+  return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);
+}
+
+
 char *
 gcvtf (float d,
  int ndigit,
@@ -148,18 +166,3 @@ ecvtf (float d,
 {
   return ecvt ((double) d, ndigit, decpt, sign);
 }
-
-
-char *
-gcvt (double d,
- int ndigit,
- char *buf)
-{
-  char *tbuf = buf;
-  if (d < 0) {
-    *buf = '-';
-    buf++;
-    ndigit--;
-  }
-  return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);
-}
--
2.17.1

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/2] fix conflicting types (wint_t)

Corinna Vinschen
In reply to this post by uchan0+newlib
On Jul 23 21:15, [hidden email] wrote:

> From: uchan-nos <[hidden email]>
>
> ---
>  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

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] fix compile errors for efgcvt.c

Corinna Vinschen
In reply to this post by uchan0+newlib
On Jul 23 21:15, [hidden email] wrote:

> From: uchan-nos <[hidden email]>
>
> ---
>  newlib/libc/stdlib/efgcvt.c | 33 ++++++++++++++++++---------------
>  1 file changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/newlib/libc/stdlib/efgcvt.c b/newlib/libc/stdlib/efgcvt.c
> index 9314bf361..3cdb9c420 100644
> --- a/newlib/libc/stdlib/efgcvt.c
> +++ b/newlib/libc/stdlib/efgcvt.c
> @@ -102,6 +102,9 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
>  #include <stdlib.h>
>  #include "local.h"
>  
> +char * ecvtbuf (double, int, int*, int*, char *);
> +char * fcvtbuf (double, int, int*, int*, char *);
> +
>  char *
>  fcvt (double d,
>   int ndigit,
> @@ -121,6 +124,21 @@ fcvtf (float d,
>  }
>  
>  
> +char *
> +gcvt (double d,
> + int ndigit,
> + char *buf)
> +{
> +  char *tbuf = buf;
> +  if (d < 0) {
> +    *buf = '-';
> +    buf++;
> +    ndigit--;
> +  }
> +  return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);
> +}
> +
> +
>  char *
>  gcvtf (float d,
>   int ndigit,
> @@ -148,18 +166,3 @@ ecvtf (float d,
>  {
>    return ecvt ((double) d, ndigit, decpt, sign);
>  }
> -
> -
> -char *
> -gcvt (double d,
> - int ndigit,
> - char *buf)
> -{
> -  char *tbuf = buf;
> -  if (d < 0) {
> -    *buf = '-';
> -    buf++;
> -    ndigit--;
> -  }
> -  return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);
> -}
> --
> 2.17.1
Why does your patch arbitrarily move the gcvt function?  There's
no functional change, so this move should not be part of the patch.


Corinna

--
Corinna Vinschen
Cygwin Maintainer
Red Hat

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] fix compile errors for efgcvt.c

uchan0+newlib
On Wed, Jul 24, 2019 at 4:25 PM Corinna Vinschen <[hidden email]> wrote:
> Why does your patch arbitrarily move the gcvt function?  There's
> no functional change, so this move should not be part of the patch.

The movement is the core of this patch.

When efgcvt.c is compiled under some specific conditions,
gcvt's function prototype is NOT provided by stdlib.h.
(Its prototype is gurded by macros)

If gcvt is below gcvtf, gcvt is implicitly declared as int
since gcvtf calls gcvt.
The implicit declaration is not compatible with its actual type.

So the possible options will be:
- To move gcvt above gcvtf, or
- To declare gcvt's prototype above gcvtf.

Should I choose 2nd option?
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] fix compile errors for efgcvt.c

Corinna Vinschen
On Jul 24 17:43, Kota Uchida wrote:

> On Wed, Jul 24, 2019 at 4:25 PM Corinna Vinschen <[hidden email]> wrote:
> > Why does your patch arbitrarily move the gcvt function?  There's
> > no functional change, so this move should not be part of the patch.
>
> The movement is the core of this patch.
>
> When efgcvt.c is compiled under some specific conditions,
> gcvt's function prototype is NOT provided by stdlib.h.
> (Its prototype is gurded by macros)
>
> If gcvt is below gcvtf, gcvt is implicitly declared as int
> since gcvtf calls gcvt.
> The implicit declaration is not compatible with its actual type.
>
> So the possible options will be:
> - To move gcvt above gcvtf, or
> - To declare gcvt's prototype above gcvtf.
>
> Should I choose 2nd option?
No, I pushed the patch.


Thanks,
Corinna

--
Corinna Vinschen
Cygwin Maintainer
Red Hat

signature.asc (849 bytes) Download Attachment