Fix compile error with string literals in ternary operator
The ':' symbol was not recognized as a separator in stringize mode so you always got a weird compile error with a code like this: (condition) ? "yes : "no" error 001: expected token: "-string end-", but found "-identifier-" See 2) here: http://forum.sa-mp.com/showthread.php?t=355877 Test code: native print(const s[]); main() { new a = 5; print((a == 5) ? "is five" : !"is not five"); print((a != 5) ? !"is not five" : "is five"); }
This commit is contained in:
parent
4831cb76a3
commit
0c8f23453e
@ -1432,7 +1432,7 @@ static const unsigned char *skippgroup(const unsigned char *string)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
close='\0'; /* only to avoid a compiler warning */
|
close='\0'; /* only to avoid a compiler warning */
|
||||||
}/* switch */
|
}/* switch */
|
||||||
|
|
||||||
string++;
|
string++;
|
||||||
@ -1745,7 +1745,8 @@ static const unsigned char *unpackedstring(const unsigned char *lptr,int *flags)
|
|||||||
lptr--;
|
lptr--;
|
||||||
instring=1;
|
instring=1;
|
||||||
*flags |= STRINGIZE;
|
*flags |= STRINGIZE;
|
||||||
} else if (*lptr==')' || *lptr==',' || *lptr=='}' || *lptr==';' || *lptr=='\r' || *lptr=='\n') {
|
} else if (*lptr==')' || *lptr==',' || *lptr=='}' || *lptr==';' |
|
||||||
|
*lptr==':' || *lptr=='\r' || *lptr=='\n') {
|
||||||
break;
|
break;
|
||||||
} else if (*lptr!=' ' && *lptr!='\t') {
|
} else if (*lptr!=' ' && *lptr!='\t') {
|
||||||
error(1,"-string end-","-identifier-");
|
error(1,"-string end-","-identifier-");
|
||||||
@ -1767,7 +1768,8 @@ static const unsigned char *unpackedstring(const unsigned char *lptr,int *flags)
|
|||||||
lptr=stringize+1;
|
lptr=stringize+1;
|
||||||
*flags &= ~STRINGIZE;
|
*flags &= ~STRINGIZE;
|
||||||
continue;
|
continue;
|
||||||
} else if (*stringize==',' || *stringize==')' || *stringize=='}' || *stringize==';') { /* end */
|
} else if (*stringize==',' || *stringize==')' || *stringize=='}' ||
|
||||||
|
*stringize==';' || *stringize==':') { /* end */
|
||||||
lptr=stringize;
|
lptr=stringize;
|
||||||
break;
|
break;
|
||||||
} else if (*stringize=='\0') {
|
} else if (*stringize=='\0') {
|
||||||
@ -1785,8 +1787,9 @@ static const unsigned char *unpackedstring(const unsigned char *lptr,int *flags)
|
|||||||
litadd(litchar(&lptr,*flags | UTF8MODE)); /* litchar() alters "lptr" */
|
litadd(litchar(&lptr,*flags | UTF8MODE)); /* litchar() alters "lptr" */
|
||||||
} /* while */
|
} /* while */
|
||||||
litadd(0);
|
litadd(0);
|
||||||
|
|
||||||
if (*lptr==',' || *lptr==')' || *lptr=='}' || *lptr==';' || *lptr=='\n' || *lptr=='\r')
|
if (*lptr==',' || *lptr==')' || *lptr=='}' || *lptr==';' ||
|
||||||
|
*lptr==':' || *lptr=='\n' || *lptr=='\r')
|
||||||
lptr=stringize; /* backtrack to end of last string for closing " */
|
lptr=stringize; /* backtrack to end of last string for closing " */
|
||||||
return lptr;
|
return lptr;
|
||||||
}
|
}
|
||||||
@ -1797,7 +1800,7 @@ static const unsigned char *packedstring(const unsigned char *lptr,int *flags)
|
|||||||
ucell val,c;
|
ucell val,c;
|
||||||
unsigned char *stringize;
|
unsigned char *stringize;
|
||||||
int instring=1;
|
int instring=1;
|
||||||
if (*flags & STRINGIZE)
|
if (*flags & STRINGIZE)
|
||||||
while (*lptr==' ' || *lptr=='\t')
|
while (*lptr==' ' || *lptr=='\t')
|
||||||
lptr++;
|
lptr++;
|
||||||
|
|
||||||
@ -1816,7 +1819,8 @@ static const unsigned char *packedstring(const unsigned char *lptr,int *flags)
|
|||||||
lptr--;
|
lptr--;
|
||||||
instring=1;
|
instring=1;
|
||||||
*flags |= STRINGIZE;
|
*flags |= STRINGIZE;
|
||||||
} else if (*lptr==')' || *lptr==',' || *lptr=='}' || *lptr==';' || *lptr=='\r' || *lptr=='\n') {
|
} else if (*lptr==')' || *lptr==',' || *lptr=='}' || *lptr==';' ||
|
||||||
|
*lptr==':' || *lptr=='\r' || *lptr=='\n') {
|
||||||
break;
|
break;
|
||||||
} else if (*lptr!=' ' && *lptr!='\t') {
|
} else if (*lptr!=' ' && *lptr!='\t') {
|
||||||
error(1,"-string end-","-identifier-");
|
error(1,"-string end-","-identifier-");
|
||||||
@ -1838,7 +1842,8 @@ static const unsigned char *packedstring(const unsigned char *lptr,int *flags)
|
|||||||
lptr=stringize+1;
|
lptr=stringize+1;
|
||||||
*flags &= ~STRINGIZE;
|
*flags &= ~STRINGIZE;
|
||||||
continue;
|
continue;
|
||||||
} else if (*stringize==',' || *stringize==')' || *stringize=='}' || *stringize==';') { /* end */
|
} else if (*stringize==',' || *stringize==')' || *stringize=='}' |
|
||||||
|
*stringize==';' || *stringize==':') { /* end */
|
||||||
lptr=stringize;
|
lptr=stringize;
|
||||||
break;
|
break;
|
||||||
} else if (*stringize=='\0') {
|
} else if (*stringize=='\0') {
|
||||||
@ -1869,7 +1874,8 @@ static const unsigned char *packedstring(const unsigned char *lptr,int *flags)
|
|||||||
else
|
else
|
||||||
litadd(0); /* add full cell of zeros */
|
litadd(0); /* add full cell of zeros */
|
||||||
|
|
||||||
if (*lptr==',' || *lptr==')' || *lptr=='}' || *lptr==';' || *lptr=='\n' || *lptr=='\r')
|
if (*lptr==',' || *lptr==')' || *lptr=='}' || *lptr==';' ||
|
||||||
|
*lptr==':' || *lptr=='\n' || *lptr=='\r')
|
||||||
lptr=stringize; /* backtrack to end of last string for closing " */
|
lptr=stringize; /* backtrack to end of last string for closing " */
|
||||||
return lptr;
|
return lptr;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user