-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
several improvements #5
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,10 @@ class rtf_keyword{ | |
int param; | ||
char ctrl_chr; | ||
bool is_ctrl_chr; | ||
|
||
char value_8bit; | ||
bool is_8bit; | ||
|
||
public: | ||
// iter must point after the backslash starting the keyword. We don't check it. | ||
// after construction, iter points at the char following the keyword | ||
|
@@ -64,18 +68,38 @@ class rtf_keyword{ | |
{ return param; } | ||
char control_char() const | ||
{ return ctrl_chr; } | ||
bool is_symbol_8bit() const | ||
{ return is_8bit; } | ||
char symbol_8bit() const | ||
{ return value_8bit; } | ||
}; | ||
|
||
template <class InputIter> | ||
rtf_keyword::rtf_keyword(InputIter &iter) | ||
{ | ||
char curchar=*iter; | ||
is_ctrl_chr=!isalpha(curchar); | ||
is_8bit = false; | ||
|
||
if (is_ctrl_chr) | ||
{ | ||
ctrl_chr=curchar; | ||
++iter; | ||
if (curchar == '\'') | ||
{ | ||
char buf[4] = {0, 0, 0, 0}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not 3? Just in case? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better alignment :) |
||
value_8bit = 0; | ||
is_ctrl_chr = false; | ||
is_8bit = true; | ||
curchar = *(++iter); | ||
for (int i = 0; i < 2 && isxdigit(curchar); ++i, curchar = *(++iter)) | ||
buf[i] = curchar; | ||
|
||
value_8bit = strtol(buf, NULL, 16); | ||
} | ||
else | ||
{ | ||
ctrl_chr=curchar; | ||
++iter; | ||
} | ||
} | ||
else | ||
{ | ||
|
@@ -92,7 +116,7 @@ rtf_keyword::rtf_keyword(InputIter &iter) | |
param=-1; | ||
else | ||
param=std::atoi(param_str.c_str()); | ||
if (curchar==' ') | ||
if (isspace(curchar)) | ||
++iter; | ||
keyword_map::iterator kw_pos=keymap.find(s_keyword); | ||
if (kw_pos==keymap.end()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,10 +69,8 @@ std::string table::make() | |
// first, we'll determine all the rowspans and leftsides | ||
for (row=begin(); row!=end(); ++row) | ||
{ | ||
if ((*row)->CellDefs->size()!=(*row)->Cells.size()) | ||
throw std::logic_error("Number of Cells and number of CellDefs are unequal!"); | ||
for (cell_def=(*row)->CellDefs->begin(), cell=(*row)->Cells.begin(); | ||
cell!=(*row)->Cells.end(); | ||
cell!=(*row)->Cells.end() && cell_def!=(*row)->CellDefs->end(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you seen any cases when we had this error on a real rtf file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I have. I converted RTF specifaction (from here: https://www.microsoft.com/en-us/download/details.aspx?id=10725) to RTF format using LibreOffice Writer 5.1.4.2. Then I tried to make an HTML file from it using rtf2html. And I got that error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so which list was longer? And what was in its 'extra' elements? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to know before I pull this, as the situation itself looks very strange. |
||
++cell, prev_cell_def=cell_def++ | ||
) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
.write()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, write_char is probably redundant