[TUHS] What is this 1972 C/NB program?
Will Senn via TUHS
tuhs at tuhs.org
Fri May 15 03:46:35 AEST 2026
Ah, duly noted. I read it as old C, but not that old :).
Will
On 5/14/26 08:46, Clem Cole wrote:
> Will. That was the original B/C syntax. Remember that B, like BLISS
> has only one data type: word. So pointers are not special. I suspect
> this is very early C, possibly nB given that it has a char type.
>
>
> Sent from a handheld expect more typos than usual
>
> On Thu, May 14, 2026 at 9:22 AM Will Senn via TUHS <tuhs at tuhs.org> wrote:
>
> it's looking for hyphens as previously explained, but here are a
> couple
> of notes:
>
> int nread 1;
>
> should probably be int nread = 1;
>
> static ibuf;
>
> should probably be static char *ibuf;
>
> or
>
> static int *ibuf;
>
> These look like bugs, but old c was quirky, so I wouldn't swear by it.
>
> Will
>
> On 5/13/26 20:57, Thalia Archibald via TUHS wrote:
> > This mysterious program is in the s1 tape, but has not yet been
> identified.
> > Does it look familiar?
> >
> https://github.com/DoctorWkt/unix-jun72/blob/master/src/cmd/unknown.c
> >
> > It looks like it processes line continuations. It filters files
> to only runs of
> > lines continued with hyphen with the adjoining whitespace
> stripped. Only letters
> > and hyphens are allowed in such lines.
> > [a-zA-Z-]+(-\n[\t\n]*[a-zA-Z-]+)*
> >
> > But there's bugs, so the grammar is actually the following,
> where EOF is
> > included in the negated sets as NUL:
> > ([a-zA-Z]|-[^\n])+(-\n[ \t\n]*[^ \t\n]([a-zA-Z]|-[^\n])*)*
> >
> > Could this be a sort of preprocessor? Perhaps for some sort of a
> configuration
> > language?
> >
> > It reads the list of named files, printing each filename with
> "%s:\n \n" before.
> > The space on an empty line is strange.
> >
> > It uses & and | for conditionals and is typed, characteristic of
> early C and NB.
> >
> > It uses this horrid indentation style, which doesn't match ken
> or dmr.
> > Do you recognize who? Example:
> >
> > while((b[++i] = get(ifile)) != 0)
> > {if((b[i] >= 'a' & b[i] <= 'z') |
> > (b[i] >= 'A' & b[i] <= 'Z'))
> > {c[j++] = b[i];
> > goto cont;
> > }
> >
> > I've taken some liberties to simplify it below. I changed it to
> operate on a
> > single file. And equivalently, I reformatted it, replaced an
> unnecessary buffer
> > with a single char, and simplified control flow. See the above
> link for the
> > original.
> >
> > char c[60];
> >
> > main(argc, argv)
> > int argc;
> > char *argv[];
> > {
> > char b;
> > int isw, j, k;
> >
> > isw = j = 0;
> > while((b = getchar()) != 0) {
> > if((b >= 'a' && b <= 'z') || (b >= 'A' && b <=
> 'Z')) {
> > c[j++] = b;
> > continue;
> > }
> > if(b == '-') {
> > c[j++] = b;
> > if((b = getchar()) != '\n') {
> > c[j++] = b;
> > continue;
> > }
> > if(j == 1) {
> > isw = j = 0;
> > continue;
> > }
> > isw = 1;
> > while(((b = getchar()) == ' ') || (b ==
> '\t') || (b == '\n'))
> > ;
> > c[j++] = b;
> > continue;
> > }
> > if(isw == 1) {
> > k = 0;
> > c[j++] = '\n';
> > while(k < j)
> > putchar(c[k++]);
> > }
> > isw = j = 0;
> > }
> > }
> >
> > Thalia
> >
> >
>
More information about the TUHS
mailing list