1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00

clear map file on error; trim spaces in manifest

This commit is contained in:
Lu Wang 2013-05-06 17:25:41 +08:00
parent ff36ae6942
commit c1104cb00f
2 changed files with 23 additions and 7 deletions

View File

@ -346,12 +346,13 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
{ {
string map_filename;
ofstream map_outf; ofstream map_outf;
if(param.debug) if(param.debug)
{ {
string fn = (char*)str_fmt("%s/f%llx.map", param.tmp_dir.c_str(), info.id); map_filename = (char*)str_fmt("%s/f%llx.map", param.tmp_dir.c_str(), info.id);
tmp_files.add(fn); tmp_files.add(map_filename);
map_outf.open(fn); map_outf.open(map_filename);
} }
unordered_set<int> codeset; unordered_set<int> codeset;
@ -427,7 +428,8 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
cur_code = -1; cur_code = -1;
if(param.debug) if(param.debug)
{ {
map_outf.seekp(0); map_outf.close();
map_outf.open(map_filename);
} }
continue; continue;
} }

View File

@ -396,9 +396,23 @@ void HTMLRenderer::post_process(void)
continue; continue;
} }
if(line.empty() // trim space at both sides
|| (line.find_first_not_of(' ') == string::npos) {
|| line[0] == '#') static const char * whitespaces = " \t\n\v\f\r";
auto idx1 = line.find_first_not_of(whitespaces);
if(idx1 == string::npos)
{
line.clear();
}
else
{
auto idx2 = line.find_last_not_of(whitespaces);
assert(idx2 >= idx1);
line = line.substr(idx1, idx2 - idx1 + 1);
}
}
if(line.empty() || line[0] == '#')
continue; continue;