You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/02/07 21:11:08 UTC
[tomcat] branch 8.5.x updated: Align with 9.0.x onwards
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new ce9e6c3 Align with 9.0.x onwards
ce9e6c3 is described below
commit ce9e6c321241ecfae6f86378c59e12131cf2738c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Feb 7 21:10:59 2022 +0000
Align with 9.0.x onwards
---
java/org/apache/tomcat/buildutil/CheckEol.java | 48 +++++++++++++++++++-------
1 file changed, 35 insertions(+), 13 deletions(-)
diff --git a/java/org/apache/tomcat/buildutil/CheckEol.java b/java/org/apache/tomcat/buildutil/CheckEol.java
index e33fddf..f9b9839 100644
--- a/java/org/apache/tomcat/buildutil/CheckEol.java
+++ b/java/org/apache/tomcat/buildutil/CheckEol.java
@@ -32,17 +32,21 @@ import org.apache.tools.ant.types.FileSet;
/**
* Ant task that checks that all the files in the given fileset have end-of-line
- * delimiters that are appropriate for the current OS.
+ * delimiters that are appropriate.
*
* <p>
- * The goal is to check whether we have problems with svn:eol-style property
- * when files are committed on one OS and then checked on another one.
+ * The goal is to check whether we have problems with Subversion's svn:eol-style
+ * property or Git's autocrlf setting when files are committed on one OS and then
+ * checked on another one.
*/
public class CheckEol extends Task {
/** The files to be checked */
private final List<FileSet> filesets = new LinkedList<>();
+ /** The line ending mode (either LF, CRLF, or null for OS specific) */
+ private Mode mode;
+
/**
* Sets the files to be checked
*
@@ -53,6 +57,29 @@ public class CheckEol extends Task {
}
/**
+ * Sets the line ending mode.
+ *
+ * @param mode The line ending mode (either LF or CRLF)
+ */
+ public void setMode( String mode ) {
+ this.mode = Mode.valueOf( mode.toUpperCase() );
+ }
+
+ private Mode getMode() {
+ if ( mode != null ) {
+ return mode;
+ } else {
+ if ("\n".equals(System.lineSeparator())) {
+ return Mode.LF;
+ } else if ("\r\n".equals(System.lineSeparator())) {
+ return Mode.CRLF;
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Perform the check
*
* @throws BuildException if an error occurs during execution of
@@ -61,14 +88,9 @@ public class CheckEol extends Task {
@Override
public void execute() throws BuildException {
- Mode mode = null;
- if ("\n".equals(System.lineSeparator())) {
- mode = Mode.LF;
- } else if ("\r\n".equals(System.lineSeparator())) {
- mode = Mode.CRLF;
- } else {
- log("Line ends check skipped, because OS line ends setting is neither LF nor CRLF.",
- Project.MSG_VERBOSE);
+ Mode mode = getMode();
+ if ( mode == null ) {
+ log("Line ends check skipped, because OS line ends setting is neither LF nor CRLF.", Project.MSG_VERBOSE);
return;
}
@@ -83,8 +105,8 @@ public class CheckEol extends Task {
String[] files = ds.getIncludedFiles();
if (files.length > 0) {
log("Checking line ends in " + files.length + " file(s)");
- for (int i = 0; i < files.length; i++) {
- File file = new File(basedir, files[i]);
+ for (String filename : files) {
+ File file = new File(basedir, filename);
log("Checking file '" + file + "' for correct line ends",
Project.MSG_DEBUG);
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org