[MOAB-dev] r3271 - MOAB/trunk/tools/iMesh

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Tue Nov 3 12:31:31 CST 2009


Author: kraftche
Date: 2009-11-03 12:31:31 -0600 (Tue, 03 Nov 2009)
New Revision: 3271

Modified:
   MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
Log:
portability fix: std::string may maintain as an explicit value and need not null-terminate its internal string rep unless c_str() is called, so setting a character in the string to NIL is not a valid way to truncate it.

Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2009-11-03 16:05:44 UTC (rev 3270)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2009-11-03 18:31:31 UTC (rev 3271)
@@ -2993,8 +2993,9 @@
 
 void eatwhitespace(std::string &this_string) 
 {
-  std::string::size_type len = this_string.find_last_not_of(" ");
-  if (len != this_string.npos) this_string[len+1] = '\0';
+  std::string::size_type p = this_string.find_last_not_of(" ");
+  if (p != this_string.npos)
+    this_string.resize(p+1);
 }
   
 void cfunc_(int arg3, char *mystr, char *mystr2, int arg2, 



More information about the moab-dev mailing list