version 1.8, 2003/06/26 07:59:49 |
version 1.9, 2003/09/24 20:21:40 |
|
|
if (newline) { |
if (newline) { |
if (prevchar == '\n') |
if (prevchar == '\n') |
c = '\n'; /* lf to cr,lf */ |
c = '\n'; /* lf to cr,lf */ |
else c = '\0'; /* cr to cr,nul */ |
else |
|
c = '\0'; /* cr to cr,nul */ |
newline = 0; |
newline = 0; |
} |
} else { |
else { |
|
c = getc(file); |
c = getc(file); |
if (c == EOF) break; |
if (c == EOF) break; |
if (c == '\n' || c == '\r') { |
if (c == '\n' || c == '\r') { |
|
|
* CR,NUL -> CR and CR,LF => LF. |
* CR,NUL -> CR and CR,LF => LF. |
* Note spec is undefined if we get CR as last byte of file or a |
* Note spec is undefined if we get CR as last byte of file or a |
* CR followed by anything else. In this case we leave it alone. |
* CR followed by anything else. In this case we leave it alone. |
*/ |
n */ |
int |
int |
write_behind(FILE *file, int convert) |
write_behind(FILE *file, int convert) |
{ |
{ |
|
|
p = buf; |
p = buf; |
ct = count; |
ct = count; |
while (ct--) { /* loop over the buffer */ |
while (ct--) { /* loop over the buffer */ |
c = *p++; /* pick up a character */ |
c = *p++; /* pick up a character */ |
if (prevchar == '\r') { /* if prev char was cr */ |
if (prevchar == '\r') { /* if prev char was cr */ |
if (c == '\n') /* if have cr,lf then just */ |
if (c == '\n') /* if have cr,lf then just */ |
fseek(file, -1, 1); /* smash lf on top of the cr */ |
fseek(file, -1, 1); /* smash lf on top of the cr */ |
else |
else if (c == '\0') /* if have cr,nul then */ |
if (c == '\0') /* if have cr,nul then */ |
goto skipit; /* just skip over the putc */ |
goto skipit; /* just skip over the putc */ |
/* else just fall through and allow it */ |
/* else just fall through and allow it */ |
} |
} |
putc(c, file); |
putc(c, file); |
|
skipit: |
skipit: |
prevchar = c; |
prevchar = c; |
} |
} |
return count; |
return count; |
} |
} |
|
|
j++; |
j++; |
fromlen = sizeof from; |
fromlen = sizeof from; |
(void) recvfrom(f, rbuf, sizeof (rbuf), 0, |
(void) recvfrom(f, rbuf, sizeof (rbuf), 0, |
(struct sockaddr *)&from, &fromlen); |
(struct sockaddr *)&from, &fromlen); |
} else { |
} else { |
return(j); |
return(j); |
} |
} |