Re: Can't debug without source code.

"John E. Davis" <[email protected]> Fri, 24 Sep 2010 12:56:59 -0400
Newsgroups gmane.network.slrn.user
Message-ID <[email protected]>
Brian Murray <[email protected]> wrote:
> I was sort of wondering how I could proceed in debugging it myself but
> of course I am happy to have others look at it too.

One of the things that I would like to do is to add support for the
sldb debugger to slrn.  I believe that it can be accomplished without
too much effort.

> You'll find it attached.  I've also added in comment that is an example
> of a subject that was not threaded.
> define subject_compare_hook ( subject1, subject2 )
>{
> variable bracket_pattern;
> variable parens_pattern;
> variable hyphen_image_pat;
> variable bracket_matches, bracket_matches2;
> variable parens_matches, parens_matches2;
> variable hyphen_image_matches, hyphen_image_matches2;
> variable replacement, replacement2;
>
> bracket_pattern = "\\[[0-9]+ ?\\(?:of\\) ?/\\([0-9]+\\)\\]";
> parens_pattern = "([0-9]+/[0-9]+)";
> hyphen_image_pat = " ?\\([0-9]+[ -_]?\\)[0-9]+\\(.[jJ][pP][gG]\\)";

   Are these slang regular expressions?  I suspect that
   bracket_pattern is trying to match strings such as

      "[17 of 89]"
      "[17/89]"

   If so, then bracket_pattern will not work when interpreted as a
   slang RE.  You might want to use the onigurama or pcre modules for
   more powerful REs.  Alternatively, you can try:

      bracket_pattern = "\[[0-9]+ ?[o/]f? ?\([0-9]+\)\]"R;

   The above pattern will match

      "[17 of 89]"
      "[17/89]"

   as well as the false positives:

      "[17 /f89]"
      "[17o89]"

   It looks like you also want to match the forms using "(".  If so,
   use:

      bracket_pattern = "[[(][0-9]+ ?[o/]f? ?\([0-9]+\)[])]"R;

> bracket_matches = string_matches(subject1, bracket_pattern, 1);
> if ( bracket_matches[0] != NULL )

The above works only because upon failure, bracket_matches will be
NULL, which is a scalar that will be interpreted in the above context
as an array with a single element.  It is better to simply use

   if (bracket_matches != NULL) ...

>{
>     ( subject1, ) = strreplace(subject1, bracket_matches[0], bracket_matches[1], 1);

  Here, you are replacing 1 occurance of bracket_matches[0] in
  subject1 with bracket_matches[1].  So you are replacing the entire
  string of characters matched by bracket_pattern with the characters
  matched by the "?:of" bit of the pattern.  Since "?:of" looks a bit
  odd I suspect that you are not using a slang RE.

[...]
> % check and see if the stripped subjects now match
> if ( 0 == strcmp(subject1, subject2) )

  You can also use:

    if (subject1 == subject2)

I hope this helps.
--John

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev