[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: subjects not being parsed?
From: |
Andrew Gray |
Subject: |
Re: subjects not being parsed? |
Date: |
Thu, 7 Mar 2002 22:44:50 +1100 |
Hi Chad and Milan,
> CCW> OK. I'm at a loss here. A couple months ago, I deployed gnats
> CCW> 3.999 packages from the woody distribution of Debian. During
> CCW> that deployment and testing phase, I recall file-pr correctly
> CCW> parsing the subject line and adding audit text to the PR.
> Yes, there was change in subject matching. The matching was changed,
> to improve a correct recognition of new reports and replies. It's
> not unlikely bugs were made during the change.
>
> If you can, please look at the function `checkIfReply' in file-pr.c.
> Maybe you'll find out what's wrong.
I saw a similar problem with email's that were replies to existing PRs
not being recognised as such. I have had a look at the checkIfReply
function in file-pr.c and identified a couple of problems. The regular
expression currently used in checkIfReply is:
"\\<((PR[ \t/])|([-a-z0-9_+.]+)/)([0-9]+)"
(This is how it appears in the C source code, the \\ is
interpretted by the C compiler as a single backslash and \t as a
horizontal tab.)
Since the RE_NO_BK_VBAR bit defined in regex.h is not set using
re_set_syntax, \| is the alternation operator, so the vertical bar
should be preceded by a backslash in the regular expression:
"\\<((PR[ \t/])\\|([-a-z0-9_+.]+)/)([0-9]+)"
Currently checkIfReply uses re_match, but this function only tries to
match the regular expression at the start of the string. To match
subject lines that have miscellaneous text, such as "Re: " precedding
the PR identifier, the re_search function should be used.
Using the modified regular expression and re_search will match Subject
lines such as the following:
gnats/85
Re: gnats/85
FW: RE: gnats/85
Here is the patchfile to make these changes:
Index: file-pr.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/file-pr.c,v
retrieving revision 1.45
diff -u -p -r1.45 file-pr.c
--- file-pr.c 10 Feb 2002 18:23:42 -0000 1.45
+++ file-pr.c 7 Mar 2002 11:33:53 -0000
@@ -594,10 +594,11 @@ checkIfReply (PR *pr, ErrorDesc *err)
regex.translate = case_fold;
{
- const char *const PAT = "\\<((PR[ \t/])|([-a-z0-9_+.]+)/)([0-9]+)";
+ const char *const PAT = "\\<((PR[ \t/])\\|([-a-z0-9_+.]+)/)([0-9]+)";
re_compile_pattern (PAT, strlen (PAT), ®ex);
}
- i = re_match (®ex, headerValue, strlen (headerValue), 0, ®s);
+ i = re_search (®ex, headerValue, strlen (headerValue), 0,
+ strlen (headerValue), ®s);
regex.translate = NULL;
regfree (®ex);
re_set_syntax (old_syntax);
Regards,
Andrew Gray