I got this patch from Rob Robertson , to fix a bug with XHDR returning incorrect data for non-existent headers. *** article.c.orig Thu Mar 18 16:04:41 1993 --- article.c Tue Sep 6 09:44:43 1994 *************** *** 29,34 **** --- 29,35 ---- char *Header; int Length; BOOL HasHeader; + BOOL NeedsHeader; } ARTOVERFIELD; *************** *** 38,43 **** --- 39,45 ---- STATIC QIOSTATE *ARTqp; STATIC ARTOVERFIELD *ARTfields; STATIC int ARTfieldsize; + STATIC int ARTfirstfullfield = 0; STATIC SENDDATA SENDbody = { STbody, NNTP_BODY_FOLLOWS_VAL, "body" }; *************** *** 93,102 **** continue; if ((p = strchr(buff, ':')) != NULL) { *p++ = '\0'; ! fp->HasHeader = EQ(p, "full"); } else ! fp->HasHeader = FALSE; fp->Header = COPY(buff); fp->Length = strlen(buff); fp++; --- 95,106 ---- continue; if ((p = strchr(buff, ':')) != NULL) { *p++ = '\0'; ! fp->NeedsHeader = EQ(p, "full"); ! if (ARTfirstfullfield == 0) ! ARTfirstfullfield = fp - ARTfields + 1; } else ! fp->NeedsHeader = FALSE; fp->Header = COPY(buff); fp->Length = strlen(buff); fp++; *************** *** 648,662 **** ARTOVERFIELD *fp; char *next; /* Skip leading headers. */ ! for (fp = &ARTfields[field - 1]; --field >= 0 && *p; p++) if ((p = strchr(p, '\t')) == NULL) return NULL; if (*p == '\0') return NULL; ! if (fp->HasHeader) ! p += fp->Length + 2; /* Figure out length; get space. */ if ((next = strchr(p, '\t')) != NULL) --- 652,677 ---- ARTOVERFIELD *fp; char *next; + fp = &ARTfields[field - 1]; + + if (fp->NeedsHeader) /* we're going to need an exact match */ + field = ARTfirstfullfield; + /* Skip leading headers. */ ! for (; --field >= 0 && *p; p++) if ((p = strchr(p, '\t')) == NULL) return NULL; if (*p == '\0') return NULL; ! if (fp->NeedsHeader) { /* find an exact match */ ! while (strncmp(fp->Header, p, fp->Length) != 0) { ! if ((p = strchr(p, '\t')) == NULL) ! return NULL; ! p++; ! } ! p += fp->Length + 2; ! } /* Figure out length; get space. */ if ((next = strchr(p, '\t')) != NULL) *************** *** 781,788 **** /* Set up place to store headers. */ if (Headers == NULL) { Headers = NEW(ARTOVERFIELD, ARTfieldsize); ! for (hp = Headers, i = ARTfieldsize; --i >= 0; hp++) hp->Length = 0; } for (hp = Headers, i = ARTfieldsize; --i >= 0; hp++) hp->HasHeader = FALSE; --- 796,805 ---- /* Set up place to store headers. */ if (Headers == NULL) { Headers = NEW(ARTOVERFIELD, ARTfieldsize); ! for (fp = ARTfields, hp = Headers, i = ARTfieldsize; --i >= 0; hp++, fp++) { hp->Length = 0; + hp->NeedsHeader = fp->NeedsHeader; + } } for (hp = Headers, i = ARTfieldsize; --i >= 0; hp++) hp->HasHeader = FALSE; *************** *** 813,819 **** continue; } *colon = ':'; ! if (fp->HasHeader) p = line; else /* Skip colon and whitespace, store value. */ --- 830,836 ---- continue; } *colon = ':'; ! if (fp->NeedsHeader) p = line; else /* Skip colon and whitespace, store value. */ *************** *** 887,892 **** --- 904,911 ---- /* Glue all the fields together. */ p = buff + strlen(strcpy(buff, name)); for (hp = Headers, i = ARTfieldsize; --i >= 0; hp++) { + if (hp->NeedsHeader && !hp->HasHeader) + continue; *p++ = '\t'; if (hp->HasHeader) p += strlen(strcpy(p, hp->Header)); *************** *** 1080,1086 **** } Printf("%d %s matches follow.\r\n", NNTP_HEAD_FOLLOWS_VAL, header); ! for (pattern = Glom(&av[3]), i = range.Low; i < range.High; i++) { if (ARTfind(i) < 0) continue; --- 1099,1105 ---- } Printf("%d %s matches follow.\r\n", NNTP_HEAD_FOLLOWS_VAL, header); ! for (pattern = Glom(&av[3]), i = range.Low; i <= range.High; i++) { if (ARTfind(i) < 0) continue;