Fixed compiler issues (gcc-4.3, msvc 7.1)

This commit is contained in:
Andreas Huggel
2007-09-24 06:33:17 +00:00
parent 16c95f0fab
commit 91c4dafbf9
11 changed files with 81 additions and 47 deletions
+18
View File
@@ -376,6 +376,9 @@
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\orfimage.cpp">
</File>
<File
RelativePath="..\..\src\tiffparser.cpp">
<FileConfiguration
@@ -436,6 +439,9 @@
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\properties.cpp">
</File>
<File
RelativePath="..\..\src\types.cpp">
<FileConfiguration
@@ -466,6 +472,9 @@
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\xmp.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
@@ -537,6 +546,9 @@
<File
RelativePath="..\..\src\panasonicmn.hpp">
</File>
<File
RelativePath="..\..\src\properties.hpp">
</File>
<File
RelativePath="..\..\src\rafimage.hpp">
</File>
@@ -555,6 +567,9 @@
<File
RelativePath="..\..\src\tiffimage.hpp">
</File>
<File
RelativePath="..\..\src\orfimage.hpp">
</File>
<File
RelativePath="..\..\src\tiffparser.hpp">
</File>
@@ -573,6 +588,9 @@
<File
RelativePath="..\..\src\value.hpp">
</File>
<File
RelativePath="..\..\src\xmp.hpp">
</File>
</Filter>
<Filter
Name="Resource Files"
+21 -20
View File
@@ -44,6 +44,7 @@ EXIV2_RCSID("@(#) $Id$")
// + standard includes
#include <string>
#include <memory>
#include <cstring>
#include <cassert>
#include <cstdio> // for remove, rename
#include <cstdlib> // for alloc, realloc, free
@@ -128,7 +129,7 @@ namespace Exiv2 {
// If file is > 1MB then use a file, otherwise use memory buffer
if (ret != 0 || buf.st_size > 1048576) {
pid_t pid = getpid();
pid_t pid = ::getpid();
std::string tmpname = path_ + toString(pid);
std::auto_ptr<FileIo> fileIo(new FileIo(tmpname));
if (fileIo->open("w+b") != 0) {
@@ -172,22 +173,22 @@ namespace Exiv2 {
if (oldOpMode == opSeek) return 0;
// Flush. On msvcrt fflush does not do the job
fseek(fp_, 0, SEEK_CUR);
std::fseek(fp_, 0, SEEK_CUR);
return 0;
}
// Reopen the file
long offset = ftell(fp_);
long offset = std::ftell(fp_);
if (offset == -1) return -1;
if (open("r+b") != 0) return 1;
return fseek(fp_, offset, SEEK_SET);
return std::fseek(fp_, offset, SEEK_SET);
}
long FileIo::write(const byte* data, long wcount)
{
assert(fp_ != 0);
if (switchMode(opWrite) != 0) return 0;
return (long)fwrite(data, 1, wcount, fp_);
return (long)std::fwrite(data, 1, wcount, fp_);
}
long FileIo::write(BasicIo& src)
@@ -202,7 +203,7 @@ namespace Exiv2 {
long writeCount = 0;
long writeTotal = 0;
while ((readCount = src.read(buf, sizeof(buf)))) {
writeTotal += writeCount = (long)fwrite(buf, 1, readCount, fp_);
writeTotal += writeCount = (long)std::fwrite(buf, 1, readCount, fp_);
if (writeCount != readCount) {
// try to reset back to where write stopped
src.seek(writeCount-readCount, BasicIo::cur);
@@ -230,7 +231,7 @@ namespace Exiv2 {
}
close();
struct stat buf;
if (stat(path_.c_str(), &buf) == -1) {
if (::stat(path_.c_str(), &buf) == -1) {
throw Error(2, path_, strError(), "stat");
}
// MSVCRT rename that does not overwrite existing files
@@ -242,7 +243,7 @@ namespace Exiv2 {
}
std::remove(fileIo->path_.c_str());
// Set original file permissions
if (chmod(path_.c_str(), buf.st_mode) == -1) {
if (::chmod(path_.c_str(), buf.st_mode) == -1) {
throw Error(2, fileIo->path_, strError(), "chmod");
}
}
@@ -287,13 +288,13 @@ namespace Exiv2 {
}
if (switchMode(opSeek) != 0) return 1;
return fseek(fp_, offset, fileSeek);
return std::fseek(fp_, offset, fileSeek);
}
long FileIo::tell() const
{
assert(fp_ != 0);
return ftell(fp_);
return std::ftell(fp_);
}
@@ -301,7 +302,7 @@ namespace Exiv2 {
{
// Flush and commit only if the file is open for writing
if (fp_ != 0 && (openMode_[0] != 'r' || openMode_[1] == '+')) {
fflush(fp_);
std::fflush(fp_);
#if defined WIN32 && !defined __CYGWIN__
// This is required on msvcrt before stat after writing to a file
_commit(_fileno(fp_));
@@ -309,7 +310,7 @@ namespace Exiv2 {
}
struct stat buf;
int ret = stat(path_.c_str(), &buf);
int ret = ::stat(path_.c_str(), &buf);
if (ret != 0) return -1;
return buf.st_size;
@@ -324,12 +325,12 @@ namespace Exiv2 {
int FileIo::open(const std::string& mode)
{
if (fp_ != 0) {
fclose(fp_);
std::fclose(fp_);
}
openMode_ = mode;
opMode_ = opSeek;
fp_ = fopen(path_.c_str(), mode.c_str());
fp_ = std::fopen(path_.c_str(), mode.c_str());
if (!fp_) return 1;
return 0;
}
@@ -342,7 +343,7 @@ namespace Exiv2 {
int FileIo::close()
{
if (fp_ != 0) {
fclose(fp_);
std::fclose(fp_);
fp_= 0;
}
return 0;
@@ -361,7 +362,7 @@ namespace Exiv2 {
{
assert(fp_ != 0);
if (switchMode(opRead) != 0) return 0;
return (long)fread(buf, 1, rcount, fp_);
return (long)std::fread(buf, 1, rcount, fp_);
}
int FileIo::getb()
@@ -379,7 +380,7 @@ namespace Exiv2 {
bool FileIo::eof() const
{
assert(fp_ != 0);
return feof(fp_) != 0;
return feof(fp_) != 0;
}
std::string FileIo::path() const
@@ -449,7 +450,7 @@ namespace Exiv2 {
{
reserve(wcount);
assert(isMalloced_);
memcpy(&data_[idx_], data, wcount);
std::memcpy(&data_[idx_], data, wcount);
idx_ += wcount;
return wcount;
}
@@ -562,7 +563,7 @@ namespace Exiv2 {
{
long avail = size_ - idx_;
long allow = std::min(rcount, avail);
memcpy(buf, &data_[idx_], allow);
std::memcpy(buf, &data_[idx_], allow);
idx_ += allow;
if (rcount > avail) eof_ = true;
return allow;
@@ -602,7 +603,7 @@ namespace Exiv2 {
throw Error(10, path, "rb", strError());
}
struct stat st;
if (0 != stat(path.c_str(), &st)) {
if (0 != ::stat(path.c_str(), &st)) {
throw Error(2, path, strError(), "stat");
}
DataBuf buf(st.st_size);
+6 -6
View File
@@ -33,6 +33,7 @@
#include "error.hpp"
#include "futils.hpp"
#include "basicio.hpp"
#include <cstring>
#include <iostream>
using Exiv2::byte;
@@ -135,8 +136,8 @@ int WriteReadSeek(BasicIo &io)
const char tester2[] = "Appending this on the end";
const char expect[] = "this is a little teAppending this on the end";
const long insert = 19;
const long len1 = (long)strlen(tester1) + 1;
const long len2 = (long)strlen(tester2) + 1;
const long len1 = (long)std::strlen(tester1) + 1;
const long len2 = (long)std::strlen(tester2) + 1;
if (io.open() != 0) {
throw Error(9, io.path(), strError());
@@ -155,7 +156,7 @@ int WriteReadSeek(BasicIo &io)
io.seek(-len1, BasicIo::cur);
int c = EOF;
memset(buf, -1, sizeof(buf));
std::memset(buf, -1, sizeof(buf));
for (int i = 0; (c=io.getb()) != EOF; ++i) {
buf[i] = (byte)c;
}
@@ -204,7 +205,7 @@ int WriteReadSeek(BasicIo &io)
if (io.open() != 0) {
throw Error(9, io.path(), strError());
}
memset(buf, -1, sizeof(buf));
std::memset(buf, -1, sizeof(buf));
if (io.read(buf, sizeof(buf)) != insert + len2) {
std::cerr << ": WRS something went wrong\n";
return 10;
@@ -216,11 +217,10 @@ int WriteReadSeek(BasicIo &io)
return 11;
}
if (strcmp(expect, (char*)buf) != 0 ) {
if (std::strcmp(expect, (char*)buf) != 0 ) {
std::cerr << ": WRS strings don't match 2\n";
return 12;
}
return 0;
}
+2 -2
View File
@@ -543,8 +543,8 @@ namespace Exiv2 {
if (outIo.write(tmpBuf, 33) != 33) throw Error(21);
// Write new XMP packet
if ( outIo.write(reinterpret_cast<const byte*>(xmpPacket_.data()), xmpPacket_.size())
!= static_cast<long>(xmpPacket_.size())) throw Error(21);
if ( outIo.write(reinterpret_cast<const byte*>(xmpPacket_.data()), static_cast<long>(xmpPacket_.size()))
!= static_cast<long>(xmpPacket_.size())) throw Error(21);
if (outIo.error()) throw Error(21);
--search;
}
+3 -2
View File
@@ -44,6 +44,7 @@ EXIV2_RCSID("@(#) $Id$")
#include <iomanip>
#include <iostream>
#include <cassert>
#include <cstring>
// *****************************************************************************
// class member definitions
@@ -74,7 +75,7 @@ namespace Exiv2 {
: MakerNote(rhs), absShift_(rhs.absShift_), shift_(rhs.shift_),
start_(rhs.start_), header_(rhs.header_.size_), ifd_(rhs.ifd_)
{
memcpy(header_.pData_, rhs.header_.pData_, header_.size_);
std::memcpy(header_.pData_, rhs.header_.pData_, header_.size_);
}
int IfdMakerNote::read(const byte* buf,
@@ -153,7 +154,7 @@ namespace Exiv2 {
long IfdMakerNote::copyHeader(byte* buf) const
{
if (header_.size_ != 0) memcpy(buf, header_.pData_, header_.size_);
if (header_.size_ != 0) std::memcpy(buf, header_.pData_, header_.size_);
return header_.size_;
}
+2 -2
View File
@@ -221,8 +221,8 @@ namespace Exiv2 {
std::string::size_type idx = xmpPacket.find_first_of('<');
if (idx != std::string::npos && idx > 0) {
#ifndef SUPPRESS_WARNINGS
std::cerr << "Warning: Removing " << idx << " characters "
<< "from the beginning of the XMP packet\n";
std::cerr << "Warning: Removing " << static_cast<unsigned long>(idx)
<< " characters from the beginning of the XMP packet\n";
#endif
xmpPacket = xmpPacket.substr(idx);
}
+4 -3
View File
@@ -44,6 +44,7 @@ EXIV2_RCSID("@(#) $Id$")
#include <ctime>
#include <cstdio>
#include <cassert>
#include <cstring>
// *****************************************************************************
// class member definitions
@@ -111,7 +112,7 @@ namespace Exiv2 {
{
if (size > 0) {
pData_ = new byte[size];
memcpy(pData_, pData, size);
std::memcpy(pData_, pData, size);
size_ = size;
}
}
@@ -326,8 +327,8 @@ namespace Exiv2 {
assert(tm != 0);
int rc = 1;
int year, mon, mday, hour, min, sec;
int scanned = sscanf(buf, "%4d:%2d:%2d %2d:%2d:%2d",
&year, &mon, &mday, &hour, &min, &sec);
int scanned = std::sscanf(buf, "%4d:%2d:%2d %2d:%2d:%2d",
&year, &mon, &mday, &hour, &min, &sec);
if (scanned == 6) {
tm->tm_year = year - 1900;
tm->tm_mon = mon - 1;
+2 -1
View File
@@ -49,6 +49,7 @@ EXIV2_RCSID("@(#) $Id$")
# include <unistd.h> // for getopt(), stat()
#endif
#include <climits>
#include <cerrno>
#include <cstdlib>
#include <cstring>
@@ -136,7 +137,7 @@ namespace Util {
{
if (!nptr || *nptr == '\0') return false;
char* endptr = 0;
long tmp = ::strtol(nptr, &endptr, 10);
long tmp = std::strtol(nptr, &endptr, 10);
if (*endptr != '\0') return false;
if (tmp == LONG_MAX || tmp == LONG_MIN) return false;
n = tmp;
+13 -3
View File
@@ -463,8 +463,8 @@ namespace Exiv2 {
std::ostringstream os;
write(os);
std::string s = os.str();
memcpy(buf, &s[0], s.size());
return s.size();
std::memcpy(buf, &s[0], s.size());
return static_cast<long>(s.size());
}
int XmpValue::read(const byte* buf,
@@ -479,7 +479,7 @@ namespace Exiv2 {
{
std::ostringstream os;
write(os);
return os.str().size();
return static_cast<long>(os.str().size());
}
XmpTextValue::XmpTextValue()
@@ -675,6 +675,11 @@ namespace Exiv2 {
return new LangAltValue(*this);
}
DateValue::DateValue()
: Value(date)
{
}
DateValue::DateValue(int year, int month, int day)
: Value(date)
{
@@ -776,6 +781,11 @@ namespace Exiv2 {
return l;
}
TimeValue::TimeValue()
: Value(time)
{
}
TimeValue::TimeValue(int hour, int minute,
int second, int tzHour,
int tzMinute)
+9 -7
View File
@@ -42,6 +42,7 @@
#include <iostream>
#include <sstream>
#include <memory>
#include <cstring>
// *****************************************************************************
// namespace extensions
@@ -919,7 +920,7 @@ namespace Exiv2 {
//! @name Creators
//@{
//! Default constructor.
DateValue() : Value(date) { memset(&date_, 0, sizeof(date_)); }
DateValue();
//! Constructor
DateValue(int year, int month, int day);
//! Virtual destructor.
@@ -929,6 +930,7 @@ namespace Exiv2 {
//! Simple Date helper structure
struct Date
{
Date() : year(0), month(0), day(0) {}
int year; //!< Year
int month; //!< Month
int day; //!< Day
@@ -950,8 +952,8 @@ namespace Exiv2 {
1 in case of an unsupported date format
*/
virtual int read(const byte* buf,
long len,
ByteOrder byteOrder =invalidByteOrder);
long len,
ByteOrder byteOrder =invalidByteOrder);
/*!
@brief Set the value to that of the string buf.
@@ -1022,7 +1024,7 @@ namespace Exiv2 {
//! @name Creators
//@{
//! Default constructor.
TimeValue() : Value(time) { memset(&time_, 0, sizeof(time_)); }
TimeValue();
//! Constructor
TimeValue(int hour, int minute, int second =0,
int tzHour =0, int tzMinute =0);
@@ -1414,7 +1416,7 @@ namespace Exiv2 {
{
if (rhs.sizeDataArea_ > 0) {
pDataArea_ = new byte[rhs.sizeDataArea_];
memcpy(pDataArea_, rhs.pDataArea_, rhs.sizeDataArea_);
std::memcpy(pDataArea_, rhs.pDataArea_, rhs.sizeDataArea_);
sizeDataArea_ = rhs.sizeDataArea_;
}
}
@@ -1435,7 +1437,7 @@ namespace Exiv2 {
byte* tmp = 0;
if (rhs.sizeDataArea_ > 0) {
tmp = new byte[rhs.sizeDataArea_];
memcpy(tmp, rhs.pDataArea_, rhs.sizeDataArea_);
std::memcpy(tmp, rhs.pDataArea_, rhs.sizeDataArea_);
}
delete[] pDataArea_;
pDataArea_ = tmp;
@@ -1586,7 +1588,7 @@ namespace Exiv2 {
byte* tmp = 0;
if (len > 0) {
tmp = new byte[len];
memcpy(tmp, buf, len);
std::memcpy(tmp, buf, len);
}
delete[] pDataArea_;
pDataArea_ = tmp;
+1 -1
View File
@@ -126,7 +126,7 @@ namespace Exiv2 {
if (rhs.value_.get() != 0) value_ = rhs.value_->clone(); // deep copy
}
Xmpdatum::Impl::Impl& Xmpdatum::Impl::operator=(const Impl& rhs)
Xmpdatum::Impl& Xmpdatum::Impl::operator=(const Impl& rhs)
{
if (this == &rhs) return *this;
key_.reset();