Pattern match causing runtime exception 
Author Message
 Pattern match causing runtime exception

I want to match a chunk of Matlab code which is neither a string
nor a comment, and I have come up with

    (?:             # Non-backreferencing grouping parenthesis.
      [])}\w.]'     # Either a character followed by a single quote
                    #   character that is a transpose operator
        |           # or else
      [^'%]         #   any character except single quote (which starts
                    #   a string) or a percent sign (which starts a
                    #   comment).
    )+              # Match one or more times.

A Matlab string is started by a single quote (') and a comment is
started by a percent sign. The single quote is also a transpose
operator but only if after a closing delimiter, letter, digit,
underscore or dot.

This regex works, but if the matched code is larger than 5648 bytes
and it is only matched by the [^'%] part (i.e., code has no transpose
operators), Perl crashes with a runtime exception.

Why?

Here is a way to see that it goes wrong. First generate a test
file, then apply regex. If the 78 is replaced by 77 everyting
is OK.

perl -we "print( ('x' x 72 . \"\n\") x 78)" > test.txt
perl -0777 -wne "print 'OK' if /(?:[])}\w.]'|[^'%])+/" test.txt

I use Perl for Win32 so the delimiters might need to be changed.

Peter



Sat, 24 Jun 2000 03:00:00 GMT  
 Pattern match causing runtime exception


Quote:
>I want to match a chunk of Matlab code which is neither a string
>nor a comment, and I have come up with

[deleted]

Quote:
>This regex works, but if the matched code is larger than 5648 bytes
>and it is only matched by the [^'%] part (i.e., code has no transpose
>operators), Perl crashes with a runtime exception.
>I use Perl for Win32

I tried your test case on an AIX 4.1 system running Perl 5.004_03 and
had no problems. Maybe you just have a bad Win32 port.

--
 Dave Wolfe



Sat, 24 Jun 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Perl, Tk, FTP cause Runtime Exception

2. Runtime exception with Win32::ODBC

3. gdwin32 doesn't appear to work (Runtime Exception)

4. EventLog Gets Runtime Exception Error

5. HELP! Runtime Exception Error

6. Error : Runtime exception with Win32::ODBC

7. runtime exception in activestate perl when using modules

8. Error : Runtime exception with win32Api...

9. Intermitent 'Runtime exception', Why?

10. DBD-ODBC connect gives runtime exception

11. Runtime exception problem.

12. Runtime exception driving me crazy

 

 
Powered by phpBB® Forum Software