Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit c9cde21

Browse files
committed
added some comments from debugging XML parsing segfault
1 parent 9b3efa4 commit c9cde21

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/character/character-generator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ int parse_args(int argc, char* argv[], Character* &character) {
126126
**/
127127
int main(int argc, char* argv[]) {
128128
Character* character = nullptr;
129+
129130
int status = parse_args(argc, argv, character); // may exit
130131

131132
if(character == nullptr) {

src/character/character.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,10 @@ namespace ORPG {
585585
Character* import_character(string file) {
586586
if(file.empty()) return new Character;
587587

588-
// TODO(incomingstick): check whether the file is XML or not
589-
590588
// create the container for the XML file to be opened
591589
Core::XMLDocument document;
592590

591+
// TODO(incomingstick): check whether the file is XML or not
593592
if (document.load_file(file)) {
594593
//TODO: create a character based on the imported XML file
595594
} else {

src/core/xml.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ XMLDocument::~XMLDocument() {
274274
* TODO doc comments
275275
* FIXME this crashes with the following error
276276
* Expression: cannot dereference string iterator because it is out of range (e.g. an end iterator)
277+
* This error is occuring when it reaches the "<noteList>" tag, as the notes span multiple lines. We
278+
* need to handle XMLAttribute data spanning multiple lines, as this is a very common things.
277279
**/
278280
bool XMLDocument::load_file(string filename) {
279281
//TODO load file
@@ -285,6 +287,7 @@ bool XMLDocument::load_file(string filename) {
285287
XMLElementClosingType closeType = XMLElementClosingType::DEFAULT;
286288
XMLElement* currElement = root;
287289

290+
// Do we want to zero index this and add 1 back after the fact, or just start at 1?
288291
currLine = 0;
289292

290293
// begin parsing the XML document one line at a time
@@ -358,6 +361,7 @@ bool XMLDocument::load_file(string filename) {
358361
/* TODO store this data */
359362
string data = "";
360363

364+
// TODO This only allows data to be a single line, what if it spans multiple lines?
361365
while(ch != buffer.end() && *ch != '<') {
362366
data += *ch++;
363367
}

0 commit comments

Comments
 (0)