mirror of https://github.com/aria2/aria2
2007-08-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Merged Dan's patch: * src/ByteArrayDiskWriter.cc: ios_base -> ios Use va_copy to avoid core dump on amd64: * src/SimpleLogger.ccpull/1/head
parent
46e8c332cd
commit
54be1cbc4f
|
@ -1,3 +1,11 @@
|
|||
2007-08-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Merged Dan's patch:
|
||||
* src/ByteArrayDiskWriter.cc: ios_base -> ios
|
||||
|
||||
Use va_copy to avoid core dump on amd64:
|
||||
* src/SimpleLogger.cc
|
||||
|
||||
2007-08-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Make a2netcompat.h include a2io.h to fix compilation error:
|
||||
|
|
|
@ -67,18 +67,18 @@ void ByteArrayDiskWriter::openExistingFile(const string& filename,
|
|||
|
||||
void ByteArrayDiskWriter::writeData(const char* data, int32_t dataLength, int64_t position) {
|
||||
if(size() < position) {
|
||||
buf.seekg(0, ios_base::end);
|
||||
buf.seekg(0, ios::end);
|
||||
for(int32_t i = size(); i < position; ++i) {
|
||||
buf.put('\0');
|
||||
}
|
||||
} else {
|
||||
buf.seekg(position, ios_base::beg);
|
||||
buf.seekg(position, ios::beg);
|
||||
}
|
||||
buf.write(data, dataLength);
|
||||
}
|
||||
|
||||
int32_t ByteArrayDiskWriter::readData(char* data, int32_t len, int64_t position) {
|
||||
buf.seekg(position, ios_base::beg);
|
||||
buf.seekg(position, ios::beg);
|
||||
buf.read(data, len);
|
||||
// TODO we have to call buf.clear() here? YES
|
||||
buf.clear();
|
||||
|
|
|
@ -41,6 +41,14 @@
|
|||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined(va_copy)
|
||||
# if defined(__va_copy)
|
||||
# define va_copy(dest, src) __va_copy(dest, src)
|
||||
# else
|
||||
# define va_copy(dest, src) (dest = src)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define WRITE_LOG(LEVEL, MSG) \
|
||||
va_list ap;\
|
||||
va_start(ap, MSG);\
|
||||
|
@ -89,6 +97,8 @@ void SimpleLogger::writeHeader(FILE* file, string date, string level) const {
|
|||
|
||||
void SimpleLogger::writeLog(FILE* file, Logger::LEVEL level, const char* msg, va_list ap, Exception* e, bool printHeader) const
|
||||
{
|
||||
va_list apCopy;
|
||||
va_copy(apCopy, ap);
|
||||
string levelStr;
|
||||
switch(level) {
|
||||
case Logger::DEBUG:
|
||||
|
@ -117,7 +127,7 @@ void SimpleLogger::writeLog(FILE* file, Logger::LEVEL level, const char* msg, va
|
|||
if(printHeader) {
|
||||
writeHeader(file, datestr, levelStr);
|
||||
}
|
||||
vfprintf(file, string(Util::replace(msg, "\r", "")+"\n").c_str(), ap);
|
||||
vfprintf(file, string(Util::replace(msg, "\r", "")+"\n").c_str(), apCopy);
|
||||
for(Exception* nestedEx = e; nestedEx; nestedEx = nestedEx->getCause()) {
|
||||
// TODO a quick hack not to print header in console
|
||||
if(printHeader) {
|
||||
|
@ -126,6 +136,7 @@ void SimpleLogger::writeLog(FILE* file, Logger::LEVEL level, const char* msg, va
|
|||
fprintf(file, "exception: %s\n", Util::replace(nestedEx->getMsg(), "\r", "").c_str());
|
||||
}
|
||||
fflush(file);
|
||||
va_end(apCopy);
|
||||
}
|
||||
|
||||
void SimpleLogger::writeFile(Logger::LEVEL level, const char* msg, va_list ap, Exception* e) const {
|
||||
|
|
Loading…
Reference in New Issue