/*

dedupe  --crb3 07apr97/08may03/31Mar07

a short and simple filter I brought over from my Turbo-C (DOS)
stuff, where I wrote the original somewhere around 1990.

takes in a (sorted) stream of lines at stdin. emits all but the
duplicates.

/home/crb3/crb3/c/tool/

gcc -o dedupe dedupe.c

*/


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

#define MAXLINE 1024+1

main()
{
  char *px,*py,*ptemp;
  char bufa[MAXLINE+1],bufb[MAXLINE+1];

    px=bufa; py=bufb;

    bufa[0]=0; bufb[0]=0;

    while(fgets(px,MAXLINE,stdin) != NULL)
    {
        if(strcmp(px,py))
            fputs(px,stdout);

        ptemp=py; py=px; px=ptemp;      /* swap pointers. */
    }
}

Grab a
gzipped
copy
here
 
Syntax highlighting using Syntax::Highlight::Engine::Kate