You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-dev@jakarta.apache.org by jo...@locus.apache.org on 2000/08/22 19:19:42 UTC

cvs commit: jakarta-regexp/src/java/org/apache/regexp RE.java

jon         00/08/22 10:19:40

  Modified:    src/java/org/apache/regexp RE.java
  Log:
  I'm wondering how is it possible, that nobody during that time needed to
  match an pattern
  agains whole file contents kept in a string - I mean perl 's' modifier
  that makes '.' to
  match line endings. This is not supported by jakarta-regexp (or I was to
  dumb to find it).
  
  Rafal Krzewski <Ra...@e-point.pl>
  
  Revision  Changes    Path
  1.6       +22 -5     jakarta-regexp/src/java/org/apache/regexp/RE.java
  
  Index: RE.java
  ===================================================================
  RCS file: /home/cvs/jakarta-regexp/src/java/org/apache/regexp/RE.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RE.java	2000/06/22 20:39:01	1.5
  +++ RE.java	2000/08/22 17:19:38	1.6
  @@ -347,7 +347,7 @@
    * @see RECompiler
    *
    * @author <a href="mailto:jonl@muppetlabs.com">Jonathan Locke</a>
  - * @version $Id: RE.java,v 1.5 2000/06/22 20:39:01 jon Exp $
  + * @version $Id: RE.java,v 1.6 2000/08/22 17:19:38 jon Exp $
    */
   public class RE
   {
  @@ -366,6 +366,11 @@
        */
       public static final int MATCH_MULTILINE       = 0x0002;
   
  +    /**
  +     * Consider all input a single body of text - newlines are matched by .
  +     */
  +    public static final int MATCH_SINGLELINE      = 0x0004;
  +
       /************************************************
        *                                              *
        * The format of a node in a program is:        *
  @@ -1101,12 +1106,24 @@
   
                   case OP_ANY:
   
  -                    // Match anything but a newline
  -                    if (search.isEnd(idx) || search.charAt(idx++) == '\n')
  +                    if((matchFlags & MATCH_SINGLELINE) == MATCH_SINGLELINE) {
  +                        // Match anything
  +                        if(search.isEnd(idx))
  +                        {
  +                            return -1;
  +                        }
  +                        idx++;
  +                        break;
  +                    }
  +                    else
                       {
  -                        return -1;
  +                        // Match anything but a newline
  +                        if (search.isEnd(idx) || search.charAt(idx++) == '\n')
  +                        {
  +                            return -1;
  +                        }
  +                        break;
                       }
  -                    break;
   
                   case OP_ATOM:
                       {