/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
static const char usage[] =
"[-?\n@(#)$Id: tsort (AT&T Research) 2000-03-23 $\n]"
"[+NAME?tsort - topological sort]"
"[+DESCRIPTION?\btsort\b writes to the standard output a totally ordered"
" list of items consistent with a partial ordering of items contained"
" in the input \afile\a. If \afile\a is omitted then the standard"
" input is read.]"
"[+?The input consists of pairs of items (non-empty strings) separated by"
" blanks. Pairs of different items indicate ordering. Pairs of"
" identical items indicate presence, but not ordering.]"
"\n"
"\n[ file ]\n"
"\n"
"[+SEE ALSO?\bcomm\b(1), \bsort\b(1), \buniq\b(1)]"
;
#include <ast.h>
#include <error.h>
#include <hash.h>
#define NODE_INIT 0
struct List_s;
typedef struct Node_s
{
int state;
} Node_t;
typedef struct List_s
{
} List_t;
static int
{
register List_t* p;
int cycle = 0;
switch (x->state)
{
case NODE_CYCLE:
cycle = 1;
break;
case NODE_INIT:
x->state = NODE_CYCLE;
{
cycle = 1;
break;
}
break;
}
return cycle;
}
static void
{
register int c;
register char* s;
register char* b;
Node_t* x;
List_t* p;
{
do
{
while (*s == ' ' || *s == '\t')
s++;
if (*s == 0)
break;
for (b = s; (c = *s) && c != ' ' && c != '\t'; s++);
*s++ = 0;
if (head)
{
if (head != x)
{
x->prereqs = p;
}
head = 0;
}
else
head = x;
} while (c);
}
if (head)
{
}
else
}
int
{
for (;;)
{
{
case ':':
break;
case '?':
break;
}
break;
}
if (error_info.errors)
return error_info.errors != 0;
}