Merge pull request #137 from tbeu/some-cleanup

Cleanup some issues
This commit is contained in:
Luis Díaz Más 2017-11-05 17:02:22 +01:00 committed by GitHub
commit e2940cc30b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 43 deletions

View File

@ -249,12 +249,15 @@ namespace Action {
case Params::pmRecursive: rc = printStructure(std::cout,Exiv2::kpsRecursive) ; break;
case Params::pmXMP:
option = option == Exiv2::kpsNone ? Exiv2::kpsXMP : option; // drop
case Params::pmIccProfile:{
option = option == Exiv2::kpsNone ? Exiv2::kpsIccProfile : option;
_setmode(_fileno(stdout),O_BINARY);
rc = printStructure(std::cout,option);
} break;
if (option == Exiv2::kpsNone)
option = Exiv2::kpsXMP;
// drop
case Params::pmIccProfile:
if (option == Exiv2::kpsNone)
option = Exiv2::kpsIccProfile;
_setmode(_fileno(stdout),O_BINARY);
rc = printStructure(std::cout,option);
break;
}
return rc;
}

View File

@ -1817,15 +1817,17 @@ namespace Exiv2 {
{
ExifKey key("Exif.CanonCs.Lens");
ExifData::const_iterator pos = metadata->findKey(key);
ltfl.focalLengthMin_ = 0.0;
ltfl.focalLengthMax_ = 0.0;
if ( pos != metadata->end()
&& pos->value().count() >= 3
&& pos->value().typeId() == unsignedShort) {
float fu = pos->value().toFloat(2);
if (fu != 0.0) {
ltfl.focalLengthMin_ = pos->value().toLong(1) / fu;
ltfl.focalLengthMax_ = pos->value().toLong(0) / fu;
ltfl.focalLengthMin_ = 0.0f;
ltfl.focalLengthMax_ = 0.0f;
if (pos != metadata->end()) {
const Value &value = pos->value();
if ( value.count() >= 3
&& value.typeId() == unsignedShort) {
float fu = value.toFloat(2);
if (fu != 0.0f) {
ltfl.focalLengthMin_ = value.toLong(1) / fu;
ltfl.focalLengthMax_ = value.toLong(0) / fu;
}
}
}
}
@ -1938,12 +1940,12 @@ namespace Exiv2 {
if ( value.typeId() != unsignedShort
|| value.count() == 0) return os << "(" << value << ")";
// #1034
const std::string undefined("undefined") ;
const std::string section ("canon");
if ( Internal::readExiv2Config(section,value.toString(),undefined) != undefined ) {
return os << Internal::readExiv2Config(section,value.toString(),undefined);
}
// #1034
const std::string undefined("undefined") ;
const std::string section ("canon");
if ( Internal::readExiv2Config(section,value.toString(),undefined) != undefined ) {
return os << Internal::readExiv2Config(section,value.toString(),undefined);
}
const LensIdFct* lif = find(lensIdFct, value.toLong());
if (!lif) {

View File

@ -230,7 +230,6 @@ namespace Exiv2 {
std::ostream& CasioMakerNote::print0x0015(std::ostream& os, const Value& value, const ExifData*)
{
// format is: "YYMM#00#00DDHH#00#00MM#00#00#00#00" or "YYMM#00#00DDHH#00#00MMSS#00#00#00"
std::string s;
std::vector<char> numbers;
for(long i=0; i<value.size(); i++)
{
@ -550,7 +549,6 @@ namespace Exiv2 {
std::ostream& Casio2MakerNote::print0x2001(std::ostream& os, const Value& value, const ExifData*)
{
// format is: "YYMM#00#00DDHH#00#00MM#00#00#00#00"
std::string s;
std::vector<char> numbers;
for(long i=0; i<value.size(); i++)
{

View File

@ -1498,7 +1498,7 @@ namespace {
typedef bool (*ConvFct)(std::string& str);
struct ConvFctList {
bool operator==(std::pair<const char*, const char*> fromTo) const
bool operator==(const std::pair<const char*, const char*> &fromTo) const
{ return 0 == strcmp(from_, fromTo.first) && 0 == strcmp(to_, fromTo.second); }
const char* from_;
const char* to_;

View File

@ -994,26 +994,22 @@ namespace Exiv2 {
std::string stringFormat(const char* format, ...)
{
std::string result;
std::vector<char> buffer;
size_t need = std::strlen(format); // initial guess
int rc = -1;
int need = (int) std::strlen(format)*2; // initial guess
char* buffer = NULL;
int again = 4;
int rc = -1;
do {
buffer.resize(need + 1);
va_list args; // variable arg list
va_start(args, format); // args start after format
rc = vsnprintf(&buffer[0], buffer.size(), format, args);
va_end(args); // free the args
if ( rc > 0 )
need = static_cast<size_t>(rc);
} while ( buffer.size() <= need );
while (rc < 0 && again--) {
if ( buffer ) delete[] buffer;
need *= 2 ;
buffer = new char[need];
if ( buffer ) {
va_list args; // variable arg list
va_start(args, format); // args start after format
rc=vsnprintf(buffer,(unsigned int)need, format, args);
va_end(args); // free the args
}
}
if ( rc > 0 ) result = std::string(buffer) ;
if ( buffer ) delete[] buffer; // free buffer
if ( rc > 0 )
result = std::string(&buffer[0], need);
return result;
}

View File

@ -478,7 +478,7 @@ namespace Exiv2 {
out.erase(end_pos, out.end());
bool bURI = out.find("http://") != std::string::npos ;
bool bNS = out.find(":") != std::string::npos && !bURI;
bool bNS = out.find(':') != std::string::npos && !bURI;
// pop trailing ':' on a namespace
if ( bNS ) {