diff options
Diffstat (limited to 'crawl-ref/source/format.cc')
-rw-r--r-- | crawl-ref/source/format.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc index 390133f3d5..9eb82cb8d3 100644 --- a/crawl-ref/source/format.cc +++ b/crawl-ref/source/format.cc @@ -314,3 +314,22 @@ void formatted_string::fs_op::display() const break; } } + +int count_linebreaks(const formatted_string& fs) +{ + std::string::size_type where = 0; + const std::string s = fs; + int count = 0; + while ( 1 ) + { + where = s.find(EOL, where); + if ( where == std::string::npos ) + break; + else + { + ++count; + ++where; + } + } + return count; +} |