> sed '/^$/,$ s/^From / From /' >$TMP.msg
> 
> needs to be replaced with a c program that does this
> conversion without coercing its input text into utf-8.

I had one to hand, called /sys/src/cmd/upas/padfrom.c
I think I wrote it, though it may have come from somone
else on the list, if so I appologise.

#include <u.h>
#include <libc.h>
#include <bio.h>

main()
{
        char *p;
        Biobuf bi, bo;

        Binit(&bi, 0, OREAD);
        Binit(&bo, 1, OWRITE);

        while ((p = Brdline(&bi, '\n')) != nil && Blinelen(&bi) > 1)
                Bwrite(&bo, p, Blinelen(&bi));
        Bputc(&bo, '\n');
        while ((p = Brdline(&bi, '\n')) != nil){
                if (strncmp(p, "From ", 5) == 0)
                        Bputc(&bo, ' ');
                Bwrite(&bo, p, Blinelen(&bi));
        }
}

Reply via email to