Skip to content

Commit 90f77f8

Browse files
authored
Merge pull request #11663 from ethereum/more-fixes-for-deprecated-escapes
Remove deprecated escapes from docs + rename `escapeAndQuoteYulString()`
2 parents 41e06ea + 6753c8f commit 90f77f8

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

docs/types/value-types.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,17 +514,21 @@ Additionally, string literals also support the following escape characters:
514514
- ``\\`` (backslash)
515515
- ``\'`` (single quote)
516516
- ``\"`` (double quote)
517-
- ``\b`` (backspace)
518-
- ``\f`` (form feed)
519517
- ``\n`` (newline)
520518
- ``\r`` (carriage return)
521519
- ``\t`` (tab)
522-
- ``\v`` (vertical tab)
523520
- ``\xNN`` (hex escape, see below)
524521
- ``\uNNNN`` (unicode escape, see below)
525522

526523
``\xNN`` takes a hex value and inserts the appropriate byte, while ``\uNNNN`` takes a Unicode codepoint and inserts an UTF-8 sequence.
527524

525+
.. note::
526+
527+
Until version 0.8.0 there were three additional escape sequences: ``\b``, ``\f`` and ``\v``.
528+
They are commonly available in other languages but rarely needed in practice.
529+
If you do need them, they can still be inserted via hexadecimal escapes, i.e. ``\x08``, ``\x0c``
530+
and ``\x0b``, respectively, just as any other ASCII character.
531+
528532
The string in the following example has a length of ten bytes.
529533
It starts with a newline byte, followed by a double quote, a single
530534
quote a backslash character and then (without separator) the

libevmasm/Assembly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Functionalizer
153153
return;
154154
m_out << m_prefix << " /*";
155155
if (m_location.sourceName)
156-
m_out << " " + escapeAndQuoteYulString(*m_location.sourceName);
156+
m_out << " " + escapeAndQuoteString(*m_location.sourceName);
157157
if (m_location.hasText())
158158
m_out << ":" << to_string(m_location.start) + ":" + to_string(m_location.end);
159159
m_out << " " << locationFromSources(m_sourceCodes, m_location);

libsolidity/codegen/ir/IRGeneratorForStatements.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3166,5 +3166,5 @@ bool IRGeneratorForStatements::visit(TryCatchClause const& _clause)
31663166
string IRGeneratorForStatements::linkerSymbol(ContractDefinition const& _library) const
31673167
{
31683168
solAssert(_library.isLibrary(), "");
3169-
return "linkersymbol(" + util::escapeAndQuoteYulString(_library.fullyQualifiedName()) + ")";
3169+
return "linkersymbol(" + util::escapeAndQuoteString(_library.fullyQualifiedName()) + ")";
31703170
}

libsolutil/CommonData.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,11 @@ string solidity::util::formatAsStringOrNumber(string const& _value)
192192
if (c <= 0x1f || c >= 0x7f || c == '"')
193193
return "0x" + h256(_value, h256::AlignLeft).hex();
194194

195-
// The difference in escaping is only in characters below 0x1f and the string does not have them
196-
// so this will work for Solidity strings too.
197-
return escapeAndQuoteYulString(_value);
195+
return escapeAndQuoteString(_value);
198196
}
199197

200198

201-
string solidity::util::escapeAndQuoteYulString(string const& _input)
199+
string solidity::util::escapeAndQuoteString(string const& _input)
202200
{
203201
string out;
204202

libsolutil/CommonData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,9 @@ bool isValidDecimal(std::string const& _string);
552552
/// _value cannot be longer than 32 bytes.
553553
std::string formatAsStringOrNumber(std::string const& _value);
554554

555-
/// @returns a string with the usual backslash-escapes for non-ASCII
555+
/// @returns a string with the usual backslash-escapes for non-printable and non-ASCII
556556
/// characters and surrounded by '"'-characters.
557-
std::string escapeAndQuoteYulString(std::string const& _input);
557+
std::string escapeAndQuoteString(std::string const& _input);
558558

559559
template<typename Container, typename Compare>
560560
bool containerEqual(Container const& _lhs, Container const& _rhs, Compare&& _compare)

libyul/AsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ string AsmPrinter::operator()(Literal const& _literal) const
5757
break;
5858
}
5959

60-
return escapeAndQuoteYulString(_literal.value.str()) + appendTypeName(_literal.type);
60+
return escapeAndQuoteString(_literal.value.str()) + appendTypeName(_literal.type);
6161
}
6262

6363
string AsmPrinter::operator()(Identifier const& _identifier) const

0 commit comments

Comments
 (0)