You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by tbee <tb...@tbee.org> on 2003/02/21 09:19:38 UTC
ANT translate fix
Hey guys,
I found a bug in the optional ANT translate task. It is not able to
replace two tokens that are to close together. For example:
@aaa;,@bbb;
The problem is in the replace-token-with-value algorithm in the
Translate.java file. The algorithm simply isn't pure (no offence to
any developer intended), so I've rewritten it.
Unfortunately, but understandable, I cannot check my new source in.
So I've attached it to this email:
- Test.java: demonstrates my algorithm
- Translate.java: the modified source
Please tell me if you'll include it, so I don't need to use a patched
Translate.java. Or give me write premission on CVS on Translate.java.
Thanks for a great tool!
Tom
Re: ANT translate fix
Posted by tbee <tb...@tbee.org>.
>Go to http://nagoya.apache.org/bugzilla and create a bug report,
>then attach the patch to the bug report.
Okay. Done.
--
Tom
Re: ANT translate fix
Posted by Jesse Stockall <je...@cryptocard.com>.
On Friday, February 21, 2003, at 11:00 AM, Tbee wrote:
> Ahhhh... well, I would, but how do I do that?
Go to http://nagoya.apache.org/bugzilla and create a bug report, then
attach the patch to the bug report.
Jesse Stockall - jesse@cryptocard.com
CRYPTOCard Corp.
Re: ANT translate fix
Posted by Tbee <tb...@tbee.org>.
Ahhhh... well, I would, but how do I do that?
Tom
ps: just in case, I've pasted the code below, it replaces the code between
the "readline" while loop and the "out.write(line)" in the translate method.
// is there a startToken
// and there is still stuff following the startToken
int startIndex = line.indexOf(startToken);
while ( startIndex >= 0 && (startIndex+1) <= line.length() )
{
// the new value, this needs to be here
// because it is required to calculate the next
position to search from
// at the end of the loop
String replace = null;
// we found a starttoken, is there an endtoken
following?
// start at token+tokensize because start and end token
may be indentical
int endIndex = line.indexOf(endToken, startIndex +
startToken.length());
if (endIndex < 0) startIndex += 1;
else
{
// grab the token
String token = line.substring(startIndex +
startToken.length(), endIndex);
// If there is a white space or = or :, then
// it isn't to be treated as a valid key.
boolean validToken = true;
for (int k = 0; k < token.length() && validToken; k++)
{
char c = token.charAt(k);
if ( c == ':'
|| c == '='
|| Character.isSpaceChar(c)
)
{
validToken = false;
}
}
if (validToken)
{
// find the replace string
if (resourceMap.containsKey(token)) replace = (String)
resourceMap.get(token);
else replace = token;
// generate the new line
line = line.substring(0, startIndex)
+ replace
+ line.substring(endIndex + endToken.length());
}
// set start position for next search
startIndex += replace.length();
}
// find next starttoken
startIndex = line.indexOf(startToken, startIndex);
Quoting Magesh Umasankar <um...@apache.org>:
> Still no good!! Will you please try putting it
> as a patch on http://nagoya.apache.org/bugzilla ?
>
> Cheers,
> Magesh
>
> *************************************************************
> * Miser: A person who lives poor so that he can die rich. *
> *************************************************************
> ----- Original Message -----
> From: "tbee" <tb...@tbee.org>
> To: "Ant Developers List" <de...@ant.apache.org>
> Sent: Friday, February 21, 2003 10:16 AM
> Subject: Re: ANT translate fix
>
>
> Here ya go.
>
>
>
> On Fri, 21 Feb 2003 08:56:45 -0500, Magesh Umasankar wrote:
> >The patch did not come thru' - Please zip it up and try resending.
> >
> >----- Original Message ----- From: "tbee" <tb...@tbee.org> To:
> ><de...@ant.apache.org> Sent: Friday, February 21, 2003 3:19 AM
> >Subject: ANT translate fix
> >
> >
> >Hey guys,
> >
> >I found a bug in the optional ANT translate task. It is not able to
> >replace two tokens that are to close together. For example:
> >
> >@aaa;,@bbb;
> >
> >The problem is in the replace-token-with-value algorithm in the
> >Translate.java file. The algorithm simply isn't pure (no offence to
> >any developer intended), so I've rewritten it.
> >
> >Unfortunately, but understandable, I cannot check my new source in.
> >So I've attached it to this email:
> >
> >- Test.java: demonstrates my algorithm - Translate.java: the
> >modified source
> >
> >Please tell me if you'll include it, so I don't need to use a
> >patched Translate.java. Or give me write premission on CVS on
> >Translate.java.
> >
> >Thanks for a great tool!
> >
> >Tom
> >
> >
> >
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >------- ----
> >
> >
> >>
> >>--------------------------------------------------------------------
> >>- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For
> >>additional commands, e-mail: dev-help@ant.apache.org
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For
> >additional commands, e-mail: dev-help@ant.apache.org
>
>
>
>
>
>
> ----------------------------------------------------------------------------
> ----
>
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> > For additional commands, e-mail: dev-help@ant.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>
Re: ANT translate fix
Posted by Magesh Umasankar <um...@apache.org>.
Still no good!! Will you please try putting it
as a patch on http://nagoya.apache.org/bugzilla ?
Cheers,
Magesh
*************************************************************
* Miser: A person who lives poor so that he can die rich. *
*************************************************************
----- Original Message -----
From: "tbee" <tb...@tbee.org>
To: "Ant Developers List" <de...@ant.apache.org>
Sent: Friday, February 21, 2003 10:16 AM
Subject: Re: ANT translate fix
Here ya go.
On Fri, 21 Feb 2003 08:56:45 -0500, Magesh Umasankar wrote:
>The patch did not come thru' - Please zip it up and try resending.
>
>----- Original Message ----- From: "tbee" <tb...@tbee.org> To:
><de...@ant.apache.org> Sent: Friday, February 21, 2003 3:19 AM
>Subject: ANT translate fix
>
>
>Hey guys,
>
>I found a bug in the optional ANT translate task. It is not able to
>replace two tokens that are to close together. For example:
>
>@aaa;,@bbb;
>
>The problem is in the replace-token-with-value algorithm in the
>Translate.java file. The algorithm simply isn't pure (no offence to
>any developer intended), so I've rewritten it.
>
>Unfortunately, but understandable, I cannot check my new source in.
>So I've attached it to this email:
>
>- Test.java: demonstrates my algorithm - Translate.java: the
>modified source
>
>Please tell me if you'll include it, so I don't need to use a
>patched Translate.java. Or give me write premission on CVS on
>Translate.java.
>
>Thanks for a great tool!
>
>Tom
>
>
>
>
>
>
>
>---------------------------------------------------------------------
>------- ----
>
>
>>
>>--------------------------------------------------------------------
>>- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For
>>additional commands, e-mail: dev-help@ant.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For
>additional commands, e-mail: dev-help@ant.apache.org
----------------------------------------------------------------------------
----
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
Re: ANT translate fix
Posted by tbee <tb...@tbee.org>.
Here ya go.
On Fri, 21 Feb 2003 08:56:45 -0500, Magesh Umasankar wrote:
>The patch did not come thru' - Please zip it up and try resending.
>
>----- Original Message ----- From: "tbee" <tb...@tbee.org> To:
><de...@ant.apache.org> Sent: Friday, February 21, 2003 3:19 AM
>Subject: ANT translate fix
>
>
>Hey guys,
>
>I found a bug in the optional ANT translate task. It is not able to
>replace two tokens that are to close together. For example:
>
>@aaa;,@bbb;
>
>The problem is in the replace-token-with-value algorithm in the
>Translate.java file. The algorithm simply isn't pure (no offence to
>any developer intended), so I've rewritten it.
>
>Unfortunately, but understandable, I cannot check my new source in.
>So I've attached it to this email:
>
>- Test.java: demonstrates my algorithm - Translate.java: the
>modified source
>
>Please tell me if you'll include it, so I don't need to use a
>patched Translate.java. Or give me write premission on CVS on
>Translate.java.
>
>Thanks for a great tool!
>
>Tom
>
>
>
>
>
>
>
>---------------------------------------------------------------------
>------- ----
>
>
>>
>>--------------------------------------------------------------------
>>- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For
>>additional commands, e-mail: dev-help@ant.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For
>additional commands, e-mail: dev-help@ant.apache.org
Re: ANT translate fix
Posted by Magesh Umasankar <um...@apache.org>.
The patch did not come thru' - Please zip it up
and try resending.
----- Original Message -----
From: "tbee" <tb...@tbee.org>
To: <de...@ant.apache.org>
Sent: Friday, February 21, 2003 3:19 AM
Subject: ANT translate fix
Hey guys,
I found a bug in the optional ANT translate task. It is not able to
replace two tokens that are to close together. For example:
@aaa;,@bbb;
The problem is in the replace-token-with-value algorithm in the
Translate.java file. The algorithm simply isn't pure (no offence to
any developer intended), so I've rewritten it.
Unfortunately, but understandable, I cannot check my new source in.
So I've attached it to this email:
- Test.java: demonstrates my algorithm
- Translate.java: the modified source
Please tell me if you'll include it, so I don't need to use a patched
Translate.java. Or give me write premission on CVS on Translate.java.
Thanks for a great tool!
Tom
----------------------------------------------------------------------------
----
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org