diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 538e0a39c2..9f1290da3f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,49 @@ The license applies to all entries newer than 2009-04-28. */ +2012-11-11 12:51 UTC+0100 Viktor Szakats (harbour syenar.net) + * utils/hbmk2/hbmk2.prg + ! fixed to automatically create target directory + for import library, if any. + + * extras/hbusb/hbusb.hbp + * making options more uniform + ; TODO: apply these to other 'extras' libs + + * extras/gfspell/spellc.c + ! fixed compilation errors in spellc.c. + ! fixed non-ANSI C comments. + ! fixed warnings. + * removed excessive parenthesis + + + extras/gfspell/gfspell.hbx + * extras/gfspell/gfspell.hbp + + added .hbx file + + added option to build dynamic lib + + * extras/gfspell/spell.ch + * extras/gfspell/spell.prg + ! fixed to use lower-case filenames + ! fixed '=' operators + ! fixed BIT() calls to have the 1st param passed by ref + ! fixed some formatting errors left by hbformat (notably: "{|xx|") + ! disabled permanently enabled debug screen messages + ! fixed to not leave temporary index on disk + + some changes to make code more unicode compatible (incomplete) + * Use F_ERROR + * hbformatted using new .hbx + % use hb_FileExists() + ; NOTE: Strangely all this is not enough to make this + work, because crucial files are missing from this packages, + f.e. dict.dic and thes.dic. Anybody has these? + + * extras/gfspell/words.dbf + ! fixed field name to be WORD (not W_ORD). I'm not even + sure how this can go wrong, byt anyways. + + * contrib/hbnf/menuto.prg + * minor + 2012-11-10 18:32 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * src/rtl/rat.c % Small optimization. diff --git a/harbour/contrib/hbnf/menuto.prg b/harbour/contrib/hbnf/menuto.prg index cd296802d1..9f120efa0f 100644 --- a/harbour/contrib/hbnf/menuto.prg +++ b/harbour/contrib/hbnf/menuto.prg @@ -36,8 +36,8 @@ #include "setcurs.ch" #include "inkey.ch" -#xtranslate isOkay( ) => ( \ > 0 .AND. \ <= nCount ) -#xtranslate isBetween( , , ) => ( \ >= .AND. \ <= ) +#xtranslate isOkay( ) => ( \> 0 .AND. \<= nCount ) +#xtranslate isBetween( , , ) => ( \>= .AND. \<= ) // These arrays hold information about each menu item diff --git a/harbour/extras/gfspell/gfspell.hbp b/harbour/extras/gfspell/gfspell.hbp index 427ba7c246..4b15ce06bc 100644 --- a/harbour/extras/gfspell/gfspell.hbp +++ b/harbour/extras/gfspell/gfspell.hbp @@ -12,4 +12,7 @@ spell.prg spellc.c +-hbx=${hb_name}.hbx +${hb_name}.hbx +$hb_pkg_dynlib.hbm $hb_pkg_install.hbm diff --git a/harbour/extras/gfspell/gfspell.hbx b/harbour/extras/gfspell/gfspell.hbx new file mode 100644 index 0000000000..43fd149f5c --- /dev/null +++ b/harbour/extras/gfspell/gfspell.hbx @@ -0,0 +1,52 @@ +/* -------------------------------------------------------------------- + * NOTE: You can add manual override which functions to include or + * exclude from automatically generated EXTERNAL/DYNAMIC list. + * Syntax: // HB_FUNC_INCLUDE + * // HB_FUNC_EXCLUDE + */ + +/* -------------------------------------------------------------------- + * WARNING: Automatically generated code below. DO NOT EDIT! + * Regenerate using hbmk2 '-hbx=' option. + */ + +#ifndef __HBEXTERN_CH__GFSPELL__ +#define __HBEXTERN_CH__GFSPELL__ + +#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__GFSPELL__ANNOUNCE ) + ANNOUNCE __HBEXTERN__GFSPELL__ +#endif + +#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__GFSPELL__REQUEST ) + #command DYNAMIC => EXTERNAL +#endif + +DYNAMIC aWords +DYNAMIC bit +DYNAMIC C_Metafone +DYNAMIC DBF2Dic +DYNAMIC Dic2DBF +DYNAMIC fat +DYNAMIC Sp_Add +DYNAMIC Sp_Cache +DYNAMIC Sp_Check +DYNAMIC Sp_Clear +DYNAMIC Sp_Expand +DYNAMIC Sp_GetSet +DYNAMIC Sp_Init +DYNAMIC Sp_Line +DYNAMIC Sp_LoadAux +DYNAMIC Sp_Quick +DYNAMIC Sp_Rate +DYNAMIC Sp_Split +DYNAMIC Sp_Suggest +DYNAMIC Sp_WildCard +DYNAMIC WildCard +DYNAMIC xForm +DYNAMIC xUnForm + +#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__GFSPELL__REQUEST ) + #uncommand DYNAMIC => EXTERNAL +#endif + +#endif diff --git a/harbour/extras/gfspell/spell.ch b/harbour/extras/gfspell/spell.ch index 0a6cae9786..9027f3bbcf 100644 --- a/harbour/extras/gfspell/spell.ch +++ b/harbour/extras/gfspell/spell.ch @@ -11,10 +11,10 @@ #define ADD_SUFFIXES 7 #define ADD_PREFIXES 8 #define ADD_PLURALS 9 -#define SORT_SUGGESTIONS 10 -#define SUGGEST_PREFERENCE 11 -#define MINIMUM_WORD_LENGTH 12 -#define METAPHONE_SIZE 13 -#define MAX_DIFFERENCE 14 -#define THESAURUS_NAME 15 -#define CHECK_FOR_RUNONS 16 +#define SORT_SUGGESTIONS 10 +#define SUGGEST_PREFERENCE 11 +#define MINIMUM_WORD_LENGTH 12 +#define METAPHONE_SIZE 13 +#define MAX_DIFFERENCE 14 +#define THESAURUS_NAME 15 +#define CHECK_FOR_RUNONS 16 diff --git a/harbour/extras/gfspell/spell.prg b/harbour/extras/gfspell/spell.prg index 0120faf709..b0f4ec1df7 100644 --- a/harbour/extras/gfspell/spell.prg +++ b/harbour/extras/gfspell/spell.prg @@ -9,16 +9,16 @@ // spell check a string and to also work with individual // words. // -// SP_Add() - Add word to the dictionary -// SP_Cache() - Add word to spelling cache -// SP_Check() - Is word spelled correctly? -// SP_Clear() - Clear the spelling cache -// SP_Init() - Initialize the spelling dictionary -// SP_GetSet() - Get/Set global parameters -// SP_LoadAux() - Loads an auxiliary dictionary -// SP_Suggest() - Offer list of sound alike suggestions -// SP_Quick() - Offer list of suggested spellings -// SP_WildCard() - List of wildcard matches +// Sp_Add() - Add word to the dictionary +// Sp_Cache() - Add word to spelling cache +// Sp_Check() - Is word spelled correctly? +// Sp_Clear() - Clear the spelling cache +// Sp_Init() - Initialize the spelling dictionary +// Sp_GetSet() - Get/Set global parameters +// Sp_LoadAux() - Loads an auxiliary dictionary +// Sp_Suggest() - Offer list of sound alike suggestions +// Sp_Quick() - Offer list of suggested spellings +// Sp_WildCard() - List of wildcard matches // // DBF2Dic() - Convert a DBF file to a DIC file // Dic2DBF() - Convert a DIC file to a DBF file @@ -26,78 +26,78 @@ #include "fileio.ch" -#xtranslate StoreWord( ) => Xform( ) -#xtranslate ExtractWord( ) => Xunform( ) +#xtranslate StoreWord( ) => Xform( ) +#xtranslate ExtractWord( ) => Xunform( ) -#define NSIZE ( 26 * 26 * 6 ) -#define EACH_WORD 6 -#define CRLF Chr( 13 ) + Chr( 10 ) -#define FOUR_BYTES Chr( 0 ) + Chr( 0 ) + Chr( 0 ) + Chr( 0 ) -#define MAX_STRING 40000 +#define NSIZE ( 26 * 26 * 6 ) +#define EACH_WORD 6 +#define CRLF Chr( 13 ) + Chr( 10 ) +#define FOUR_BYTES Chr( 0 ) + Chr( 0 ) + Chr( 0 ) + Chr( 0 ) +#define MAX_STRING 40000 -#define COMMON_WORDS aGlobal[ 1] -#define CACHE_WORDS aGlobal[ 2] -#define DICTIONARY_PATH aGlobal[ 3] -#define DICTIONARY_NAME aGlobal[ 4] -#define AUXILIARY_DICTIONARY aGlobal[ 5] -#define EXTRA_CODE_BLOCK aGlobal[ 6] -#define ADD_SUFFIXES aGlobal[ 7] -#define ADD_PREFIXES aGlobal[ 8] -#define ADD_PLURALS aGlobal[ 9] -#define SORT_SUGGESTIONS aGlobal[10] -#define SUGGEST_PREFERENCE aGlobal[11] -#define MINIMUM_WORD_LENGTH aGlobal[12] -#define METAPHONE_SIZE aGlobal[13] -#define MAX_DIFFERENCE aGlobal[14] -#define THESAURUS_NAME aGlobal[15] -#define CHECK_RUNONS aGlobal[16] +#define COMMON_WORDS aGlobal[ 1 ] +#define CACHE_WORDS aGlobal[ 2 ] +#define DICTIONARY_PATH aGlobal[ 3 ] +#define DICTIONARY_NAME aGlobal[ 4 ] +#define AUXILIARY_DICTIONARY aGlobal[ 5 ] +#define EXTRA_CODE_BLOCK aGlobal[ 6 ] +#define ADD_SUFFIXES aGlobal[ 7 ] +#define ADD_PREFIXES aGlobal[ 8 ] +#define ADD_PLURALS aGlobal[ 9 ] +#define SORT_SUGGESTIONS aGlobal[ 10 ] +#define SUGGEST_PREFERENCE aGlobal[ 11 ] +#define MINIMUM_WORD_LENGTH aGlobal[ 12 ] +#define METAPHONE_SIZE aGlobal[ 13 ] +#define MAX_DIFFERENCE aGlobal[ 14 ] +#define THESAURUS_NAME aGlobal[ 15 ] +#define CHECK_RUNONS aGlobal[ 16 ] -// #define REDUCE_MEMORY_NEEDS +// #define REDUCE_MEMORY_NEEDS THREAD STATIC aGlobal := { ; - NIL,; - "",; - "",; - "DICT.DIC",; - "",; - NIL,; - .T.,; - .T.,; - .T.,; - .T.,; - "B",; // (M)etaphone, (A)lgorithmic, (B)oth - 2,; - 5,; - 1,; - "THES.DIC",; + NIL, ; + "", ; + "", ; + "dict.dic", ; + "", ; + NIL, ; + .T., ; + .T., ; + .T., ; + .T., ; + "B", ; // (M)etaphone, (A)lgorithmic, (B)oth + 2, ; + 5, ; + 1, ; + "thes.dic", ; .T. } STATIC aContracts := { ; - { "CAN'T" ,"CANNOT" },; - { "WON'T" ,"WILL NOT" },; - { "AREN'T" ,"ARE NOT" },; - { "AIN'T" ,"ARE NOT" },; - { "THEY'RE" ,"THEY ARE" },; - { "THEY'VE" ,"THEY HAVE" },; - { "IT'S" ,"IT IS" },; - { "I'LL" ,"I WILL" },; - { "I'D" ,"I WOULD" },; + { "CAN'T" ,"CANNOT" }, ; + { "WON'T" ,"WILL NOT" }, ; + { "AREN'T" ,"ARE NOT" }, ; + { "AIN'T" ,"ARE NOT" }, ; + { "THEY'RE" ,"THEY ARE" }, ; + { "THEY'VE" ,"THEY HAVE" }, ; + { "IT'S" ,"IT IS" }, ; + { "I'LL" ,"I WILL" }, ; + { "I'D" ,"I WOULD" }, ; { "DON'T" ,"DO NOT" } } -THREAD STATIC nHandle := 0 +THREAD STATIC nHandle := F_ERROR THREAD STATIC cOffsets -// Function: SP_Add() +// Function: Sp_Add() // Purpose: Adds a word to the dictionary -// Syntax: := SP_Add(cWord) +// Syntax: := Sp_Add( cWord ) // Arguments: cWord - Word to add to the auxiliary dictionary // Returns: - TRUE if added, // FALSE otherwise @@ -106,7 +106,7 @@ THREAD STATIC cOffsets // dictionary. // -FUNCTION SP_Add( cWord ) +FUNCTION Sp_Add( cWord ) LOCAL was_added := .F. // Was word written to dictionary? LOCAL nAuxHandle // Dictionary file handle @@ -116,9 +116,9 @@ FUNCTION SP_Add( cWord ) // an auxiliary dictionary name was specified // *DEBUG** - @ 24, 30 SAY "At SP_ADD" + // @ 24, 30 SAY "At SP_ADD" - IF SP_Init() .AND. ! Empty( AUXILIARY_DICTIONARY ) + IF Sp_Init() .AND. ! Empty( AUXILIARY_DICTIONARY ) cWord := Upper( AllTrim( cWord ) ) // @@ -126,7 +126,7 @@ FUNCTION SP_Add( cWord ) // we will create it for the user // - IF File( AUXILIARY_DICTIONARY ) + IF hb_FileExists( AUXILIARY_DICTIONARY ) nAuxHandle := FOpen( AUXILIARY_DICTIONARY, FO_READWRITE + FO_DENYWRITE ) ELSE nAuxHandle := FCreate( AUXILIARY_DICTIONARY ) @@ -135,10 +135,10 @@ FUNCTION SP_Add( cWord ) FSeek( nAuxHandle, 0, FS_END ) // Bottom of the file nWritten := FWrite( nAuxHandle, ; // Write word into file - cWord + CRLF, Len( cWord ) + 2 ) + cWord + CRLF ) FClose( nAuxHandle ) // Close the file - SP_Cache( cWord ) // Add word to cache + Sp_Cache( cWord ) // Add word to cache was_added := ( nWritten == Len( cWord ) + 2 ) ENDIF @@ -160,13 +160,13 @@ FUNCTION SP_Add( cWord ) // Notes: Check to see if the word already exists in the cache // -FUNCTION Sp_cache( cWord ) +FUNCTION Sp_Cache( cWord ) LOCAL cTemp := "|" + Upper( AllTrim( cWord ) ) + "|" LOCAL lAdded := .F. // *DEBUG** - @ 24, 30 SAY "At SP_cache" + // @ 24, 30 SAY "At SP_cache" IF ! cTemp $ CACHE_WORDS .AND. Len( CACHE_WORDS ) < MAX_STRING CACHE_WORDS += cTemp @@ -177,9 +177,9 @@ FUNCTION Sp_cache( cWord ) // -// Function: Sp_check() +// Function: Sp_Check() // Purpose: To check the spelling of a word -// Syntax: := Sp_check(cWord) +// Syntax: := Sp_Check( cWord ) // Arguments: cWord - upper case, all trimmed word to check // Returns: - TRUE if valid spelling // FALSE otherwise @@ -193,7 +193,7 @@ FUNCTION Sp_cache( cWord ) // // -FUNCTION SP_Check( cWord ) +FUNCTION Sp_Check( cWord ) STATIC cBuf := "" STATIC cLast @@ -214,16 +214,16 @@ FUNCTION SP_Check( cWord ) LOCAL cTemp // *DEBUG** - @ 24, 30 SAY "At SP_init" + // @ 24, 30 SAY "At SP_init" - IF sp_init() + IF Sp_Init() IF Len( cLookup ) == 1 .AND. cLookup $ "IA" RETURN .T. ENDIF IF Len( cLookup ) < MINIMUM_WORD_LENGTH RETURN .T. ENDIF - IF Right( cLookup, 2 ) = "'S" + IF Right( cLookup, 2 ) == "'S" cLookUp := SubStr( cLookup, 1, Len( cLookup ) -2 ) ENDIF cTemp := "|" + cLookup + "|" @@ -239,13 +239,13 @@ FUNCTION SP_Check( cWord ) cOffsets := Space( 6 ) FSeek( nHandle, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * 6 + 1 ) + 5, FS_SET ) FRead( nHandle, @cOffsets, 6 ) - x := Bin2L( SubStr( cOffsets, 1, 4 ) ) - y := Bin2W( SubStr( cOffsets, 5, 2 ) ) + x := Bin2L( hb_BSubStr( cOffsets, 1, 4 ) ) + y := Bin2W( hb_BSubStr( cOffsets, 5, 2 ) ) #else - x := Bin2L( SubStr( cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 1 ), 4 ) ) - y := Bin2W( SubStr( cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 5 ), 2 ) ) + x := Bin2L( hb_BSubStr( cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 1 ), 4 ) ) + y := Bin2W( hb_BSubStr( cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 5 ), 2 ) ) #endif @@ -258,18 +258,18 @@ FUNCTION SP_Check( cWord ) ELSE nBuffCount++ ENDIF - IF Len( cLookup ) = 3 - z := Asc( SubStr( cLookup, 3, 1 ) ) -64 - ok := bit( cBuf, z ) + IF Len( cLookup ) == 3 + z := Asc( SubStr( cLookup, 3, 1 ) ) - 64 + ok := bit( @cBuf, z ) ELSEIF Len( cLookup ) < 3 - ok := bit( cBuf, 27 ) + ok := bit( @cBuf, 27 ) ELSEIF y > 4 cTemp := StoreWord( cLookup ) DO WHILE z < y z := fat( cTemp, cBuf, z ) IF z < 6 EXIT - ELSEIF SubStr( cBuf, z - 1, 1 ) < Chr( 128 ) + ELSEIF hb_BSubStr( cBuf, z - 1, 1 ) < Chr( 128 ) z++ ELSE EXIT @@ -309,16 +309,16 @@ STATIC FUNCTION sp_GetBuf( cLetters ) LOCAL x LOCAL y LOCAL cBuf := "" - LOCAL nRow := Asc( SubStr( cLetters, 1, 1 ) ) -64 - LOCAL nCol := Asc( SubStr( cLetters, 2, 1 ) ) -64 + LOCAL nRow := Asc( SubStr( cLetters, 1, 1 ) ) - 64 + LOCAL nCol := Asc( SubStr( cLetters, 2, 1 ) ) - 64 // *DEBUG** - @ 24, 30 SAY "At SP_getbuf" + // @ 24, 30 SAY "At SP_getbuf" IF ( nRow > 0 .AND. nRow <= 26 ) .AND. ( nCol > 0 .AND. nCol <= 26 ) - x := Bin2L( SubStr( cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 1 ), 4 ) ) + x := Bin2L( hb_BSubStr( cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 1 ), 4 ) ) IF ! Empty( x ) - y := Bin2W( SubStr( cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 5 ), 2 ) ) + y := Bin2W( hb_BSubStr( cOffsets, ( ( nRow - 1 ) * 156 ) + ( ( nCol - 1 ) * EACH_WORD + 5 ), 2 ) ) cBuf := Space( y ) FSeek( nHandle, x + 4, FS_SET ) FRead( nHandle, @cBuf, y - 4 ) @@ -341,7 +341,7 @@ STATIC FUNCTION sp_GetBuf( cLetters ) FUNCTION sp_clear // *DEBUG** - @ 24, 30 SAY "At SP_clear" + // @ 24, 30 SAY "At SP_clear" CACHE_WORDS := "" @@ -364,7 +364,7 @@ FUNCTION Sp_GetSet( nWhich, xNewSetting ) LOCAL xOld := NIL // *DEBUG** - @ 24, 30 SAY "At SP_getset" + // @ 24, 30 SAY "At SP_getset" IF nWhich != NIL .AND. ( nWhich > 0 .AND. nWhich <= Len( aGlobal ) ) xOld := aGlobal[ nWhich ] @@ -395,15 +395,15 @@ FUNCTION Sp_LoadAux( cFile ) LOCAL nSize // *DEBUG** - @ 24, 30 SAY "At SP_loadaux" + // @ 24, 30 SAY "At SP_loadaux" IF ! Empty( cFile ) - IF File( cFile ) + IF hb_FileExists( cFile ) x := FOpen( cFile, FO_READ + FO_DENYNONE ) ELSE x := FCreate( cFile ) ENDIF - SP_GetSet( 5, cFile ) + Sp_GetSet( 5, cFile ) IF x > 0 nSize := FSeek( x, 0, FS_END ) @@ -500,12 +500,12 @@ FUNCTION Sp_Suggest( cWord, lInclude ) LOCAL arr_ // *DEBUG** - @ 24, 30 SAY "At SP_suggest" + // @ 24, 30 SAY "At SP_suggest" cWord := Upper( RTrim( cWord ) ) zz := Len( cWord ) - IF zz = 1 // Don't offer suggestions for + IF zz == 1 // Don't offer suggestions for RETURN aRet_ // single letter words ENDIF @@ -520,14 +520,14 @@ FUNCTION Sp_Suggest( cWord, lInclude ) ENDIF IF "'" $ cWord - cHold := SP_Expand( cWord ) + cHold := Sp_Expand( cWord ) IF ! Empty( cHold ) AAdd( aRet_, "A1AA" + cHold ) ENDIF ENDIF IF CHECK_RUNONS - arr_ := SP_Split( cWord ) + arr_ := Sp_Split( cWord ) FOR jj := 1 TO Len( arr_ ) AAdd( aRet_, "A1AA" + arr_[ jj ] ) NEXT @@ -548,8 +548,8 @@ FUNCTION Sp_Suggest( cWord, lInclude ) // to see if it is a valid word. // - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) - AAdd( aRet_, "B" + SP_Rate( cHold, cWord ) + cHold ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) + AAdd( aRet_, "B" + Sp_Rate( cHold, cWord ) + cHold ) ENDIF ENDIF NEXT @@ -565,8 +565,8 @@ FUNCTION Sp_Suggest( cWord, lInclude ) // to see if it is a valid word. // - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) - AAdd( aRet_, "B" + SP_Rate( cHold, cWord ) + cHold ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) + AAdd( aRet_, "B" + Sp_Rate( cHold, cWord ) + cHold ) ENDIF NEXT @@ -577,8 +577,8 @@ FUNCTION Sp_Suggest( cWord, lInclude ) FOR jj := 2 TO zz cHold := Left( cWord, jj - 2 ) + SubStr( cWord, jj, 1 ) + ; SubStr( cWord, jj - 1, 1 ) + SubStr( cWord, jj + 1 ) - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) - AAdd( aRet_, "B" + SP_Rate( cHold, cWord ) + cHold ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) + AAdd( aRet_, "B" + Sp_Rate( cHold, cWord ) + cHold ) ENDIF NEXT @@ -588,8 +588,8 @@ FUNCTION Sp_Suggest( cWord, lInclude ) cHold := cWord + "E" - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) - AAdd( aRet_, "B" + SP_Rate( cHold, cWord ) + cHold ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) + AAdd( aRet_, "B" + Sp_Rate( cHold, cWord ) + cHold ) ENDIF // @@ -603,8 +603,8 @@ FUNCTION Sp_Suggest( cWord, lInclude ) DO WHILE ( ii := fat( aParts_[ jj, 1 ], cWord, ii ) ) > 0 FOR kk := 1 TO Len( aParts_[ jj, 2 ] ) cHold := SubStr( cWord, 1, ii - 1 ) + aParts_[ jj, 2, kk ] + SubStr( cWord, ii + 1 ) - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) - AAdd( aRet_, "B" + SP_Rate( cHold, cWord ) + cHold ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) + AAdd( aRet_, "B" + Sp_Rate( cHold, cWord ) + cHold ) ENDIF NEXT ii++ @@ -612,8 +612,8 @@ FUNCTION Sp_Suggest( cWord, lInclude ) ELSE FOR kk := 1 TO Len( aParts_[ jj, 2 ] ) cHold := StrTran( cWord, aParts_[ jj, 1 ], aParts_[ jj, 2, kk ] ) - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) - AAdd( aRet_, "B" + SP_Rate( cHold, cWord ) + cHold ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cHold } ) == 0 .AND. Sp_Check( cHold ) + AAdd( aRet_, "B" + Sp_Rate( cHold, cWord ) + cHold ) ENDIF NEXT ENDIF @@ -636,9 +636,9 @@ FUNCTION Sp_Suggest( cWord, lInclude ) IF ADD_SUFFIXES FOR kk := 1 TO nSuffix cTemp := cHold + aEnds[ kk ] - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - Sp_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF NEXT // @@ -647,9 +647,9 @@ FUNCTION Sp_Suggest( cWord, lInclude ) FOR kk := 1 TO nSuffix cTemp := cHold + SubStr( cHold, zz, 1 ) + aEnds[ kk ] - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF NEXT // @@ -659,9 +659,9 @@ FUNCTION Sp_Suggest( cWord, lInclude ) IF SubStr( cHold, -1, 1 ) == "C" FOR kk := 1 TO nSuffix cTemp := cHold + "K" + aEnds[ kk ] - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF NEXT ENDIF @@ -671,20 +671,20 @@ FUNCTION Sp_Suggest( cWord, lInclude ) IF SubStr( cHold, -2, 2 ) == "ND" cTemp := SubStr( cHold, 1, zz - 1 ) + "SE" - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF FOR kk := 1 TO nSuffix cTemp := SubStr( cHold, 1, zz - 1 ) + "SE" + aEnds[ kk ] - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF cTemp := SubStr( cHold, 1, zz - 1 ) + "S" + aEnds[ kk ] - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF NEXT ENDIF @@ -695,9 +695,9 @@ FUNCTION Sp_Suggest( cWord, lInclude ) IF SubStr( cHold, zz, 1 ) == "E" FOR kk := 1 TO nSuffix cTemp := SubStr( cHold, 1, zz - 1 ) + aEnds[ kk ] - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF NEXT ENDIF @@ -706,37 +706,37 @@ FUNCTION Sp_Suggest( cWord, lInclude ) IF ADD_PREFIXES FOR kk := 1 TO 7 cTemp := aBegs[ kk ] + cHold - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF NEXT ENDIF IF ADD_PLURALS cTemp := cHold + "S" - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF IF SubStr( cHold, zz, 1 ) == "Y" cTemp := SubStr( cHold, 1, zz - 1 ) + "IES" - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF ELSEIF SubStr( cHold, zz, 1 ) == "F" cTemp := SubStr( cHold, 1, zz - 1 ) + "VES" - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF ELSEIF SubStr( cHold, zz, 1 ) == "O" cTemp := cHold + "ES" - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; - SP_Check( cTemp ) - AAdd( aRet_, "C" + SP_Rate( cTemp, cWord ) + cTemp ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cTemp } ) == 0 .AND. ; + Sp_Check( cTemp ) + AAdd( aRet_, "C" + Sp_Rate( cTemp, cWord ) + cTemp ) ENDIF ENDIF ENDIF @@ -757,9 +757,9 @@ FUNCTION Sp_Suggest( cWord, lInclude ) ELSE zz := METAPHONE_SIZE ENDIF - cTemp := SP_GetBuf( cWord ) + cTemp := Sp_GetBuf( cWord ) ii := Len( cTemp ) - cMeta := C_Metafone( cWord, zz ) + cMeta := C_MetaFone( cWord, zz ) zz := Len( cMeta ) cFirst := SubStr( cWord, 1, 2 ) @@ -773,11 +773,11 @@ FUNCTION Sp_Suggest( cWord, lInclude ) DO WHILE kk > 0 IF Asc( SubStr( cTemp, kk, 1 ) ) >= 128 // End of word cHold := cFirst + xUnForm( SubStr( cTemp, kk + 1, jj - kk ) ) - cKey := c_metafone( cHold, zz ) - IF cMeta == c_Metafone( cHold, zz ) + cKey := C_Metafone( cHold, zz ) + IF cMeta == C_Metafone( cHold, zz ) IF MAX_DIFFERENCE < 0 .OR. Abs( Len( cWord ) -Len( cHold ) ) <= MAX_DIFFERENCE - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cHold } ) == 0 - AAdd( aRet_, "B" + SP_Rate( cHold, cWord ) + cHold ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cHold } ) == 0 + AAdd( aRet_, "B" + Sp_Rate( cHold, cWord ) + cHold ) ENDIF ENDIF ELSEIF cKey < cMeta @@ -796,11 +796,11 @@ FUNCTION Sp_Suggest( cWord, lInclude ) DO WHILE kk < ii IF Asc( SubStr( cTemp, kk, 1 ) ) >= 128 // End of word cHold := cFirst + xUnForm( SubStr( cTemp, jj, kk - jj + 1 ) ) - cKey := c_metafone( cHold, zz ) - IF cMeta == c_Metafone( cHold, zz ) + cKey := C_Metafone( cHold, zz ) + IF cMeta == C_Metafone( cHold, zz ) IF MAX_DIFFERENCE < 0 .OR. Abs( Len( cWord ) -Len( cHold ) ) <= MAX_DIFFERENCE - IF AScan( aRet_, {|xx| SubStr( xx, 5 ) == cHold } ) == 0 - AAdd( aRet_, "B" + SP_Rate( cHold, cWord ) + cHold ) + IF AScan( aRet_, {| xx | SubStr( xx, 5 ) == cHold } ) == 0 + AAdd( aRet_, "B" + Sp_Rate( cHold, cWord ) + cHold ) ENDIF ENDIF ELSEIF cKey > cMeta @@ -853,7 +853,7 @@ FUNCTION Sp_Quick( cWord ) LOCAL cHold, ll, cTemp // *DEBUG** - @ 24, 30 SAY "At SP_quick" + // @ 24, 30 SAY "At SP_quick" cWord := Upper( RTrim( cWord ) ) @@ -950,7 +950,7 @@ FUNCTION Sp_Quick( cWord ) STATIC FUNCTION ChrCount( cChar, cString ) // *DEBUG** - @ 24, 30 SAY "At ChrCount" + // @ 24, 30 SAY "At ChrCount" RETURN Len( cString ) -Len( StrTran( cString, cChar ) ) @@ -962,13 +962,13 @@ FUNCTION Sp_Split( cWord ) LOCAL cWord2 // *DEBUG** - @ 24, 30 SAY "At SP_split" + // @ 24, 30 SAY "At SP_split" FOR x := 2 TO Len( cWord ) cWord1 := Left( cWord, x - 1 ) cWord2 := SubStr( cWord, x ) IF Len( cWord1 ) > 1 .AND. Len( cWord2 ) > 1 - IF SP_Check( cWord1 ) .AND. SP_Check( cWord2 ) + IF Sp_Check( cWord1 ) .AND. Sp_Check( cWord2 ) AAdd( arr_, cWord1 + " " + cWord2 ) ENDIF ENDIF @@ -976,18 +976,18 @@ FUNCTION Sp_Split( cWord ) RETURN arr_ -FUNCTION SP_Expand( cWord ) +FUNCTION Sp_Expand( cWord ) LOCAL x LOCAL cExpand // *DEBUG** - @ 24, 30 SAY "At SP_expand" + // @ 24, 30 SAY "At SP_expand" cWord := Upper( AllTrim( cWord ) ) - x := AScan( aContracts, {|jj| jj[ 1 ] = cWord } ) + x := AScan( aContracts, {| jj | Left( jj[ 1 ], Len( cWord ) ) == cWord } ) // LEFTEQUAL() IF x > 0 - cExpand := aContracts[ x, 2 ] + cExpand := aContracts[ x, 2 ] ENDIF RETURN cExpand @@ -1003,7 +1003,7 @@ FUNCTION SP_Expand( cWord ) // Returns: aSuggest - List of matching words // -FUNCTION Sp_Wildcard( cPattern ) +FUNCTION Sp_WildCard( cPattern ) LOCAL cTemp LOCAL ii, kk, jj, cFirst, cHold, x, z @@ -1011,11 +1011,11 @@ FUNCTION Sp_Wildcard( cPattern ) LOCAL nStart, nEnd // *DEBUG** - @ 24, 30 SAY "At SP_wildcard" + // @ 24, 30 SAY "At SP_wildcard" cPattern := Upper( cPattern ) - IF SP_Init() + IF Sp_Init() x := fat( "*", cPattern ) IF x == 0 x := fat( "?", cPattern ) @@ -1033,7 +1033,7 @@ FUNCTION Sp_Wildcard( cPattern ) FOR z := nStart TO nEnd - cTemp := SP_GetBuf( SubStr( cPattern, 1, 1 ) + Chr( z + 64 ) ) + cTemp := Sp_GetBuf( SubStr( cPattern, 1, 1 ) + Chr( z + 64 ) ) ii := Len( cTemp ) cFirst := SubStr( cPattern, 1, 1 ) + Chr( z + 64 ) @@ -1062,7 +1062,7 @@ FUNCTION Sp_Wildcard( cPattern ) // The following functions are internal and should not be modified. * -// Function: SP_Init() +// Function: Sp_Init() // Purpose: Internal function to initialize the dictionary // Arguments: NONE // Returns: - Was dictionary initialized? @@ -1070,7 +1070,7 @@ FUNCTION Sp_Wildcard( cPattern ) // Notes: // -FUNCTION Sp_init +FUNCTION Sp_Init() LOCAL isok := .T. LOCAL cBuf @@ -1081,12 +1081,12 @@ FUNCTION Sp_init LOCAL nFileSize // *DEBUG** - @ 24, 30 SAY "At SP_init" + // @ 24, 30 SAY "At SP_init" IF cOffsets == NIL isok := .F. nHandle := FOpen( DICTIONARY_PATH + DICTIONARY_NAME, FO_READ + FO_DENYWRITE ) - IF nHandle > 0 + IF nHandle != F_ERROR #ifdef REDUCE_MEMORY_NEEDS @@ -1119,20 +1119,20 @@ FUNCTION Sp_init isok := .T. ENDIF IF ! Empty( AUXILIARY_DICTIONARY ) - SP_LoadAux( AUXILIARY_DICTIONARY ) + Sp_LoadAux( AUXILIARY_DICTIONARY ) ENDIF ENDIF IF aGlobal[ 1 ] == NIL - SP_Common() + Sp_Common() ENDIF // * Thesaurus comented out as not needed #if 0 IF ! Empty( THESAURUS_NAME ) - IF File( DICTIONARY_PATH + THESAURUS_NAME ) - SP_OpenThes( DICTIONARY_PATH + THESAURUS_NAME ) - ELSEIF File( THESAURUS_NAME ) - SP_OpenThes( THESAURUS_NAME ) + IF hb_FileExists( DICTIONARY_PATH + THESAURUS_NAME ) + Sp_OpenThes( DICTIONARY_PATH + THESAURUS_NAME ) + ELSEIF hb_FileExists( THESAURUS_NAME ) + Sp_OpenThes( THESAURUS_NAME ) ENDIF ENDIF #endif @@ -1146,12 +1146,12 @@ FUNCTION Sp_init // // Function: DBF2Dic() // Purpose: To create a DIC file from a DBF list of words -// Syntax: nStatus := DBF2Dic( , ) +// Syntax: nStatus := DBF2Dic( , ) // Arguments: - DBF containing sorted list of upper // case words. The field name must be // WORD and of type character // - Name of DIC file to create, assumes -// DICT.DIC +// 'dict.dic' // Returns: nStatus - 0 if successful // -1 DBF file does not exist // -2 Field WORD does not exist in DBF @@ -1180,10 +1180,10 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk ) // // *DEBUG** - @ 24, 30 SAY "At DBF2DIC" + // @ 24, 30 SAY "At DBF2DIC" IF cDictionary == NIL - cDictionary := "DICT.DIC" + cDictionary := "dict.dic" ENDIF IF lTalk == NIL @@ -1196,14 +1196,14 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk ) // IF ! "." $ cDBF - cDBF += ".DBF" + cDBF += ".dbf" ENDIF - IF ! File( cDBF ) + IF ! hb_FileExists( cDBF ) RETURN -1 ENDIF - USE ( cDbf ) ALIAS DICT new + USE ( cDbf ) ALIAS DICT NEW IF FieldPos( "WORD" ) == 0 USE RETURN -2 @@ -1221,8 +1221,8 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk ) ENDIF - INDEX ON SubStr( DICT->word, 1, 2 ) + PadR( c_metafone( AllTrim( DICT->word ), 5 ), 6 ) to $$ temp - GO TOP + INDEX ON SubStr( DICT->word, 1, 2 ) + PadR( c_metafone( AllTrim( DICT->word ), 5 ), 6 ) TO ( "$$temp" ) + dbGoTop() IF lTalk @@ -1235,22 +1235,22 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk ) // // ADDED - 02/08/96 - JAMES - IF nHandle > 0 // Is dictionary already open? - FClose( nHandle ) // Yes, close it - nHandle := 0 + IF nHandle != F_ERROR // Is dictionary already open? + FClose( nHandle ) // Yes, close it + nHandle := F_ERROR ENDIF // END OF ADDITION nH := FCreate( cDictionary ) - IF nH >= 0 + IF nH != F_ERROR // // Write out enough bytes to hold the index information // - FWrite( nH, "JJ" + L2Bin( NSIZE + 4 ) + Replicate( Chr( 0 ), NSIZE ) + Space( 10 ), NSIZE + 16 ) + FWrite( nH, "JJ" + L2Bin( NSIZE + 4 ) + Replicate( Chr( 0 ), NSIZE ) + Space( 10 ) ) FOR i := 1 TO 26 - DO WHILE SubStr( DICT->word, 1, 1 ) == Chr( i + 64 ) .AND. ! Eof() + DO WHILE Left( DICT->word, 1 ) == Chr( i + 64 ) .AND. ! Eof() FOR j := 1 TO 26 temp := "" cBits := FOUR_BYTES @@ -1258,41 +1258,41 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk ) IF Len( AllTrim( DICT->word ) ) > 0 cOther += "|" + AllTrim( DICT->word ) ENDIF - skip + 1 + dbSkip() ENDDO DO WHILE SubStr( DICT->word, 2, 1 ) == Chr( j + 64 ) .AND. ! Eof() - IF Len( RTrim( DICT->word ) ) = 3 - Bit( cBits, Asc( SubStr( DICT->word, 3, 1 ) ) -64, .T. ) + IF Len( RTrim( DICT->word ) ) == 3 + bit( @cBits, Asc( SubStr( DICT->word, 3, 1 ) ) - 64, .T. ) ELSEIF Len( RTrim( DICT->word ) ) == 2 - Bit( cBits, 27, .T. ) + bit( @cBits, 27, .T. ) ELSE temp += StoreWord( RTrim( DICT->word ) ) ENDIF - skip + 1 + dbSkip() IF lTalk nCurRec++ - @ 10, 41 say ( nCurRec / nSize ) * 100 PICTURE "999.9%" COLOR "W+/R" + @ 10, 41 SAY ( nCurRec / nSize ) * 100 PICTURE "999.9%" COLOR "W+/R" ENDIF ENDDO - IF ! Empty( temp ) .OR. cBits != FOUR_BYTES + IF ! Empty( temp ) .OR. !( cBits == FOUR_BYTES ) nWhere := FSeek( nH, 0, FS_END ) FSeek( nH, ( ( i - 1 ) * 26 * EACH_WORD ) + ( ( j - 1 ) * EACH_WORD ) + 6 ) - FWrite( nH, L2Bin( nWhere ) + I2Bin( Len( temp ) + 4 ), EACH_WORD ) + FWrite( nH, L2Bin( nWhere ) + I2Bin( hb_BLen( temp ) + 4 ), EACH_WORD ) FSeek( nH, 0, FS_END ) - FWrite( nH, cBits + temp, Len( temp ) + 4 ) + FWrite( nH, cBits + temp ) ENDIF NEXT ENDDO NEXT j := FSeek( nH, 0, FS_END ) FSeek( nH, 2, FS_SET ) - FWrite( nH, L2Bin( j ), 4 ) + FWrite( nH, L2Bin( j ) ) IF ! Empty( cOther ) FSeek( nH, j, FS_SET ) cOther += "|" - FWrite( nH, cOther, Len( cOther ) ) + FWrite( nH, cOther ) ENDIF FClose( nH ) ELSE @@ -1305,7 +1305,7 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk ) SELECT DICT USE - // ferase("$$TEMP"+indexext()) + FErase( "$$temp" + IndexExt() ) RETURN nStatus @@ -1313,10 +1313,10 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk ) // // Function: Dic2DBF() // Purpose: To create a DBF file from a DIC file -// Syntax: nStatus := DIC2DBF( , ) +// Syntax: nStatus := DIC2DBF( , ) // Arguments: - Name of DIC file to read, assumes -// DICT.DIC -// - Name of DBF to create, assumes DICT.DBF +// dict.dic +// - Name of DBF to create, assumes dict.dbf // It will contain a single field called // WORD of type character // Returns: nStatus - 0 if successful @@ -1326,7 +1326,7 @@ FUNCTION DBF2Dic( cDbf, cDictionary, lTalk ) // Calls: // -FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) +FUNCTION Dic2DBF( cDictionary, cDBF, lTalk ) LOCAL nStatus := 0 // Status code LOCAL i // Loop counters @@ -1339,21 +1339,21 @@ FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) LOCAL nSize // *DEBUG** - @ 24, 30 SAY "At DIC2DBF" + // @ 24, 30 SAY "At DIC2DBF" // // DEFAULT name for dictionary file // IF cDictionary == NIL - cDictionary := "DICT.DIC" + cDictionary := "dict.dic" ENDIF IF lTalk == NIL lTalk := .F. ENDIF - IF ! File( cDictionary ) + IF ! hb_FileExists( cDictionary ) RETURN -1 ENDIF @@ -1363,7 +1363,7 @@ FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) // Read the dictionary file // - IF ! SP_Init() + IF ! Sp_Init() RETURN -2 ENDIF // @@ -1371,12 +1371,12 @@ FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) // IF ! "." $ cDBF - cDBF += ".DBF" + cDBF += ".dbf" ENDIF dbCreate( cDbf, { { "WORD", "C", 25, 0 } } ) - USE ( cDbf ) ALIAS DICT new + USE ( cDbf ) ALIAS DICT NEW IF lTalk cSave := SaveScreen( 8, 30, 12, 48 ) @@ -1396,7 +1396,7 @@ FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) FOR i := 2 TO Len( CACHE_WORDS ) IF SubStr( CACHE_WORDS, i, 1 ) == "|" - APPEND BLANK + dbAppend() REPLACE DICT->word WITH SubStr( CACHE_WORDS, j, i - j ) j := i + 1 ENDIF @@ -1411,21 +1411,21 @@ FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) y := Bin2W( SubStr( cOffsets, ( ( i - 1 ) * 156 ) + ( ( j - 1 ) * EACH_WORD + 5 ), 2 ) ) IF lTalk - @ 10, 43 say ( x / nSize ) * 100 PICTURE "999%" COLOR "W+/R" - @ 11, 41 SAY LastRec() PICTURE "99,999" COLOR "W+/R" + @ 10, 43 SAY ( x / nSize ) * 100 PICTURE "999%" COLOR "W+/R" + @ 11, 41 SAY LastRec() PICTURE "99,999" COLOR "W+/R" ENDIF cBuf := Space( y ) FSeek( nHandle, x, FS_SET ) FRead( nHandle, @cBuf, y ) FOR z := 1 TO 26 - IF bit( cBuf, z ) - APPEND BLANK + IF bit( @cBuf, z ) + dbAppend() REPLACE DICT->word WITH temp + Chr( z + 64 ) ENDIF NEXT - IF bit( cBuf, 27 ) - APPEND BLANK + IF bit( @cBuf, 27 ) + dbAppend() REPLACE DICT->word WITH temp ENDIF cBuf := SubStr( cBuf, 5 ) @@ -1433,7 +1433,7 @@ FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) DO WHILE ! Empty( cBuf ) IF SubStr( cBuf, z, 1 ) >= Chr( 128 ) cWord := SubStr( cBuf, 1, z ) - APPEND BLANK + dbAppend() REPLACE DICT->word WITH temp + ExtractWord( cWord ) cWord := "" cBuf := SubStr( cBuf, z + 1 ) @@ -1462,11 +1462,10 @@ FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) USE RETURN nStatus -// -// Function: SP_Common() +// Function: Sp_Common() // Purpose: Loads the COMMON word static array element -// Syntax: SP_Common() +// Syntax: Sp_Common() // Arguments: // Returns: NIL // @@ -1475,7 +1474,7 @@ FUNCTION DIC2DBF( cDictionary, cDBF, lTalk ) // dictionary lookup for 70-80% of the words. // // -STATIC FUNCTION SP_common +STATIC FUNCTION Sp_Common() #ifdef REDUCE_MEMORY_NEEDS @@ -1554,7 +1553,7 @@ STATIC FUNCTION SP_common #endif // *DEBUG** - @ 24, 30 SAY "At SP_common" + // @ 24, 30 SAY "At SP_common" RETURN NIL @@ -1569,7 +1568,7 @@ FUNCTION WildCard( cPattern, cString ) LOCAL nStrSize, nPatSize // *DEBUG** - @ 24, 30 SAY "At wildcard" + // @ 24, 30 SAY "At wildcard" cString := Upper( AllTrim( cString ) ) @@ -1600,14 +1599,14 @@ FUNCTION WildCard( cPattern, cString ) lMatch := .T. FOR y := 1 TO nPatSize IF !( SubStr( cPattern, y, 1 ) == "?" ) .AND. ; - !( SubStr( cPattern, y, 1 ) == SubStr( cString, y, 1 ) ) + !( SubStr( cPattern, y, 1 ) == SubStr( cString, y, 1 ) ) lMatch := .F. EXIT ENDIF NEXT ENDIF ELSE - lMatch := Upper( cPattern ) = Upper( cString ) + lMatch := Left( Upper( cPattern ), Len( Upper( cString ) ) ) == Upper( cString ) ENDIF ENDIF @@ -1623,7 +1622,7 @@ FUNCTION aWords( cLine ) LOCAL nOffset // *DEBUG** - @ 24, 30 SAY "At clip52" + // @ 24, 30 SAY "At clip52" z := 0 DO WHILE z <= nSize @@ -1650,12 +1649,12 @@ FUNCTION aWords( cLine ) #endif // Find an occurrence of 'f_str' in 'l_str' starting from position 'f_rom' -FUNCTION FAT( f_str, l_str, f_rom ) +FUNCTION fat( f_str, l_str, f_rom ) LOCAL ret_val // *DEBUG** - @ 24, 30 SAY "At FAT" + // @ 24, 30 SAY "At FAT" IF PCount() < 3 // Is f_rom passed? f_rom := 1 diff --git a/harbour/extras/gfspell/spellc.c b/harbour/extras/gfspell/spellc.c index da57a0c5a6..9be1dc30fa 100644 --- a/harbour/extras/gfspell/spellc.c +++ b/harbour/extras/gfspell/spellc.c @@ -2,10 +2,11 @@ * $Id$ */ -// #define _CLIPDEFS_H // Don't redefine basic types +/* #define _CLIPDEFS_H */ /* Don't redefine basic types */ #include "extend.h" -// #include "hbapi.h" +/* #include "hbapi.h" */ #include "hbapifs.h" +#include "hbapiitm.h" #include "extend.api" #include "hbundoc.api" @@ -13,25 +14,20 @@ typedef char uchar; typedef unsigned int uint; #define abs( a ) ( ( ( a ) > 0 ) ? ( a ) : -( a ) ) -#define min( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) -#define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) -//Org extern cdecl int _bscan( uchar *, int, uchar ); -//Org extern cdecl int _bcmp( uchar *, uchar *, int ); uchar * cSearch = "INEDTIERESTEON"; uchar * cRepl = "[\\]^_`a"; - -//////////////////////////// -// Function: xForm() -// Purpose: Internal function to translate words to dictionary -// Arguments: cWord - upper case word to format -// Returns: cXformed - translated word -// -// Notes: I'm assuming that the passed word won't exceed 128 bytes. -//////////////////////////// +/*************************** + * Function: xForm() + * Purpose: Internal function to translate words to dictionary + * Arguments: cWord - upper case word to format + * Returns: cXformed - translated word + * + * Notes: I'm assuming that the passed word won't exceed 128 bytes. + **************************/ HB_FUNC( XFORM ) { uchar cRet[ 128 ]; @@ -90,15 +86,14 @@ HB_FUNC( XFORM ) } - -//////////////////////////// -// Function: xUnForm() -// Purpose: Internal function to translate words from dictionary -// Arguments: cWord - formatted word -// Returns: cXformed - unformatted word -// -// Notes: I'm assuming that the returned word won't exceed 128 bytes. -//////////////////////////// +/*************************** + * Function: xUnForm() + * Purpose: Internal function to translate words from dictionary + * Arguments: cWord - formatted word + * Returns: cXformed - unformatted word + * + * Notes: I'm assuming that the returned word won't exceed 128 bytes. + **************************/ HB_FUNC( XUNFORM ) { uchar cRet[ 128 ]; @@ -123,8 +118,7 @@ HB_FUNC( XUNFORM ) else c -= 128; -//Org if ( ( x = _bscan( cRepl, 7, c ) ) <= 6 ) - if( ( x = memchr( cRepl, c, 7 ) ) <= 6 ) + if( ( x = ( int ) memchr( cRepl, c, 7 ) ) <= 6 ) { if( x == 0 ) { @@ -152,27 +146,26 @@ HB_FUNC( XUNFORM ) } - -//////////////////////////// -// Function: SP_Rate() -// Syntax: cRating := SP_Rate(cFound,cWord) -// Purpose: Returns a letter code indicating how similar the two -// words are. This is primarily used to sort the list -// of suggested words. -// Arguments: cFound - Word from dictionary -// cWord - Word to compare with dictionary word -// Returns: cRating - Letter A-I or Z -// Category: INTERNAL -// Called by: SP_SUGGEST() -// Notes: SP_Rate() assigns a rating based upon how likely the -// word matches the dictionary word. It compares the -// first 5 letters of the boths word, then the last 5, -// down to 2 letters. This results in a rating from A-H. -// If none of these matched, then the function will return -// either an I if the words are the same length, or a Z. -// -// C Notes: I'm assuming the words passed are already trimmed. -//////////////////////////// +/*************************** + * Function: SP_Rate() + * Syntax: cRating := SP_Rate(cFound,cWord) + * Purpose: Returns a letter code indicating how similar the two + * words are. This is primarily used to sort the list + * of suggested words. + * Arguments: cFound - Word from dictionary + * cWord - Word to compare with dictionary word + * Returns: cRating - Letter A-I or Z + * Category: INTERNAL + * Called by: SP_SUGGEST() + * Notes: SP_Rate() assigns a rating based upon how likely the + * word matches the dictionary word. It compares the + * first 5 letters of the boths word, then the last 5, + * down to 2 letters. This results in a rating from A-H. + * If none of these matched, then the function will return + * either an I if the words are the same length, or a Z. + * + * C Notes: I'm assuming the words passed are already trimmed. + **************************/ HB_FUNC( SP_RATE ) { const uchar * cFound; @@ -188,16 +181,16 @@ HB_FUNC( SP_RATE ) nFound = _parclen( 1 ); cWord = _parc( 2 ); nWord = _parclen( 2 ); - nMinLen = min( nFound, nWord ); + nMinLen = HB_MIN( nFound, nWord ); x = abs( nFound - nWord ); - *cRating = ( uchar ) ( min( x, 9 ) + '0' ); - lim = min( nMinLen, 5 ); + *cRating = ( uchar ) ( HB_MIN( x, 9 ) + '0' ); + lim = HB_MIN( nMinLen, 5 ); for( x = 0; x < lim; x++ ) { if( *( cFound + x ) != *( cWord + x ) ) break; - *( cRating + 1 ) = 'A' - 1 + lim - x; + *( cRating + 1 ) = ( uchar ) ( 'A' - 1 + lim - x ); } cFound = cFound + nFound - 1; @@ -207,7 +200,7 @@ HB_FUNC( SP_RATE ) { if( *cFound != *cWord ) break; - *( cRating + 2 ) = 'A' - 1 + lim - x; + *( cRating + 2 ) = ( uchar ) ( 'A' - 1 + lim - x ); cFound--; cWord--; } @@ -216,9 +209,9 @@ HB_FUNC( SP_RATE ) } -// ** End of Spell ** +/** End of Spell **/ -// ** Start of Metaphone ** +/** Start of Metaphone **/ /* @@ -234,25 +227,22 @@ HB_FUNC( SP_RATE ) * ............................................................................. *---------------------------- ALL RIGHTS RESERVED ----------------------------*/ -// #include "extend.h" - /* This function replaces the ft_Metaph() that Joe Booth used in his spelling checker article in the Aquarium.*/ HB_FUNC( C_METAFONE ) { - char * sReturn; /* Pointer to the return string. */ - const char * sMeta; /* Pointer to the passed string. */ - unsigned int iRetLen; /* Length of the return string. */ - unsigned int iStrLen; /* Length of the passed string. */ - unsigned int iRetPtr; /* Pointer into the return string. */ - unsigned int iStrPtr; /* Pointer into the passed string. */ + char * sReturn; /* Pointer to the return string. */ + char * sMeta; /* Pointer to the passed string. */ + HB_SIZE iRetLen; /* Length of the return string. */ + HB_SIZE iStrLen; /* Length of the passed string. */ + HB_SIZE iRetPtr; /* Pointer into the return string. */ + HB_SIZE iStrPtr; /* Pointer into the passed string. */ /* If no string was passed then return an empty string. */ if( PCOUNT == 0 ) { -//Org sMeta = _xalloc( 1 ) ; sMeta = hb_xgrab( 1 ); sMeta[ 1 ] = '\0'; iStrLen = 0; @@ -261,21 +251,18 @@ HB_FUNC( C_METAFONE ) /* If no return lenght was passed, default to 4. */ else if( PCOUNT == 1 ) { - sMeta = _parc( 1 ); - iStrLen = _parclen( 1 ); + hb_itemGetWriteCL( hb_param( 1, HB_IT_STRING ), &sMeta, &iStrLen ); iRetLen = 4; } else { - sMeta = _parc( 1 ); - iStrLen = _parclen( 1 ); + hb_itemGetWriteCL( hb_param( 1, HB_IT_STRING ), &sMeta, &iStrLen ); iRetLen = _parni( 2 ); } /* Set up the buffer to hold the return string. Be sure to make it 1 character longer than needed so there is space for the null terminator. */ -//Org sReturn = _xalloc( iRetLen + 1 ) ; sReturn = hb_xgrab( iRetLen + 1 ); iRetPtr = 0; iStrPtr = 0; @@ -397,19 +384,16 @@ HB_FUNC( C_METAFONE ) iStrPtr += 2; } break; - } /* End of prefix switch...case. */ /* Now we want to loop until we have stepped through the entire passed string or we have filled the return string. */ - while( ( iStrPtr < iStrLen ) && ( iRetPtr < iRetLen ) ) + while( iStrPtr < iStrLen && iRetPtr < iRetLen ) { - /* Use a switch...case statement for each character combination. */ switch( sMeta[ iStrPtr ] ) { - /* If it is a vowel other than 'I', skip it if it isn't the first character of the passed string. */ case 'A': @@ -426,9 +410,9 @@ HB_FUNC( C_METAFONE ) case 'I': if( iStrPtr == 0 ) sReturn[ iRetPtr++ ] = sMeta[ iStrPtr ]; - if( ( sMeta[ iStrPtr + 1 ] == 'S' ) && - ( sMeta[ iStrPtr + 2 ] == 'C' ) && - ( sMeta[ iStrPtr + 3 ] == 'H' ) ) + if( sMeta[ iStrPtr + 1 ] == 'S' && + sMeta[ iStrPtr + 2 ] == 'C' && + sMeta[ iStrPtr + 3 ] == 'H' ) { sReturn[ iRetPtr++ ] = 'X'; iStrPtr += 3; @@ -439,8 +423,8 @@ HB_FUNC( C_METAFONE ) /* Skip B if it is the last character and after an 'M'. */ case 'B': if( ( ( iStrPtr == iStrLen - 1 ) || - ( sMeta[ iStrPtr + 1 ] == ' ' ) ) && - ( sMeta[ iStrPtr - 1 ] == 'M' ) ) + sMeta[ iStrPtr + 1 ] == ' ' ) && + sMeta[ iStrPtr - 1 ] == 'M' ) { iStrPtr++; continue; @@ -469,9 +453,9 @@ HB_FUNC( C_METAFONE ) /* DGE, DGI, DGY -> J */ if( sMeta[ iStrPtr + 1 ] == 'G' ) { - if( ( sMeta[ iStrPtr + 2 ] == 'E' ) || - ( sMeta[ iStrPtr + 2 ] == 'I' ) || - ( sMeta[ iStrPtr + 2 ] == 'Y' ) ) + if( sMeta[ iStrPtr + 2 ] == 'E' || + sMeta[ iStrPtr + 2 ] == 'I' || + sMeta[ iStrPtr + 2 ] == 'Y' ) { sReturn[ iRetPtr++ ] = 'J'; iStrPtr += 3; @@ -499,23 +483,23 @@ HB_FUNC( C_METAFONE ) iStrPtr++; /* GE, GI, GY -> J (if not following a double). */ - if( ( ( sMeta[ iStrPtr + 1 ] == 'E' ) || - ( sMeta[ iStrPtr + 1 ] == 'I' ) || - ( sMeta[ iStrPtr + 1 ] == 'Y' ) ) && - ! ( sMeta[ iStrPtr - 1 ] == 'G' ) ) + if( ( sMeta[ iStrPtr + 1 ] == 'E' || + sMeta[ iStrPtr + 1 ] == 'I' || + sMeta[ iStrPtr + 1 ] == 'Y' ) && + sMeta[ iStrPtr - 1 ] != 'G' ) { sReturn[ iRetPtr++ ] = 'J'; iStrPtr += 2; } /* vGHT -> T or vGH, vGHTH -> W leaving TH to be processed. */ - else if( ( sMeta[ iStrPtr + 1 ] == 'H' ) && - ( ( sMeta[ iStrPtr - 1 ] == 'A' ) || - ( sMeta[ iStrPtr - 1 ] == 'E' ) || - ( sMeta[ iStrPtr - 1 ] == 'I' ) || - ( sMeta[ iStrPtr - 1 ] == 'O' ) || - ( sMeta[ iStrPtr - 1 ] == 'U' ) ) ) + else if( sMeta[ iStrPtr + 1 ] == 'H' && + ( sMeta[ iStrPtr - 1 ] == 'A' || + sMeta[ iStrPtr - 1 ] == 'E' || + sMeta[ iStrPtr - 1 ] == 'I' || + sMeta[ iStrPtr - 1 ] == 'O' || + sMeta[ iStrPtr - 1 ] == 'U' ) ) { - if( ( sMeta[ iStrPtr + 2 ] == 'T' ) && + if( sMeta[ iStrPtr + 2 ] == 'T' && ! ( sMeta[ iStrPtr + 3 ] == 'H' ) ) { sReturn[ iRetPtr++ ] = 'T'; @@ -524,8 +508,8 @@ HB_FUNC( C_METAFONE ) else { /* OUGH -> F */ - if( ( sMeta[ iStrPtr - 2 ] == 'O' ) && - ( sMeta[ iStrPtr - 1 ] == 'U' ) ) + if( sMeta[ iStrPtr - 2 ] == 'O' && + sMeta[ iStrPtr - 1 ] == 'U' ) { sReturn[ iRetPtr++ ] = 'F'; iStrPtr += 2; @@ -538,12 +522,12 @@ HB_FUNC( C_METAFONE ) } } /* GHv -> K */ - else if( ( sMeta[ iStrPtr + 1 ] == 'H' ) && - ( ( sMeta[ iStrPtr + 2 ] == 'A' ) || - ( sMeta[ iStrPtr + 2 ] == 'E' ) || - ( sMeta[ iStrPtr + 2 ] == 'I' ) || - ( sMeta[ iStrPtr + 2 ] == 'O' ) || - ( sMeta[ iStrPtr + 2 ] == 'U' ) ) ) + else if( sMeta[ iStrPtr + 1 ] == 'H' && + ( sMeta[ iStrPtr + 2 ] == 'A' || + sMeta[ iStrPtr + 2 ] == 'E' || + sMeta[ iStrPtr + 2 ] == 'I' || + sMeta[ iStrPtr + 2 ] == 'O' || + sMeta[ iStrPtr + 2 ] == 'U' ) ) { sReturn[ iRetPtr++ ] = 'K'; iStrPtr += 2; @@ -556,8 +540,8 @@ HB_FUNC( C_METAFONE ) } /* The suffix NG is skipped. */ else if( ( ( iStrPtr == iStrLen - 1 ) || - ( sMeta[ iStrPtr + 1 ] == ' ' ) ) && - ( sMeta[ iStrPtr - 1 ] == 'N' ) ) + sMeta[ iStrPtr + 1 ] == ' ' ) && + sMeta[ iStrPtr - 1 ] == 'N' ) iStrPtr++; /* G -> K */ @@ -604,18 +588,18 @@ HB_FUNC( C_METAFONE ) /* SCH -> SK */ - if( ( sMeta[ iStrPtr + 1 ] == 'C' ) && - ( sMeta[ iStrPtr + 2 ] == 'H' ) ) + if( sMeta[ iStrPtr + 1 ] == 'C' && + sMeta[ iStrPtr + 2 ] == 'H' ) { sReturn[ iRetPtr++ ] = 'S'; sReturn[ iRetPtr++ ] = 'K'; iStrPtr += 3; } /* SIO, SIA, SH -> X */ - else if( ( ( sMeta[ iStrPtr + 1 ] == 'I' ) && - ( ( sMeta[ iStrPtr + 2 ] == 'A' ) || - ( sMeta[ iStrPtr + 2 ] == 'O' ) ) ) || - ( sMeta[ iStrPtr + 1 ] == 'H' ) ) + else if( ( sMeta[ iStrPtr + 1 ] == 'I' && + ( sMeta[ iStrPtr + 2 ] == 'A' || + sMeta[ iStrPtr + 2 ] == 'O' ) ) || + sMeta[ iStrPtr + 1 ] == 'H' ) { sReturn[ iRetPtr++ ] = 'X'; iStrPtr += ( sMeta[ iStrPtr + 1 ] == 'H' ) ? 2 : 3; @@ -623,9 +607,9 @@ HB_FUNC( C_METAFONE ) /* SCE, SCI, SCY -> S */ else if( sMeta[ iStrPtr + 1 ] == 'C' ) { - if( ( sMeta[ iStrPtr + 2 ] == 'E' ) || - ( sMeta[ iStrPtr + 2 ] == 'I' ) || - ( sMeta[ iStrPtr + 2 ] == 'Y' ) ) + if( sMeta[ iStrPtr + 2 ] == 'E' || + sMeta[ iStrPtr + 2 ] == 'I' || + sMeta[ iStrPtr + 2 ] == 'Y' ) { sReturn[ iRetPtr++ ] = 'S'; iStrPtr += 3; @@ -650,11 +634,11 @@ HB_FUNC( C_METAFONE ) iStrPtr++; /* TIA, TIO, TCH -> X */ - if( ( ( sMeta[ iStrPtr + 1 ] == 'I' ) && - ( ( sMeta[ iStrPtr + 2 ] == 'A' ) || - ( sMeta[ iStrPtr + 2 ] == 'O' ) ) ) || - ( ( sMeta[ iStrPtr + 1 ] == 'C' ) && - ( sMeta[ iStrPtr + 2 ] == 'H' ) ) ) + if( ( sMeta[ iStrPtr + 1 ] == 'I' && + ( sMeta[ iStrPtr + 2 ] == 'A' || + sMeta[ iStrPtr + 2 ] == 'O' ) ) || + ( sMeta[ iStrPtr + 1 ] == 'C' && + sMeta[ iStrPtr + 2 ] == 'H' ) ) { sReturn[ iRetPtr++ ] = 'X'; iStrPtr += 3; @@ -694,18 +678,18 @@ HB_FUNC( C_METAFONE ) /* SCH -> SK */ - if( ( sMeta[ iStrPtr + 1 ] == 'C' ) && - ( sMeta[ iStrPtr + 2 ] == 'H' ) ) + if( sMeta[ iStrPtr + 1 ] == 'C' && + sMeta[ iStrPtr + 2 ] == 'H' ) { sReturn[ iRetPtr++ ] = 'S'; sReturn[ iRetPtr++ ] = 'K'; iStrPtr += 3; } /* SIO, SIA, SH -> X */ - else if( ( ( sMeta[ iStrPtr + 1 ] == 'I' ) && - ( ( sMeta[ iStrPtr + 2 ] == 'A' ) || - ( sMeta[ iStrPtr + 2 ] == 'O' ) ) ) || - ( sMeta[ iStrPtr + 1 ] == 'H' ) ) + else if( ( sMeta[ iStrPtr + 1 ] == 'I' && + ( sMeta[ iStrPtr + 2 ] == 'A' || + sMeta[ iStrPtr + 2 ] == 'O' ) ) || + sMeta[ iStrPtr + 1 ] == 'H' ) { sReturn[ iRetPtr++ ] = 'X'; iStrPtr += ( sMeta[ iStrPtr + 1 ] == 'H' ) ? 2 : 3; @@ -713,9 +697,9 @@ HB_FUNC( C_METAFONE ) /* SCE, SCI, SCY -> S */ else if( sMeta[ iStrPtr + 1 ] == 'C' ) { - if( ( sMeta[ iStrPtr + 2 ] == 'E' ) || - ( sMeta[ iStrPtr + 2 ] == 'I' ) || - ( sMeta[ iStrPtr + 2 ] == 'Y' ) ) + if( sMeta[ iStrPtr + 2 ] == 'E' || + sMeta[ iStrPtr + 2 ] == 'I' || + sMeta[ iStrPtr + 2 ] == 'Y' ) { sReturn[ iRetPtr++ ] = 'S'; iStrPtr += 3; @@ -749,18 +733,18 @@ HB_FUNC( C_METAFONE ) case 'C': /* CC, CH, CIA -> X */ - if( ( sMeta[ iStrPtr + 1 ] == 'C' ) || - ( sMeta[ iStrPtr + 1 ] == 'H' ) || - ( ( sMeta[ iStrPtr + 1 ] == 'I' ) && - ( sMeta[ iStrPtr + 2 ] == 'A' ) ) ) + if( sMeta[ iStrPtr + 1 ] == 'C' || + sMeta[ iStrPtr + 1 ] == 'H' || + ( sMeta[ iStrPtr + 1 ] == 'I' && + sMeta[ iStrPtr + 2 ] == 'A' ) ) { sReturn[ iRetPtr++ ] = 'X'; iStrPtr += ( sMeta[ iStrPtr + 1 ] == 'I' ) ? 3 : 2; } /* CE, CI, CY -> S */ - else if( ( sMeta[ iStrPtr + 1 ] == 'E' ) || - ( sMeta[ iStrPtr + 1 ] == 'I' ) || - ( sMeta[ iStrPtr + 1 ] == 'Y' ) ) + else if( sMeta[ iStrPtr + 1 ] == 'E' || + sMeta[ iStrPtr + 1 ] == 'I' || + sMeta[ iStrPtr + 1 ] == 'Y' ) { sReturn[ iRetPtr++ ] = 'S'; iStrPtr += 2; @@ -779,27 +763,27 @@ HB_FUNC( C_METAFONE ) /* Y - If not followed by a vowel, skip it. */ case 'Y': - if( ( sMeta[ iStrPtr + 1 ] == 'A' ) || - ( sMeta[ iStrPtr + 1 ] == 'E' ) || - ( sMeta[ iStrPtr + 1 ] == 'I' ) || - ( sMeta[ iStrPtr + 1 ] == 'O' ) || - ( sMeta[ iStrPtr + 1 ] == 'U' ) ) + if( sMeta[ iStrPtr + 1 ] == 'A' || + sMeta[ iStrPtr + 1 ] == 'E' || + sMeta[ iStrPtr + 1 ] == 'I' || + sMeta[ iStrPtr + 1 ] == 'O' || + sMeta[ iStrPtr + 1 ] == 'U' ) sReturn[ iRetPtr++ ] = 'Y'; iStrPtr++; break; /* H - Skip if preceeded by and not followed by a vowel. */ case 'H': - if( ( ( sMeta[ iStrPtr - 1 ] == 'A' ) || - ( sMeta[ iStrPtr - 1 ] == 'E' ) || - ( sMeta[ iStrPtr - 1 ] == 'I' ) || - ( sMeta[ iStrPtr - 1 ] == 'O' ) || - ( sMeta[ iStrPtr - 1 ] == 'U' ) ) && ! - ( ( sMeta[ iStrPtr + 1 ] == 'A' ) || - ( sMeta[ iStrPtr + 1 ] == 'E' ) || - ( sMeta[ iStrPtr + 1 ] == 'I' ) || - ( sMeta[ iStrPtr + 1 ] == 'O' ) || - ( sMeta[ iStrPtr + 1 ] == 'U' ) ) ) + if( ( sMeta[ iStrPtr - 1 ] == 'A' || + sMeta[ iStrPtr - 1 ] == 'E' || + sMeta[ iStrPtr - 1 ] == 'I' || + sMeta[ iStrPtr - 1 ] == 'O' || + sMeta[ iStrPtr - 1 ] == 'U' ) && ! + ( sMeta[ iStrPtr + 1 ] == 'A' || + sMeta[ iStrPtr + 1 ] == 'E' || + sMeta[ iStrPtr + 1 ] == 'I' || + sMeta[ iStrPtr + 1 ] == 'O' || + sMeta[ iStrPtr + 1 ] == 'U' ) ) iStrPtr++; else { @@ -814,7 +798,7 @@ HB_FUNC( C_METAFONE ) } /* End of switch...case statement. */ - } /* end while ( ( iStrPtr < iStrLen ) && ( iRetPtr < iRetLen ) ) */ + } /* end while ( iStrPtr < iStrLen && iRetPtr < iRetLen ) */ /* Return the prepared string. Return only the lenght that we know is good so we don't return any uninitialized part of memory. */ @@ -824,19 +808,16 @@ HB_FUNC( C_METAFONE ) hb_xfree( sReturn ); /* We're all finished now, so let's return control to Clipper. */ - return; - } -// ** End of Metaphone ** +/** End of Metaphone **/ -// ** Start of Bit ** +/** Start of Bit **/ /******************************************************************************* - * Program Id: bit.c * Version: 1.00 ******************************************************************************** * @@ -845,42 +826,43 @@ HB_FUNC( C_METAFONE ) * to stay as fast as possible, minimal parameter checking is * performed. It is up to the user to not be too stupid. * - * Syntax: bit( , [, ] ) + * Syntax: bit( @, [, ] ) * ********************************************************************************/ -//#include HB_FUNC( BIT ) { unsigned char mask; - const unsigned char * ptr; - unsigned int loc, - offset = _parni( 2 ) - 1, - res = 0; + char * ptr; + unsigned int loc, + offset = _parni( 2 ) - 1, + res = 0; loc = offset / 8; if( loc < _parclen( 1 ) ) { - ptr = _parc( 1 ) + loc; - loc = offset % 8; - res = *ptr << loc & 0x80; + HB_SIZE nLen; + hb_itemGetWriteCL( hb_param( 1, HB_IT_STRING ), &ptr, &nLen ); + ptr += loc; + loc = offset % 8; + res = ( HB_UCHAR ) *ptr << loc & 0x80; if( PCOUNT > 2 ) { mask = ( unsigned char ) 0x80 >> loc; if( _parl( 3 ) ) - *ptr = *ptr | mask; + *ptr = ( HB_UCHAR ) *ptr | mask; else - *ptr = *ptr & ~mask; + *ptr = ( HB_UCHAR ) *ptr & ~mask; } } _retl( res ); } -// ** End of Bit ** +/** End of Bit **/ -// ** Start of SP_LINE ** +/** Start of SP_LINE **/ static int WordSep( unsigned char c ) @@ -889,7 +871,7 @@ static int WordSep( unsigned char c ) || ( c != 39 && ( c > ' ' && c < '0' ) ) || ( c > '9' && c < 'A' ) || ( c > 'Z' && c < 'a' ) - || ( c > 'z' && c < 128 ); // Support international characters, too. + || ( c > 'z' && c < 128 ); /* Support international characters, too. */ } /*-----------------01-20-94 07:51pm----------------- @@ -915,8 +897,8 @@ HB_FUNC( SP_LINE ) int nCount = 0; int nWrap = 0; unsigned int nOffset = 0; - const BYTEP cIn; - BYTEP p; + const char * cIn; + const char * p; BYTE cTest; int nLineLen; unsigned int nStop; @@ -932,35 +914,35 @@ HB_FUNC( SP_LINE ) nOffset--; } - if( nOffset < nStop ) // In string somewhere + if( nOffset < nStop ) /* In string somewhere */ { - // Default line len to 75 + /* Default line len to 75 */ nLineLen = nArgs > 2 && ISNUM( 3 ) ? _parni( 3 ) - 1 : 75; - p = &cIn[ nOffset ]; // Starting pointer + p = &cIn[ nOffset ]; /* Starting pointer */ - if( nOffset + nLineLen > nStop ) // Past end of string? - nLineLen = nStop - nOffset; // Limit to end of string + if( nOffset + nLineLen > nStop ) /* Past end of string? */ + nLineLen = nStop - nOffset; /* Limit to end of string */ while( ( ! bLineBreak ) && ( nCount++ < nLineLen ) ) { cTest = *p++; - if( cTest == 13 || cTest == 141 ) // Hard or soft return? + if( cTest == 13 || cTest == 141 ) /* Hard or soft return? */ bLineBreak = TRUE; - else if( WordSep( cTest ) ) // Wrappable character? + else if( WordSep( cTest ) ) /* Wrappable character? */ nWrap = nCount - 1; } - if( ( ! bLineBreak ) && ( nWrap > 0 ) ) // Back up to wrap pos + if( ( ! bLineBreak ) && ( nWrap > 0 ) ) /* Back up to wrap pos */ nCount = nWrap; _retclen( &( cIn[ nOffset ] ), nCount + 1 - ( bLineBreak ? 2 : 0 ) ); nOffset += nCount + 1; if( ! bLineBreak ) { - while( cIn[ nOffset ] == 32 ) // Remove leading spaces + while( cIn[ nOffset ] == 32 ) /* Remove leading spaces */ nOffset++; } - nOffset++; // +1 for Clipper string + nOffset++; /* +1 for Clipper string */ } else { @@ -972,6 +954,6 @@ HB_FUNC( SP_LINE ) else _retc( "" ); - if( ISBYREF( 2 ) ) // Change reference val + if( ISBYREF( 2 ) ) /* Change reference val */ _stornl( nOffset, 2 ); } diff --git a/harbour/extras/gfspell/words.dbf b/harbour/extras/gfspell/words.dbf index 9a8127c92f..e269a2b689 100644 Binary files a/harbour/extras/gfspell/words.dbf and b/harbour/extras/gfspell/words.dbf differ diff --git a/harbour/extras/hbusb/hbusb.hbp b/harbour/extras/hbusb/hbusb.hbp index c18c620845..ba765dc520 100644 --- a/harbour/extras/hbusb/hbusb.hbp +++ b/harbour/extras/hbusb/hbusb.hbp @@ -17,13 +17,10 @@ -depimplibs=libusb:../../MS64/dll/libusb-1.0.dll{win&x86_64} -depimplibd=libusb:libusb-1 --hbx=hbusb.hbx - -hbusb.hbx - core.c -{hbdyn}hbusb.hbc - +-hbx=${hb_name}.hbx +${hb_name}.hbx +{hbdyn}${hb_name}.hbc $hb_pkg_dynlib.hbm $hb_pkg_install.hbm diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 0e69384646..c5c7b1132d 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -6536,6 +6536,11 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel ) IF ! hb_DirBuild( hb_FNameDir( hbmk[ _HBMK_cPROGNAME ] ) ) _hbmk_OutErr( hbmk, hb_StrFormat( I_( "Warning: Cannot create directory for target '%1$s'." ), hbmk[ _HBMK_cPROGNAME ] ) ) ENDIF + IF ! Empty( l_cIMPLIBNAME ) + IF ! hb_DirBuild( hb_FNameDir( l_cIMPLIBNAME ) ) + _hbmk_OutErr( hbmk, hb_StrFormat( I_( "Warning: Cannot create directory for import library '%1$s'." ), l_cIMPLIBNAME ) ) + ENDIF + ENDIF IF hbmk[ _HBMK_lREBUILD ] .OR. ; ( ! hbmk[ _HBMK_lINC ] .AND. lStopAfterCComp .AND. hbmk[ _HBMK_lCreateLib ] .AND. ! Empty( cBin_Lib ) ) /* non-incremental + static lib */