mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-23 05:00:12 +00:00
Preproc: output string literals, and fix escape bug
This commit is contained in:
parent
c9521067f0
commit
1cdba39aa0
@ -220,7 +220,10 @@ void CFile::TryConvertString()
|
|||||||
|
|
||||||
SkipWhitespace();
|
SkipWhitespace();
|
||||||
|
|
||||||
std::printf("{ ");
|
if (noTerminator)
|
||||||
|
std::printf("{ ");
|
||||||
|
else
|
||||||
|
std::printf("(");
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -241,8 +244,16 @@ void CFile::TryConvertString()
|
|||||||
RaiseError(e.what());
|
RaiseError(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < length; i++)
|
if (!noTerminator)
|
||||||
printf("0x%02X, ", s[i]);
|
printf("\"");
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
if (noTerminator)
|
||||||
|
printf("0x%02X, ", s[i]);
|
||||||
|
else
|
||||||
|
printf(' ' <= s[i] && s[i] <= '~' && s[i] != '\\' && s[i] != '\"' ? "%c" : "\\%03o", s[i]);
|
||||||
|
}
|
||||||
|
if (!noTerminator)
|
||||||
|
printf("\"");
|
||||||
}
|
}
|
||||||
else if (m_buffer[m_pos] == ')')
|
else if (m_buffer[m_pos] == ')')
|
||||||
{
|
{
|
||||||
@ -263,7 +274,7 @@ void CFile::TryConvertString()
|
|||||||
if (noTerminator)
|
if (noTerminator)
|
||||||
std::printf(" }");
|
std::printf(" }");
|
||||||
else
|
else
|
||||||
std::printf("0x00 }");
|
std::printf(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFile::CheckIdentifier(const std::string& ident)
|
bool CFile::CheckIdentifier(const std::string& ident)
|
||||||
|
@ -44,6 +44,7 @@ std::string StringParser::ReadCharOrEscape()
|
|||||||
if (sequence.length() == 0)
|
if (sequence.length() == 0)
|
||||||
RaiseError("no mapping exists for double quote");
|
RaiseError("no mapping exists for double quote");
|
||||||
|
|
||||||
|
m_pos++;
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
else if (m_buffer[m_pos] == '\\')
|
else if (m_buffer[m_pos] == '\\')
|
||||||
@ -53,6 +54,7 @@ std::string StringParser::ReadCharOrEscape()
|
|||||||
if (sequence.length() == 0)
|
if (sequence.length() == 0)
|
||||||
RaiseError("no mapping exists for backslash");
|
RaiseError("no mapping exists for backslash");
|
||||||
|
|
||||||
|
m_pos++;
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user