Browse Source

Make the length of a TAB customizable.

Suggested by:	Michael B. Allen <Michael_B_Allen@ml.com>
Submitted by:	Vitaly Stulsky <vitaly_stulsky@yahoo.com>
Modified by:	James Sieben <EUSJASI@am1.ericsson.se>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267742 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
2c873f525b
2 changed files with 22 additions and 5 deletions
  1. +6
    -0
      docs/index.html
  2. +16
    -5
      src/main/org/apache/tools/ant/taskdefs/FixCRLF.java

+ 6
- 0
docs/index.html View File

@@ -1229,6 +1229,12 @@ relative to the <i>src</i> directory.</p>
</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">tablength</td>
<td valign="top">The number of characters a TAB stop corresponds to.
Default for this parameter is 8.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">eof</td>
<td valign="top">Specifies how DOS end of file (control-Z) characters are


+ 16
- 5
src/main/org/apache/tools/ant/taskdefs/FixCRLF.java View File

@@ -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)<col) {
while ((diff|(tablength-1))<col) {
outdata[o++]=(byte)'\t';
line-=7-(diff&7);
line-=(tablength-1)-(diff&(tablength-1));
diff=o-line;
};
};


Loading…
Cancel
Save