gnats-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to gnats/gnats/file-pr.c


From: Andrew J. Gray
Subject: Changes to gnats/gnats/file-pr.c
Date: Sat, 08 Mar 2003 21:28:47 -0500

Index: gnats/gnats/file-pr.c
diff -c gnats/gnats/file-pr.c:1.51 gnats/gnats/file-pr.c:1.52
*** gnats/gnats/file-pr.c:1.51  Fri Nov  1 06:37:51 2002
--- gnats/gnats/file-pr.c       Sat Mar  8 21:28:45 2003
***************
*** 595,608 ****
  static char *
  checkIfReply (PR *pr, ErrorDesc *err)
  {
!   char *prID = NULL;
    AdmEntry *cat;
    const char *headerValue;
    struct re_pattern_buffer regex;
    struct re_registers regs;
!   int i, start, end, idstart;
!   char case_fold[256];
!   char *possiblePrNum;
    reg_syntax_t old_syntax;
  
    headerValue = header_value (pr, SUBJECT);
--- 595,607 ----
  static char *
  checkIfReply (PR *pr, ErrorDesc *err)
  {
!   char *prID;
!   char *prCat;
    AdmEntry *cat;
    const char *headerValue;
    struct re_pattern_buffer regex;
    struct re_registers regs;
!   int i, len;
    reg_syntax_t old_syntax;
  
    headerValue = header_value (pr, SUBJECT);
***************
*** 612,633 ****
        return NULL;
      }
  
!   old_syntax = re_set_syntax (RE_NO_BK_PARENS);
    memset ((void *) &regex, 0, sizeof (regex));
  
-   for (i=0; i<256; i++)
-     {
-       case_fold[i] = tolower(i);
-     }
-   regex.translate = case_fold;
-   
    {
!     const char *const PAT = "\\<((PR[ \t/])\\|([-a-z0-9_+.]+)/)([0-9]+)";
      re_compile_pattern (PAT, strlen (PAT), &regex);
    }
    i = re_search (&regex, headerValue, strlen (headerValue), 0,
                 strlen (headerValue), &regs);
-   regex.translate = NULL;
    regfree (&regex);
    re_set_syntax (old_syntax);
  
--- 611,626 ----
        return NULL;
      }
  
!   old_syntax = re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR
!                             | RE_CHAR_CLASSES);
    memset ((void *) &regex, 0, sizeof (regex));
  
    {
!     const char *const PAT = "\\<(PR[ \t#/]?|([-[:alnum:]_+.]+)/)([0-9]+)";
      re_compile_pattern (PAT, strlen (PAT), &regex);
    }
    i = re_search (&regex, headerValue, strlen (headerValue), 0,
                 strlen (headerValue), &regs);
    regfree (&regex);
    re_set_syntax (old_syntax);
  
***************
*** 636,678 ****
        return NULL;
      }
  
!   start = regs.start[0];
!   end = regs.end[0];
!   idstart = regs.start[4] - start;
! 
!   free (regs.start);
!   free (regs.end);
! 
!   possiblePrNum = xmalloc (end - start + 1);
!   memcpy (possiblePrNum, headerValue + start, end - start);
!   possiblePrNum[end - start] = '\0';
! 
!   *(possiblePrNum + idstart - 1) = '\0';
! 
!   /* See if the category exists: */
!   cat = get_adm_record (CATEGORY (pr->database), possiblePrNum);
! 
!   /* If no such category, then this is not a reply to a valid
!    * problem report.  This situtation can arise, for example, when
!    * someone has the string "OS/2" in their Subject header.
!    */
!   /* Folks often send in "pr/1234" instead of a valid category */
!   if ((cat != NULL) || (strcasecmp (possiblePrNum, "pr") == 0))
      {
!       /* We only needed res, never cat, so free cat. */
!       free_adm_entry (cat);
!       prID = xstrdup (possiblePrNum + idstart);
      }
  
!   free (possiblePrNum);
  
!   if (prID != NULL)
      {
!       if (! prExists (pr->database, prID, err))
!       {
!         free (prID);
!         prID = NULL;
!       }
      }
  
    return prID;
--- 629,667 ----
        return NULL;
      }
  
!   /* Check the category if there is one. */
!   if (regs.start[2] > -1)
      {
!       len = regs.end[2] - regs.start[2];
!       prCat = xmalloc (len + 1);
!       memcpy (prCat, headerValue + regs.start[2], len);
!       prCat[len] = '\0';
! 
!       /* See if the category exists: */
!       cat = get_adm_record (CATEGORY (pr->database), prCat);
!       free_adm_entry(cat);
!       free (prCat);
!       if (cat == NULL)
!       {
!           free (regs.start);
!           free (regs.end);
!         return NULL;
!       }
      }
  
!   /* Check the PR number. */
!   len = regs.end[3] - regs.start[3];
!   prID = xmalloc (len + 1);
!   memcpy (prID, headerValue + regs.start[3], len);
!   prID[len] = '\0';
! 
!   free (regs.start);
!   free (regs.end);
  
!   if (! prExists (pr->database, prID, err))
      {
!       free (prID);
!       prID = NULL;
      }
  
    return prID;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]