This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 7c7e0ec6ae Trivial tweak for `replaceEscapes`
7c7e0ec6ae is described below
commit 7c7e0ec6ae97fcc7d1d67d9023f03990428f2b57
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Jan 11 20:19:02 2025 +0900
Trivial tweak for `replaceEscapes`
---
.../apache/groovy/parser/antlr4/util/StringUtils.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git
a/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
b/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
index a312eeed7b..1c80045e5b 100644
--- a/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
+++ b/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
@@ -36,9 +36,11 @@ public class StringUtils {
public static final int DOLLAR_SLASHY = 2;
public static String replaceEscapes(String text, int slashyType) {
- if (slashyType == SLASHY || slashyType == DOLLAR_SLASHY) {
- text = StringUtils.replaceHexEscapes(text);
- text = StringUtils.replaceLineEscape(text);
+ if (slashyType == NONE_SLASHY) {
+ text = replaceEscapes(text);
+ } else if (slashyType == SLASHY || slashyType == DOLLAR_SLASHY) {
+ text = replaceHexEscapes(text);
+ text = replaceLineEscape(text);
if (slashyType == SLASHY) {
text = replace(text,"\\/", "/");
@@ -46,9 +48,7 @@ public class StringUtils {
text = replace(text,"$/", "/");
text = replace(text,"$$", "$");
}
- } else if (slashyType == NONE_SLASHY) {
- text = StringUtils.replaceEscapes(text);
- } else {
+ } else {
throw new IllegalArgumentException("Invalid slashyType: " +
slashyType);
}
@@ -160,8 +160,8 @@ public class StringUtils {
private static String replaceEscapes(String text) {
if (!text.contains(BACKSLASH)) return text;
text = replace(text,"\\$", "$");
- text = StringUtils.replaceLineEscape(text);
- return
StringUtils.replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text)));
+ text = replaceLineEscape(text);
+ return
replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text)));
}
private static String replaceLineEscape(String text) {