Skip to content

Commit

Permalink
Revert _format_string_literal back
Browse files Browse the repository at this point in the history
  • Loading branch information
rihi committed Jul 31, 2024
1 parent f9b4ae5 commit 641f243
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion decompiler/backend/cexpressiongenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,10 @@ def _format_string_literal(constant: expressions.Constant) -> str:
string_representation = str(constant)
if string_representation.startswith('"') and string_representation.endswith('"'):
string_representation = str(constant)[1:-1]
return f"{string_representation.translate(CExpressionGenerator.ESCAPE_TABLE)}"
if '"' in string_representation:
escaped = string_representation.replace('"', '\\"').translate(CExpressionGenerator.ESCAPE_TABLE)
return f'"{escaped}"'
return f"{constant}"

@staticmethod
def format_variables_declaration(var_type: Type, var_names: list[str]) -> str:
Expand Down

0 comments on commit 641f243

Please sign in to comment.