From 2c873f525b1a2073ac41dbe080edd2f5b8232337 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Fri, 7 Jul 2000 07:20:17 +0000
Subject: [PATCH] Make the length of a TAB customizable.
Suggested by: Michael B. Allen
Submitted by: Vitaly Stulsky
Modified by: James Sieben
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267742 13f79535-47bb-0310-9956-ffa450edef68
---
docs/index.html | 6 ++++++
.../apache/tools/ant/taskdefs/FixCRLF.java | 21 ++++++++++++++-----
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/docs/index.html b/docs/index.html
index 7ba5db927..51629d8e1 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1229,6 +1229,12 @@ relative to the src directory.
No |
+
+ tablength |
+ The number of characters a TAB stop corresponds to.
+ Default for this parameter is 8. |
+ No |
+
eof |
Specifies how DOS end of file (control-Z) characters are
diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
index d21262739..6866e7291 100644
--- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
+++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
@@ -94,6 +94,7 @@ public class FixCRLF extends MatchingTask {
private int addcr; // cr: -1 => remove, 0 => asis, +1 => add
private int addtab; // tab: -1 => remove, 0 => asis, +1 => add
private int ctrlz; // eof: -1 => remove, 0 => asis, +1 => add
+ private int tablength = 8; // length of tab in spaces
private File srcDir;
private File destDir = null;
@@ -176,6 +177,15 @@ public class FixCRLF extends MatchingTask {
}
}
+ /**
+ * Specify tab length in characters
+ *
+ * @param tlength specify the length of tab in spaces, has to be a power of 2
+ */
+ public void setTablength(String tlength) {
+ tablength = Integer.parseInt(tlength);
+ }
+
/**
* Specify how DOS EOF (control-z) charaters are to be handled
*
@@ -226,7 +236,8 @@ public class FixCRLF extends MatchingTask {
log("options:" +
" cr=" + (addcr==-1 ? "add" : addcr==0 ? "asis" : "remove") +
" tab=" + (addtab==-1 ? "add" : addtab==0 ? "asis" : "remove") +
- " eof=" + (ctrlz==-1 ? "add" : ctrlz==0 ? "asis" : "remove"),
+ " eof=" + (ctrlz==-1 ? "add" : ctrlz==0 ? "asis" : "remove") +
+ " tablength=" + tablength,
Project.MSG_VERBOSE);
DirectoryScanner ds = super.getDirectoryScanner(srcDir);
@@ -270,7 +281,7 @@ public class FixCRLF extends MatchingTask {
int outsize = count;
if (addcr != 0) outsize-=cr;
if (addcr == +1) outsize+=lf;
- if (addtab == -1) outsize+=tab*7;
+ if (addtab == -1) outsize+=tab*(tablength-1);
if (ctrlz == +1) outsize+=1;
// copy the data
@@ -294,7 +305,7 @@ public class FixCRLF extends MatchingTask {
col++;
} else {
// advance column to next tab stop
- col = (col|7)+1;
+ col = (col|(tablength-1))+1;
}
break;
@@ -322,9 +333,9 @@ public class FixCRLF extends MatchingTask {
// add tabs until this column would be passed
// note: the start of line is adjusted to match
- while ((diff|7) |