jakarta-oro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-oro/src/java/org/apache/oro/text/awk AwkCompiler.java
Date Tue, 20 Feb 2001 03:34:36 GMT
dfs         01/02/19 19:34:35

  Modified:    .        CHANGES
               src/java/org/apache/oro/text/awk AwkCompiler.java
  Log:
  Added MULTILINE_MASK flag to AwkCompiler and changed default behavior of
  '.' to match newlines, conforming with normal awk behavior.
  Updated CHANGES file to reflect latest changes.
  
  Revision  Changes    Path
  1.4       +14 -1     jakarta-oro/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/CHANGES,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CHANGES	2001/01/29 00:19:00	1.3
  +++ CHANGES	2001/02/20 03:34:35	1.4
  @@ -1,4 +1,17 @@
  -$Id: CHANGES,v 1.3 2001/01/29 00:19:00 dfs Exp $
  +$Id: CHANGES,v 1.4 2001/02/20 03:34:35 dfs Exp $
  +
  +Version 2.0.2-dev-3
  +
  +o Fixed default behavior of '.' in awk package.  Previously it wouldn't
  +  match newlines, which isn't how AWK behaves.  The default behavior now
  +  matches any character, but a compilation mask (MULTILINE_MASK) has been
  +  added to AwkCompiler to enable the old behavior.
  +
  +o Replaced the use of Vector with ArrayList in Perl5Substitution.
  +
  +o Replaced the use of deprecated Perl5Util split method in printPasswd
  +  example with newer method.  Also updated splitExample to use
  +  ArrayList instead of Vector.
   
   Version 2.0.2-dev-2
   
  
  
  
  1.3       +28 -4     jakarta-oro/src/java/org/apache/oro/text/awk/AwkCompiler.java
  
  Index: AwkCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/awk/AwkCompiler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AwkCompiler.java	2000/07/23 23:25:18	1.2
  +++ AwkCompiler.java	2001/02/20 03:34:35	1.3
  @@ -135,7 +135,7 @@
    * </ul></ul>
   
    @author <a href="mailto:dfs@savarese.org">Daniel F. Savarese</a>
  - @version $Id: AwkCompiler.java,v 1.2 2000/07/23 23:25:18 jon Exp $
  + @version $Id: AwkCompiler.java,v 1.3 2001/02/20 03:34:35 dfs Exp $
   
    * @see org.apache.oro.text.regex.PatternCompiler
    * @see org.apache.oro.text.regex.MalformedPatternException
  @@ -143,12 +143,33 @@
    * @see AwkMatcher
    */                        
   public final class AwkCompiler implements PatternCompiler {
  +
  +  /**
  +   * The default mask for the {@link #compile compile} methods.
  +   * It is equal to 0 and indicates no special options are active.
  +   */
     public static final int DEFAULT_MASK          = 0;
  +
  +  /**
  +   * A mask passed as an option to the {@link #compile compile} methods
  +   * to indicate a compiled regular expression should be case insensitive.
  +   */
     public static final int CASE_INSENSITIVE_MASK = 0x0001;
   
  +
  +  /**
  +   * A mask passed as an option to the  {@link #compile compile} methods
  +   * to indicate a compiled regular expression should treat input as having
  +   * multiple lines.  This option affects the interpretation of
  +   * the <b> . </b> metacharacters.  When this mask is used,
  +   * the <b> . </b> metacharacter will not match newlines.  The default
  +   * behavior is for <b> . </b> to match newlines.
  +   */
  +  public static final int MULTILINE_MASK = 0x0002;
  +
     static final char _END_OF_INPUT = '\uFFFF';
     
  -  private boolean __inCharacterClass, __caseSensitive;
  +  private boolean __inCharacterClass, __caseSensitive, __multiline;
     private boolean __beginAnchor, __endAnchor;
     private char __lookahead;
     private int __position, __bytesRead, __expressionLength;
  @@ -611,7 +632,8 @@
   
         __match('.');
         characterSet = new NegativeCharacterClassNode(__position++);
  -      characterSet._addToken('\n');
  +      if(__multiline)
  +	characterSet._addToken('\n');
         current = characterSet;
       } else if(__lookahead == '\\') {
         current = __backslashToken();
  @@ -801,8 +823,9 @@
       SyntaxTree tree;
       AwkPattern regexp;
   
  -    __beginAnchor = __endAnchor = false;
  +    __beginAnchor   = __endAnchor = false;
       __caseSensitive = ((options & CASE_INSENSITIVE_MASK) == 0);
  +    __multiline     = ((options & MULTILINE_MASK) != 0);
       tree   = _parse(pattern);
       regexp = new AwkPattern(new String(pattern), tree);
       regexp._options = options;
  @@ -835,6 +858,7 @@
   
       __beginAnchor = __endAnchor = false;
       __caseSensitive = ((options & CASE_INSENSITIVE_MASK) == 0);
  +    __multiline     = ((options & MULTILINE_MASK) != 0);
       tree   = _parse(pattern.toCharArray());
       regexp = new AwkPattern(pattern, tree);
       regexp._options = options;
  
  
  

Mime
View raw message