chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] string-ref problem


From: Felix Winkelmann
Subject: Re: [Chicken-users] string-ref problem
Date: Mon, 13 Jan 2003 10:20:17 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530

Joerg F. Wittenberger wrote:
felix <address@hidden> writes:


Joerg F. Wittenberger wrote:

#define C_character_code(x)       (((x) >> 8) & 0xffff)
is there any reason not to change back?

This was, in fact, a preparatory "fix" for allowing 16-bit characters.
But it turned out to break "C_subchar()" which extracts a char from
a string and treated it as signed.

I fixed the latter, so the current CVS version should work, now.


Not sure about that.  I have:

(string-for-each
 (lambda (c) (display (vector-ref mapping (char->integer c)) port))
 obj)

where mapping is a vector:
 (define html-encoding (make-vector 256 "[unknown]"))

and I see:

Sat, 11 Jan 2003 23:34:21 +0100 HTTP EXCEPTION exception out of range (#("" "" "" "" "" "" "" "" 
" "    " "
" "
   " "
" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" " " "!" "&quot;" "#" "$" "%" "&amp;" "'" "(" ")" "*" "+" "," "-" "." "/" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" ":" ";" "&lt;" "=" "&gt;" "?" "@" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "[" "\\" "]" "^" "_" "`" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "{" "|" "}" "~" "" "EUR" "?" "," "f" """ "..." "+" "++" "^" "0/00" "S(" "<" "OE" "?" "Z(" "?" "?" "'" "'" """ """ "." "-" "--" "~" "^(TM)" "s(" ">" "oe" "?" "z(" "Y"" "&nbsp;" "¡" "¢" "£" "¤" "¥" "¦" "§" "¨" "©" "ª" "«" "¬" "­" "®" "¯" "°" "±" "²" ""³" "´" "µ" "¶" "·" "¸" "¹" "º" "»" "¼" "½" "¾" "¿" "À" "Á" "Â" "Ã" "Ä" "Å" "Æ" "Ç" "È" "É" "Ê" "Ë" "Ì" "Í" "Î" "Ï" "Ð" "Ñ" "Ò" "Ó" "Ô" "Õ" "Ö" "×" "Ø" "Ù" "Ú" "Û" "Ü" "Ý" "Þ" "ß" "à" "á" "â" "ã" "ä" "å" "æ" "ç" "è" "é" "ê" "ë" "ì" "í" "î" "ï" "ð" "ñ" "ò" "ó" "ô" "õ" "ö" "÷" "ø" "ù" "ú" "û" "ü" "ý" "þ" "ÿ") 65526)

I'm pretty sure the char->integer result should be != 65526.

But I understand that it might be a chicken-and-egg problem, where the
compiler compiled itself.  Either something went wrong, I compiled the
wrong code (unlikely, but you never know), or there is one more thing
to fix.


string-ref should always return a character in the range 0-255.
The problem was in C_subchar(), which is a macro that extracts a
character from a string, which (wrongly) returned a signed integer.
With the extended range of possible character code that characters
now accept, it sign-extended the code. I have changed it to
convert the code to unsigned first. Since this is a C macro, it
is *crucial* to recompile everything that does string-ref, since -O2
(or -usual-integrations) will replace calls to string-ref with
the macro.

If the problem persists, change the definitions of C_make_character
and C_character code to the 8-bit (0xff) versions, to get a working
system, and I will investigate further.


cheers,
felix





reply via email to

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