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/11 13:28:29 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Cvs.java FixCRLF.java

bodewig     00/07/11 04:28:27

  Modified:    docs     index.html
               src/main/org/apache/tools/ant/taskdefs Cvs.java FixCRLF.java
  Log:
  Ensure tablength is a positive power of 2 in FixCRLF.
  
  Revision  Changes    Path
  1.42      +2 -2      jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- index.html	2000/07/11 11:14:45	1.41
  +++ index.html	2000/07/11 11:28:24	1.42
  @@ -1244,8 +1244,8 @@
     </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">The number of characters a TAB stop corresponds to. 
  +      Must be a positive power of 2, default for this parameter is 8.</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  
  
  
  1.7       +5 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Cvs.java
  
  Index: Cvs.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Cvs.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Cvs.java	2000/06/23 14:50:34	1.6
  +++ Cvs.java	2000/07/11 11:28:25	1.7
  @@ -62,6 +62,7 @@
    *
    * @author costin@dnt.ro
    * @author stefano@apache.org
  + * @author Wolfgang Werner <a href="mailto:wwerner@picturesafe.de">wwerner@picturesafe.de</a>
    */
   
   public class Cvs extends Exec {
  @@ -141,12 +142,12 @@
   	this.command = c;
       }
       
  -    public void setQuiet(String q) {
  -        quiet = Project.toBoolean(q);
  +    public void setQuiet(boolean q) {
  +        quiet = q;
       }
       
  -    public void setNoexec(String ne) {
  -        noexec = Project.toBoolean(ne);
  +    public void setNoexec(boolean ne) {
  +        noexec = ne;
       }
   }
   
  
  
  
  1.8       +10 -10    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FixCRLF.java	2000/07/07 07:20:17	1.7
  +++ FixCRLF.java	2000/07/11 11:28:26	1.8
  @@ -116,21 +116,17 @@
   
       /**
        * Set the source dir to find the source text files.
  -     *
  -     * @param srcDirName name of the source directory.
        */
  -    public void setSrcdir(String srcDirName) {
  -        srcDir = project.resolveFile(srcDirName);
  +    public void setSrcdir(File srcDir) {
  +        this.srcDir = srcDir;
       }
   
       /**
        * Set the destination where the fixed files should be placed.
        * Default is to replace the original file.
  -     *
  -     * @param destDirName name of the destination directory.
        */
  -    public void setDestdir(String destDirName) {
  -        destDir = project.resolveFile(destDirName);
  +    public void setDestdir(File destDir) {
  +        this.destDir = destDir;
       }
   
       /**
  @@ -182,8 +178,12 @@
        *
        * @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);
  +    public void setTablength(int tlength) throws BuildException {
  +        if (tlength < 2 || (tlength % 2) != 0) {
  +            throw new BuildException("tablength must be a positive power of 2",
  +                                     location);
  +        }
  +        tablength = tlength;
       }
   
       /**
  
  
  

Re: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Cvs.java FixCRLF.java

Posted by Fergus Gallagher <Fe...@OrbisUK.com>.
You appear to have enforced tablength as even, not as an (integer) power of 
2.   Enforcing the latter is not easy in a System with rounding errors

         n = 2^k

         k = ln(n)/ln(2) must be integer > 1

probably want k "close enough" to an integer.

(Ah, I remember maths)

Fergus

At 11:28 11/07/00 +0000, bodewig@locus.apache.org wrote:
>bodewig     00/07/11 04:28:27
>
>   Modified:    docs     index.html
>                src/main/org/apache/tools/ant/taskdefs Cvs.java FixCRLF.java
>   Log:
>   Ensure tablength is a positive power of 2 in FixCRLF.
>
>   Revision  Changes    Path
>   1.42      +2 -2      jakarta-ant/docs/index.html
>
>   Index: index.html
>   ===================================================================
>   RCS file: /home/cvs/jakarta-ant/docs/index.html,v
>   retrieving revision 1.41
>   retrieving revision 1.42
>   diff -u -r1.41 -r1.42
>   --- index.html        2000/07/11 11:14:45     1.41
>   +++ index.html        2000/07/11 11:28:24     1.42
>   @@ -1244,8 +1244,8 @@
>      </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">The number of characters a TAB stop corresponds to.
>   +      Must be a positive power of 2, default for this parameter is 8.</td>
>        <td valign="top" align="center">No</td>
>      </tr>
>      <tr>
>
>
>
>   1.7       +5 
> -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Cvs.java
>
>   Index: Cvs.java
>   ===================================================================
>   RCS file: 
> /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Cvs.java,v
>   retrieving revision 1.6
>   retrieving revision 1.7
>   diff -u -r1.6 -r1.7
>   --- Cvs.java  2000/06/23 14:50:34     1.6
>   +++ Cvs.java  2000/07/11 11:28:25     1.7
>   @@ -62,6 +62,7 @@
>     *
>     * @author costin@dnt.ro
>     * @author stefano@apache.org
>   + * @author Wolfgang Werner <a 
> href="mailto:wwerner@picturesafe.de">wwerner@picturesafe.de</a>
>     */
>
>    public class Cvs extends Exec {
>   @@ -141,12 +142,12 @@
>         this.command = c;
>        }
>
>   -    public void setQuiet(String q) {
>   -        quiet = Project.toBoolean(q);
>   +    public void setQuiet(boolean q) {
>   +        quiet = q;
>        }
>
>   -    public void setNoexec(String ne) {
>   -        noexec = Project.toBoolean(ne);
>   +    public void setNoexec(boolean ne) {
>   +        noexec = ne;
>        }
>    }
>
>
>
>
>   1.8       +10 
> -10    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.7
>   retrieving revision 1.8
>   diff -u -r1.7 -r1.8
>   --- FixCRLF.java      2000/07/07 07:20:17     1.7
>   +++ FixCRLF.java      2000/07/11 11:28:26     1.8
>   @@ -116,21 +116,17 @@
>
>        /**
>         * Set the source dir to find the source text files.
>   -     *
>   -     * @param srcDirName name of the source directory.
>         */
>   -    public void setSrcdir(String srcDirName) {
>   -        srcDir = project.resolveFile(srcDirName);
>   +    public void setSrcdir(File srcDir) {
>   +        this.srcDir = srcDir;
>        }
>
>        /**
>         * Set the destination where the fixed files should be placed.
>         * Default is to replace the original file.
>   -     *
>   -     * @param destDirName name of the destination directory.
>         */
>   -    public void setDestdir(String destDirName) {
>   -        destDir = project.resolveFile(destDirName);
>   +    public void setDestdir(File destDir) {
>   +        this.destDir = destDir;
>        }
>
>        /**
>   @@ -182,8 +178,12 @@
>         *
>         * @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);
>   +    public void setTablength(int tlength) throws BuildException {
>   +        if (tlength < 2 || (tlength % 2) != 0) {
>   +            throw new BuildException("tablength must be a positive 
> power of 2",
>   +                                     location);
>   +        }
>   +        tablength = tlength;
>        }
>
>        /**
>
>
>

--
Fergus Gallagher
Orbis
http://www.orbisuk.com/
+44-(0)20-8987 0717