2012-11-11 18:41 UTC+0100 Viktor Szakats (harbour syenar.net)

* extras/gfspell/spell.prg
    % deleted commented full screen debug trace lines
    % deleted not operational REDUCE_MEMORY_NEEDS built-time
      option. It was dead code that didn't even compile and
      caused RTE when fixed
    * other formatting
This commit is contained in:
Viktor Szakats
2012-11-11 17:42:46 +00:00
parent f0e715efc4
commit 92be5b0370
2 changed files with 20 additions and 132 deletions

View File

@@ -16,6 +16,14 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-11-11 18:41 UTC+0100 Viktor Szakats (harbour syenar.net)
* extras/gfspell/spell.prg
% deleted commented full screen debug trace lines
% deleted not operational REDUCE_MEMORY_NEEDS built-time
option. It was dead code that didn't even compile and
caused RTE when fixed
* other formatting
2012-11-11 17:33 UTC+0100 Viktor Szakats (harbour syenar.net)
* extras/gfspell/spell.prg
* comment cleanup

View File

@@ -26,8 +26,6 @@
#include "fileio.ch"
// #define REDUCE_MEMORY_NEEDS
#xtranslate StoreWord( <cWord> ) => xForm( <cWord> )
#xtranslate ExtractWord( <cWord> ) => xUnForm( <cWord> )
@@ -108,9 +106,6 @@ FUNCTION Sp_Add( cWord )
// Initialize the spell checker and make sure
// an auxiliary dictionary name was specified
// *DEBUG**
// @ 24, 30 SAY "At SP_ADD"
IF Sp_Init() .AND. ! Empty( AUXILIARY_DICTIONARY )
cWord := Upper( AllTrim( cWord ) )
@@ -139,7 +134,6 @@ FUNCTION Sp_Add( cWord )
RETURN was_added
// Function: Sp_cache()
// Purpose: To add a word to the cache list
// Syntax: <logical> := Sp_cache(cWord)
@@ -156,9 +150,6 @@ FUNCTION Sp_Cache( cWord )
LOCAL cTemp := "|" + Upper( AllTrim( cWord ) ) + "|"
LOCAL lAdded := .F.
// *DEBUG**
// @ 24, 30 SAY "At SP_cache"
IF ! cTemp $ CACHE_WORDS .AND. Len( CACHE_WORDS ) < MAX_STRING
CACHE_WORDS += cTemp
lAdded := .T.
@@ -166,7 +157,6 @@ FUNCTION Sp_Cache( cWord )
RETURN lAdded
// Function: Sp_Check()
// Purpose: To check the spelling of a word
// Syntax: <logical> := Sp_Check( cWord )
@@ -197,9 +187,6 @@ FUNCTION Sp_Check( cWord )
LOCAL z := 4
LOCAL cTemp
// *DEBUG**
// @ 24, 30 SAY "At SP_init"
IF Sp_Init()
IF Len( cLookup ) == 1 .AND. cLookup $ "IA"
RETURN .T.
@@ -218,21 +205,9 @@ FUNCTION Sp_Check( cWord )
nCol := Asc( SubStr( cLookup, 2, 1 ) ) - 64
IF ( nRow > 0 .AND. nRow <= 26 ) .AND. ( nCol > 0 .AND. nCol <= 26 )
#ifdef REDUCE_MEMORY_NEEDS
t_cOffsets := Space( 6 )
FSeek( t_nHandle, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * 6 + 1 ) + 5, FS_SET )
FRead( t_nHandle, @t_cOffsets, 6 )
x := Bin2L( hb_BSubStr( t_cOffsets, 1, 4 ) )
y := Bin2W( hb_BSubStr( t_cOffsets, 5, 2 ) )
#else
x := Bin2L( hb_BSubStr( t_cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 1 ), 4 ) )
y := Bin2W( hb_BSubStr( t_cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 5 ), 2 ) )
#endif
IF ! Empty( x )
IF !( t_cLast == SubStr( cLookup, 1, 2 ) )
t_cBuf := Space( y )
@@ -279,7 +254,6 @@ FUNCTION Sp_Check( cWord )
RETURN ok
// Function: Sp_GetBuf()
// Purpose: To get all words within the buffer
// Syntax: Sp_GetBuf( <cLetters> )
@@ -294,9 +268,6 @@ STATIC FUNCTION sp_GetBuf( cLetters )
LOCAL nRow := Asc( SubStr( cLetters, 1, 1 ) ) - 64
LOCAL nCol := Asc( SubStr( cLetters, 2, 1 ) ) - 64
// *DEBUG**
// @ 24, 30 SAY "At SP_getbuf"
IF ( nRow > 0 .AND. nRow <= 26 ) .AND. ( nCol > 0 .AND. nCol <= 26 )
x := Bin2L( hb_BSubStr( t_cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 1 ), 4 ) )
IF ! Empty( x )
@@ -309,7 +280,6 @@ STATIC FUNCTION sp_GetBuf( cLetters )
RETURN cBuf
// Function: Sp_clear()
// Purpose: To clear out the cache list
// Syntax: Sp_clear()
@@ -319,14 +289,10 @@ STATIC FUNCTION sp_GetBuf( cLetters )
FUNCTION Sp_Clear()
// *DEBUG**
// @ 24, 30 SAY "At SP_clear"
CACHE_WORDS := ""
RETURN NIL
// Function: Sp_GetSet()
// Purpose: To get/set a parameter for the spell check function
// Syntax: <xOldValue> := Sp_GetSet( nWhich [,xNewSetting] )
@@ -341,9 +307,6 @@ FUNCTION Sp_GetSet( nWhich, xNewSetting )
LOCAL xOld := NIL
// *DEBUG**
// @ 24, 30 SAY "At SP_getset"
IF nWhich != NIL .AND. ( nWhich > 0 .AND. nWhich <= Len( t_aGlobal ) )
xOld := t_aGlobal[ nWhich ]
IF ValType( xNewSetting ) == ValType( xOld )
@@ -353,7 +316,6 @@ FUNCTION Sp_GetSet( nWhich, xNewSetting )
RETURN xOld
// Function: Sp_LoadAux()
// Purpose: To load an auxiliary dictionary of words
@@ -364,9 +326,6 @@ FUNCTION Sp_LoadAux( cFile )
LOCAL cStr := ""
LOCAL nSize
// *DEBUG**
// @ 24, 30 SAY "At SP_loadaux"
IF ! Empty( cFile )
IF hb_FileExists( cFile )
x := FOpen( cFile, FO_READ + FO_DENYNONE )
@@ -391,7 +350,6 @@ FUNCTION Sp_LoadAux( cFile )
RETURN is_ok
// Function: Sp_Suggest()
// Purpose: To return an array of possible spellings
// Syntax: aSuggest_ := Sp_Suggest(cWord [,lInclude] )
@@ -467,9 +425,6 @@ FUNCTION Sp_Suggest( cWord, lInclude )
LOCAL cKey
LOCAL arr_
// *DEBUG**
// @ 24, 30 SAY "At SP_suggest"
cWord := Upper( RTrim( cWord ) )
zz := Len( cWord )
@@ -774,7 +729,7 @@ FUNCTION Sp_Suggest( cWord, lInclude )
ELSEIF cKey > cMeta
EXIT
ENDIF
jj := kk + 1
jj := kk + 1
ENDIF
kk++
ENDDO
@@ -782,7 +737,6 @@ FUNCTION Sp_Suggest( cWord, lInclude )
ENDIF
ENDIF
nSugg := Len( aRet_ )
IF nSugg > 1 .AND. SORT_SUGGESTIONS
ASort( aRet_ )
@@ -816,9 +770,6 @@ FUNCTION Sp_Quick( cWord )
LOCAL arr_ := {}
LOCAL cHold, ll, cTemp
// *DEBUG**
// @ 24, 30 SAY "At SP_quick"
cWord := Upper( RTrim( cWord ) )
zz := Len( cWord )
@@ -910,10 +861,6 @@ FUNCTION Sp_Quick( cWord )
RETURN arr_
STATIC FUNCTION ChrCount( cChar, cString )
// *DEBUG**
// @ 24, 30 SAY "At ChrCount"
RETURN Len( cString ) - Len( StrTran( cString, cChar ) )
FUNCTION Sp_Split( cWord )
@@ -923,9 +870,6 @@ FUNCTION Sp_Split( cWord )
LOCAL cWord1
LOCAL cWord2
// *DEBUG**
// @ 24, 30 SAY "At SP_split"
FOR x := 2 TO Len( cWord )
cWord1 := Left( cWord, x - 1 )
cWord2 := SubStr( cWord, x )
@@ -943,9 +887,6 @@ FUNCTION Sp_Expand( cWord )
LOCAL x
LOCAL cExpand
// *DEBUG**
// @ 24, 30 SAY "At SP_expand"
cWord := Upper( AllTrim( cWord ) )
x := AScan( sc_aContracts, {| jj | Left( jj[ 1 ], Len( cWord ) ) == cWord } ) // LEFTEQUAL()
IF x > 0
@@ -954,7 +895,6 @@ FUNCTION Sp_Expand( cWord )
RETURN cExpand
// Function: Sp_WildCard()
// Purpose: To return an array of wildcard matches
// Syntax: aSuggest := Sp_WildCard( cPattern )
@@ -968,9 +908,6 @@ FUNCTION Sp_WildCard( cPattern )
LOCAL arr_ := {}
LOCAL nStart, nEnd
// *DEBUG**
// @ 24, 30 SAY "At SP_wildcard"
cPattern := Upper( cPattern )
IF Sp_Init()
@@ -1014,8 +951,7 @@ FUNCTION Sp_WildCard( cPattern )
RETURN arr_
// The following functions are internal and should not be modified. *
// The following functions are internal and should not be modified.
// Function: Sp_Init()
// Purpose: Internal function to initialize the dictionary
@@ -1031,43 +967,25 @@ FUNCTION Sp_Init()
LOCAL cOther := ""
LOCAL nFileSize
// *DEBUG**
// @ 24, 30 SAY "At SP_init"
IF t_cOffsets == NIL
isok := .F.
isok := .F.
t_nHandle := FOpen( DICTIONARY_PATH + DICTIONARY_NAME, FO_READ + FO_DENYWRITE )
IF t_nHandle != F_ERROR
#ifdef REDUCE_MEMORY_NEEDS
cBuf := Space( 6 )
FRead( t_nHandle, @cBuf, 6 )
#else
cBuf := Space( NSIZE + 6 )
FRead( t_nHandle, @cBuf, NSIZE + 6 )
#endif
IF SubStr( cBuf, 1, 2 ) == "JJ"
nOther := Bin2L( SubStr( cBuf, 3, 4 ) )
#ifndef REDUCE_MEMORY_NEEDS
t_cOffsets := hb_BSubStr( cBuf, 7 )
#endif
nOther := Bin2L( SubStr( cBuf, 3, 4 ) )
t_cOffsets := hb_BSubStr( cBuf, 7 )
nFileSize := FSeek( t_nHandle, 0, FS_END )
IF nFileSize - nOther > 0
cOther := Space( nFileSize - nOther )
cOther := Space( nFileSize - nOther )
FSeek( t_nHandle, nOther, FS_SET )
FRead( t_nHandle, @cOther, ( nFileSize - nOther ) )
ENDIF
t_aGlobal[ 2 ] += cOther
isok := .T.
isok := .T.
ENDIF
IF ! Empty( AUXILIARY_DICTIONARY )
Sp_LoadAux( AUXILIARY_DICTIONARY )
@@ -1093,7 +1011,6 @@ FUNCTION Sp_Init()
RETURN isok
// Function: DBF2Dic()
// Purpose: To create a DIC file from a DBF list of words
// Syntax: nStatus := DBF2Dic( <cDBF_file>, <cDIC_file> )
@@ -1126,9 +1043,6 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk )
// DEFAULT name for dictionary file
//
// *DEBUG**
// @ 24, 30 SAY "At DBF2DIC"
IF cDictionary == NIL
cDictionary := "dict.dic"
ENDIF
@@ -1137,7 +1051,6 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk )
lTalk := .F.
ENDIF
//
// See if the DBF file exists
//
@@ -1170,7 +1083,6 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk )
INDEX ON SubStr( DICT->word, 1, 2 ) + PadR( C_MetaFone( AllTrim( DICT->word ), 5 ), 6 ) TO ( "$$temp" )
dbGoTop()
IF lTalk
hb_DispOutAt( 9, 31, "Percent ", "W/R" )
hb_DispOutAt( 10, 31, "Complete: ", "W/R" )
@@ -1255,7 +1167,6 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk )
RETURN nStatus
// Function: Dic2DBF()
// Purpose: To create a DBF file from a DIC file
// Syntax: nStatus := DIC2DBF( <cDIC_file>, <cDBF_file> )
@@ -1280,9 +1191,6 @@ FUNCTION Dic2DBF( cDictionary, cDBF, lTalk )
LOCAL cSave
LOCAL nSize
// *DEBUG**
// @ 24, 30 SAY "At DIC2DBF"
//
// DEFAULT name for dictionary file
//
@@ -1414,17 +1322,6 @@ FUNCTION Dic2DBF( cDictionary, cDBF, lTalk )
STATIC FUNCTION Sp_Common()
#ifdef REDUCE_MEMORY_NEEDS
t_aGlobal_[ 1 ] := ;
"|THE|OF|AND|TO|A|IN|THAT|FOR|IS|WAS|IT|HE|I|AS" + ;
"|WITH|ON|HIS|BE|AT|BY|NOT|THIS|HAD|HAVE|YOU|BUT" + ;
"|FROM|ARE|OR|WHICH|AN|THEY|WILL|ONE|WERE|ALL|WE" + ;
"|HER|SHE|WOULD|THERE|HAS|BEEN|HIM|THEIR|IF|WHEN" + ;
"|SO|MORE|NO|WHO|YOUR|OUT|MY|I'VE|I'D|I'LL|CAN'T|"
#else
t_aGlobal[ 1 ] := ;
"|THE|OF|AND|TO|A|IN|THAT|FOR|IS|WAS|IT|HE|I|AS|WITH|ON|HIS|BE|AT|BY" + ;
"|NOT|THIS|HAD|HAVE|YOU|BUT|FROM|ARE|OR|WHICH|AN|THEY|WILL|ONE|WERE|ALL" + ;
@@ -1467,9 +1364,7 @@ STATIC FUNCTION Sp_Common()
"|HARD|SCHOOLS|STRONG|BELIEVE|PLAY|VARIOUS|SURFACE|MAKING|MEAN|SOON|VALUE" + ;
"|LINES|MODERN|NEAR|TABLE|PRIVATE|RED|ROAD|TAX|ALONE|MINUTES|PERSONAL|PROCESS" + ;
"|SITUATION|THAT'S|GONE|IDEA|INCREASE|NOR|PEACE|SECTION|LIVING|STARTED|BOOK" + ;
"|LONGER|CUT|FINALLY|NATURE|SECRETARY|MONTHS|THIRD|CALL|COMPLETE|GREATER"
t_aGlobal[ 1 ] += ;
"|LONGER|CUT|FINALLY|NATURE|SECRETARY|MONTHS|THIRD|CALL|COMPLETE|GREATER" + ;
"|EXPECTED|FIRE|NEEDED|KEPT|VALUES|VIEW|BASIS|DARK|EVERYTHING|PRESSURE" + ;
"|GROUND|EAST|RECENT|REQUIRED|SPIRIT|UNION|HOPE|I'LL|MOVED|NATIONS|WROTE" + ;
"|CONDITIONS|RETURN|SUPPORT|ATTENTION|LATE|PARTICULAR|BROWN|COSTS|ELSE|NATION" + ;
@@ -1487,26 +1382,17 @@ STATIC FUNCTION Sp_Common()
"|WORKING|EFFORT|SAT|ENTIRE|HAPPENED|LABOR|PURPOSE|RESULTS|CASES|DIFFERENCE" + ;
"|HAIR|PRODUCTION|STAND|I'VE|I'D|WON'T|"
#endif
// *DEBUG**
// @ 24, 30 SAY "At SP_common"
RETURN NIL
FUNCTION WildCard( cPattern, cString )
LOCAL lMatch := .F.
LOCAL x := At( "*", cPattern )
LOCAL lMatch := .F.
LOCAL x := At( "*", cPattern )
LOCAL cBefore
LOCAL cAfter
LOCAL y
LOCAL nStrSize, nPatSize
// *DEBUG**
// @ 24, 30 SAY "At wildcard"
cString := Upper( AllTrim( cString ) )
IF cPattern == "*"
@@ -1530,8 +1416,8 @@ FUNCTION WildCard( cPattern, cString )
ELSE
x := At( "?", cPattern )
IF x > 0
nPatSize := Len( cPattern )
nStrSize := Len( cString )
nPatSize := Len( cPattern )
nStrSize := Len( cString )
IF nPatSize == nStrSize
lMatch := .T.
FOR y := 1 TO nPatSize
@@ -1557,9 +1443,6 @@ FUNCTION aWords( cLine )
LOCAL cWord := ""
LOCAL nOffset
// *DEBUG**
// @ 24, 30 SAY "At clip52"
z := 0
DO WHILE z <= nSize
z++
@@ -1588,9 +1471,6 @@ FUNCTION fat( f_str, l_str, f_rom )
LOCAL ret_val
// *DEBUG**
// @ 24, 30 SAY "At FAT"
IF PCount() < 3 // Is f_rom passed?
f_rom := 1
ENDIF