mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
Fix compiler warnings. Should be no change in generated code.
This commit is contained in:
parent
5d7ee61448
commit
948981434b
1 changed files with 22 additions and 23 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* -*- compile-command: "g++ -DDEBUG -O -o dict2dawg dict2dawg.cpp"; -*- */
|
/* -*- compile-command: "g++ -DDEBUG -O -Wall -o dict2dawg dict2dawg.cpp"; -*- */
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* adapted from perl code that was itself adapted from C++ code
|
* adapted from perl code that was itself adapted from C++ code
|
||||||
* Copyright (C) 2000 Falk Hueffner
|
* Copyright (C) 2000 Falk Hueffner
|
||||||
|
@ -71,7 +71,7 @@ static int gCurrentWordLen;
|
||||||
|
|
||||||
char* gCurWord = NULL; // save so can check for sortedness
|
char* gCurWord = NULL; // save so can check for sortedness
|
||||||
bool gDone = false;
|
bool gDone = false;
|
||||||
static int gNextWordIndex;
|
static unsigned int gNextWordIndex;
|
||||||
static void (*gReadWordProc)(void) = NULL;
|
static void (*gReadWordProc)(void) = NULL;
|
||||||
NodeList gNodes; // final array of nodes
|
NodeList gNodes; // final array of nodes
|
||||||
unsigned int gNBytesPerOutfile = 0xFFFFFFFF;
|
unsigned int gNBytesPerOutfile = 0xFFFFFFFF;
|
||||||
|
@ -108,7 +108,6 @@ int gLimHigh = MAX_WORD_LEN;
|
||||||
static char* parseARGV( int argc, char** argv, const char** inFileName );
|
static char* parseARGV( int argc, char** argv, const char** inFileName );
|
||||||
static void usage( const char* name );
|
static void usage( const char* name );
|
||||||
static void error_exit( int line, const char* fmt, ... );
|
static void error_exit( int line, const char* fmt, ... );
|
||||||
static char parsechar( const char* in );
|
|
||||||
static void makeTableHash( void );
|
static void makeTableHash( void );
|
||||||
static WordList* parseAndSort( FILE* file );
|
static WordList* parseAndSort( FILE* file );
|
||||||
static void printWords( WordList* strings );
|
static void printWords( WordList* strings );
|
||||||
|
@ -122,7 +121,7 @@ static bool TrieNodeGetIsTerminal( Node node );
|
||||||
static void TrieNodeSetIsLastSibling( Node* nodeR, bool isLastSibling );
|
static void TrieNodeSetIsLastSibling( Node* nodeR, bool isLastSibling );
|
||||||
static bool TrieNodeGetIsLastSibling( Node node );
|
static bool TrieNodeGetIsLastSibling( Node node );
|
||||||
static void TrieNodeSetLetter( Node* nodeR, int letter );
|
static void TrieNodeSetLetter( Node* nodeR, int letter );
|
||||||
static int TrieNodeGetLetter( Node node );
|
static unsigned int TrieNodeGetLetter( Node node );
|
||||||
static void TrieNodeSetFirstChildOffset( Node* nodeR, int fco );
|
static void TrieNodeSetFirstChildOffset( Node* nodeR, int fco );
|
||||||
static int TrieNodeGetFirstChildOffset( Node node );
|
static int TrieNodeGetFirstChildOffset( Node node );
|
||||||
static int findSubArray( NodeList& newedgesR );
|
static int findSubArray( NodeList& newedgesR );
|
||||||
|
@ -261,10 +260,11 @@ moveTopToFront( int* firstRef )
|
||||||
// We add diff to everything. There's no subtracting because
|
// We add diff to everything. There's no subtracting because
|
||||||
// nobody had any refs to the top list.
|
// nobody had any refs to the top list.
|
||||||
|
|
||||||
for ( int i = 0; i < gNodes.size(); ++i ) {
|
unsigned int ii;
|
||||||
int fco = TrieNodeGetFirstChildOffset( gNodes[i] );
|
for ( ii = 0; ii < gNodes.size(); ++ii ) {
|
||||||
|
int fco = TrieNodeGetFirstChildOffset( gNodes[ii] );
|
||||||
if ( fco != 0 ) { // 0 means NONE, not 0th!!
|
if ( fco != 0 ) { // 0 means NONE, not 0th!!
|
||||||
TrieNodeSetFirstChildOffset( &gNodes[i], fco + diff );
|
TrieNodeSetFirstChildOffset( &gNodes[ii], fco + diff );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // moveTopToFront
|
} // moveTopToFront
|
||||||
|
@ -335,7 +335,7 @@ addNodes( NodeList& newedgesR )
|
||||||
static void
|
static void
|
||||||
printNode( int index, Node node )
|
printNode( int index, Node node )
|
||||||
{
|
{
|
||||||
int letter = TrieNodeGetLetter(node);
|
unsigned int letter = TrieNodeGetLetter(node);
|
||||||
assert( letter < gRevMap.size() );
|
assert( letter < gRevMap.size() );
|
||||||
fprintf( stderr,
|
fprintf( stderr,
|
||||||
"[%d] letter=%d(%c); isTerminal=%s; isLastSib=%s; fco=%d;\n",
|
"[%d] letter=%d(%c); isTerminal=%s; isLastSib=%s; fco=%d;\n",
|
||||||
|
@ -348,9 +348,10 @@ printNode( int index, Node node )
|
||||||
static void
|
static void
|
||||||
printNodes( NodeList& nodesR )
|
printNodes( NodeList& nodesR )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < nodesR.size(); ++i ) {
|
unsigned int ii;
|
||||||
Node node = nodesR[i];
|
for ( ii = 0; ii < nodesR.size(); ++ii ) {
|
||||||
printNode( i, node );
|
Node node = nodesR[ii];
|
||||||
|
printNode( ii, node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +470,6 @@ readOneWord( char* wordBuf, int bufLen, int* lenp, bool* gotEOF )
|
||||||
char* result = NULL;
|
char* result = NULL;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
bool dropWord = false;
|
bool dropWord = false;
|
||||||
bool done = false;
|
|
||||||
|
|
||||||
// for each byte, append to an internal buffer up to size limit.
|
// for each byte, append to an internal buffer up to size limit.
|
||||||
// On reaching an end-of-word or EOF, check if the word formed is
|
// On reaching an end-of-word or EOF, check if the word formed is
|
||||||
|
@ -634,7 +634,7 @@ tileToAscii( char* out, int outSize, const char* in )
|
||||||
if ( '\0' == ch ) {
|
if ( '\0' == ch ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert( ch < gRevMap.size() );
|
assert( (unsigned int)ch < gRevMap.size() );
|
||||||
*out++ = gRevMap[ch];
|
*out++ = gRevMap[ch];
|
||||||
tilesLen += sprintf( &tiles[tilesLen], "%d,", ch );
|
tilesLen += sprintf( &tiles[tilesLen], "%d,", ch );
|
||||||
assert( (out - orig) < outSize );
|
assert( (out - orig) < outSize );
|
||||||
|
@ -667,7 +667,6 @@ parseAndSort( FILE* infile )
|
||||||
bool eof = false;
|
bool eof = false;
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
int len;
|
int len;
|
||||||
char buf[MAX_WORD_LEN+1];
|
|
||||||
char* word = readOneWord( str, memleft, &len, &eof );
|
char* word = readOneWord( str, memleft, &len, &eof );
|
||||||
|
|
||||||
if ( NULL == word ) {
|
if ( NULL == word ) {
|
||||||
|
@ -769,7 +768,7 @@ TrieNodeSetLetter( Node* nodeR, int letter )
|
||||||
*nodeR |= (letter << 24); // set new ones
|
*nodeR |= (letter << 24); // set new ones
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static unsigned int
|
||||||
TrieNodeGetLetter( Node node )
|
TrieNodeGetLetter( Node node )
|
||||||
{
|
{
|
||||||
node >>= 24;
|
node >>= 24;
|
||||||
|
@ -899,7 +898,7 @@ emitNodes( unsigned int nBytesPerOutfile, const char* outFileBase )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextIndex = 0;
|
unsigned int nextIndex = 0;
|
||||||
int nextFileNum;
|
int nextFileNum;
|
||||||
|
|
||||||
for ( nextFileNum = 0; ; ++nextFileNum ) {
|
for ( nextFileNum = 0; ; ++nextFileNum ) {
|
||||||
|
@ -917,26 +916,26 @@ emitNodes( unsigned int nBytesPerOutfile, const char* outFileBase )
|
||||||
outFileBase, nextFileNum);
|
outFileBase, nextFileNum);
|
||||||
FILE* OUTFILE = fopen( outName, "w" );
|
FILE* OUTFILE = fopen( outName, "w" );
|
||||||
assert( OUTFILE );
|
assert( OUTFILE );
|
||||||
int curSize = 0;
|
unsigned int curSize = 0;
|
||||||
|
|
||||||
while ( nextIndex < gNodes.size() ) {
|
while ( nextIndex < gNodes.size() ) {
|
||||||
// scan to find the next terminal
|
// scan to find the next terminal
|
||||||
int i;
|
unsigned int ii;
|
||||||
for ( i = nextIndex; !TrieNodeGetIsLastSibling(gNodes[i]); ++i ) {
|
for ( ii = nextIndex; !TrieNodeGetIsLastSibling(gNodes[ii]); ++ii ) {
|
||||||
|
|
||||||
// do nothing but a sanity check
|
// do nothing but a sanity check
|
||||||
if ( i >= gNodes.size() ) {
|
if ( ii >= gNodes.size() ) {
|
||||||
ERROR_EXIT( "bad trie format: last node not last sibling" );
|
ERROR_EXIT( "bad trie format: last node not last sibling" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
++i; // move beyond the terminal
|
++ii; // move beyond the terminal
|
||||||
int nextSize = (i - nextIndex) * gNBytesPerNode;
|
int nextSize = (ii - nextIndex) * gNBytesPerNode;
|
||||||
if (curSize + nextSize > nBytesPerOutfile ) {
|
if (curSize + nextSize > nBytesPerOutfile ) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// emit the subarray
|
// emit the subarray
|
||||||
while ( nextIndex < i ) {
|
while ( nextIndex < ii ) {
|
||||||
outputNode( gNodes[nextIndex], gNBytesPerNode, OUTFILE );
|
outputNode( gNodes[nextIndex], gNBytesPerNode, OUTFILE );
|
||||||
++nextIndex;
|
++nextIndex;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue