Allow to add/set tags without a value with the command line tool.

v0.27.3
Andreas Huggel 14 years ago
parent 863772fba1
commit 19f165629f

@ -384,6 +384,10 @@ is determined based on \fIkey\fP.
The remaining text on the line is the value. It can optionally be The remaining text on the line is the value. It can optionally be
enclosed in single quotes ('\fIvalue\fP') or double quotes ("\fIvalue\fP"). enclosed in single quotes ('\fIvalue\fP') or double quotes ("\fIvalue\fP").
.sp 1 .sp 1
The value is optional. Not providing any value is equivalent to an
empty value ("") and is mainly useful to create an XMP array property,
e.g., a bag.
.sp 1
The format of Exif \fBComment\fP values includes an optional charset The format of Exif \fBComment\fP values includes an optional charset
specification at the beginning: specification at the beginning:
.sp 1 .sp 1

@ -1098,21 +1098,24 @@ namespace {
bool explicitType = false; bool explicitType = false;
if (cmdId != del) { if (cmdId != del) {
// Get type and value // Get type and value
std::string::size_type typeStart std::string::size_type typeStart = std::string::npos;
= line.find_first_not_of(delim, keyEnd+1); if (keyEnd != std::string::npos) typeStart = line.find_first_not_of(delim, keyEnd+1);
std::string::size_type typeEnd std::string::size_type typeEnd = std::string::npos;
= line.find_first_of(delim, typeStart+1); if (typeStart != std::string::npos) typeEnd = line.find_first_of(delim, typeStart+1);
std::string::size_type valStart = typeStart; std::string::size_type valStart = typeStart;
std::string::size_type valEnd = line.find_last_not_of(delim); std::string::size_type valEnd = std::string::npos;
if (valStart != std::string::npos) valEnd = line.find_last_not_of(delim);
if ( keyEnd == std::string::npos if ( cmdId == reg
|| typeStart == std::string::npos && ( keyEnd == std::string::npos
|| valStart == std::string::npos) { || valStart == std::string::npos)) {
throw Exiv2::Error(1, Exiv2::toString(num) throw Exiv2::Error(1, Exiv2::toString(num)
+ ": " + _("Invalid command line") + " " ); + ": " + _("Invalid command line") + " " );
} }
if (cmdId != reg && typeEnd != std::string::npos) { if ( cmdId != reg
&& typeStart != std::string::npos
&& typeEnd != std::string::npos) {
std::string typeStr(line.substr(typeStart, typeEnd-typeStart)); std::string typeStr(line.substr(typeStart, typeEnd-typeStart));
Exiv2::TypeId tmpType = Exiv2::TypeInfo::typeId(typeStr); Exiv2::TypeId tmpType = Exiv2::TypeInfo::typeId(typeStr);
if (tmpType != Exiv2::invalidTypeId) { if (tmpType != Exiv2::invalidTypeId) {
@ -1126,11 +1129,13 @@ namespace {
} }
} }
value = parseEscapes(line.substr(valStart, valEnd+1-valStart)); if (valStart != std::string::npos) {
std::string::size_type last = value.length()-1; value = parseEscapes(line.substr(valStart, valEnd+1-valStart));
if ( (value[0] == '"' && value[last] == '"') std::string::size_type last = value.length()-1;
|| (value[0] == '\'' && value[last] == '\'')) { if ( (value[0] == '"' && value[last] == '"')
value = value.substr(1, value.length()-2); || (value[0] == '\'' && value[last] == '\'')) {
value = value.substr(1, value.length()-2);
}
} }
} }

Loading…
Cancel
Save