cross reference builder

By Goldman of Chaos -- postmaster CRI-US ·

TML message #7216From bundle 575

Hello All!  Happy day.  I thought through the problem a bit more and
came up with the following 3 programs.  The program is expecting a
datafile in the format of

[SOF]
Subject 1
<tab>Subinfo-1
<tab>Subinfo-2
  .
  .
  .
<tab>Subinfo-n

Subject 2
<tab>Subinfo-1
<tab>Subinfo-2
  .
  .
  .
<tab>Subinfo-n
[EOF]

Note that '[SOF]' is start of file.  That isn't really in the file.
'[EOF]' is end of file.  '<tab>' is for the tab character, and blank
lines seperate the data bits.

The first program is the shell script that runs it.




- ----- cut here ----- cut here -----
build_list*	build_list.c	cross-01.txt	do_ref*		spit_list*
#!/bin/sh
#
#
# This program will build a cross reference for datafiles.
#

BIN1=build_list
BIN2=spit_list

cat $* | ${BIN1} | sort -uf | awk -F'|' -f ${BIN2}
- ----- cut here ----- cut here -----




The next program is the source for build_list.  Build it
with your favorite compiler:



- ----- cut here ----- cut here -----
/*
  part one of the cross referencing program.
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define MAX_ENTRIES 5000


main ()
{
  char *current;
  char  line[MAX_ENTRIES],
        header[MAX_ENTRIES];

  strcpy (header, "XXXXX");
  while ((fgets (line, MAX_ENTRIES, stdin)) != NULL) {
    if (strlen(line) != 1) {
      while ((current = strchr(line, '\n')) != NULL) {
        *current = '\000';
      }
      if (line[0] != '\t') {
        strcpy (header, line);
      }
      else {
        current = line;
        current++;
        strcpy (line, current);
        printf ("%s|%s\n", header, line);
        printf ("%s|%s\n", line, header);
      }
    }
  }
}
- ----- cut here ----- cut here -----




finally there is the awk program spit_list



- ----- cut here ----- cut here -----
BEGIN {
  LAST="XXXXXX"
}

{
  if ( $1 != LAST ) {
    print " "
    print "------------------------------------"
    print " "
    print $1
    LAST = $1;
  }
  print "	" $2
}
- ----- cut here ----- cut here -----

eventually I'll modify spit_list to generate psroff output; however,
I'm happy with it as it stands.  This should generate really nice
patterns of data.  If you run my datfile from a few days ago though
the shell script, you'll see what I mean.  I'm very open to
suggestions on improvements.  If anyone takes the time to put the
three programs together as one programme, I'd like to see the result.

Matt

P.S.  If anyone takes the time to make cross reference entries, send
them to me and I'll add them to my database.

MD 'Doc' Goldman
- --
Matthew Goldman  E-mail: [email removed] Work: [phone removed]

My day today? Nothing major, just Xenon base gone, Scorpio gone,
Tarrant dead, Tarrant alive and then I found out Blake sold us out.