Skip to content

Commit

Permalink
gemmi-tags: set max length of values written to a tsv file
Browse files Browse the repository at this point in the history
  • Loading branch information
wojdyr committed Dec 12, 2024
1 parent 7bfaf42 commit e4b934b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions prog/tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const option::Descriptor Usage[] = {

constexpr int ENUM_GATHER_LIMIT = 1000;
constexpr int ENUM_SHOW_LIMIT = 20;
constexpr int VALUE_LENGTH_LIMIT = 128;

struct TagStats {
int file_count = 0;
Expand Down Expand Up @@ -214,6 +215,10 @@ auto prepare_pairs(const TagStats& ts) {
});
for (auto& pair : pairs) {
std::string& s = pair.first;
if (s.size() > VALUE_LENGTH_LIMIT) {
s.resize(VALUE_LENGTH_LIMIT);
s += "[...]";
}
std::string::size_type pos = 0;
while ((pos = s.find_first_of("&<\"\t\r\n", pos)) != std::string::npos) {
std::string new_symbol;
Expand Down

0 comments on commit e4b934b

Please sign in to comment.