/* mysortu0.c Jim Plank 25 January, 1995 */ /* This program is just like mysort.c, except that it does not print duplicate lines. Since the external list is sorted, you can tell whether a line is a duplicate by checking to see if it is the same as the previous line in the external node list. This program does this. */ #include #include #include "fields.h" #include "rb.h" main() { IS is; char *copy; Rb_node sorted_lines, tmp; int found; sorted_lines = make_rb(); is = new_inputstruct(NULL); while(get_line(is) >= 0) { copy = strdup(is->text1); rb_insert(sorted_lines, copy, NULL); } rb_traverse(tmp, sorted_lines) { if (tmp == rb_first(sorted_lines) || strcmp(tmp->k.key, tmp->c.list.blink->k.key) != 0) printf("%s", tmp->k.key); } }