version 1.54, 2008/01/04 00:50:09 |
version 1.55, 2008/04/19 09:22:31 |
|
|
return (-1); |
return (-1); |
lbuf = NULL; |
lbuf = NULL; |
while ((buf = fgetln(fp, &len))) { |
while ((buf = fgetln(fp, &len))) { |
if (buf[len - 1] == '\n') |
if (buf[len - 1] == '\n') { |
buf[len - 1] = '\0'; |
buf[len - 1] = '\0'; |
else { |
--len; |
|
} else { |
/* EOF without EOL, copy and add the NUL */ |
/* EOF without EOL, copy and add the NUL */ |
if ((lbuf = malloc(len + 1)) == NULL) |
if ((lbuf = malloc(len + 1)) == NULL) |
goto end; |
goto end; |
|
|
copylen = sp - buf; |
copylen = sp - buf; |
else |
else |
copylen = len; |
copylen = len; |
if (atomicio(vwrite, dst, buf, copylen) != copylen || |
if (atomicio(vwrite, dst, buf, copylen) != copylen) |
atomicio(vwrite, dst, "\n", 1) != 1) |
|
goto end; |
goto end; |
if (!ep) |
if (!ep) |
break; |
break; |
|
|
len -= ep - buf + 1; |
len -= ep - buf + 1; |
buf = ep + 1; |
buf = ep + 1; |
} |
} |
|
if (atomicio(vwrite, dst, "\n", 1) != 1) |
|
goto end; |
} |
} |
rval = 0; |
rval = 0; |
end: |
end: |