/[gnats]/gnats/gnats/file-pr.c
ViewVC logotype

Diff of /gnats/gnats/file-pr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.43 by pdm, Tue Sep 4 18:24:19 2001 UTC revision 1.44 by pdm, Sun Dec 23 20:22:20 2001 UTC
# Line 546  checkIfReply (PR *pr, ErrorDesc *err) Line 546  checkIfReply (PR *pr, ErrorDesc *err)
546    char *prID = NULL;    char *prID = NULL;
547    AdmEntry *cat;    AdmEntry *cat;
548    const char *headerValue;    const char *headerValue;
   char *c;  
549    struct re_pattern_buffer regex;    struct re_pattern_buffer regex;
550    struct re_registers regs;    struct re_registers regs;
551    int i, start, end;    int i, start, end, idstart;
552    char case_fold[256];    char case_fold[256];
553    char *possiblePrNum;    char *possiblePrNum;
554    reg_syntax_t old_syntax;    reg_syntax_t old_syntax;
# Line 569  checkIfReply (PR *pr, ErrorDesc *err) Line 568  checkIfReply (PR *pr, ErrorDesc *err)
568        case_fold[i] = tolower(i);        case_fold[i] = tolower(i);
569      }      }
570    regex.translate = case_fold;    regex.translate = case_fold;
571      
572    /* look for "category/1234" and "category: 1234" */    {
573  #define PAT "(.*re[ \t]*(\\[[0-9]+\\])?:)?[ \t]*([-a-z0-9_+.]*[:/][ \t]*([0-9]+))"      const char *const PAT = "\\<((PR[ \t/])|([-a-z0-9_+.]+)/)([0-9]+)";
574        re_compile_pattern (PAT, strlen (PAT), &regex);
575    re_compile_pattern (PAT, strlen (PAT), &regex);    }
576    i = re_match (&regex, headerValue, strlen (headerValue), 0, &regs);    i = re_match (&regex, headerValue, strlen (headerValue), 0, &regs);
577    regex.translate = NULL;    regex.translate = NULL;
578    regfree (&regex);    regfree (&regex);
# Line 584  checkIfReply (PR *pr, ErrorDesc *err) Line 583  checkIfReply (PR *pr, ErrorDesc *err)
583        return NULL;        return NULL;
584      }      }
585    
586    start = regs.start[3];    start = regs.start[0];
587    end = regs.end[3];    end = regs.end[0];
588      idstart = regs.start[4] - start;
589    
590    free (regs.start);    free (regs.start);
591    free (regs.end);    free (regs.end);
# Line 594  checkIfReply (PR *pr, ErrorDesc *err) Line 594  checkIfReply (PR *pr, ErrorDesc *err)
594    memcpy (possiblePrNum, headerValue + start, end - start);    memcpy (possiblePrNum, headerValue + start, end - start);
595    possiblePrNum[end - start] = '\0';    possiblePrNum[end - start] = '\0';
596    
597    c = strchr (possiblePrNum, '/');    *(possiblePrNum + idstart - 1) = '\0';
   if (c == NULL)  
     {  
       c = strchr (possiblePrNum, ':');  
     }  
   
   if (c != NULL)  
     {  
       *c = '\0';  
598    
599        /* See if the category exists: */    /* See if the category exists: */
600        cat = get_adm_record (CATEGORY (pr->database), possiblePrNum);    cat = get_adm_record (CATEGORY (pr->database), possiblePrNum);
601    
602        /* If no such category, then this is not a reply to a valid    /* If no such category, then this is not a reply to a valid
603         * problem report.  This situtation can arise, for example, when     * problem report.  This situtation can arise, for example, when
604         * someone has the string "OS/2" in their Subject header.     * someone has the string "OS/2" in their Subject header.
605         */     */
606        /* Folks often send in "pr/1234" instead of a valid category */    /* Folks often send in "pr/1234" instead of a valid category */
607        if ((cat != NULL) || (strcasecmp(possiblePrNum, "pr") == 0))    if ((cat != NULL) || (strcasecmp (possiblePrNum, "pr") == 0))
608          {      {
609            /* We only needed res, never cat, so free cat. */        /* We only needed res, never cat, so free cat. */
610            free_adm_entry (cat);        free_adm_entry (cat);
611          prID = xstrdup (possiblePrNum + idstart);
           c++;                          /* skip sep */  
           while (*c != '\0' && isspace ((int) *c))  
             {  
               c++;  
             }  
           prID = xstrdup (c);  
         }  
     }  
   else  
     {  
       prID = xstrdup (possiblePrNum);  
612      }      }
613    
614    free (possiblePrNum);    free (possiblePrNum);

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26