From 32f5de396df8a4072a0756bdbd9ca37ddcc42004 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Fri, 12 Oct 2012 16:38:14 +0200 Subject: [PATCH] Remove a type Fix ONCE AND FOR ALL compilation issues for g++ prior to ver. 4.5 (remove for( : ) iterations and some instances of auto). --- xml-tree-inc.hpp | 2 +- xml-tree.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/xml-tree-inc.hpp b/xml-tree-inc.hpp index 90717de..de88de0 100644 --- a/xml-tree-inc.hpp +++ b/xml-tree-inc.hpp @@ -28,7 +28,7 @@ xml_tree::subtree_tags(xml_tree::node_t x, xml_tree::tag_t label) const xml_tree::node_t y = bp_find_close(this->par, x); if (y - x < 10) { uint32_t count = 0; - for (xml_tree::node i = x; i <= y; ++i) + for (xml_tree::node_t i = x; i <= y; ++i) count += (tag(i) == label); return count; } else { diff --git a/xml-tree.cpp b/xml-tree.cpp index 158ec1b..0e597e3 100644 --- a/xml-tree.cpp +++ b/xml-tree.cpp @@ -97,8 +97,12 @@ xml_tree::xml_tree(std::vector *tags_, this->tag_ids = tag_ids; tag_names = new std::vector(); tag_names->resize(tag_ids->size()); - for(auto val : *(this->tag_ids)) - (*this->tag_names)[val.second] = val.first; + std::unordered_map::iterator val; + //for(auto val : *(this->tag_ids)) + //(*this->tag_names)[val.second] = val.first; + for(val = this->tag_ids->begin(); val != this->tag_ids->end(); ++val) + (*this->tag_names)[val->second] = val->first; + uint32_t max_tag = tag_names->size() - 1; bit_vector *tmp_bitmap = new bit_vector(npar, 1, 0); @@ -371,8 +375,7 @@ std::pair xml_tree::text_id_range(xml_tree::node_t x) const i = 0; else i = text_positions->rank1(x-1); - - j = text_positions->rank1(y); + j = text_positions->rank1(y); // fprintf(stderr, "Rank of node %i is %i, rank of closing %i is %i\n", x, i, y, j); if (i == j) return std::make_pair(xml_tree::NIL, xml_tree::NIL); @@ -446,7 +449,8 @@ const char * xml_tree::get_tag_name_by_ref(xml_tree::tag_t tagid) const xml_tree::tag_t xml_tree::register_tag(char *s) { - auto found = tag_ids->find(std::string(s)); + std::unordered_map::iterator found; + found = tag_ids->find(std::string(s)); if (found == tag_ids->end()) return xml_tree::NIL_TAG_ID; else @@ -499,7 +503,7 @@ void xml_tree::print(xml_tree::node_t x, int fd, bool no_text) unsigned char * orig_text; unsigned char * current_text; - auto r = text_id_range(x); + std::pair r = text_id_range(x); if (r.first == xml_tree::NIL) current_text = 0; else { -- 2.17.1