diff --git a/msvc/exiv2lib/exiv2lib.vcproj b/msvc/exiv2lib/exiv2lib.vcproj index c3221562..8bde9827 100644 --- a/msvc/exiv2lib/exiv2lib.vcproj +++ b/msvc/exiv2lib/exiv2lib.vcproj @@ -376,6 +376,9 @@ ObjectFile="$(IntDir)/$(InputName)1.obj"/> + + + + + + + + @@ -555,6 +567,9 @@ + + @@ -573,6 +588,9 @@ + + #include +#include #include #include // for remove, rename #include // 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(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); diff --git a/src/iotest.cpp b/src/iotest.cpp index dfb45784..9f17c7b5 100644 --- a/src/iotest.cpp +++ b/src/iotest.cpp @@ -33,6 +33,7 @@ #include "error.hpp" #include "futils.hpp" #include "basicio.hpp" +#include #include 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; } - diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index d085d430..4c04defc 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -543,8 +543,8 @@ namespace Exiv2 { if (outIo.write(tmpBuf, 33) != 33) throw Error(21); // Write new XMP packet - if ( outIo.write(reinterpret_cast(xmpPacket_.data()), xmpPacket_.size()) - != static_cast(xmpPacket_.size())) throw Error(21); + if ( outIo.write(reinterpret_cast(xmpPacket_.data()), static_cast(xmpPacket_.size())) + != static_cast(xmpPacket_.size())) throw Error(21); if (outIo.error()) throw Error(21); --search; } diff --git a/src/makernote.cpp b/src/makernote.cpp index c48c07fe..4ad4eb86 100644 --- a/src/makernote.cpp +++ b/src/makernote.cpp @@ -44,6 +44,7 @@ EXIV2_RCSID("@(#) $Id$") #include #include #include +#include // ***************************************************************************** // 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_; } diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp index a7baf3ce..29b151f7 100644 --- a/src/tiffvisitor.cpp +++ b/src/tiffvisitor.cpp @@ -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(idx) + << " characters from the beginning of the XMP packet\n"; #endif xmpPacket = xmpPacket.substr(idx); } diff --git a/src/types.cpp b/src/types.cpp index 33080ea5..8feb0d6a 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -44,6 +44,7 @@ EXIV2_RCSID("@(#) $Id$") #include #include #include +#include // ***************************************************************************** // 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; diff --git a/src/utils.cpp b/src/utils.cpp index b7dfbddf..c1355f2c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -49,6 +49,7 @@ EXIV2_RCSID("@(#) $Id$") # include // for getopt(), stat() #endif +#include #include #include #include @@ -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; diff --git a/src/value.cpp b/src/value.cpp index bcc99e76..fae83982 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -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(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(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) diff --git a/src/value.hpp b/src/value.hpp index 70e0d029..c6f67882 100644 --- a/src/value.hpp +++ b/src/value.hpp @@ -42,6 +42,7 @@ #include #include #include +#include // ***************************************************************************** // 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; diff --git a/src/xmp.cpp b/src/xmp.cpp index 9242755f..e2668d34 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -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();