[comp.sys.dec.micro] uudecode - missing blanks

hart@TAURUS.BITNET (09/22/88)

[]

Some mailers do indeed throw away blanks at the end of the line.
There is however no problem to add them back, since the length
of the line is encoded in the first character.

Following is a simple program to do just that.  I don't remember
where I got it from, but it works!

====================================================================
/*
    Try to repair uuencoded files when trailing space has been removed.
    It pads short lines with spaces whenever needed.
    It reads from stdin and writes to stdout.

        use: pgm <uuencoded > repaired
             uudecode repaired

        or:  pgm <uuencoded | uudecode

    If it doesn't work, I can't help you.
*/

#include <stdio.h>

main()
  {
    char c;
    int tab, len;

    tab = 0;
    while ((c = getchar()) != EOF)
      {
        if (tab == 0)
          {
            if (' '<=c && c<='Z') len = ((c-' '+2)/3)*4+1;
            else len = 1;
          }
        if (c == '\n')
          {
            while (tab++<len) putchar(' ');
            tab = 0;
          }
        else tab++;
        putchar (c);
      }
  }

===============================================================

           -Sergiu Hart
---------------------------------------------------------------------
     MAIL:      School of Mathematical Sciences
                Tel-Aviv University
                69978  Tel-Aviv,  Israel
     E-MAIL:    hart@taurus.bitnet,    hart@math.tau.ac.il,
                hart%math.tau.ac.il@cunyvm.cuny.edu,
                hart%taurus.bitnet@cunyvm.cuny.edu,
                hart%taurus.bitnet@cornellc.ccs.cornell.edu,
                hart%taurus.bitnet@cnuce-vm.arpa
---------------------------------------------------------------------