stupid bug fixes. writef() used the wrong variable as the number

of bytes to write.  readf() forgot to prepare the va_list.
This commit is contained in:
crs 2001-10-14 14:56:06 +00:00
parent 22b99b6ca4
commit c6ed114410
1 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#include "CProtocolUtil.h" #include "CProtocolUtil.h"
#include "IInputStream.h" #include "IInputStream.h"
#include "IOutputStream.h" #include "IOutputStream.h"
#include "CLog.h"
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
@ -14,6 +15,7 @@ void CProtocolUtil::writef(IOutputStream* stream,
{ {
assert(stream != NULL); assert(stream != NULL);
assert(fmt != NULL); assert(fmt != NULL);
log((CLOG_DEBUG "writef(%s)", fmt));
va_list args; va_list args;
@ -36,7 +38,8 @@ void CProtocolUtil::writef(IOutputStream* stream,
// write buffer // write buffer
UInt8* scan = buffer; UInt8* scan = buffer;
while (count > 0) { while (count > 0) {
const UInt32 n = stream->write(scan, n); const UInt32 n = stream->write(scan, count);
log((CLOG_DEBUG "wrote %d of %d bytes", n, count));
count -= n; count -= n;
scan += n; scan += n;
} }
@ -51,6 +54,7 @@ void CProtocolUtil::readf(IInputStream* stream,
assert(fmt != NULL); assert(fmt != NULL);
va_list args; va_list args;
va_start(args, fmt);
// begin scanning // begin scanning
while (*fmt) { while (*fmt) {
@ -162,6 +166,8 @@ void CProtocolUtil::readf(IInputStream* stream,
++fmt; ++fmt;
} }
} }
va_end(args);
} }
UInt32 CProtocolUtil::getLength( UInt32 CProtocolUtil::getLength(