Bug 15993

Summary: PCRE needs a bath
Product: WebKit Reporter: Eric Seidel (no email) <eric>
Component: JavaScriptCoreAssignee: Eric Seidel (no email) <eric>
Status: RESOLVED FIXED    
Severity: Normal CC: darin
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
the patch
none
Add a couple more minor cleanups to PCRE, -b diff sam: review+

Description Eric Seidel (no email) 2007-11-14 16:12:48 PST
PCRE needs a bath

Wow.  Talk about hard to read code.

Anyway, in attempting to understand what jsRegExpCompile was doing, I ended up abstracting out the pattern length calculation and giving the entire method a bath.

All I did here was move out the length calculating code (along with associated local variables), move all variable declarations from the start of the block to where they are used (now that this is c++ and we can!), fix a few minor cases where the style disagreed with WebKit style (single line ifs, for example, where { goes, etc.)  I'm *certain* I did not catch all style violations. :)

There are *no* functional changes in this patch.  It passes all the tests.
Comment 1 Eric Seidel (no email) 2007-11-14 16:13:20 PST
Created attachment 17284 [details]
the patch
Comment 2 Eric Seidel (no email) 2007-11-14 16:17:46 PST
Oh, and the very very first thing I did was to ask Xcode to re-indent the entire jsRegExpCompile function so I had some clue where blocks started and ended. :)
Comment 3 Eric Seidel (no email) 2007-11-14 16:56:24 PST
Created attachment 17285 [details]
Add a couple more minor cleanups to PCRE, -b diff

This now includes some additional cleanup I'd been working on for my next patch.  However using -b to ignore whitespace makes for a smaller patch even with those extra changes.  I can get you the original diff ignoring whitespace if that would be easier.

My additional changes were to add a constructor to compile_data and to break out the debug printf code into its own separate function.  I also added returnError to replace the PCRE_ERROR_RETURN goto.

Yay for more-readable code!
Comment 4 Eric Seidel (no email) 2007-11-14 17:17:53 PST
r27802