]> mj.ucw.cz Git - misc.git/commitdiff
Probírka starých programů...
authorMartin Mares <mj@ucw.cz>
Sun, 11 Jun 2017 20:32:11 +0000 (22:32 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 11 Jun 2017 20:32:11 +0000 (22:32 +0200)
19 files changed:
ant.c [deleted file]
buckets.c [deleted file]
callback.c [deleted file]
censor.p [deleted file]
count.c [deleted file]
fortcmp.c [deleted file]
heapsort.p [deleted file]
hobble.c [deleted file]
math.c [deleted file]
oggtest.c [deleted file]
pipprox.c [deleted file]
pstopsfix [deleted file]
puzzle.c [deleted file]
tla [deleted file]
tla.db [deleted file]
trains.c [deleted file]
un602.c [deleted file]
unword.c [deleted file]
whatsit.c [deleted file]

diff --git a/ant.c b/ant.c
deleted file mode 100644 (file)
index 0749a29..0000000
--- a/ant.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- *  A simple ant-ology of genetic algorithms.
- *
- *  mj@ucw.cz, Discord YOLD 3166
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define NSTATES 16
-#define NMARKS 4
-#define SENSE_FOOD
-#ifdef SENSE_FOOD
-#define NTYPES 3
-#else
-#define NTYPES 8
-#endif
-#define NWAYS 1
-#define NSLOTS (NMARKS*NTYPES*NWAYS)
-#define SLOT(m,t,w) (((m)*NTYPES+(t))*NWAYS+(w))
-
-struct slot {
-  unsigned char op, mark, state;
-};
-
-#define OP_NOP 0
-#define OP_LEFT 1
-#define OP_RIGHT 2
-#define OP_UTB 3
-#define OP_MAX 4
-
-struct state {
-  struct slot slots[NSLOTS];
-};
-
-struct automaton {
-  struct state states[NSTATES];
-  int fitness;
-};
-
-#if 0
-#define XSIZE 10
-#define YSIZE 10
-#define XSTART 1
-#define YSTART 1
-
-char *maze =
-"##########"
-"#.#$#....#"
-"#.#.#$$$.#"
-"#.#.#$$$.#"
-"#.#.#$$$.#"
-"#.#.####.#"
-"#.#...$..#"
-"#.##.#####"
-"#.$......#"
-"##########"
-;
-#else
-#define XSIZE 34
-#define YSIZE 34
-#define XSTART 1
-#define YSTART 1
-char *maze =
-"##################################"
-"#.$$$............................#"
-"#...$............................#"
-"#...$.....................$$$....#"
-"#...$....................$....$..#"
-"#...$....................$....$..#"
-"#...$$$$.$$$$$........$$.........#"
-"#............$................$..#"
-"#............$.......$...........#"
-"#............$.......$...........#"
-"#............$.......$........$..#"
-"#....................$...........#"
-"#............$...................#"
-"#............$................$..#"
-"#............$.......$...........#"
-"#............$.......$.....$$$...#"
-"#.................$.....$........#"
-"#................................#"
-"#............$...................#"
-"#............$...$.......$.......#"
-"#............$...$..........$....#"
-"#............$...$...............#"
-"#............$...$...............#"
-"#............$.............$.....#"
-"#............$..........$........#"
-"#...$$..$$$$$....$...............#"
-"#.$..............$...............#"
-"#.$..............$...............#"
-"#.$......$$$$$$$.................#"
-"#.$.....$........................#"
-"#.......$........................#"
-"#..$$$$..........................#"
-"#................................#"
-"##################################"
-;
-
-#endif
-
-#define MI(a,b) ((b)*XSIZE+(a))
-char mazec[XSIZE*YSIZE];
-char *types = "$#.012345";
-
-#define POPSIZE 100
-
-struct automaton autpool[POPSIZE];
-struct automaton *pop[POPSIZE];
-
-void
-maze_init(void)
-{
-  int i;
-
-  puts("Initializing maze");
-  for(i=0; i<XSIZE*YSIZE; i++)
-    {
-      char *z = strchr(types, maze[i]);
-      if (!z) { fprintf(stderr, "Maze bug\n"); exit(1); }
-      mazec[i] = z - types;
-    }
-}
-
-void
-aut_gen_random(struct automaton *aut)
-{
-  int i, j;
-
-  for(i=0; i<NSTATES; i++)
-    for(j=0; j<NSLOTS; j++)
-      {
-       struct slot *s = &aut->states[i].slots[j];
-       s->op = random() % OP_MAX;
-       s->state = random() % NSTATES;
-       s->mark = random() % NMARKS;
-      }
-}
-
-void
-show(char *z)
-{
-  int i, j;
-  int x = 0;
-  for(i=0; i<YSIZE; i++)
-    {
-      for(j=0; j<XSIZE; j++)
-       putchar(types[(int)z[x++]]);
-      putchar('\n');
-    }
-}
-
-int
-fitness(struct automaton *aut, int flag)
-{
-  char tmp[XSIZE*YSIZE];
-  int state = 0;
-  int x = XSTART;
-  int y = YSTART;
-  int d = 0;
-  static int dx[4] = { 0, -1, 0, 1 };
-  static int dy[4] = { 1, 0, -1, 0 };
-  int energy = 50;
-  int bonus = 1;
-
-  memcpy(tmp, mazec, XSIZE*YSIZE);
-  while (energy > 0)
-    {
-      int way = random() % NWAYS;
-      int here = tmp[MI(x,y)];
-      int mark = (here < 3) ? 0 : here-3;
-      int ahead = tmp[MI(x+dx[d],y+dy[d])];
-      int right = tmp[MI(x+dx[(d+1)%4],y+dy[(d+1)%4])];
-      int left = tmp[MI(x+dx[(d+3)%4],y+dy[(d+3)%4])];
-#ifdef SENSE_FOOD
-      int view = (ahead >= 2) ? 2 : ahead;
-#else
-      int view = ((ahead==1)?4:0) | ((left==1)?2:0) | ((right==1)?1:0);
-#endif
-      struct slot *s = &aut->states[state].slots[SLOT(mark, view, way)];
-      tmp[MI(x,y)] = s->mark + 3;
-      bonus++;
-      energy--;
-      switch (s->op)
-       {
-       case OP_NOP:    break;
-       case OP_LEFT:   d = (d+3) % 4; break;
-       case OP_RIGHT:  d = (d+1) % 4; break;
-       case OP_UTB:    d = (d+2) % 4; break;
-       }
-      ahead = tmp[MI(x+dx[d],y+dy[d])];
-      switch (ahead)
-       {
-       case 0:         energy+=10; bonus+=100; /* food */
-       default:        x+=dx[d]; y+=dy[d]; break;  /* empty */
-       case 1:         energy-=5; break; /* wall */
-       }
-      state = s->state;
-    }
-  if (flag)
-    show(tmp);
-  return bonus;
-}
-
-void
-pop_init(void)
-{
-  int i;
-
-  for(i=0; i<POPSIZE; i++)
-    {
-      aut_gen_random(&autpool[i]);
-      pop[i] = &autpool[i];
-    }
-}
-
-int
-fcmp(struct automaton **a, struct automaton **b)
-{
-  int fa = (*a)->fitness;
-  int fb = (*b)->fitness;
-
-  return (fa < fb) ? -1 : (fa > fb) ? 1 : 0;
-}
-
-void
-mutate(struct automaton *a)
-{
-  int state, slot, i;
-  struct slot *s;
-
-  for(i=0; i<40; i++)
-    {
-      state = random() % NSTATES;
-      slot = random() % NSLOTS;
-      s = &a->states[state].slots[slot];
-      s->op = random() % OP_MAX;
-      s->state = random() % NSTATES;
-      s->mark = random() % NMARKS;
-    }
-}
-
-void
-crossover(struct automaton *a, struct automaton *b)
-{
-  int marks[NMARKS], types[NTYPES], ways[NWAYS], slots[NSLOTS];
-  int i, j, k;
-
-  if (a == b)
-    return;
-  for(i=0; i<NMARKS; i++)
-    marks[i] = random() % 2;
-  for(i=0; i<NTYPES; i++)
-    types[i] = random() % 2;
-  for(i=0; i<NWAYS; i++)
-    ways[i] = random() % 2;
-  for(i=0; i<NMARKS; i++)
-    for(j=0; j<NTYPES; j++)
-      for(k=0; k<NWAYS; k++)
-       slots[SLOT(i,j,k)] = marks[i] && types[j] && ways[k];
-  for(i=0; i<NSTATES; i++)
-    if (random() % 2)
-      for(j=0; j<NSLOTS; j++)
-       if (slots[j])
-         {
-           struct slot z;
-           z = a->states[i].slots[j];
-           a->states[i].slots[j] = b->states[i].slots[j];
-           b->states[i].slots[j] = z;
-         }
-}
-
-struct automaton *
-rgenom(struct automaton **x, int n, int t)
-{
-  int z = random() % t;
-  int k = 0;
-  int i = 0;
-
-  while (k <= z && n--)
-    k += x[i++]->fitness;
-  return x[i-1];
-}
-
-void
-step(void)
-{
-  int i, total, death;
-
-  for(i=0; i<POPSIZE; i++)
-    {
-      struct automaton *a = pop[i];
-      a->fitness = (fitness(a,0) + fitness(a,0) + fitness(a,0)) / 3;
-    }
-  qsort(pop, POPSIZE, sizeof(struct automaton *), (int(*)(const void *,const void *)) fcmp);
-  for(i=0; i<POPSIZE; i++)
-    {
-      struct automaton *a = pop[i];
-      //      printf("%d: %d\n", i, a->fitness);
-      total += a->fitness;
-    }
-  fitness(pop[POPSIZE-1], 1);
-  printf("best=%d worst=%d\n", pop[POPSIZE-1]->fitness, pop[0]->fitness);
-
-  total = 0;
-  death = POPSIZE/2;
-  for(i=death; i<POPSIZE; i++)
-    total += pop[i]->fitness;
-  for(i=0; i<death; i++)
-    {
-      struct automaton *a = pop[i];
-      struct automaton *x = rgenom(pop+death, POPSIZE-death, total);
-      memcpy(a, x, sizeof(struct automaton));
-    }
-
-  for(i=0; i<POPSIZE; i++)
-    {
-      struct automaton *a = pop[i];
-      int what = random() % 1024;
-      //      printf("%d %d\n", i, what);
-      if (what < 50)
-       mutate(a);
-      else if (what < 100)
-       crossover(a, rgenom(pop+death, POPSIZE-death, total));
-    }
-}
-
-int
-main(void)
-{
-  int gen = 0;
-
-  maze_init();
-  pop_init();
-  for(;;)
-    {
-      step();
-      printf("gen=%d\n", gen++);
-      //      sleep(1);
-    }
-  //  srandom(time(NULL));
-  return 0;
-}
diff --git a/buckets.c b/buckets.c
deleted file mode 100644 (file)
index f5f955d..0000000
--- a/buckets.c
+++ /dev/null
@@ -1,107 +0,0 @@
-#include <stdio.h>
-
-#define MAX 12         // actually, it's 1 more than max
-#define NST (MAX*MAX*MAX)
-
-int status[NST], queue[NST], back[NST], qr, qw;
-int capa[3], goal[MAX], gback[MAX];
-
-#define ENCODE(i,j,k) ((i)*MAX*MAX+(j)*MAX+(k))
-#define DECODE(i,j,k,x) (i)=(x)/(MAX*MAX), (j)=(x)/MAX%MAX, (k)=(x)%MAX
-
-static void go(int x, int *t)
-{
-  // printf("\t-> %d %d %d\n", t[0], t[1], t[2]);
-  int y = ENCODE(t[0], t[1], t[2]);
-  if (status[y] < 0)
-    {
-      status[y] = status[x] + 1;
-      queue[qw++] = y;
-      back[y] = x;
-    }
-}
-
-static void search(void)
-{
-  for (int i=1; i<NST; i++)
-    status[i] = -1;
-  for (int i=0; i<MAX; i++)
-    goal[i] = -1;
-  status[0] = 0;
-  queue[0] = 0;
-  qr = 0;
-  qw = 1;
-  while (qr < qw)
-    {
-      int x = queue[qr++];
-      int t[3];
-      DECODE(t[0],t[1],t[2],x);
-      // printf("%5d %d,%d,%d (%d)\n", x, t[0], t[1], t[2], status[x]);
-      for (int i=0; i<3; i++)
-       if (goal[t[i]] < 0)
-         {
-           goal[t[i]] = status[x];
-           gback[t[i]] = x;
-         }
-      for (int i=0; i<3; i++)
-       {
-         int z = t[i];
-         t[i] = 0;
-         go(x, t);
-         t[i] = capa[i];
-         go(x, t);
-         t[i] = z;
-       }
-      for (int i=0; i<3; i++)
-       for (int j=0; j<3; j++)
-         if (i != j)
-           {
-             int r = capa[j] - t[j];
-             if (r > t[i])
-               r = t[i];
-             t[i]-=r; t[j]+=r;
-             go(x, t);
-             t[i]+=r; t[j]-=r;
-           }
-    }
-}
-
-int main(void)
-{
-#if 1
-  for (int f=0; f<NST; f++)
-    {
-      DECODE(capa[0], capa[1], capa[2], f);
-      if (!capa[0] || !capa[1] || !capa[2]
-         || (capa[0] == capa[1] || capa[0] == capa[2] || capa[1] == capa[2]) && 1
-         || !(capa[0] <= capa[1] && capa[1] <= capa[2])
-         )
-       continue;
-      printf("%d,%d,%d: ", capa[0], capa[1], capa[2]);
-      search();
-      int best = 0;
-      for (int i=0; i<MAX; i++)
-       if (goal[i] > goal[best])
-         best = i;
-      int reach = 0;
-      for (int i=0; i<NST; i++)
-       if (status[i] >= 0)
-         reach++;
-      printf("%2d (%d) r=%d\n", goal[best], best, reach);
-    }
-#else
-  capa[0] = 8;
-  capa[1] = 5;
-  capa[2] = 3;
-  search();
-  int r = gback[4];
-  while (r > 0)
-    {
-      int a,b,c;
-      DECODE(a,b,c,r);
-      printf("%d,%d,%d\n", a,b,c);
-      r = back[r];
-    }
-#endif
-  return 0;
-}
diff --git a/callback.c b/callback.c
deleted file mode 100644 (file)
index 1c62ccb..0000000
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- *             Modem Call Back
- *
- *             (c) 1995 Martin Mares
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <termios.h>
-#include <signal.h>
-#include <utmp.h>
-#include <sys/wait.h>
-#include <sys/file.h>
-
-#define MODEM_PORT "/dev/cua3"
-
-int modem_handle;
-int alarm_got;
-int termios_backed_up;
-int modem_active;
-struct termios old_termios;
-
-struct termios new_termios = {
-       IGNBRK | IGNPAR,
-       0,
-       0,
-       0,
-       N_TTY,
-       { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
-       };
-
-void err(char *);
-
-void
-set_timeout(int n)
-{
-       alarm_got = 0;
-       alarm(n);
-}
-
-void
-delay(int n)
-{
-       set_timeout(n);
-       do pause(); while (!alarm_got);
-}
-
-void
-pulse_dtr(void)
-{
-int o = new_termios.c_cflag;
-       fprintf(stderr, "Pulsing DTR\n");
-       new_termios.c_cflag &= ~CBAUD;
-       if (tcsetattr(modem_handle, TCSANOW, &new_termios))
-               err("Unable to lower DTR");
-       delay(2);
-       new_termios.c_cflag = o;
-       if (tcsetattr(modem_handle, TCSANOW, &new_termios))
-               err("Unable to raise DTR");
-}
-
-void
-send(char *s)
-{
-       fprintf(stderr, "Sending %s", s);
-       write(modem_handle, s, strlen(s));
-}
-
-int
-wait_for(char *c, int tim)
-{
-char *s = c;
-char b;
-int l;
-       fprintf(stderr,"Waiting %d sec for %s\n", tim, c);
-       while (*s)
-               {
-               set_timeout(tim);
-               l = read(modem_handle, &b, 1);
-               if (!l)
-                       err("EOF");
-               if (l == -1)
-                       {
-                       if (errno == EINTR)
-                               return 0;
-                       else
-                               err("Read error");
-                       }
-               fprintf(stderr, "Got %c\n", b);
-               if (b == *s)
-                       s++;
-               else
-                       s = c;
-               }
-       alarm(0);
-       return 1;
-}
-
-void
-cmd(char *s)
-{
-       send(s);
-       if (!wait_for("OK",5))
-               err("Timeout");
-}
-
-void
-drain(void)
-{
-char buf[256];
-       if (!fcntl(modem_handle, F_SETFL, O_NONBLOCK))
-               {
-               while (read(modem_handle, buf, 256) > 0) ;
-               fcntl(modem_handle, F_SETFL, 0);
-               }
-}
-
-void
-modem_init(char *name)
-{
-       modem_handle = open(name, O_RDWR);
-       if (modem_handle < 0)
-               err("Unable to open modem device");
-       if (tcgetattr(modem_handle, &old_termios))
-               err("Unable to fetch old termios");
-       termios_backed_up = 1;
-       new_termios.c_cflag = (old_termios.c_cflag | CRTSCTS) & ~HUPCL;
-       if (!(new_termios.c_cflag & CBAUD))
-               new_termios.c_cflag |= B19200;
-       if (tcsetattr(modem_handle, TCSANOW, &new_termios))
-               err("Unable to set termios");
-       modem_active = 1;
-       pulse_dtr();
-       send("ATZ\r\n");
-       delay(2);
-       drain();
-       cmd("ATE0M1Q0\r\n");
-}
-
-void
-err2(char *text)
-{
-       perror(text);
-}
-
-void
-cleanup(void)
-{
-       if (modem_handle < 0)
-               return;
-       fprintf(stderr, "Cleanup.\n");
-       if (modem_active)
-               {
-               modem_active = 0;
-               pulse_dtr();
-               send("ATZ\n");
-               delay(1);
-               pulse_dtr();
-               }
-       if (termios_backed_up)
-               {
-               termios_backed_up = 0;
-               if (tcsetattr(modem_handle, TCSANOW, &old_termios))
-                       err2("Termios cannot be restored");
-               }
-       fprintf(stderr, "Done.\n");
-       close(modem_handle);
-       modem_handle = -1;
-}
-
-void
-sig_err(int n)
-{
-       fprintf(stderr, "Caught fatal signal %d -- aborting !\n", n);
-       cleanup();
-       exit(1);
-}
-
-void
-sig_alarm(int n)
-{
-       alarm_got = 1;
-       signal(SIGALRM, sig_alarm);
-}
-
-void
-signal_init(void)
-{
-int i;
-       for (i=0; i<32; i++)
-               signal(i, sig_err);
-       signal(SIGALRM, sig_alarm);
-}
-
-void
-err(char *txt)
-{
-       err2(txt);
-       cleanup();
-       exit(1);
-}
-
-int
-connect(char *nr)
-{
-char buf[256];
-int i;
-       sprintf(buf, "atd%s\r\n", nr);
-       send(buf);
-       i = wait_for("CONNECT", 60);
-       delay(1);
-       drain();
-       return i;
-}
-
-struct termios tios = {
-       ICRNL | IXON | IXOFF,
-       OPOST | ONLCR,
-       0,
-       ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE,
-       N_TTY,
-       { 3, 0x1c, 0x7f, 0x15, 4, 0, 1, 0, 0x11, 0x13, 0x1a, 0, 0x12, 0x0f, 0x17,
-               0x16, 0 }
-       };
-
-void
-okay(void)
-{
-int pid, i, wt;
-struct utmp ut;
-char *port = MODEM_PORT;
-       pid = fork();
-       if (pid < 0)
-               err("Cannot fork()");
-       if (!pid)
-               {
-               setsid();
-               for (i=0; i<3; i++)
-                       {
-                       close(i);
-                       open(port, O_RDWR);
-                       }
-               tios.c_cflag = new_termios.c_cflag | HUPCL;
-               tcsetattr(0, TCSANOW, &tios);
-               utmpname(_PATH_UTMP);
-               memset(&ut, 0, sizeof(ut));
-               strcpy(ut.ut_user, "LOGIN");
-               strcpy(ut.ut_line, port+5);
-               strncpy(ut.ut_id, ut.ut_line + 3, sizeof(ut.ut_id));
-               time(&ut.ut_time);
-               ut.ut_type = LOGIN_PROCESS;
-               ut.ut_pid = getpid();
-               pututline(&ut);
-               endutent();
-               wt = open(_PATH_WTMP, O_APPEND|O_WRONLY);
-               if (wt >= 0)
-                       {
-                       flock(wt, LOCK_EX);
-                       write(wt, &ut, sizeof(ut));
-                       flock(wt, LOCK_UN);
-                       close(wt);
-                       }
-               execl("/usr/sbin/callback-login", "/usr/sbin/callback-login", NULL);
-               }
-       else
-               {
-               wait(&i);
-               i = open(MODEM_PORT, O_RDWR);
-               close(modem_handle);
-               modem_handle = i;
-               if (modem_handle >= 0)
-                       tcsetattr(modem_handle, TCSANOW, &new_termios);
-               }
-}
-
-void
-main(int argc, char **argv)
-{
-char *dest;
-int i;
-       if (geteuid())
-               {
-               fprintf(stderr, "Must be run by root!\n");
-               exit(1);
-               }
-       if (getuid() != 1000 && getuid())
-               {
-               fprintf(stderr,"Only mj is allowed to call this utility!\n");
-               exit(1);
-               }
-       if (argc != 2)
-               {
-               fprintf(stderr,"Usage: callback <number>\n");
-               exit(1);
-               }
-       dest = argv[1];
-       signal_init();
-       for(i=0;i<3;i++)
-               {
-               modem_init(MODEM_PORT);
-               if (connect(dest))
-                       {
-                       fprintf(stderr, "Connected...\n");
-                       okay();
-                       fprintf(stderr, "Disconnecting...\n");
-                       cleanup();
-                       return;
-                       }
-               cleanup();
-               fprintf(stderr, "Retrying...\n");
-               }
-       fprintf(stderr, "Failed.\n");
-       exit(1);
-}
diff --git a/censor.p b/censor.p
deleted file mode 100644 (file)
index 4a036eb..0000000
--- a/censor.p
+++ /dev/null
@@ -1,50 +0,0 @@
-program censor;
-
-var w0,s01,w1,s12,w2,s23:string[255];
-    c:char;
-
-procedure shift;
-var i,j,k:integer;
-    t:string[255];
-begin
-   t:=w1;
-   for i:=1 to length(t) do
-      if t[i]='o' then begin
-         if w0='' then
-           j:=length(w2)
-        else if (w2='') or (length(w0)<length(w2)) then
-           j:=length(w0)
-        else
-           j:=length(w2);
-         for k:=0 to j do begin
-           if k<i then w1[i-k]:='*'
-           else if w0<>'' then w0[length(w0)-(k-i)]:='*';
-            if k<=length(w1)-i then w1[i+k]:='*'
-           else if w2<>'' then w2[k-(length(w1)-i)]:='*';
-        end;
-      end;
-   write(w0);
-   for i:=1 to length(s01) do
-      if s01[i]='n' then writeln
-                    else write(s01[i]);
-   w0:=w1; s01:=s12; w1:=w2; s12:=s23;
-   w2:=''; s23:='';
-end;
-
-begin
-   w0:=''; s01:=''; w1:=''; s12:=''; w2:=''; s23:='';
-   while not eof(input) do begin
-      if eoln(input) then begin
-         readln;
-         s23:=s23+'n';
-      end else begin
-         read(c);
-        if (c >= 'a') and (c <= 'z') or (c >= 'A') and (c <= 'Z') then begin
-           if s23<>'' then shift;
-           w2 := w2+c;
-        end else
-           s23 := s23+c;
-      end;
-   end;
-   shift; shift; shift;
-end.
diff --git a/count.c b/count.c
deleted file mode 100644 (file)
index 4377eb7..0000000
--- a/count.c
+++ /dev/null
@@ -1,76 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-struct state {
-       struct state *fwd[256], *back, *qnext, *qprev;
-       char *out;
-       int count;
-};
-
-struct state root, *head, *tail;
-
-struct state *step(struct state *s, int c)
-{
-       while (s) {
-               if (s->fwd[c])
-                       return s->fwd[c];
-               s = s->back;
-       }
-       return &root;
-}
-
-void insert(char *x)
-{
-       struct state *s = &root;
-       int c;
-       for (char *y = x; c=*y++; ) {
-               if (!s->fwd[c])
-                       s->fwd[c] = calloc(1, sizeof(struct state));
-               s = s->fwd[c];
-       }
-       s->out = x;
-}
-
-void build(void)
-{
-       struct state *s;
-       head = tail = &root;
-       while (head) {
-               for (int c=0; c<256; c++)
-                       if (s = head->fwd[c]) {
-                               s->back = step(head->back, c);
-                               tail->qnext = s;
-                               s->qprev = tail;
-                               tail = s;
-                       }
-               head = head->qnext;
-       }
-}
-
-void run(void)
-{
-       struct state *s = &root;
-       for (int c; (c = getchar()) != EOF;) {
-               s = step(s, c);
-               s->count++;
-       }
-}
-
-void count(void)
-{
-       for (struct state *s=tail; s != &root; s=s->qprev) {
-               s->back->count += s->count;
-               if (s->out)
-                       printf("%6d %s\n", s->count, s->out);
-       }
-}
-
-int main(int argc, char **argv)
-{
-       for (int i=1; i<argc; i++)
-               insert(argv[i]);
-       build();
-       run();
-       count();
-       return 0;
-}
diff --git a/fortcmp.c b/fortcmp.c
deleted file mode 100644 (file)
index ee45606..0000000
--- a/fortcmp.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- *             Fortune Cookie Comparison
- *
- *             (c) 1996 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void
-die(char *msg)
-{
-       fputs(msg, stderr);
-       exit(1);
-}
-
-static void *
-xmalloc(unsigned i)
-{
-       void *k = malloc(i);
-
-       if (!k)
-               die("Out of memory!\n");
-       return k;
-}
-
-#define HASH 16384
-
-struct woord {
-       struct woord *next;
-       unsigned id;
-       char w[1];
-       };
-
-static struct woord *words[HASH];
-static unsigned lastid;
-
-static struct woord *
-findword(char *wd)
-{
-       unsigned h;
-       char *c;
-       struct woord *p;
-
-       c = wd;
-       h = strlen(wd);
-       while (*c)
-               h = 13*h + *c++;
-       h = h & (HASH-1);
-       for(p = words[h]; p; p = p->next)
-               if (!strcasecmp(p->w, wd))
-                       return p;
-       p = xmalloc(sizeof(struct woord) + strlen(wd));
-       p->next = words[h];
-       words[h] = p;
-       strcpy(p->w, wd);
-       p->id = lastid++;
-}
-
-#define MFL 4096
-#define FHASH 16384
-
-struct fortune {
-       struct fortune *next;
-       char *fn;
-       unsigned line;
-       unsigned count;
-       unsigned words[0];
-       };
-
-static struct fortune *forts[FHASH];
-
-static int
-comp(unsigned *p, unsigned *q)
-{
-       if (*p < *q)
-               return -1;
-       else if (*p > *q)
-               return 1;
-       else
-               return 0;
-}
-
-static void
-addfort(char *fn, unsigned line, unsigned *fort, unsigned len)
-{
-       unsigned i, h;
-       struct fortune *foo;
-
-//     printf("Adding %s:%d (%d)\n", fn, line, len);
-       qsort(fort, len, sizeof(unsigned), (void *) comp);
-       h = len;
-       for(i=0; i<len; i++)
-               h = 13*h + fort[i];
-       h &= (FHASH-1);
-       for(foo=forts[h]; foo; foo=foo->next)
-               if (len == foo->count && !memcmp(fort, foo->words, sizeof(unsigned)*len))
-                       {
-                               printf("Possible DUP %s:%d with %s:%d\n", fn, line, foo->fn, foo->line);
-                               return;
-                       }
-       foo = xmalloc(sizeof(struct fortune) + sizeof(unsigned)*len);
-       foo->next = forts[h];
-       forts[h] = foo;
-       foo->fn = fn;
-       foo->line = line;
-       foo->count = len;
-       memcpy(foo->words, fort, len * sizeof(unsigned));
-}
-
-static void
-dofort(char *fn)
-{
-       struct woord *name = findword(fn);
-       struct woord *wo;
-       FILE *f;
-       char line[256];
-       unsigned forty[MFL];
-       unsigned posn, lino, cnt, xxx;
-       char *c, *d, e;
-
-       printf("%s...", fn);
-       fflush(stdout);
-       f = fopen(fn, "r");
-       if (!f)
-               die("open failed!\n");
-       xxx = lino = posn = cnt = 0;
-       for(;;)
-               {
-                       lino++;
-                       fgets(line, 256, f);
-                       if (feof(f))
-                               break;
-                       c = strchr(line, '\n');
-                       if (c)
-                               *c = 0;
-                       if (line[0] == '%' && !line[1])
-                               {
-                                       if (cnt)
-                                               {
-                                                       addfort(name->w, posn, forty, cnt);
-                                                       xxx++;
-                                               }
-                                       cnt = 0;
-                               }
-                       else
-                               {
-                                       if (!cnt)
-                                               posn = lino;
-                                       c = line;
-                                       for(;;)
-                                               {
-                                                       while (*c && (*c < 'A' || *c > 'Z') && (*c < 'a' || *c > 'z') && (*c < '0' || *c > '9'))
-                                                               c++;
-                                                       if (!*c)
-                                                               break;
-                                                       d = c;
-                                                       while ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9'))
-                                                               {
-                                                                       *c = toupper(*c);
-                                                                       c++;
-                                                               }
-                                                       e = *c;
-                                                       *c = 0;
-                                                       wo = findword(d);
-                                                       *c = e;
-                                                       if (cnt >= MFL)
-                                                               die("Too long!\n");
-                                                       forty[cnt++] = wo->id;
-                                               }
-                               }
-               }
-       fclose(f);
-       printf("%d lines, %d fortunes\n", lino, xxx);
-}
-
-int
-main(int argc, char **argv)
-{
-       if (argc < 2)
-               die("Nothing to do.\n");
-       while (argc > 1)
-               {
-                       dofort(argv[1]);
-                       argc--;
-                       argv++;
-               }
-       return 0;
-}
diff --git a/heapsort.p b/heapsort.p
deleted file mode 100644 (file)
index edf9c2e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-const max=100;
-
-var A:array [1..max] of integer;
-    i,N:integer;
-
-procedure bubbledown(n,i:integer);
-var j,x:integer;
-begin
-   while 2*i <= n do begin
-      j := 2*i;
-      if (j<n) and (A[j+1] > A[j]) then inc(j);
-      if A[i] >= A[j] then break;
-      x := A[i];
-      A[i] := A[j];
-      A[j] := x;
-      i := j;
-   end;
-end;
-
-procedure heapsort;
-var i,x:integer;
-begin
-   for i:=N div 2 downto 1 do
-      bubbledown(N,i);
-   for i:=N downto 2 do begin
-      x := A[1];
-      A[1] := A[i];
-      A[i] := x;
-      bubbledown(i-1,1);
-   end;
-end;
-
-begin
-   read(N);
-   for i:=1 to N do read(A[i]);
-   heapsort;
-   for i:=1 to N do write(A[i], ' ');
-   writeln;
-end.
diff --git a/hobble.c b/hobble.c
deleted file mode 100644 (file)
index c233ba5..0000000
--- a/hobble.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- *             The Hobbling Horse Problem
- *
- *             (c) 1996 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-
-#define MAX 35
-
-signed char dist[MAX][MAX][2];
-
-signed char queue[15*MAX*MAX];
-
-int M, N, x0, y0, x1, y1;
-
-struct delta { int dx, dy; };
-
-struct delta king[] = { {-1,-1}, {0,-1}, {1,-1}, {-1,0}, {1,0}, {-1,1}, {0,1}, {1,1} };
-struct delta horse[] = { {-1,-2}, {-1,2}, {-2,-1}, {2,-1}, {-2,1}, {2,1}, {1,-2}, {1,2} };
-
-void
-fill(void)
-{
-  int qr, qw, x, y, z, k, xx, yy, rho;
-  struct delta *d;
-
-  memset(dist, 99, sizeof(dist));
-  queue[0] = x0;
-  queue[1] = y0;
-  queue[2] = 0;
-  dist[x0][y0][0] = 0;
-  qr = 0;
-  qw = 3;
-  while (qr < qw)
-       {
-         x = queue[qr++];
-         y = queue[qr++];
-         z = queue[qr++];
-         if (z)
-               {
-                 d = king;
-                 k = sizeof(king) / sizeof(struct delta);
-               }
-         else
-               {
-                 d = horse;
-                 k = sizeof(horse) / sizeof(struct delta);
-               }
-         rho = dist[x][y][z] + 1;
-         z = !z;
-         while (k--)
-               {
-                 xx = x + d->dx;
-                 yy = y + d->dy;
-                 if (xx >= 0 && xx < M && yy >= 0 && yy < N && dist[xx][yy][z] > rho)
-                       {
-                         dist[xx][yy][z] = rho;
-                         queue[qw++] = xx;
-                         queue[qw++] = yy;
-                         queue[qw++] = z;
-                       }
-                 d++;
-               }
-       }
-}
-
-void
-bug1(void)
-{
-  int qr, qw, x, y, z, k, xx, yy, rho;
-  struct delta *d;
-
-  memset(dist, 99, sizeof(dist));
-  queue[0] = x0;
-  queue[1] = y0;
-  dist[x0][y0][0] = 0;
-  qr = 0;
-  qw = 2;
-  while (qr < qw)
-       {
-         x = queue[qr++];
-         y = queue[qr++];
-         rho = dist[x][y][0] + 1;
-         z = rho & 1;
-         if (!z)
-               {
-                 d = king;
-                 k = sizeof(king) / sizeof(struct delta);
-               }
-         else
-               {
-                 d = horse;
-                 k = sizeof(horse) / sizeof(struct delta);
-               }
-         while (k--)
-               {
-                 xx = x + d->dx;
-                 yy = y + d->dy;
-                 if (xx >= 0 && xx < M && yy >= 0 && yy < N && dist[xx][yy][0] > rho)
-                       {
-                         dist[xx][yy][0] = rho;
-                         queue[qw++] = xx;
-                         queue[qw++] = yy;
-                       }
-                 d++;
-               }
-       }
-}
-
-void
-draw(void)
-{
-  int i,j,k,l;
-
-  for(i=0; i<N; i++)
-       {
-         for(j=0; j<M; j++)
-               {
-                 k = dist[j][i][0];
-                 l = dist[j][i][1];
-                 if (k > l)
-                       k = l;
-                 printf("%3d", k);
-               }
-         putchar('\n');
-       }
-}
-
-int
-dlt(int a, int b)
-{
-  if (a < b)
-       return b-a;
-  else
-       return a-b;
-}
-
-void
-checkpath(int lim)
-{
-  int x,y,d;
-
-  x = x0;
-  y = y0;
-  d = 0;
-  for(;;)
-       {
-//       printf("%d %d\n", x, y);
-         if (dist[x][y][0] > d++)
-               {
-                 printf("BUG: %dx%d: %d.%d->%d.%d\n", M, N, x0, y0, x1, y1);
-                 exit(1);
-               }
-         if (dlt(x, x1) <= lim && dlt(y, y1) <= lim)
-               break;
-         if (dlt(x, x1) > dlt(y, y1))
-               {
-                 if (x < x1)
-                       x += 2;
-                 else if (x > x1)
-                       x -= 2;
-                 else if (x >= M/2)
-                       x -= 2;
-                 else
-                       x += 2;
-                 if (y < y1)
-                       y++;
-                 else if (y > y1)
-                       y--;
-                 else if (y >= N/2)
-                       y--;
-                 else
-                       y++;
-               }
-         else
-               {
-                 if (y < y1)
-                       y += 2;
-                 else if (y > y1)
-                       y -= 2;
-                 else if (y >= N/2)
-                       y -= 2;
-                 else
-                       y += 2;
-                 if (x < x1)
-                       x++;
-                 else if (x > x1)
-                       x--;
-                 else if (x >= M/2)
-                       x--;
-                 else
-                       x++;
-               }
-//       printf("%d %d\n", x, y);
-         if (dist[x][y][1] > d++)
-               {
-                 printf("BUG: %dx%d: %d.%d->%d.%d\n", M, N, x0, y0, x1, y1);
-                 exit(1);
-               }
-         if (dlt(x, x1) <= lim && dlt(y, y1) <= lim)
-               break;
-         if (x < x1)
-               x++;
-         else if (x > x1)
-               x--;
-         if (y < y1)
-               y++;
-         else if (y > y1)
-               y--;
-       }
-}
-
-int
-main(void)
-{
-  int i;
-
-  srand(time(NULL));
-
-#if 1
-  for(i=0; i<100000; i++)
-       {
-         M = 2 + rand() % 5;
-         N = 3 + rand() % 5;
-         x0 = rand() % M;
-         y0 = rand() % N;
-         x1 = rand() % M;
-         y1 = rand() % N;
-         printf("\n %dx%d: %d.%d->%d.%d\n", M, N, x0, y0, x1, y1);
-         fill();
-         draw();
-         checkpath(2);
-       }
-#else
-  M = 30;
-  N = 30;
-  x0 = 13;
-  y0 = 14;
-  fill();
-  draw();
-#endif
-
-  return 0;
-}
diff --git a/math.c b/math.c
deleted file mode 100644 (file)
index f563e41..0000000
--- a/math.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
-Simple Numeric Operations
-(c) 1995 Martin Mares, MJSoft System Software
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define MAXSTEPS 9
-#define MAXNUM 5001
-
-#define FIRSTUNARY 10
-#define NUMOPS 15
-
-int able[MAXSTEPS+1][MAXNUM];
-int func[MAXSTEPS+1][MAXNUM];
-int op1[MAXSTEPS+1][MAXNUM];
-int op2[MAXSTEPS+1][MAXNUM];
-int op1l[MAXSTEPS+1][MAXNUM];
-int op2l[MAXSTEPS+1][MAXNUM];
-int max[MAXSTEPS+1];
-int penalty[MAXSTEPS+1][MAXNUM];
-
-int maxdisp,digit,maxsteps,maxnum;
-
-/*            0 1 2 3 4 5 6  7  8  9 10 1112  13  */
-#if 0
-int pen[] = { 1,1,2,2,6,3,60,30,60,6,4,20,3,150,150 };
-#else
-int pen[] = { 1,1,2,2,5,3,8 ,6 ,8 ,5,4,6 ,3,13 ,13  };
-#endif
-/*            + - * / % ^ @  C  $  \ ! S  R r   t   */
-int pri[] = { 2,2,3,3,4,5,3, 7, 3, 3,9,7, 7,7,  7   };
-
-/* PRI == 7 <=> left-associative function with no priority */
-
-int op(int code,int a,int b,int src1,int src2)
-{
-int i,j,k,l;
-   switch(code)
-          {
-               case 0: return a+b;
-               case 1: return a-b;
-               case 2: return a*b;
-               case 3: if (b && !(a%b)) return a/b; else return -1; /* DIV */
-               case 4: if (b) return a%b; else return -1;                        /* MODULO */
-               case 5: i=1;                                                                                                      /* POWER */
-                                 while (b--)
-                                    {
-                                         i *= a;
-                                         if (i >= maxnum) return -1;
-                                         }
-                                 return i;
-               case 6: if (!b || a%b || able[src2][b] != 2) return -1; /* A/.(B) */
-                                 i=0;
-                                 a/=b;
-                                 while (b)
-                                    {
-                                         i=i*10+9;
-                                         b/=10;
-                                         }
-                                 return a*i;
-               case 7: if (a < b) return -1;                                                                   /* COMBINATION */
-                                 i=1; j=a; k=2; l=b;
-                                 while (l || k<=b)
-                                    {
-                                         while (k<=b && !(i%k))
-                                            {
-                                                 i/=k;
-                                                 k++;
-                                                 }
-                                         if (l)
-                                            {
-                                                 i*=j;
-                                                 l--;
-                                                 j--;
-                                                 }
-                                         if (i>100000) return -1;
-                                         }
-                                 return i;
-               case 8: if (!b || a%b || able[src2][b] != 2) return -1; /* A/.B */
-                                 i=1;
-                                 a/=b;
-                                 while (b)
-                                    {
-                                         i=i*10;
-                                         b/=10;
-                                         }
-                                 return a*i;
-               case 9: if (b) return a/b; else return -1;                              /* DIV */
-               case FIRSTUNARY: i=1;                                                                                   /* FACT */
-                                 while (a)
-                                    {
-                                         i*=a;
-                                         if (i >= maxnum) return -1;
-                                         a--;
-                                         }
-                                 return i;
-               case FIRSTUNARY+1: if (a) return 1; else return 0;                      /* SIGNUM */
-               case FIRSTUNARY+2: for(i=0;i<maxnum;i++)                                                /* ROOT */
-                          {
-                                         j=i*i;
-                                         if (j == a) return i;
-                                         if (j > a) return -1;
-                                         }
-                                       return -1;
-               case FIRSTUNARY+3: for(i=0;i<maxnum;i++)                                                /* UPPER ROOT */
-                          {
-                                         j=i*i;
-                                         if (j >= a) return i;
-                                         }
-                                 return -1;
-               case FIRSTUNARY+4: for(i=0;i<maxnum;i++)                                                /* LOWER ROOT */
-                          {
-                                         j=i*i;
-                                         if (j == a) return i;
-                                         if (j > a) return i-1;
-                                         }
-                                 return -1;
-               }
-       return -1;
-}
-
-int doop(int dest,int k,int i,int j,int src1,int src2,int p)
-{
-int l = op(k,i,j,src1,src2);
-       if (l>=0 && l<maxnum)
-          if (!able[dest][l] || penalty[dest][l] > p+pen[k])
-          {
-               able[dest][l] = 1;
-          func[dest][l] = k;
-               op1[dest][l] = i;
-               op1l[dest][l] = src1;
-               op2[dest][l] = j;
-               op2l[dest][l] = src2;
-               penalty[dest][l] = p+pen[k];
-               if (l > max[dest]) max[dest] = l;
-               return 1;
-               }
-       return 0;
-}
-
-void try(int dest,int src1,int src2)
-{
-int i,j,k,l;
-       fprintf(stderr,"Trying %d %d -> %d\n",src1+1,src2+1,dest+1);
-       l=0;
-   for(i=0;i<=max[src1];i++)
-          if (able[src1][i])
-                       {
-                       if (i-l>=10 || i<15) { fprintf(stderr,"%d\r",i); l=i; }
-                  for(j=0;j<=max[src2];j++)
-                          if (able[src2][j])
-                                  for(k=0;k<FIRSTUNARY;k++)
-                                               doop(dest,k,i,j,src1,src2,penalty[src1][i]+penalty[src2][j]);
-                       }
-}
-
-void tryuna(int dest)
-{
-int i,j,k;
-       fprintf(stderr,"Trying unary ops for level %d\n",dest+1);
-       do
-          {
-       j=0;
-          for(i=0;i<=max[dest];i++)
-                  if (able[dest][i])
-                               for(k=FIRSTUNARY;k<NUMOPS;k++)
-                                  if (doop(dest,k,i,0,dest,0,penalty[dest][i]))
-                                          j=1;
-               }
-       while (j);
-}
-
-#ifdef SIMPLE_DUMP
-
-void dump(int level,int i)
-{
-   if (able[level][i] == 2) printf("%d",i);
-       else if (func[level][i] < FIRSTUNARY)
-          {
-               putchar('(');
-               dump(op1l[level][i],op1[level][i]);
-               putchar("+-*/%^@C$\\"[func[level][i]]);
-               dump(op2l[level][i],op2[level][i]);
-               putchar(')');
-               }
-       else
-          {
-               putchar("!SRrt"[func[level][i]-FIRSTUNARY]);
-               putchar('(');
-               dump(op1l[level][i],op1[level][i]);
-               putchar(')');
-               }
-}
-
-#else
-
-union par {
-       int value;
-       struct node *p;
-       };
-
-struct node {
-       unsigned char op;
-       union par a[2];
-       };
-
-#define OP_CONST 0xff
-
-char *unam[] = {"sgn","sqr","ceil sqr","int sqr"};
-
-struct node *firstfree;
-
-struct node *obtain_node(void)
-{
-struct node *p;
-       if (firstfree)
-               {
-               p=firstfree;
-               firstfree=p->a[0].p;
-               }
-       else p=malloc(sizeof(struct node));
-       return p;
-}
-
-void free_node(struct node *p)
-{
-       p->a[0].p = firstfree;
-       firstfree=p;
-}
-
-void free_tree(struct node *p)
-{
-       if (p->op != OP_CONST)
-               {
-               free_tree(p->a[0].p);
-               if (p->op < FIRSTUNARY) free_tree(p->a[1].p);
-               }
-       free_node(p);
-}
-
-struct node *build_tree(int level,int i)
-{
-struct node *p = obtain_node();
-       if (able[level][i] == 2)
-               {
-               p->op = OP_CONST;
-               p->a[0].value = i;
-               }
-       else
-               {
-               p->op = func[level][i];
-               p->a[0].p = build_tree(op1l[level][i],op1[level][i]);
-               if (p->op < FIRSTUNARY)
-                       p->a[1].p = build_tree(op2l[level][i],op2[level][i]);
-               }
-       return p;
-}
-
-void print_tree(struct node *n,int p,int orop)
-{
-int g,r;
-       if (n->op == OP_CONST) printf("%d",n->a[0].value);
-       else
-               {
-               g = (pri[n->op] < p
-                   || (pri[n->op] == p &&
-                                 (orop == 1 || orop == 3 || orop == 4 || orop == 6
-                                            || orop == 8))
-                       );
-               if (g) putchar('(');
-               r=pri[n->op];
-               if (r==7) r=0;
-               if (n->op <= 5)         /* standard binary */
-                       {
-                       print_tree(n->a[0].p,r,n->op);
-                       putchar("+-*/%^"[n->op]);
-                       print_tree(n->a[1].p,r,n->op);
-                       }
-               else if (n->op == 6)            /* /.() */
-                       {
-                       print_tree(n->a[0].p,r,n->op);
-                       printf("/.(");
-                       print_tree(n->a[1].p,r,n->op);
-                       putchar(')');
-                       }
-               else if (n->op == 7)            /* COMB */
-                       {
-                       printf("C(");
-                       print_tree(n->a[0].p,r,n->op);
-                       putchar(',');
-                       print_tree(n->a[1].p,r,n->op);
-                       putchar(')');
-                       }
-               else if (n->op == 8)            /* /. */
-                       {
-                       print_tree(n->a[0].p,r,n->op);
-                       printf("/.");
-                       print_tree(n->a[1].p,r,n->op);
-                       }
-               else if (n->op == 9)            /* DIV */
-                       {
-                       print_tree(n->a[0].p,r,n->op);
-                       putchar('\\');
-                       print_tree(n->a[1].p,r,n->op);
-                       }
-               else if (n->op == FIRSTUNARY)           /* FACT */
-                       {
-                       print_tree(n->a[0].p,r,n->op);
-                       putchar('!');
-                       }
-               else                                                                            /* classical prefix unary */
-                       {
-                       printf(unam[n->op-FIRSTUNARY-1]);
-                       print_tree(n->a[0].p,255,255);
-                       }
-               if (g) putchar(')');
-               }
-}
-
-void dump(int level,int i)
-{
-struct node *root;
-       root = build_tree(level,i);
-       print_tree(root,0,-1);
-       free_tree(root);
-}
-
-#endif
-
-void fillin(void)
-{
-int i,j;
-       i=0;
-       for(j=0;j<=maxsteps;j++)
-               {
-               i=i*10+digit;
-               if (i>=maxnum) return;
-               able[j][i]=2;
-               max[j]=i;
-               }
-}
-
-void findall(void)
-{
-int steps,i;
-       tryuna(0);
-       for(steps=1;steps<=maxsteps;steps++)
-          {
-               for(i=0;i<steps;i++)
-                  try(steps,i,steps-i-1);
-               tryuna(steps);
-               }
-}
-
-void prtall(void)
-{
-int steps,totb,i;
-       putchar('\n');
-       steps=0; totb=0;
-       for(i=0;i<maxdisp;i++)
-          if (able[maxsteps][i])
-                  {
-                       printf("%d = ",i);
-                  dump(maxsteps,i);
-                       printf("  {%d}\n",penalty[maxsteps][i]);
-                       totb += penalty[maxsteps][i];
-                       steps++;
-                       }
-               else printf("%d : MISSING\n",i);
-       printf("%d of %d. {%d}\n",steps,maxdisp,totb);
-}
-
-void err(char *e)
-{
-       fprintf(stderr,e);
-       exit(1);
-}
-
-int main(int argc,char **argv)
-{
-       if (argc != 5)
-               {
-               printf("Usage: math <digit> <count> <limit> <calclimit>\n");
-               return 0;
-               }
-       digit = atol(argv[1]);
-       if (digit<0 || digit>9) err("Invalid digit!");
-       maxsteps = atol(argv[2])-1;
-       if (maxsteps<0 || maxsteps>MAXSTEPS) err("Invalid digit count!");
-       maxdisp = atol(argv[3])+1;
-       maxnum = atol(argv[4])+1;
-       if (maxnum<1 || maxnum>MAXNUM) err("Invalid internal maximum!");
-       if (maxdisp<1 || maxdisp>maxnum) err("Invalid limit!");
-       fillin();
-       findall();
-       prtall();
-       return 0;
-}
diff --git a/oggtest.c b/oggtest.c
deleted file mode 100644 (file)
index 98e3b23..0000000
--- a/oggtest.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <ogg/ogg.h>
-
-int main(void)
-{
-  ogg_sync_state osy;
-
-  ogg_sync_init(&osy);
-  for (;;)
-    {
-      char *buf = ogg_sync_buffer(&osy, 4096);
-      int len = read(0, buf, 4096);
-      if (len < 0)
-       {
-         fprintf(stderr, "read error: %m\n");
-         return 1;
-       }
-      if (!len)
-       break;
-      ogg_sync_wrote(&osy, len);
-
-      int ok;
-      ogg_page opg;
-      while (ok = ogg_sync_pageout(&osy, &opg))
-       {
-         if (ok < 0)
-           fprintf(stderr, "Skipping...\n");
-         else
-           {
-             fprintf(stderr, "Page (v=%d, stream=%x, bos=%d, eos=%d, pos=%Ld, pgno=%d)\n",
-                     ogg_page_version(&opg),
-                     ogg_page_serialno(&opg),
-                     ogg_page_bos(&opg),
-                     ogg_page_eos(&opg),
-                     (unsigned long long) ogg_page_granulepos(&opg),
-                     (unsigned int) ogg_page_pageno(&opg));
-           }
-       }
-    }
-  fprintf(stderr, "Done.\n");
-
-  return 0;
-}
diff --git a/pipprox.c b/pipprox.c
deleted file mode 100644 (file)
index cf6d266..0000000
--- a/pipprox.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdio.h>
-#include <math.h>
-
-int main(void)
-{
-  double delta = 1e30;
-
-  for (unsigned y=1; y < ~0U/M_PI; y++)
-    {
-      unsigned x = y*M_PI + 0.5;
-      double a = (double)x / y;
-      double d = fabs(a-M_PI);
-      if (d < delta)
-       {
-         delta = d;
-         printf("%u/%u = %.20f (%.20f)\n", x, y, a, d);
-       }
-    }
-
-  return 0;
-}
diff --git a/pstopsfix b/pstopsfix
deleted file mode 100755 (executable)
index bdea303..0000000
--- a/pstopsfix
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/perl
-# A filter for fixing PS generated by pstops
-# (c) 2008 Martin Mares <mj@ucw.cz>
-
-my $seen_procset = 0;
-my @procset = ();
-my $seen_setup = 0;
-while (<>) {
-       if (/^%%BeginProcSet: PStoPS/) {
-               $seen_procset = 1;
-       } elsif ($seen_procset == 1) {
-               if (/^%%EndProcSet/) {
-                       $seen_procset = 2;
-               } else {
-                       push @procset, $_;
-               }
-       } elsif (/^%%BeginSetup/) {
-               print;
-               if ($seen_procset == 2) {
-                       print "%%BeginFeature: PStoPS\n";
-                       print join("", @procset);
-                       print "%%EndFeature\n";
-                       $seen_procset = 3;
-               }
-               $seen_setup = 1;
-       } else {
-               print;
-       }
-}
-
-$seen_setup or die "No setup section seen\n";
-$seen_procset or die "No PStoPS procset seen\n";
-$seen_procset >= 2 or die "PStoPS procset not terminated\n";
-$seen_procset >= 3 or die "Setup section precedes PStoPS procset\n";
-exit 0;
diff --git a/puzzle.c b/puzzle.c
deleted file mode 100644 (file)
index 10b059c..0000000
--- a/puzzle.c
+++ /dev/null
@@ -1,166 +0,0 @@
-#include <stdio.h>
-
-struct {
-  int id;
-  char x[4];
-} list[] = {
-  {  0, {0,0,0,0} },
-  { 11, {0,0,0,1} },
-  { 13, {0,0,0,2} },
-  { 11, {0,0,1,0} },
-  {  3, {0,0,1,1} },
-  { 15, {0,0,1,2} },
-  { 13, {0,0,2,0} },
-  { 16, {0,0,2,1} },
-  {  4, {0,0,2,2} },
-  { 11, {0,1,0,0} },
-  {  6, {0,1,0,1} },
-  { 21, {0,1,0,2} },
-  {  3, {0,1,1,0} },
-  {  9, {0,1,1,1} },
-  { 18, {0,1,1,2} },
-  { 15, {0,1,2,0} },
-  { 22, {0,1,2,1} },
-  { 19, {0,1,2,2} },
-  { 13, {0,2,0,0} },
-  { 21, {0,2,0,1} },
-  {  7, {0,2,0,2} },
-  { 16, {0,2,1,0} },
-  { 17, {0,2,1,1} },
-  { 23, {0,2,1,2} },
-  {  4, {0,2,2,0} },
-  { 20, {0,2,2,1} },
-  { 10, {0,2,2,2} },
-  { 11, {1,0,0,0} },
-  {  3, {1,0,0,1} },
-  { 16, {1,0,0,2} },
-  {  6, {1,0,1,0} },
-  {  9, {1,0,1,1} },
-  { 22, {1,0,1,2} },
-  { 21, {1,0,2,0} },
-  { 17, {1,0,2,1} },
-  { 20, {1,0,2,2} },
-  {  3, {1,1,0,0} },
-  {  9, {1,1,0,1} },
-  { 17, {1,1,0,2} },
-  {  9, {1,1,1,0} },
-  {  1, {1,1,1,1} },
-  { 14, {1,1,1,2} },
-  { 18, {1,1,2,0} },
-  { 14, {1,1,2,1} },
-  {  5, {1,1,2,2} },
-  { 15, {1,2,0,0} },
-  { 18, {1,2,0,1} },
-  { 23, {1,2,0,2} },
-  { 22, {1,2,1,0} },
-  { 14, {1,2,1,1} },
-  {  8, {1,2,1,2} },
-  { 19, {1,2,2,0} },
-  {  5, {1,2,2,1} },
-  { 12, {1,2,2,2} },
-  { 13, {2,0,0,0} },
-  { 15, {2,0,0,1} },
-  {  4, {2,0,0,2} },
-  { 21, {2,0,1,0} },
-  { 18, {2,0,1,1} },
-  { 19, {2,0,1,2} },
-  {  7, {2,0,2,0} },
-  { 23, {2,0,2,1} },
-  { 10, {2,0,2,2} },
-  { 16, {2,1,0,0} },
-  { 22, {2,1,0,1} },
-  { 20, {2,1,0,2} },
-  { 17, {2,1,1,0} },
-  { 14, {2,1,1,1} },
-  {  5, {2,1,1,2} },
-  { 23, {2,1,2,0} },
-  {  8, {2,1,2,1} },
-  { 12, {2,1,2,2} },
-  {  4, {2,2,0,0} },
-  { 19, {2,2,0,1} },
-  { 10, {2,2,0,2} },
-  { 20, {2,2,1,0} },
-  {  5, {2,2,1,1} },
-  { 12, {2,2,1,2} },
-  { 10, {2,2,2,0} },
-  { 12, {2,2,2,1} },
-  {  2, {2,2,2,2} }
-};
-
-int rect[8][8], hbound[8][8], vbound[8][8];
-
-static void
-dump(void)
-{
-  int x,y;
-
-  for (x=1; x<=6; x++)
-    {
-      for (y=1; y<=4; y++)
-       printf(".%d. ", list[rect[x][y]].x[1]);
-      putchar('\n');
-      for (y=1; y<=4; y++)
-       printf("%d.%d ", list[rect[x][y]].x[0], list[rect[x][y]].x[2]);
-      putchar('\n');
-      for (y=1; y<=4; y++)
-       printf(".%d. ", list[rect[x][y]].x[3]);
-      putchar('\n');
-      putchar('\n');
-    }
-}
-
-static void
-fill(int x, int y, unsigned int mask)
-{
-  int i,j;
-
-  i = 9*(3*hbound[x][y]+vbound[x][y]);
-  for (j=0; j<9; i++, j++)
-    if (!(mask & (1 << list[i].id)))
-      {
-       //      printf("place <%d,%d> %d\n", x, y, list[i].id);
-       rect[x][y] = i;
-       //      if (hbound[x][y] != list[i].x[0] ||
-       //          vbound[x][y] != list[i].x[1]) puts("BUG!!!");
-       hbound[x][y+1] = list[i].x[2];
-       vbound[x+1][y] = list[i].x[3];
-       if (x == 6)
-         {
-           if (vbound[x+1][y])
-             continue;
-           if (y == 4)
-             {
-               if (hbound[x][y+1] != 2)
-                 continue;
-               else
-                 {
-                   puts("Gotcha!!!");
-                   dump();
-                   fflush(stdout);
-                   //    exit(0);
-                   return;
-                 }
-             }
-           fill(x,y+1,mask | (1 << list[i].id));
-         }
-       else if (y == 4)
-         {
-           if (hbound[x][y+1])
-             continue;
-           fill(x+1,1,mask | (1 << list[i].id));
-         }
-       else
-         fill(x,y+1,mask | (1 << list[i].id));
-      }
-}
-
-int
-main(int argc, char **argv)
-{
-  int x;
-  for (x=1; x<=4; x++)
-    vbound[1][x] = 1;
-  fill(1,1,0);
-  puts("No chance");
-  return 0;
-}
diff --git a/tla b/tla
deleted file mode 100755 (executable)
index c43aa83..0000000
--- a/tla
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /bin/sh
-while true ; do
-echo -n "Enter TLA: "
-read xxx
-if grep $xxx tla.db >/dev/null ; then
-   echo Already present.
-else
-   echo Not present
-       echo $xxx >>tla.db
-fi
-done
diff --git a/tla.db b/tla.db
deleted file mode 100644 (file)
index 0450d3b..0000000
--- a/tla.db
+++ /dev/null
@@ -1,481 +0,0 @@
-abs
-acc
-ack
-acs
-adc
-add
-ads
-afd
-afm
-ale
-alf
-alt
-alu
-amd
-ami
-arj
-arp
-arq
-ash
-asn
-atn
-avg
-awk
-bak
-bbs
-bcc
-bcd
-bcs
-beq
-bge
-bgt
-bhi
-bin
-bit
-ble
-bls
-blt
-bmi
-bmp
-bne
-bpe
-bpl
-brk
-bvc
-bvs
-cad
-cam
-cas
-cat
-cbm
-cbw
-ccd
-cck
-ccp
-ccr
-ced
-cga
-chk
-clc
-cli
-clk
-cmc
-cmd
-cmi
-cmp
-cmr
-cms
-cmu
-cmy
-cnt
-col
-com
-cos
-cpl
-cpr
-crt
-csh
-ctc
-cti
-cts
-cur
-cwd
-dac
-dat
-dbf
-dbm
-dca
-dcb
-dcd
-ddt
-dec
-deg
-del
-des
-dfc
-dft
-dil
-dim
-dip
-dir
-div
-dll
-dma
-dos
-dra
-drv
-dsp
-dsr
-dtl
-dtr
-dvi
-ecc
-ecl
-ega
-emi
-emm
-ems
-ena
-enb
-env
-eps
-erc
-erl
-ern
-err
-esc
-exe
-exg
-exp
-ext
-faq
-fat
-fdc
-fdd
-fet
-ffp
-ffs
-fft
-fiz
-fli
-fmt
-fpr
-fpu
-ftp
-fyi
-gal
-gas
-gcc
-gcd
-gcr
-gdb
-gdt
-gid
-gif
-gnd
-gnu
-gpl
-gpr
-grp
-gsf
-gst
-gus
-hal
-ham
-hdc
-hdd
-hdr
-hex
-hgc
-hlp
-hma
-hsv
-hup
-ibm
-icc
-icr
-ier
-iff
-ifs
-iil
-imo
-imr
-inc
-inp
-ins
-int
-ipl
-ipx
-irc
-irq
-isa
-isp
-jcc
-jcs
-jeq
-jle
-jmi
-jmp
-jne
-jns
-jnz
-jpl
-kms
-ksh
-lan
-ldt
-led
-len
-ler
-lha
-lpq
-lpr
-lpt
-lru
-lsm
-lzh
-lzw
-mam
-man
-mcu
-mda
-mfj
-mfm
-mft
-mkd
-mkf
-mki
-mkl
-mml
-mmu
-mnp
-mnt
-mos
-mrm
-msd
-msw
-mul
-mux
-nak
-ncc
-ncd
-ncr
-ndd
-nfs
-nic
-nmi
-nop
-nsl
-ntp
-nul
-ocr
-oct
-ofs
-oop
-opl
-ovl
-ovr
-pal
-par
-pbm
-pci
-pcl
-pcx
-pfm
-pfs
-pga
-pgm
-pgp
-pha
-pkg
-pla
-pld
-pnm
-ppi
-ppm
-ppp
-psu
-pwd
-pxl
-qed
-qic
-qwk
-rad
-ram
-rar
-ras
-rbf
-rcl
-rcp
-rcr
-rcs
-ref
-rev
-rgb
-rip
-rkm
-rla
-rlc
-rld
-rle
-rll
-rmt
-rol
-rom
-ror
-rot
-rpc
-rra
-rrc
-rrd
-rsa
-rsh
-rsr
-rtd
-rte
-rtg
-rts
-rxd
-sad
-sbb
-sbc
-scc
-sdb
-sec
-sed
-sfc
-sid
-sin
-sla
-sli
-sls
-smd
-snd
-spc
-sql
-sqr
-sra
-srl
-ssp
-stb
-sti
-stk
-sto
-str
-sub
-swp
-sys
-tac
-tan
-tar
-tas
-tbe
-tcl
-tcp
-tee
-tfm
-tic
-tla
-tmp
-tpa
-tpc
-tph
-tpl
-tpu
-trk
-tsr
-tss
-ttl
-ttp
-tts
-tty
-txd
-ucc
-ucw
-udd
-udp
-uid
-ula
-umb
-upp
-ups
-url
-usp
-val
-vbr
-vfs
-vga
-vim
-vlb
-vma
-vms
-vpa
-wan
-wrt
-xbm
-xga
-xms
-xon
-yak
-zif
-png
-pbx
-atm
-ppc
-ggi
-ddr
-mtu
-mru
-cdr
-rpm
-bbn
-bpm
-brt
-lim
-dce
-dte
-dtp
-apm
-arm
-xor
-iso
-itu
-pcm
-pdf
-rtl
-fcc
-mbr
-bgp
-egp
-igp
-ssh
-mib
-rfu
-rpg
-rtt
-lcp
-icp
-ioi
-fel
-lea
-vtm
-zcu
-mff
-etc
-cet
-lst
-cvs
-cpp
-cls
-vip
-ccm
-cpm
-hga
-fwd
-fig
-rtf
-sak
-xdr
-sgp
-dct
-csc
-phd
-yam
-tgv
-tft
-lcd
-lpd
-ean
-elm
-ipc
-rms
-clr
-inn
-nis
-nan
-inf
-gem
-gfx
-igi
-gpm
-std
diff --git a/trains.c b/trains.c
deleted file mode 100644 (file)
index 3ae3dab..0000000
--- a/trains.c
+++ /dev/null
@@ -1,96 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-struct tariff { int kmax, price; };
-
-struct tariff tar[] = {
-  { 10, 6 },
-  { 15, 8 },
-  { 20, 11 },
-  { 25, 13 },
-  { 30, 16 },
-  { 35, 19 },
-  { 40, 22 },
-  { 50, 27 },
-  { 60, 32 },
-  { 70, 38 },
-  { 80, 43 },
-  { 90, 48 },
-  { 100, 53 },
-  { 110, 58 },
-  { 120, 62 },
-  { 140, 72 },
-  { 160, 82 },
-  { 180, 92 },
-  { 200, 101 },
-  { 225, 114 },
-  { 250, 126 },
-  { 275, 138 },
-  { 300, 148 },
-  { 350, 170 },
-  { 400, 192 },
-  { 450, 214 },
-  { 500, 236 },
-  { 550, 258 },
-  { 600, 278 },
-  { 650, 298 },
-  { 700, 318 },
-  { 99999, 342 }
-};
-
-int ftar(int km)
-{
-  int t;
-  for(t=0; tar[t].kmax < km; t++)
-    ;
-  return t;
-}
-
-int lo(int t)
-{
-  return t ? tar[t-1].kmax+1 : 0;
-}
-
-#define hi(t) tar[t].kmax
-#define pri(t) tar[t].price
-
-int main(int argc, char **argv)
-{
-  int km, t, orp, l, h;
-
-  if (argc != 2)
-    {
-      fprintf(stderr, "Usage: %s <km>\n", argv[0]);
-      return 0;
-    }
-  km = atol(argv[1]);
-  if (km > 10000)
-    km = 10000;
-  t = ftar(km);
-  printf("Original: %d-%d %d\n", lo(t), hi(t), pri(t));
-  orp = pri(t);
-  while (--t >= 0)
-    {
-      int l0 = km - hi(t);
-      int h0 = km - lo(t);
-      l = ftar(l0);
-      h = ftar(h0);
-//    printf("Trying %d-%d %d-%d\n", lo(t), hi(t), l0, h0);
-      while (l <= h)
-       {
-         int p = pri(t) + pri(l);
-         int L = lo(l) < l0 ? l0 : lo(l);
-         int H = hi(l) > h0 ? h0 : hi(l);
-//       printf("Combined %d-%d %d-%d: p=%d\n", lo(l), hi(l), L, H, p);
-         if (p < orp)
-           printf("::: %d-%d(%d) + %d-%d(%d) = %d (saved %d)\n",
-                  L, H, pri(l),
-                  lo(t), hi(t), pri(t),
-                  p, orp - p);
-         l++;
-       }
-    }
-
-  return 0;
-}
diff --git a/un602.c b/un602.c
deleted file mode 100644 (file)
index 34e01d4..0000000
--- a/un602.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-       int i;
-       int bol = 1;
-
-       while ((i = getchar()) != EOF)
-               {
-                       if (i == 10)
-                               {
-                                       bol = 1;
-                                       putchar(10);
-                                       continue;
-                               }
-                       if (i < 32)
-                               continue;
-                       if (i == '@' && bol)
-                               {
-                                       while ((i = getchar()) != EOF && i != 10)
-                                               ;
-                                       continue;
-                               }
-                       bol = 0;
-                       putchar(i);
-               }
-       
-       return 0;
-}
diff --git a/unword.c b/unword.c
deleted file mode 100644 (file)
index 12b5ed1..0000000
--- a/unword.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- *     Extract ASCII Text from M$ Word Document
- *
- *     (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
- */
-
-/* FIXME: endianity dependencies! */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-FILE *fi, *fo;
-
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned int ulg;
-
-byte
-gb(void)
-{
-  return fgetc(fi);
-}
-
-word
-gw(void)
-{
-  word k = fgetc(fi);
-  k = k | (fgetc(fi) << 8);
-  return k;
-}
-
-ulg
-gl(void)
-{
-  ulg l = gw();
-  l = l | (gw() << 16);
-  return l;
-}
-
-void
-ole(void)
-{
-  ulg p, word;
-  byte oh[0x80], pn[0x80];
-  int z, x, y;
-
-  fseek(fi, 0x30, SEEK_SET);
-  p = 0x200 * gl() + 0x200;                            /* Position of central directory */
-  word = 0;
-  printf("Central OLE directory at 0x%x\n", p);
-  fseek(fi, p, SEEK_SET);
-  while (fread(oh, sizeof(oh), 1, fi) == 1)
-       {
-         z = y = 0;
-         if ((!oh[0] && !oh[1]) || (!oh[2] && !oh[3]))
-               break;
-         if (oh[z] < 32 && !oh[z+1])
-               {
-                 z += 2;
-                 pn[y++] = '>';
-                 pn[y++] = ' ';
-               }
-         while (oh[z] || oh[z+1])
-               {
-                 x = oh[z] | (oh[z+1] << 8);
-                 if (x >= 32 && x < 127)
-                       pn[y++] = x;
-                 else
-                       pn[y++] = '?';
-                 z += 2;
-               }
-         pn[y] = 0;
-         p = 0x200 * (oh[0x74] | (oh[0x75] << 8) | (oh[0x76] << 16) | (oh[0x77] << 24)) + 0x200;
-         printf("%08x %s\n", p, pn);
-         if (!strcmp(pn, "WordDocument"))
-               word = p;
-       }
-  if (!word)
-       {
-         fprintf(stderr, "Word doc stream not found!\n");
-         exit(1);
-       }
-  fseek(fi, word, SEEK_SET);
-}
-
-struct fib {
-  word magic;
-  word vers;
-  word product;
-  word lang;
-  word pnnext;
-  byte flags1;
-  byte flags2;
-  word back;
-  ulg cryptkey;
-  byte environ;
-  byte rfu;
-  word textcharset;                                            /* 0=win, 256=mac */
-  word tablecharset;                                   /* 0=win, 256=mac */
-  ulg firsttextchar;
-  ulg xx[6];
-  ulg textlen;
-  ulg footlen;
-  ulg hdrlen;
-  ulg macrolen;
-  ulg annolen;
-  ulg endnotelen;
-  ulg textboxlen;
-  ulg htextboxlen;
-  ulg rfu2;
-  ulg stshorigp, stshorigl;
-  ulg stshp, stshl;
-  ulg footrefp, footrefl;
-  ulg foottxtp, foottxtl;
-  ulg annorefp, annorefl;
-  ulg annotxtp, annotxtl;
-  ulg sedp, sedl;
-  ulg pardp, pardl;
-  ulg pahp, pahl;
-  ulg glossp, glossl;
-  ulg glosp, glosl;
-  ulg hdrp, hdrl;
-  ulg chpbp, chpbl;
-  ulg papbp, papbl;
-  ulg seap, seal;
-  ulg ffnsp, ffnsl;
-  ulg mainfpp, mainfpl;
-  ulg headfpp, headfpl;
-  ulg footfpp, footfpl;
-  ulg annofpp, annofpl;
-  ulg macfpp, macfpl;
-  ulg boosp, boosl;
-  ulg bookop, bookol;
-  ulg booklp, bookll;
-  ulg cmdsp, cmdsl;
-  ulg mcrpp, mcrpl;
-  ulg mcrsp, mcrsl;
-  ulg pdrvp, pdrvl;
-  ulg prenvpp, prenvpl;
-  ulg prenvlp, prenvll;
-  ulg wssp, wssl;
-  ulg dopp, dopl;
-  ulg assosp, assosl;
-  ulg compp, compl;                                            /* Complex file info! */
-  ulg footpgp, footpgl;
-  ulg orignamep, orignamel;
-  ulg annoownp, annoownl;
-  ulg annobnp, annobnl;
-} __attribute__((packed));
-
-ulg txl, lbf;
-
-int
-cc(void)
-{
-  if (txl)
-       {
-         txl--;
-         return gb();
-       }
-  return -1;
-}
-
-char lb[86];
-int lbi;
-
-void
-flb(void)
-{
-  lb[lbi++] = '\n';
-  lb[lbi] = 0;
-  fputs(lb, fo);
-  lbi = 0;
-}
-
-void
-pc(int c)
-{
-  if (lbi >= 80)
-       {
-         int lc = lbi;
-         while (lc > 0 && lb[--lc] != ' ')
-               ;
-         if (!lc)
-               {
-                 lbf++;
-                 flb();
-               }
-         else
-               {
-                 char exb[80];
-                 lb[lbi] = 0;
-                 lb[lc] = 0;
-                 lbi = lc++;
-                 strcpy(exb, lb+lc);
-                 flb();
-                 strcpy(lb, exb);
-                 lbi = strlen(lb);
-               }
-       }
-  lb[lbi++] = c;
-}
-
-void
-text(void)
-{
-  int c;
-
-  for(;;)
-       switch (c = cc())
-         {
-         case -1:
-               flb();
-               if (lbf)
-                 printf("%d line breaks failed\n", lbf);
-               return;
-         case 12:
-               flb();
-               fputc(12, fo);
-               break;
-         case 13:
-               lb[lbi++] = '\n';
-               /* FALL-THRU */
-         case 11:
-               flb();
-               break;
-         case 9:
-         case 14:
-               pc(9);
-               break;
-         case 31:
-               pc('-');
-               break;
-         case 7:
-         case 19:
-         case 20:
-         case 21:
-               break;
-         case 160:
-               pc('~');
-               break;
-         default:
-               pc(c);
-         }
-}
-
-void
-unword(void)
-{
-  struct fib fib;
-  ulg where = ftell(fi);
-
-printf("%d %d\n", (int)&(((struct fib *)0)->compp), where);
-  printf("Reading %d bytes of file header\n", sizeof(fib));
-  if (fread(&fib, sizeof(fib), 1, fi) != 1)
-       {
-         fprintf(stderr, "FIB read error!\n");
-         exit(1);
-       }
-  if (fib.magic != 0xa5db && fib.magic != 0xa5dc)
-       {
-         fprintf(stderr, "Black magic!\n");
-         exit(1);
-       }
-  printf("Lang=%d, charset=[%d,%d]\n", fib.lang, fib.textcharset, fib.tablecharset);
-  if (fib.flags1 & 4)
-        {
-          if (fib.magic == 0xa5db)
-            puts("Complex format, old magic");
-          else
-            {
-                   printf("Complex format, abs start=0x%x, len=%d\n", fib.compp + where, fib.compl);
-              fprintf(stderr, "Fast-saved format not supported yet!\n");
-              exit(1);
-                 }
-       }
-  if (fib.flags2 & 1)
-       {
-         fprintf(stderr, "Encrypted files not supported yet!\n");
-         exit(1);
-       }
-  if (fib.flags2 & 0x1000)
-       puts("Extended charsets detected");
-  printf("First text char at 0x%x, len=%d\n", fib.firsttextchar + where, fib.textlen);
-  fseek(fi, fib.firsttextchar + where, SEEK_SET);
-  txl = fib.textlen;
-  text();
-}
-
-void
-convert(void)
-{
-  word id = gw();
-  if (id == 0xa5db || id == 0xa5dc)
-       {
-         fseek(fi, 0, SEEK_SET);
-         puts("Plain M$-Word file...");
-       }
-  else if (id == 0xcfd0)
-       {
-         puts("OLE file...");
-         ole();
-       }
-  else
-       {
-         fprintf(stderr, "Unknown file format!\n");
-         exit(1);
-       }
-  unword();
-}
-
-int
-main(int argc, char **argv)
-{
-  if (argc != 3)
-       {
-         fprintf(stderr, "Usage: unword <from> <to>\n");
-         return 1;
-       }
-  if (!(fi = fopen(argv[1], "r")))
-       {
-         fprintf(stderr, "Unable to open input file: %m\n");
-         return 1;
-       }
-  if (!(fo = fopen(argv[2], "w")))
-       {
-         fprintf(stderr, "Unable to open output file: %m\n");
-         return 1;
-       }
-  convert();
-  return 0;
-}
diff --git a/whatsit.c b/whatsit.c
deleted file mode 100644 (file)
index a14387e..0000000
--- a/whatsit.c
+++ /dev/null
@@ -1,12 +0,0 @@
-int f(int x, int y)
-{
-       return x ? f((x&y) << 1, x^y) : y;
-}
-
-#include <stdio.h>
-#include <stdlib.h>
-int main(int argc, char **argv)
-{
-       printf("%d\n", f(atol(argv[1]), atol(argv[2])));
-       return 0;
-}