char signed-ness bug in nl-web.c

Q&A's, tips, howto's
Locked
Cyril
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia
Contact:

char signed-ness bug in nl-web.c

Post by Cyril »

newLISP (10.1.5 and 10.1.6 checked) failed to parse an HTTP answer if it contains 8-bit characters in headers. Well, according to RFC, there should be no 8-bit character in headers, but in real live there are. In particular, I cannot avoid them in my application (the server returning them is not under my control). Anyway, dependence of char signed-ness of C implementation is usually considered a bad style. In file nl-web.c:

Code: Select all

/* socket send and receive routines with timeout */
int recvc_tm(int sock)
{
struct timeval tm;
char chr;

  // skipped

return(chr);
}
When 8-bit characters (I mean "which high bit set") are received from the socket, function returns a negative integer, which is treated as end-of-file later, leading to obscure error message. Replacing char chr; with unsigned char chr; has fixed the problem for me (I have compiled newLISP with MinGW under WinXP). I hope this (or similar) patch can be included in the next release. Thanks in advance!
With newLISP you can grow your lists from the right side!

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: char signed-ness bug in nl-web.c

Post by Lutz »

Will be changed to 'unsigned char' for the next version.

Locked