emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-bug-tracker] bug#7203: closed ([PATCH] sort: fix unportable conve


From: GNU bug Tracking System
Subject: [Emacs-bug-tracker] bug#7203: closed ([PATCH] sort: fix unportable conversion of unsigned char * -> char *)
Date: Tue, 19 Apr 2011 07:09:02 +0000

Your message dated Tue, 19 Apr 2011 09:08:28 +0200
with message-id <address@hidden>
and subject line Re: bug#7203: [PATCH] sort: fix unportable conversion of 
unsigned char * -> char *
has caused the GNU bug report #7203,
regarding [PATCH] sort: fix unportable conversion of unsigned char * -> char *
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
7203: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7203
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Date: Tue, 12 Oct 2010 13:00:03 -0700 User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8
This is another portability bug caught by the Sun C compiler.
Without this patch, cc complains:

"sort.c", line 3933: warning: assignment type mismatch:
        pointer to const char "=" pointer to unsigned char


* src/sort.c (fold_toupper): Change this back from char to
unsigned char, fixing a regression introduced in commit
59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the
C Standard doesn't let you convert from unsigned char * to char *
without a cast, and the (in theory more portable) style here is to
convert char values, not pointer values.
(getmonth): Convert char to unsigned char when needed for
comparison.
---
 src/sort.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index 89f7be3..c155eda 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -268,7 +268,7 @@ static bool nonprinting[UCHAR_LIM];
 static bool nondictionary[UCHAR_LIM];
 
 /* Translation table folding lower case to upper.  */
-static unsigned char fold_toupper[UCHAR_LIM];
+static char fold_toupper[UCHAR_LIM];
 
 #define MONTHS_PER_YEAR 12
 
@@ -1952,12 +1952,12 @@ getmonth (char const *month, char **ea)
                 *ea = (char *) m;
               return monthtab[ix].val;
             }
-          if (fold_toupper[to_uchar (*m)] < to_uchar (*n))
+          if (to_uchar (fold_toupper[to_uchar (*m)]) < to_uchar (*n))
             {
               hi = ix;
               break;
             }
-          else if (fold_toupper[to_uchar (*m)] > to_uchar (*n))
+          else if (to_uchar (fold_toupper[to_uchar (*m)]) > to_uchar (*n))
             {
               lo = ix + 1;
               break;
-- 
1.7.2




--- End Message ---
--- Begin Message --- Subject: Re: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Date: Tue, 19 Apr 2011 09:08:28 +0200
Paul Eggert wrote:
> This is another portability bug caught by the Sun C compiler.
> Without this patch, cc complains:
>
> "sort.c", line 3933: warning: assignment type mismatch:
>         pointer to const char "=" pointer to unsigned char
>
>
> * src/sort.c (fold_toupper): Change this back from char to
> unsigned char, fixing a regression introduced in commit
> 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the
> C Standard doesn't let you convert from unsigned char * to char *
> without a cast, and the (in theory more portable) style here is to
> convert char values, not pointer values.
> (getmonth): Convert char to unsigned char when needed for
> comparison.

Thanks again.
The patch went in months ago, so I'm closing this.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]