Handle tag separators

This commit is contained in:
Andreas Steffen
2014-04-15 09:28:38 +02:00
parent edd2ed860f
commit fa6c5f3506
2 changed files with 16 additions and 13 deletions
+6 -3
View File
@@ -63,9 +63,10 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator,
status_t status = SUCCESS; status_t status = SUCCESS;
/* Assemble the SWID generator command */ /* Assemble the SWID generator command */
snprintf(command, sizeof(command), "%s %s%s%s\n", generator, snprintf(command, sizeof(command), "%s %s%s%s%s\n", generator,
(this->full_tags) ? "swid" : "software-id", (this->full_tags) ? "swid" : "software-id",
(this->full_tags && pretty) ? " --pretty" : "", (this->full_tags && pretty) ? " --pretty" : "",
(this->full_tags && !pretty) ? " --doc-separator $'\n\n'" : "",
(this->full_tags && full) ? " --full" : ""); (this->full_tags && full) ? " --full" : "");
/* Open a pipe stream for reading the output of the dpkg-query commmand */ /* Open a pipe stream for reading the output of the dpkg-query commmand */
@@ -108,9 +109,10 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator,
tag_encoding = writer->get_buf(writer); tag_encoding = writer->get_buf(writer);
if (tag_encoding.len > 1)
{
/* remove trailing newline if present */ /* remove trailing newline if present */
if (tag_encoding.len > 0 && if (tag_encoding.ptr[tag_encoding.len - 1] == '\n')
tag_encoding.ptr[tag_encoding.len - 1] == '\n')
{ {
tag_encoding.len--; tag_encoding.len--;
} }
@@ -118,6 +120,7 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator,
tag = swid_tag_create(tag_encoding, tag_file_path); tag = swid_tag_create(tag_encoding, tag_file_path);
this->list->insert_last(this->list, tag); this->list->insert_last(this->list, tag);
}
writer->destroy(writer); writer->destroy(writer);
} }
} }
@@ -24,7 +24,7 @@ libimcv {
push_info = no push_info = no
} }
imc-swid { imc-swid {
swid_pretty = yes swid_pretty = no
} }
} }
} }