Skip to content

Commit

Permalink
Incorrect handling of $ in an objC string
Browse files Browse the repository at this point in the history
From an objC file we got the error:
```
ASSERT: "0" in .../src/code.l (3878)
```
due to the incorrect handling of the `$` in a string in the code like:
```
  _unicode_map['$'] = 36;
```
  • Loading branch information
albert-github committed Mar 12, 2024
1 parent c55f070 commit 1ea0bc8
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/code.l
Original file line number Diff line number Diff line change
Expand Up @@ -3668,9 +3668,28 @@ static void writeObjCMethodCall(yyscan_t yyscanner,ObjCCallCtx *ctx)
if (!ctx->format.isEmpty())
{
const char *p = ctx->format.data();
bool skip = false;
char skipChar = ' ';
while ((c=*p++)) // for each character in ctx->format
{
if (c=='$')
if (skip)
{
char s[2];
s[0]=c;s[1]=0;
codifyLines(yyscanner,s);
if (c==skipChar)
{
skip = false;
skipChar = ' ';
}
else if (c=='\\')
{
c = *p++;
s[0]=c;
codifyLines(yyscanner,s);
}
}
else if (c=='$')
{
char nc=*p++;
if (nc=='$') // escaped $
Expand Down Expand Up @@ -3878,6 +3897,14 @@ static void writeObjCMethodCall(yyscan_t yyscanner,ObjCCallCtx *ctx)
}
}
}
else if (c=='\'' || c == '"')
{
char s[2];
s[0]=c;s[1]=0;
codifyLines(yyscanner,s);
skip = true;
skipChar = c;
}
else // normal non-marker character
{
char s[2];
Expand Down

0 comments on commit 1ea0bc8

Please sign in to comment.