Commit 59c0fcd8 authored by sof's avatar sof
Browse files

[project @ 1999-09-12 19:18:22 by sof]

In case of a partial writes, buffer pointer wasn't being adjusted/used.
parent 2abf1911
/* /*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
* *
* $Id: writeFile.c,v 1.6 1999/07/12 10:43:13 sof Exp $ * $Id: writeFile.c,v 1.7 1999/09/12 19:18:22 sof Exp $
* *
* hPutStr Runtime Support * hPutStr Runtime Support
*/ */
...@@ -47,7 +47,7 @@ StgInt bytes; ...@@ -47,7 +47,7 @@ StgInt bytes;
int count, rc=0; int count, rc=0;
IOFileObject* fo = (IOFileObject*)ptr; IOFileObject* fo = (IOFileObject*)ptr;
char *p = (char *) fo->buf; char *pBuf = (char *) fo->buf;
/* Disallow short writes */ /* Disallow short writes */
if (bytes == 0 || fo->buf == NULL) if (bytes == 0 || fo->buf == NULL)
...@@ -60,10 +60,10 @@ StgInt bytes; ...@@ -60,10 +60,10 @@ StgInt bytes;
( (
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
fo->flags & FILEOBJ_WINSOCK ? fo->flags & FILEOBJ_WINSOCK ?
send(fo->fd, fo->buf, bytes, 0) : send(fo->fd, pBuf, bytes, 0) :
write(fo->fd, fo->buf, bytes))) < bytes) { write(fo->fd, pBuf, bytes))) < bytes) {
#else #else
write(fo->fd, fo->buf, bytes))) < bytes) { write(fo->fd, pBuf, bytes))) < bytes) {
#endif #endif
if (errno != EINTR) { if (errno != EINTR) {
cvtErrno(); cvtErrno();
...@@ -71,7 +71,7 @@ StgInt bytes; ...@@ -71,7 +71,7 @@ StgInt bytes;
return -1; return -1;
} }
bytes -= count; bytes -= count;
p += count; pBuf += count;
} }
/* Signal that we've emptied the buffer */ /* Signal that we've emptied the buffer */
fo->bufWPtr=0; fo->bufWPtr=0;
...@@ -88,7 +88,7 @@ StgInt len; ...@@ -88,7 +88,7 @@ StgInt len;
IOFileObject* fo = (IOFileObject*)ptr; IOFileObject* fo = (IOFileObject*)ptr;
int count; int count;
int rc = 0; int rc = 0;
char *p = (char *) buf; char *pBuf = (char *) buf;
if (len == 0 ) if (len == 0 )
return 0; return 0;
...@@ -129,18 +129,18 @@ StgInt len; ...@@ -129,18 +129,18 @@ StgInt len;
( (
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
fo->flags & FILEOBJ_WINSOCK ? fo->flags & FILEOBJ_WINSOCK ?
send(fo->fd, (char*)buf, (int)len, 0) : send(fo->fd, pBuf, (int)len, 0) :
write(fo->fd, (char*)buf, (int)len))) < len ) { write(fo->fd, pBuf, (int)len))) < len ) {
#else #else
write(fo->fd, (char*)buf, (int)len))) < len ) { write(fo->fd, pBuf, (int)len))) < len ) {
#endif #endif
if (errno != EINTR) { if (errno != EINTR) {
cvtErrno(); cvtErrno();
stdErrno(); stdErrno();
return -1; return -1;
} }
len -= count; len -= count;
p += count; pBuf += count;
} }
return 0; return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment