diff -r 31a43d94cc26 -r 21a6c17f4e3e test/TestUtils.cpp --- a/test/TestUtils.cpp Sun Sep 20 15:14:12 2009 -0700 +++ b/test/TestUtils.cpp Mon Sep 28 23:39:08 2009 -0700 @@ -11,6 +11,7 @@ #include "File.h" #include #include +#include namespace Mooseyard { @@ -24,7 +25,9 @@ void shuffle(int a[], int n, unsigned seed) { if (seed==0) { +#ifdef BSD srandomdev(); +#endif seed = random(); } fprintf(stderr,"shuffle(n=%i, seed=%u)\n", n,seed); @@ -46,15 +49,18 @@ sNWords = 0; FILE *in = fopen("/usr/share/dict/words", "r"); - const char *word; + char word[4096]; size_t wordLen; - while (NULL != (word=fgetln(in,&wordLen))) { - if (word[wordLen-1]=='\n') - wordLen--; - char *str = new char[wordLen+1]; - memcpy(str, word, wordLen); - str[wordLen] = 0; - sWords[sNWords] = str; + while (NULL != ::fgets(word, 4096, in)) { + wordLen = ::strlen(word); + if (word[wordLen-1]=='\n') { + word[wordLen-1] = '\0'; + wordLen--; + } + + if (wordLen == 0) continue; + + sWords[sNWords] = strdup(word); //if( sNWords % 10000 == 0) // printf("'%s' ... ", sWords[sNWords]->string()); sNWords++; @@ -93,7 +99,9 @@ using namespace Mooseyard; int main(int argc, char **argv) { +#if BSD srandomdev(); +#endif try { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS();