fixed a bug where too many hex digits were read for \x

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401057
This commit is contained in:
David Anderson 2007-07-07 18:46:40 +00:00
parent 904aceb435
commit 998c9dc574

View File

@ -2329,18 +2329,22 @@ static cell litchar(const unsigned char **lptr,int flags)
cptr+=1;
break;
case 'x':
{
int digits = 0;
cptr+=1;
c=0;
while (ishex(*cptr)) {
while (ishex(*cptr) && digits < 2) {
if (isdigit(*cptr))
c=(c<<4)+(*cptr-'0');
else
c=(c<<4)+(tolower(*cptr)-'a'+10);
cptr++;
digits++;
} /* while */
if (*cptr==';')
cptr++; /* swallow a trailing ';' */
break;
}
case '\'': /* \' == ' (single quote) */
case '"': /* \" == " (single quote) */
case '%': /* \% == % (percent) */