[MOAB-dev] r3856 - MOAB/trunk/src
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Thu May 6 18:06:01 CDT 2010
Author: kraftche
Date: 2010-05-06 18:06:00 -0500 (Thu, 06 May 2010)
New Revision: 3856
Modified:
MOAB/trunk/src/DebugOutput.cpp
Log:
Make debug output of Range contents a little more compact
Modified: MOAB/trunk/src/DebugOutput.cpp
===================================================================
--- MOAB/trunk/src/DebugOutput.cpp 2010-05-05 23:08:28 UTC (rev 3855)
+++ MOAB/trunk/src/DebugOutput.cpp 2010-05-06 23:06:00 UTC (rev 3856)
@@ -5,6 +5,7 @@
#include <iostream>
#include <string.h>
#include <algorithm>
+#include <assert.h>
#ifdef USE_MPI
# include "moab_mpi.h"
@@ -154,6 +155,41 @@
process_line_buffer();
}
+static void print_range( char* buffer, unsigned long begin, unsigned long end )
+{
+ assert(end > begin);
+ // begin with a space
+ *buffer = ' ';
+ char *b1 = buffer + 1;
+ // print begin-end, but keep track of where each peice is written
+ char* e1 = b1 + sprintf(b1,"%lu",begin);
+ *e1 = '-';
+ char* b2 = e1+1;
+ char* e2 = b2 + sprintf(b2,"%lu",end);
+ // if the printed strings for both numbers don't contain the same
+ // number of digits, don't do anything more
+ if (e1-b1 == e2-b2) {
+ // see how many leading digits the two numbers have in common
+ char* p = b2;
+ while (*p && *p == *b1)
+ { ++p; ++b1; }
+ // remove common shared leading digits from second number
+ if (p > b2 && *p) {
+ // shift second value down so that common leading digits are not repeated
+ while(*p) {
+ *b2 = *p;
+ ++b2;
+ ++p;
+ }
+ e2 = b2;
+ }
+ }
+ // add trailing comma
+ *e2 = ',';
+ ++e2;
+ *e2 = '\0';
+}
+
More information about the moab-dev
mailing list