lynx-dev
[Top][All Lists]
Advanced

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

LYNX-DEV 2.8pre.2: patch for longstanding bug with TOLOWER/TOUPPER


From: Андрей Чернов
Subject: LYNX-DEV 2.8pre.2: patch for longstanding bug with TOLOWER/TOUPPER
Date: Mon, 2 Mar 1998 16:25:30 +0300

Missing final (unsigned char) cast cause mismatch due to sign extension.
F.e. Lynx can't do case insensitive searches for KOI8-R.

One example (old variant):
        UPPER8(a, b) fails because
        TOUPPER(-1) != TOUPPER(0277)
assuming here '\277' is lower which becomes 0377 after toupper, i.e.
        -1 != 0377
but
        (unsigned char)-1 == (unsigned char)0377
in new variant (see patch below).

it happens when 
        char c = '\377';
then c == -1 in any expression but NOT 0377.


*** WWW/Library/Implementation/HTUtils.h.bak    Fri Feb 27 21:25:07 1998
--- WWW/Library/Implementation/HTUtils.h        Mon Mar  2 16:09:39 1998
***************
*** 424,431 ****
  
  #ifndef TOLOWER
    /* Pyramid and Mips can't uppercase non-alpha */
! #define TOLOWER(c) (isupper((unsigned char)c) ? tolower((unsigned char)c) : 
(c))
! #define TOUPPER(c) (islower((unsigned char)c) ? toupper((unsigned char)c) : 
(c))
  #endif /* TOLOWER */
  
  /*
--- 424,431 ----
  
  #ifndef TOLOWER
    /* Pyramid and Mips can't uppercase non-alpha */
! #define TOLOWER(c) (isupper((unsigned char)c) ? tolower((unsigned char)c) : 
((unsigned char)c))
! #define TOUPPER(c) (islower((unsigned char)c) ? toupper((unsigned char)c) : 
((unsigned char)c))
  #endif /* TOLOWER */
  
  /*

-- 
Andrey A. Chernov
<address@hidden>
http://www.nagual.pp.ru/~ache/

reply via email to

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