geirm       01/11/19 05:02:33

  Modified:    src/java/org/apache/velocity/runtime/parser/node
                        NodeUtils.java
  Log:
  Small fix to solve a problem discovered by
  Robert Edgar <[EMAIL PROTECTED]> where a reference-ish entity
  like \$(foo) wouldn't render the preceeding \.
  
  Revision  Changes    Path
  1.15      +55 -4     
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
  
  Index: NodeUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- NodeUtils.java    2001/11/07 13:00:29     1.14
  +++ NodeUtils.java    2001/11/19 13:02:33     1.15
  @@ -62,7 +62,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Geir Magnusson Jr.</a>
  - * @version $Id: NodeUtils.java,v 1.14 2001/11/07 13:00:29 geirm Exp $
  + * @version $Id: NodeUtils.java,v 1.15 2001/11/19 13:02:33 geirm Exp $
    */
   public class NodeUtils
   {
  @@ -83,10 +83,12 @@
               return specialText;
               
           Token tmp_t = t.specialToken;
  -        
  +
           while (tmp_t.specialToken != null)
  +        {
               tmp_t = tmp_t.specialToken;
  -        
  +        }
  +
           while (tmp_t != null)
           {
               String st = tmp_t.image;
  @@ -98,10 +100,59 @@
                   char c = st.charAt(i);
   
                   if ( c == '#' || c == '$' )
  +                {
                       sb.append( c );
  +                }
  +
  +                /*
  +                 *  more dreaded MORE hack :)
  +                 * 
  +                 *  looking for ("\\")*"$" sequences
  +                 */
  +
  +                if ( c == '\\')
  +                {
  +                    boolean ok = true;
  +                    boolean term = false;
  +
  +                    int j = i;
  +                    for( ok = true; ok && j < st.length(); j++)
  +                    {
  +                        char cc = st.charAt( j );
  +                 
  +                        if (cc == '\\')
  +                        {
  +                            /*
  +                             *  if we see a \, keep going
  +                             */
  +                            continue;
  +                        }
  +                        else if( cc == '$' )
  +                        {
  +                            /*
  +                             *  a $ ends it correctly
  +                             */
  +                            term = true;
  +                            ok = false;
  +                        }
  +                        else
  +                        {
  +                            /*
  +                             *  nah...
  +                             */
  +                            ok = false;
  +                        }
  +                    }
  +
  +                    if (term)
  +                    {
  +                        String foo =  st.substring( i, j );
  +                        sb.append( foo );
  +                        i = j;
  +                    }
  +                }
               }
               
  -            // specialText += tmp_t.image;
               specialText += sb.toString();
   
               tmp_t = tmp_t.next;
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to