+ (void)printf("%s\n", *lp);
+}
+
+typedef struct _tbl {
+ char **list;
+ int cols, *len;
+} TBL;
+#define DEFCOLS 25
+
+maketbl()
+{
+ register TBL *t;
+ register int coloff, cnt;
+ register char *p, **lp;
+ int *lens, maxcols;
+ TBL *tbl;
+ char **cols, *emalloc(), *realloc();
+
+ t = tbl = (TBL *)emalloc(entries * sizeof(TBL));
+ cols = (char **)emalloc((maxcols = DEFCOLS) * sizeof(char *));
+ lens = (int *)emalloc(maxcols * sizeof(int));
+ for (cnt = 0, lp = list; cnt < entries; ++cnt, ++lp, ++t) {
+ for (coloff = 0, p = *lp; cols[coloff] = strtok(p, "\t ");
+ p = NULL)
+ if (++coloff == maxcols) {
+ if (!(cols = (char **)realloc((char *)cols,
+ (u_int)maxcols + DEFCOLS * sizeof(char *))) ||
+ !(lens = (int *)realloc((char *)lens,
+ (u_int)maxcols + DEFCOLS * sizeof(int))))
+ nomem();
+ bzero((char *)lens + maxcols * sizeof(int),
+ DEFCOLS * sizeof(int));
+ maxcols += DEFCOLS;
+ }
+ t->list = (char **)emalloc(coloff * sizeof(char *));
+ t->len = (int *)emalloc(coloff * sizeof(int));
+ for (t->cols = coloff; --coloff >= 0;) {
+ t->list[coloff] = cols[coloff];
+ t->len[coloff] = strlen(cols[coloff]);
+ if (t->len[coloff] > lens[coloff])
+ lens[coloff] = t->len[coloff];
+ }
+ }
+ for (cnt = 0, t = tbl; cnt < entries; ++cnt, ++t) {
+ for (coloff = 0; coloff < t->cols - 1; ++coloff)
+ (void)printf("%s%*s", t->list[coloff],
+ lens[coloff] - t->len[coloff] + 2, " ");
+ (void)printf("%s\n", t->list[coloff]);
+ }