#: 18093 S12/OS9/68000 (OSK)
15-May-93 01:45:50
Sb: #18091-new unzip
Fm: Mike Haaland 72300,1433
To: Bob van der Poel 76510,2203
Hey Bob,
I did the same thing with Lha(rc) It's pretty simple. Just save the last char
you are putting to the file. If you get a LF don't output anything, then on
the next char, check it the last one was a LF, if the current char is a CR
output it, if it was anything else, output a CR then the current char. This
add the need to do an extra loop at EOF to make sure the last LF get's output
as a CR. (In case the file only had LF's).
Hope this helps,
- Mike -
#define fputc putc
outchar(fp,c)
FILE *fp;
int c;
{
static int last_c;
if (c == '\l') {
if (last_c == '\l')
fputc('\n',fp);
} else {
if (last_c == '\l' && c != '\n')
fputc('\n',fp);
fputc(c,fp);
}
last_c = c;
}
|