You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@locus.apache.org on 2000/07/07 09:20:17 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs FixCRLF.java
bodewig 00/07/07 00:20:17
Modified: docs index.html
src/main/org/apache/tools/ant/taskdefs FixCRLF.java
Log:
Make the length of a TAB customizable.
Suggested by: Michael B. Allen <Mi...@ml.com>
Submitted by: Vitaly Stulsky <vi...@yahoo.com>
Modified by: James Sieben <EU...@am1.ericsson.se>
Revision Changes Path
1.38 +6 -0 jakarta-ant/docs/index.html
Index: index.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/index.html,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- index.html 2000/07/06 12:30:49 1.37
+++ index.html 2000/07/07 07:20:16 1.38
@@ -1230,6 +1230,12 @@
<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
to be handled. Valid values for this property are:
1.7 +16 -5 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
Index: FixCRLF.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FixCRLF.java 2000/07/06 16:48:14 1.6
+++ FixCRLF.java 2000/07/07 07:20:17 1.7
@@ -94,6 +94,7 @@
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;
@@ -177,6 +178,15 @@
}
/**
+ * 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
*
* @param option valid values:
@@ -226,7 +236,8 @@
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 @@
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 @@
col++;
} else {
// advance column to next tab stop
- col = (col|7)+1;
+ col = (col|(tablength-1))+1;
}
break;
@@ -322,9 +333,9 @@
// 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;
};
};
Re: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs FixCRLF.java
Posted by Ernst de Haan <er...@jollem.com>.
Hi,
> 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
For failsafe/foolproof-ness, I suggest you check for `less than 0'
instead of checkign for `equals -1', and the opposite for 'equals +1'.
So it would become something like:
private int addcr; // cr: <0 => remove, 0 => asis, >0 => add
private int addtab; // tab: <0 => remove, 0 => asis, >0 => add
private int ctrlz; // eof: <0 => remove, 0 => asis, >0 => add
In an initial version of the JDK 1.2 java.lang.Comparable interface, the
method `int compareTo(Object)' would return -1, 0 or +1 to indicate
less-than, equals, or greater than, but this has been changed to
negative, 0 and positive. This situation is slightly different, because
it is an interface to be implemented by `untrusted' people. But on the
other hand a lot of people lay their hands on the Ant source code, so
foolproof-ness is always a good thing :)
Note that this does not apply if more modes may be added in the future.
Ernst