[rkward-cvs] SF.net SVN: rkward: [828] trunk/rkward/rkward/core/rkvariable.cpp

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Oct 8 22:05:02 UTC 2006


Revision: 828
          http://svn.sourceforge.net/rkward/?rev=828&view=rev
Author:   tfry
Date:     2006-10-08 15:04:58 -0700 (Sun, 08 Oct 2006)

Log Message:
-----------
Be more generous when extending length (fixes another crash on 100+ rows)
when in non-string mode, treat all empty strings as NA

Modified Paths:
--------------
    trunk/rkward/rkward/core/rkvariable.cpp

Modified: trunk/rkward/rkward/core/rkvariable.cpp
===================================================================
--- trunk/rkward/rkward/core/rkvariable.cpp	2006-10-08 22:04:04 UTC (rev 827)
+++ trunk/rkward/rkward/core/rkvariable.cpp	2006-10-08 22:04:58 UTC (rev 828)
@@ -347,9 +347,10 @@
 		return;
 	}
 
+	int ilength = length + 1;		// be a little generous
 	int target = myData ()->allocated_length;
 	if (!target) target = INITIAL_ALLOC;
-	while (target < length) target = target * ALLOC_STEP;
+	while (target <= ilength) target = target * ALLOC_STEP;
 	RK_DO (qDebug ("resizing from %d to %d", myData ()->allocated_length, target), OBJECTS, DL_DEBUG);
 
 	QString **new_string_data = new QString*[target];
@@ -434,7 +435,7 @@
 			myData ()->cell_string_data[row] = new QString (text);
 		}
 	} else if (getVarType () == Factor) {
-		if (text.isNull ()) {
+		if (text.isEmpty ()) {
 			myData ()->cell_string_data[row] = na_char;
 		} else if (myData ()->value_labels && myData ()->value_labels->contains (text)) {
 			myData ()->cell_double_data[row] = text.toInt ();
@@ -447,7 +448,7 @@
 		bool ok;
 		myData ()->cell_double_data[row] = text.toDouble (&ok);
 		if (!ok) {
-			if (text.isNull ()) {
+			if (text.isEmpty ()) {
 				myData ()->cell_string_data[row] = na_char;
 			} else {
 				myData ()->invalid_count++;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list