fixed a bug where too many hex digits were read for \x
authorDavid Anderson <dvander@alliedmods.net>
Sat Jul 07 18:46:40 2007 +0000 (2007-07-07)
changeset 1051978fad727f69
parent 1050 cdae545c8c92
child 1052 a2de25952811
fixed a bug where too many hex digits were read for \x
sourcepawn/compiler/sc2.c
     1.1 --- a/sourcepawn/compiler/sc2.c	Sat Jul 07 18:24:02 2007 +0000
     1.2 +++ b/sourcepawn/compiler/sc2.c	Sat Jul 07 18:46:40 2007 +0000
     1.3 @@ -2329,18 +2329,22 @@
     1.4          cptr+=1;
     1.5          break;
     1.6        case 'x':
     1.7 +      {
     1.8 +        int digits = 0;
     1.9          cptr+=1;
    1.10          c=0;
    1.11 -        while (ishex(*cptr)) {
    1.12 +        while (ishex(*cptr) && digits < 2) {
    1.13            if (isdigit(*cptr))
    1.14              c=(c<<4)+(*cptr-'0');
    1.15            else
    1.16              c=(c<<4)+(tolower(*cptr)-'a'+10);
    1.17            cptr++;
    1.18 +          digits++;
    1.19          } /* while */
    1.20          if (*cptr==';')
    1.21            cptr++;       /* swallow a trailing ';' */
    1.22          break;
    1.23 +      }
    1.24        case '\'':        /* \' == ' (single quote) */
    1.25        case '"':         /* \" == " (single quote) */
    1.26        case '%':         /* \% == % (percent) */