From: <sv...@ww...> - 2004-07-10 05:19:56
|
Author: mkrose Date: 2004-07-09 22:19:49 -0700 (Fri, 09 Jul 2004) New Revision: 1154 Modified: trunk/CSP/SimData/CHANGES.current trunk/CSP/SimData/Source/DataArchive.cpp trunk/CSP/SimData/Source/HashUtility.cpp Log: Changed the formating of HashT values to use fixed-width hex instead of decimal numbers, and cleaned up the data archive dump formatting slightly. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1154 Modified: trunk/CSP/SimData/CHANGES.current =================================================================== --- trunk/CSP/SimData/CHANGES.current 2004-07-10 05:17:16 UTC (rev 1153) +++ trunk/CSP/SimData/CHANGES.current 2004-07-10 05:19:49 UTC (rev 1154) @@ -1,5 +1,10 @@ Version 0.4.0 (in progress) =========================== +2004-07-09: onsight + * Changed the formating of HashT values to use fixed-width hex + instead of decimal numbers, and cleaned up the data archive + dump formatting slightly. + 2004-07-08: onsight * Simplify the logging classes considerably, and tweak the logging macros to skip the output stream formating for messages that Modified: trunk/CSP/SimData/Source/DataArchive.cpp =================================================================== --- trunk/CSP/SimData/Source/DataArchive.cpp 2004-07-10 05:17:16 UTC (rev 1153) +++ trunk/CSP/SimData/Source/DataArchive.cpp 2004-07-10 05:19:49 UTC (rev 1154) @@ -490,10 +490,10 @@ std::string classname = _table[i].classhash.str(); if (proxy) classname = proxy->getClassName(); std::cout << std::setw(6) << _table[i].length - << std::setw(9) << _table[i].offset - << _table[i].pathhash << " " - << classname << " " - << getPathString(_table[i].pathhash) << "\n"; + << std::setw(9) << _table[i].offset << " " + << _table[i].pathhash << " " + << classname << " " + << getPathString(_table[i].pathhash) << "\n"; } } Modified: trunk/CSP/SimData/Source/HashUtility.cpp =================================================================== --- trunk/CSP/SimData/Source/HashUtility.cpp 2004-07-10 05:17:16 UTC (rev 1153) +++ trunk/CSP/SimData/Source/HashUtility.cpp 2004-07-10 05:19:49 UTC (rev 1154) @@ -1,18 +1,18 @@ /* SimDataCSP: Data Infrastructure for Simulations * Copyright (C) 2002 Mark Rose <tm...@st...> - * + * * This file is part of SimDataCSP. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -23,11 +23,12 @@ * * Hash functions utilities * - * The hash functions coded here are from "Hash Functions for Hash + * The hash functions coded here are from "Hash Functions for Hash * Table Lookup" by Robert J. Jenokins Jr., and are Public Domain. * See <http://burtleburtle.net/bob/hash/evahash.html> */ #include <sstream> +#include <iomanip> #include <SimData/HashUtility.h> @@ -37,7 +38,7 @@ HASH<const char*> hashstring::h; -// The mixing step +// The mixing step #define mix(a,b,c) \ { \ a=a-b; a=a-c; a=a^(c>>13); \ @@ -57,12 +58,12 @@ * * @param k the string to hash * @param length the length of the string in bytes. - * @param initval the previous hash, or an arbitrary value - */ + * @param initval the previous hash, or an arbitrary value + */ uint32 newhash(register uint8 const *k, uint32 length, uint32 initval) { register uint32 a,b,c; // the internal state - uint32 len; // how many key bytes still need mixing + uint32 len; // how many key bytes still need mixing // Set up the internal state len = length; @@ -70,7 +71,7 @@ c = initval; // variable initialization of internal state // handle most of the key - + while (len >= 12) { a=a+(k[0]+((uint32)k[1]<<8)+((uint32)k[2]<<16) +((uint32)k[3]<<24)); @@ -86,7 +87,7 @@ case 11: c=c+((uint32)k[10]<<24); case 10: c=c+((uint32)k[9]<<16); case 9 : c=c+((uint32)k[8]<<8); - // the first byte of c is reserved for the length + // the first byte of c is reserved for the length case 8 : b=b+((uint32)k[7]<<24); case 7 : b=b+((uint32)k[6]<<16); case 6 : b=b+((uint32)k[5]<<8); @@ -95,7 +96,7 @@ case 3 : a=a+((uint32)k[2]<<16); case 2 : a=a+((uint32)k[1]<<8); case 1 : a=a+k[0]; - // case 0: nothing left to add + // case 0: nothing left to add } mix(a,b,c); // report the result @@ -125,7 +126,9 @@ } std::ostream & operator<<(std::ostream &o, const hasht &x) { - return o << "(" << x.b << ":" << x.a << ")"; + return o << "(" << std::hex << std::setw(8) << std::setfill('0') << x.b << ":" + << std::setw(8) << std::setfill('0') << x.a + << std::dec << std::setw(0) << std::setfill(' ') << ")"; } |