Re: Cast "const char *" pointers to "char *" to avoid compiler warnings.

Christophe Lyon <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CAKdteOYNA9xY1HgpXVm+s=_qhb+dZ1WG55cVUrxDv_ns3kkibw@mail.gmail.com>
On Thu, 11 Oct 2018 at 09:11, Corinna Vinschen <[email protected]> wrote:
>
> On Oct 10 22:37, Christophe Lyon wrote:
> > On Wed, 10 Oct 2018 at 17:02, Corinna Vinschen <[email protected]> wrote:
> > >
> > > On Oct 10 16:37, Christophe Lyon wrote:
> > > > And I think my patch (or something similar) is still needed for jp2uc.c ?
> > >
> > > I only had a look into the __loadlocal issue due to this discussion.
> > > For everything else, please send a new patch.
> > >
> >
> > OK, here is the patch for jp2uc.c:
>
> Can you please send it in `git format-patch' format?  The patch
> doesn't apply as is.  There's also no requirement anymore to add
> CVS-like commit messages.
>

Is this new version OK?

>
> Thanks,
> Corinna
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat
0001-newlib-libc-ctype-jp2uc.c-Declare-cs-variable-as-con.patch (text/x-patch, 1.3 KB)
From dfb509574e1cbbdf4fe9d4d3e8319bd3ffdca98c Mon Sep 17 00:00:00 2001
From: Christophe Lyon <[email protected]>
Date: Fri, 5 Oct 2018 09:11:05 +0000
Subject: [PATCH] newlib/libc/ctype/jp2uc.c: Declare "cs" variable as "const
 char *"

Instead of "char *" to avoid compiler warnings.
This is OK because "cs" is only used as input of strcmp.
---
 newlib/libc/ctype/jp2uc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/ctype/jp2uc.c b/newlib/libc/ctype/jp2uc.c
index b89b5ea..5e30f09 100644
--- a/newlib/libc/ctype/jp2uc.c
+++ b/newlib/libc/ctype/jp2uc.c
@@ -166,7 +166,7 @@ __uc2jp (wint_t c, int type)
 wint_t
 _jp2uc_l (wint_t c, struct __locale_t * l)
 {
-  char * cs = l ? __locale_charset(l) : __current_locale_charset();
+  const char * cs = l ? __locale_charset(l) : __current_locale_charset();
   if (0 == strcmp (cs, "JIS"))
     c = __jp2uc (c, JP_JIS);
   else if (0 == strcmp (cs, "SJIS"))
@@ -186,7 +186,7 @@ _jp2uc (wint_t c)
 wint_t
 _uc2jp_l (wint_t c, struct __locale_t * l)
 {
-  char * cs = l ? __locale_charset(l) : __current_locale_charset();
+  const char * cs = l ? __locale_charset(l) : __current_locale_charset();
   if (0 == strcmp (cs, "JIS"))
     c = __uc2jp (c, JP_JIS);
   else if (0 == strcmp (cs, "SJIS"))
-- 
2.7.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.