Skip to content

Commit

Permalink
Replace strtof with strtod (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
nacnudus committed Feb 18, 2017
1 parent d3ca388 commit 4b69818
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ color::color(rapidxml::xml_node<>* color, styles* styles) {

rapidxml::xml_attribute<>* tint = color->first_attribute("tint");
if (tint != NULL) {
tint_[0] = strtof(tint->value(), NULL);
tint_[0] = strtod(tint->value(), NULL);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/gradientFill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ gradientFill::gradientFill(

rapidxml::xml_attribute<>* left = gradientFill->first_attribute("left");
if (left != NULL)
left_[0] = strtof(left->value(), NULL);
left_[0] = strtod(left->value(), NULL);

rapidxml::xml_attribute<>* right = gradientFill->first_attribute("right");
if (right != NULL)
right_[0] = strtof(right->value(), NULL);
right_[0] = strtod(right->value(), NULL);

rapidxml::xml_attribute<>* top = gradientFill->first_attribute("top");
if (top != NULL)
top_[0] = strtof(top->value(), NULL);
top_[0] = strtod(top->value(), NULL);

rapidxml::xml_attribute<>* bottom = gradientFill->first_attribute("bottom");
if (bottom != NULL)
bottom_[0] = strtof(bottom->value(), NULL);
bottom_[0] = strtod(bottom->value(), NULL);

rapidxml::xml_node<>* stop_node = gradientFill->first_node("stop");
color1_ = color(stop_node, styles);
Expand Down
12 changes: 7 additions & 5 deletions src/xlsxcell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,16 @@ void xlsxcell::cacheValue(
if (book.styles_.isDate_[book.styles_.cellXfs_[svalue].numFmtId_[0]]) {
// local number format is a date format
sheet->data_type_[i] = "date";
double date = strtof(vvalue.c_str(), NULL);
double date = strtod(vvalue.c_str(), NULL);
if (book.dateSystem_ == 1900 && date < 61) {
warning("Dates before 1 March 1900 are off by one, due to Excel's famous bug.");
}
sheet->date_[i] = (date - book.dateOffset_) * 86400;
/* sheet->numeric_[i] = (date - book.dateOffset_) * 86400; */
return;
} else {
sheet->data_type_[i] = "numeric";
sheet->numeric_[i] = strtof(vvalue.c_str(), NULL);
sheet->numeric_[i] = strtod(vvalue.c_str(), NULL);
}
} else if (
book.styles_.isDate_[
Expand All @@ -132,15 +133,16 @@ void xlsxcell::cacheValue(
) {
// style number format is a date format
sheet->data_type_[i] = "date";
double date = strtof(vvalue.c_str(), NULL);
double date = strtod(vvalue.c_str(), NULL);
if (book.dateSystem_ == 1900 && date < 61) {
warning("Dates before 1 March 1900 are off by one, due to Excel's famous bug.");
}
sheet->date_[i] = (date - book.dateOffset_) * 86400;
/* sheet->numeric_[i] = (date - book.dateOffset_) * 86400; */
return;
} else {
sheet->data_type_[i] = "numeric";
sheet->numeric_[i] = strtof(vvalue.c_str(), NULL);
sheet->numeric_[i] = strtod(vvalue.c_str(), NULL);
}
} else if (tvalue == "s") {
// the t attribute exists and its value is exactly "s", so v is an index
Expand All @@ -155,7 +157,7 @@ void xlsxcell::cacheValue(
return;
} else if (tvalue == "b"){
sheet->data_type_[i] = "logical";
sheet->logical_[i] = strtof(vvalue.c_str(), NULL);
sheet->logical_[i] = strtod(vvalue.c_str(), NULL);
return;
} else if (tvalue == "e") {
sheet->data_type_[i] = "error";
Expand Down
8 changes: 4 additions & 4 deletions src/xlsxsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ void xlsxsheet::cacheDefaultRowColDims(rapidxml::xml_node<>* worksheet) {
rapidxml::xml_attribute<>* defaultRowHeight =
sheetFormatPr_->first_attribute("defaultRowHeight");
if (defaultRowHeight != NULL)
defaultRowHeight_ = strtof(defaultRowHeight->value(), NULL);
defaultRowHeight_ = strtod(defaultRowHeight->value(), NULL);

rapidxml::xml_attribute<>*defaultColWidth =
sheetFormatPr_->first_attribute("defaultColWidth");
if (defaultColWidth != NULL) {
defaultColWidth_ = strtof(defaultColWidth->value(), NULL);
defaultColWidth_ = strtod(defaultColWidth->value(), NULL);
} else {
// If defaultColWidth not given, ECMA says you can work it out based on
// baseColWidth, but that isn't necessarily given either, and the formula
Expand Down Expand Up @@ -110,7 +110,7 @@ void xlsxsheet::cacheColWidths(rapidxml::xml_node<>* worksheet) {
// <col> applies to columns from a min to a max, which must be iterated over
unsigned int min = strtol(col->first_attribute("min")->value(), NULL, 10);
unsigned int max = strtol(col->first_attribute("max")->value(), NULL, 10);
double width = strtof(col->first_attribute("width")->value(), NULL);
double width = strtod(col->first_attribute("width")->value(), NULL);

for (unsigned int column = min; column <= max; ++column)
colWidths_[column - 1] = width;
Expand Down Expand Up @@ -191,7 +191,7 @@ void xlsxsheet::parseSheetData(rapidxml::xml_node<>* sheetData) {
double rowHeight = defaultRowHeight_;
rapidxml::xml_attribute<>* ht = row->first_attribute("ht");
if (ht != NULL)
rowHeight = strtof(ht->value(), NULL);
rowHeight = strtod(ht->value(), NULL);

for (rapidxml::xml_node<>* c = row->first_node();
c; c = c->next_sibling()) {
Expand Down

0 comments on commit 4b69818

Please sign in to comment.