I've got this GUI encyclopedia builder thing in Tk, and it's mega-cool, but when I run it on Apple's OS X, one of the regular expressions segfaults my application. Is this a problem with the Apple port of Perl? I run this under 5.6.0 and 5.8.0 and get a segmentation fault on each. Is my expression flawed?
Below I'm posting the code that crashes. It's a huge string fed into a relatively large expression. The string has to be sufficiently long and include something enclosed in square braces to cause a problem. Sorry if this looks ugly:
$text = "\n Prefetching [sets] WebObjects to fetch a related set o
+f EOs when fetching a specified set of EOs. This can create fewer fe
+tches and free up database time for other applications.\n For instan
+ce, let's say that you have an Organization EO that had several Offic
+e EOs that each had an Address EO. Now let's say that you had a comp
+onent which listed all of the Offices and Office Addresses for a spec
+ific Organization. Usually, you would fetch the Offices for an Organ
+ization and each repeating table row would try to fault each and ever
+y \"address\" relationship in each Office. That creates a fetch for
+each relationship fault, and a lot of round trips to the database whi
+ch use a lot of resources and makes your thing slow.\n The solu
+tion is to tell WebObjects that after you fetch the Offices (using a
+single fetch), you would like to fetch all of their addresses (using
+another single fetch). This can be done with prefetching. Here we g
+o:\n\n EOFetchSpecification spec = ...;\n String keypaths
+() = {\"offices\", \"offices.address\"}; // \"offices\" is a relation
+ship in Organization, and \"address\" is a relationship in Office.\n
+ spec.setPrefetchingRelationshipKeyPaths(new NSArray(keypaths));"
+;
if ($text =~ /^
( # Any amount of:
(
\[ # An open brace
.*? # Any amount of non-brace stuff
\] # A close brace
)
| # Or
[^\[] # Anything that's not an open brac
+e.
)*
\] # Followed by a close brace
/xs
) {
print "The article contains a closing brace \"]\" with no opening br
+ace.";
} else {print "Okay, joe.";}
Thanks a bunch for looking at this. I'm going to be posting some cool Tk examples from my project in the coming weeks.
-the Pedro Picasso
(sourceCode == freeSpeech)
Edit by dws to clean up formatting
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|