tom@utcsri.UUCP (Tom Nadas) (10/17/85)
I found a couple of bugs in headings. To explaining what the bugs are and when they happen, here is an example which illustrates the problem. headings -n -h NH << !EOF! .NH Testing .NH 2 More !EOF! If you try this, then you will not get the proper second heading, and the second heading number will be incorrect. This is actually due to three different bugs, which you can discover yourself if you wish. Hints are, a) we are not using the default header, b) there is only one header, c) the heading appears on the following line, and d) the first header is not followed by the number 1. I have made a few small changes that will make the above example run correctly as well as still run the headings.test file correctly. Here is my condensed version of the patches: *** headings.old Wed Oct 16 14:39:54 1985 --- headings.c Wed Oct 16 16:04:39 1985 *************** *** 56,63 (move 2 lines out of if statement) ***** if (Nheaders < 1) /* assume -me macros for no particular reason */ { Header[0] = "sh"; Nheaders = 1; - if (Mindent == 0) - Mindent = 1; } return (optind); --- 56,63 ----- if (Nheaders < 1) /* assume -me macros for no particular reason */ { Header[0] = "sh"; Nheaders = 1; } + if (Mindent == 0) + Mindent = 1; return (optind); *************** *** 78,80 (add a variable) ***** char *ptr; /* work pointer in line */ ! int i; --- 78,80 ----- char *ptr; /* work pointer in line */ ! int i,j; *************** *** 102,111 (change 2 lines, and add 2 lines) ***** if (begins (Header[i], ptr)) { ptr += strlen (Header[i]); ! if ((Nheaders == 1) && (i = atoi (ptr))) /* numbered section */ { while (isspace (*ptr)) ptr++; ! while (!isspace (*ptr)) ptr++; } while (*ptr == '"' || isspace (*ptr)) ptr++; if (*ptr == NULL) /* section heading is on next line */ --- 102,113 ----- if (begins (Header[i], ptr)) { ptr += strlen (Header[i]); ! if ((j = atoi(ptr)) != 0) /* numbered section */ { + i += j; while (isspace (*ptr)) ptr++; ! while (!isspace (*ptr) && *ptr != NULL) ptr++; } + else i++; while (*ptr == '"' || isspace (*ptr)) ptr++; if (*ptr == NULL) /* section heading is on next line */ ------------------------------------------------------------------------------- That's all folks! -- Tom Nadas UUCP: {decvax,linus,ihnp4,uw-beaver,allegra,utzoo}!utcsri!tom CSNET: tom@toronto