[pan2: 6/268] WIP: seperate line length check for each quote level. should only be for quoted levels.
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2: 6/268] WIP: seperate line length check for each quote level. should only be for quoted levels.
- Date: Mon, 2 Jan 2012 15:38:30 +0000 (UTC)
commit 340a40823d52ead5529978c165ef14b3a2eef642
Author: K. Haley <haleykd users sf net>
Date: Fri May 28 17:55:20 2010 -0600
WIP: seperate line length check for each quote level. should only be for quoted levels.
pan/usenet-utils/text-massager.cc | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/pan/usenet-utils/text-massager.cc b/pan/usenet-utils/text-massager.cc
index 10c7cf7..9a2907a 100644
--- a/pan/usenet-utils/text-massager.cc
+++ b/pan/usenet-utils/text-massager.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <vector>
+#include <map>
#include <cstring>
#include <glib.h>
extern "C" {
@@ -26,7 +27,7 @@ extern "C" {
}
#include <glib/gunicode.h>
#include "text-massager.h"
-
+#include <pan/general/log.h>
using namespace pan;
TextMassager :: TextMassager ():
@@ -110,6 +111,8 @@ namespace
void merge_fixed (paragraphs_t ¶graphs, lines_t &lines, int wrap_col)
{
+ std::map<std::string, int> max_map;
+ std::map<std::string, int>::iterator map_end = max_map.end();
int prev_content_len = 0;
int max_len = wrap_col;
StringView cur_leader;
@@ -118,8 +121,13 @@ namespace
for (lines_cit it=lines.begin(), end=lines.end(); it!=end; ++it)
{
const Line& line (*it);
- max_len = MAX(max_len, line.leader.len + line.content.len);
+ int line_len = line.leader.len + line.content.len;
+ if (map_end != max_map.find(line.leader))
+ max_map[line.leader] = MAX(max_map[line.leader], line_len );
+ else
+ max_map.insert( std::make_pair(line.leader, line_len) );
}
+
for (lines_cit it=lines.begin(), end=lines.end(); it!=end; ++it)
{
const Line& line (*it);
@@ -138,7 +146,7 @@ namespace
// line but wasn't assume deliberate line break.
if (!paragraph_end && prev_content_len && line.content.len)
{
- int space = max_len - (prev_content_len + line.leader.len) - 1;
+ int space = max_map[line.leader] - (prev_content_len + line.leader.len) - 1;
if ( space > 0 && ((line.content.len < space)
|| g_utf8_strchr (line.content.str, space, ' ')) )
paragraph_end = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]