Corrections to buffers size and check for data correctness

Bugfix 30D shot posted on forum
This commit is contained in:
ffsup2
2011-01-09 14:06:38 +01:00
parent 15517c0c5d
commit b898608142
4 changed files with 55 additions and 38 deletions

View File

@@ -244,7 +244,9 @@ class FNumberInterpreter : public Interpreter {
FNumberInterpreter () {}
virtual std::string toString (Tag* t) {
char buffer[32];
sprintf (buffer, "%0.1f", t->toDouble());
double v = t->toDouble();
if( v < 0. || v > 1000. ) return "undef";
sprintf (buffer, "%0.1f", v);
return buffer;
}
};
@@ -255,7 +257,9 @@ class ApertureInterpreter : public Interpreter {
ApertureInterpreter () {}
virtual std::string toString (Tag* t) {
char buffer[32];
sprintf (buffer, "%0.1f", pow(2.0, t->toDouble()/2.0));
double v = pow(2.0, t->toDouble()/2.0);
if( v < 0. || v > 1000. ) return "undef";
sprintf (buffer, "%.1f", v );
return buffer;
}
};
@@ -266,7 +270,9 @@ class ExposureBiasInterpreter : public Interpreter {
ExposureBiasInterpreter () {}
virtual std::string toString (Tag* t) {
char buffer[32];
sprintf (buffer, "%+0.2f", t->toDouble());
double v = t->toDouble();
if( v < -1000. || v > 1000. ) return "undef";
sprintf (buffer, "%+0.2f", v );
return buffer;
}
};
@@ -276,12 +282,12 @@ class ShutterSpeedInterpreter : public Interpreter {
public:
ShutterSpeedInterpreter () {}
virtual std::string toString (Tag* t) {
char buffer[32];
char buffer[1024];
double d = pow (2.0, -t->toDouble());
if (d > 0.0 && d < 0.9)
sprintf (buffer, "1/%0.0f", 1.0 / d);
sprintf (buffer, "1/%.0f", 1.0 / d);
else
sprintf (buffer, "%0.1f", d);
sprintf (buffer, "%.1f", d);
return buffer;
}
};
@@ -291,12 +297,12 @@ class ExposureTimeInterpreter : public Interpreter {
public:
ExposureTimeInterpreter () {}
virtual std::string toString (Tag* t) {
char buffer[32];
char buffer[1024];
double d = t->toDouble();
if (d > 0.0 && d < 0.9)
sprintf (buffer, "1/%0.0f", 1.0 / d);
sprintf (buffer, "1/%.0f", 1.0 / d);
else
sprintf (buffer, "%0.1f", d);
sprintf (buffer, "%.1f", d);
return buffer;
}
};
@@ -307,7 +313,9 @@ class FocalLengthInterpreter : public Interpreter {
FocalLengthInterpreter () {}
virtual std::string toString (Tag* t) {
char buffer[32];
sprintf (buffer, "%0.1f", t->toDouble());
double v = t->toDouble();
if( v>1000000. || v<0 ) return "undef";
sprintf (buffer, "%.1f", v );
return buffer;
}
};