|
a/src/internfile/mh_text.cpp |
|
b/src/internfile/mh_text.cpp |
|
... |
|
... |
69 |
m_config->getConfParam("textfilepagekbs", &ps);
|
69 |
m_config->getConfParam("textfilepagekbs", &ps);
|
70 |
if (ps != -1) {
|
70 |
if (ps != -1) {
|
71 |
ps *= KB;
|
71 |
ps *= KB;
|
72 |
m_paging = true;
|
72 |
m_paging = true;
|
73 |
}
|
73 |
}
|
|
|
74 |
// Note: size_t is guaranteed unsigned, so max if ps is -1
|
74 |
m_pagesz = size_t(ps);
|
75 |
m_pagesz = size_t(ps);
|
75 |
string reason;
|
76 |
if (!readnext())
|
76 |
LOGDEB(("calling file_to_string\n"));
|
|
|
77 |
// file_to_string() takes pagesz == size_t(-1) to mean read all.
|
|
|
78 |
if (!file_to_string(fn, m_text, 0, m_pagesz, &reason)) {
|
|
|
79 |
LOGERR(("MimeHandlerText: can't read file: %s\n", reason.c_str()));
|
|
|
80 |
return false;
|
77 |
return false;
|
81 |
}
|
|
|
82 |
LOGDEB(("file_to_string OK\n"));
|
|
|
83 |
m_offs = m_text.length();
|
|
|
84 |
}
|
78 |
}
|
85 |
if (!m_forPreview) {
|
79 |
if (!m_forPreview) {
|
86 |
string md5, xmd5;
|
80 |
string md5, xmd5;
|
87 |
MD5String(m_text, md5);
|
81 |
MD5String(m_text, md5);
|
88 |
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
|
82 |
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
|
|
... |
|
... |
175 |
// EOF
|
169 |
// EOF
|
176 |
m_havedoc = false;
|
170 |
m_havedoc = false;
|
177 |
return true;
|
171 |
return true;
|
178 |
}
|
172 |
}
|
179 |
|
173 |
|
180 |
// If possible try to adjust the chunk to end right after a line
|
174 |
// If possible try to adjust the chunk to end right after a line
|
181 |
// Don't do this for the last chunk
|
175 |
// Don't do this for the last chunk. Last chunk of exactly the
|
|
|
176 |
// page size might be unduly split, no big deal
|
182 |
if (m_text.length() == m_pagesz) {
|
177 |
if (m_text.length() == m_pagesz) {
|
183 |
string::size_type pos = m_text.find_last_of("\n\r");
|
178 |
string::size_type pos = m_text.find_last_of("\n\r");
|
184 |
if (pos != string::npos && pos != 0) {
|
179 |
if (pos != string::npos && pos != 0) {
|
185 |
m_text.erase(pos);
|
180 |
m_text.erase(pos);
|
186 |
}
|
181 |
}
|