ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tbee <t...@tbee.org>
Subject Re: ANT translate fix
Date Fri, 21 Feb 2003 16:00:11 GMT
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 <umagesh@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" <tbee@tbee.org>
> To: "Ant Developers List" <dev@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" <tbee@tbee.org> To:
> ><dev@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
> 
> 



Mime
View raw message