This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Locale Build Failure #2


On Aug 16 12:43, Joel Sherrill wrote:
> On 8/16/2016 12:35 PM, Craig Howland wrote:
> > Yes, char *foo() == char *foo(), but const char *__locale_ctype_ptr(void) !=
> > char *__locale_ctype_ptr(void), which can happen if _MB_CAPABLE is not defined.
> > Could this perhaps be it?
> 
> ctype.h has an ifdef for _MB_CAPABLE missing in locale.c. I am trying
> this now. What do you all think?
> 
> diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
> index 795e163..4de4cce 100644
> --- a/newlib/libc/locale/locale.c
> +++ b/newlib/libc/locale/locale.c
> @@ -992,6 +992,9 @@ _DEFUN_VOID (__locale_ctype_ptr)
>                                  : __ctype_ptr__;
>  }
> +#ifndef _MB_CAPABLE
> +_CONST
> +#endif
>  char *
>  __locale_ctype_ptr_l (struct __locale_t *locale)
>  {

Wrong function, __locale_ctype_ptr_l vs. __locale_ctype_ptr.  But, on
second thought, maybe both functions should always return const char *.
After all we don't want values to be changed via the pointers returned
by these functions.

So what about the following patch instead of the other one?  I checked
that it builds cleanly on Cygwin.

diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h
index d34b8e5..31577d1 100644
--- a/newlib/libc/include/ctype.h
+++ b/newlib/libc/include/ctype.h
@@ -66,10 +66,7 @@ extern int toascii_l (int __c, locale_t __l);
 #define _X	0100
 #define	_B	0200
 
-#ifndef _MB_CAPABLE
-_CONST
-#endif
-char *__locale_ctype_ptr (void);
+const char *__locale_ctype_ptr (void);
 # define __CTYPE_PTR	(__locale_ctype_ptr ())
 
 #ifndef __cplusplus
@@ -103,7 +100,7 @@ char *__locale_ctype_ptr (void);
 #endif
 
 #if __POSIX_VISIBLE >= 200809
-char *__locale_ctype_ptr_l (locale_t);
+const char *__locale_ctype_ptr_l (locale_t);
 #define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)])
 
 #define	isalpha_l(__c,__l)	(__ctype_lookup_l(__c,__l)&(_U|_L))
diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
index 795e163..18c7be0 100644
--- a/newlib/libc/locale/locale.c
+++ b/newlib/libc/locale/locale.c
@@ -982,7 +982,7 @@ _DEFUN_VOID (__locale_mb_cur_max)
 #endif
 }
 
-char *
+const char *
 _DEFUN_VOID (__locale_ctype_ptr)
 {
   /* Only check if the current thread/reent has a locale.  ctype_ptr is unused
@@ -992,7 +992,7 @@ _DEFUN_VOID (__locale_ctype_ptr)
 				 : __ctype_ptr__;
 }
 
-char *
+const char *
 __locale_ctype_ptr_l (struct __locale_t *locale)
 {
   extern char *__ctype_ptr__;


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]