tMatch leading ^ in regexp with embedded newlines (Roger Peppe) - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit da7f7882a2797fa3b6fbc9886e8a2144625739bb
 (DIR) parent d91ab9ea7b4c0587b4ac5bcbddf091a269bd9213
 (HTM) Author: rsc <devnull@localhost>
       Date:   Fri, 18 May 2007 16:43:43 +0000
       
       Match leading ^ in regexp with embedded newlines (Roger Peppe)
       
       Diffstat:
         M src/libregexp/regexec.c             |       2 +-
         M src/libregexp/rregexec.c            |      19 +++++++++----------
       
       2 files changed, 10 insertions(+), 11 deletions(-)
       ---
 (DIR) diff --git a/src/libregexp/regexec.c b/src/libregexp/regexec.c
       t@@ -58,7 +58,7 @@ regexec1(Reprog *progp,        /* program to run */
                                        p = utfrune(s, '\n');
                                        if(p == 0 || s == j->eol)
                                                return match;
       -                                s = p;
       +                                s = p+1;
                                        break;
                                }
                        }
 (DIR) diff --git a/src/libregexp/rregexec.c b/src/libregexp/rregexec.c
       t@@ -25,6 +25,7 @@ rregexec1(Reprog *progp,        /* program to run */
                Relist* tle;                /* ends of this and next list */
                Relist* nle;
                int match;
       +        Rune *p;
        
                match = 0;
                checkstart = j->startchar;
       t@@ -44,20 +45,18 @@ rregexec1(Reprog *progp,        /* program to run */
                        if(checkstart) {
                                switch(j->starttype) {
                                case RUNE:
       -                                while(*s != j->startchar) {
       -                                        if(*s == 0 || s == j->reol)
       -                                                return match;
       -                                        s++;
       -                                }
       +                                p = runestrchr(s, j->startchar);
       +                                if(p == 0 || p == j->eol)
       +                                        return match;
       +                                s = p;
                                        break;
                                case BOL:
                                        if(s == bol)
                                                break;
       -                                while(*s != '\n') {
       -                                        if(*s == 0 || s == j->reol)
       -                                                return match;
       -                                        s++;
       -                                }
       +                                p = runestrchr(s, '\n');
       +                                if(p == 0 || s == j->reol)
       +                                        return match;
       +                                s = p+1;
                                        break;
                                }
                        }