mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
Fix up the whitespace normalization in TextUtils.normalizeWhitespace
Previously, all inter-line whitespace was being removed. And it now normalizes trailing new lines as well
This commit is contained in:
parent
a01bf8c832
commit
32a400396d
@ -54,7 +54,7 @@ public class TextUtils {
|
|||||||
source = normalizeNewlines(source);
|
source = normalizeNewlines(source);
|
||||||
|
|
||||||
// Remove all suffix/prefix whitespace
|
// Remove all suffix/prefix whitespace
|
||||||
Pattern pattern = Pattern.compile("((^[ \t]+)|([ \t]+))");
|
Pattern pattern = Pattern.compile("((^[ \t]+)|([ \t]+$))", Pattern.MULTILINE);
|
||||||
Matcher matcher = pattern.matcher(source);
|
Matcher matcher = pattern.matcher(source);
|
||||||
source = matcher.replaceAll("");
|
source = matcher.replaceAll("");
|
||||||
|
|
||||||
@ -63,6 +63,11 @@ public class TextUtils {
|
|||||||
Matcher matcher2 = pattern2.matcher(source);
|
Matcher matcher2 = pattern2.matcher(source);
|
||||||
source = matcher2.replaceAll("");
|
source = matcher2.replaceAll("");
|
||||||
|
|
||||||
|
// Remove a trailing new line, if present
|
||||||
|
Pattern pattern3 = Pattern.compile("\r?\n?$");
|
||||||
|
Matcher matcher3 = pattern3.matcher(source);
|
||||||
|
source = matcher3.replaceAll("");
|
||||||
|
|
||||||
// Go back to unix-style \n newlines
|
// Go back to unix-style \n newlines
|
||||||
source = normalizeNewlines(source, "\n");
|
source = normalizeNewlines(source, "\n");
|
||||||
return source;
|
return source;
|
||||||
|
Loading…
Reference in New Issue
Block a user