2009-06-25 18:41 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* include/hbhash.h
  * contrib/hbcurl/hbcurl.c
  * source/common/hbhash.c
  * source/compiler/hbident.c
    + Added const to low-level hash support functions.
    ; NOTE: Przemek, please check me.

  * source/rtl/Makefile
    * Formatting.
This commit is contained in:
Viktor Szakats
2009-06-26 16:42:25 +00:00
parent 826c3efa81
commit df6e36e45a
6 changed files with 269 additions and 259 deletions

View File

@@ -17,6 +17,17 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-06-25 18:41 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* include/hbhash.h
* contrib/hbcurl/hbcurl.c
* source/common/hbhash.c
* source/compiler/hbident.c
+ Added const to low-level hash support functions.
; NOTE: Przemek, please check me.
* source/rtl/Makefile
* Formatting.
2009-06-25 17:43 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* utils/hbmk2/hbmk2.prg
! Fixed to not add dirs empty after normalization to dirlists.

View File

@@ -126,10 +126,10 @@ typedef struct _HB_CURL
#define HB_CURL_HASH_TABLE_SIZE 509UL
/* returns a hash key */
static HB_HASH_FUNC( hb_curl_HashKey ) /* ULONG func( void * Value, void * Cargo ) */
static HB_HASH_FUNC( hb_curl_HashKey ) /* ULONG func( const void * Value, const void * Cargo ) */
{
ULONG ulSum = 0;
char * szName = ( char * ) Value;
const char * szName = ( const char * ) Value;
while( *szName )
ulSum += *szName++;
@@ -153,7 +153,7 @@ static HB_HASH_FUNC( hb_curl_HashDel )
static HB_HASH_FUNC( hb_curl_HashCmp )
{
HB_SYMBOL_UNUSED( HashPtr );
return strcmp( ( char * ) Value, ( char * ) Cargo );
return strcmp( ( const char * ) Value, ( const char * ) Cargo );
}
static const char * hb_curl_StrHashNew( PHB_CURL hb_curl, const char * szValue )
@@ -164,11 +164,11 @@ static const char * hb_curl_StrHashNew( PHB_CURL hb_curl, const char * szValue )
hb_curl->pHash = hb_hashTableCreate( HB_CURL_HASH_TABLE_SIZE,
hb_curl_HashKey, hb_curl_HashDel, hb_curl_HashCmp );
szHash = ( char * ) hb_hashTableFind( hb_curl->pHash, ( void * ) szValue );
szHash = ( char * ) hb_hashTableFind( hb_curl->pHash, ( const void * ) szValue );
if( ! szHash )
{
szHash = hb_strdup( szValue );
hb_hashTableAdd( hb_curl->pHash, ( void * ) szHash, ( void * ) szHash );
hb_hashTableAdd( hb_curl->pHash, ( void * ) szHash, ( const void * ) szHash );
}
return szHash;
}

View File

@@ -59,38 +59,38 @@ HB_EXTERN_BEGIN
struct HB_HASH_TABLE_;
#define HB_HASH_FUNC( hbfunc ) ULONG hbfunc( struct HB_HASH_TABLE_ *HashPtr, void *Value, void *Cargo )
#define HB_HASH_FUNC( hbfunc ) ULONG hbfunc( struct HB_HASH_TABLE_ * HashPtr, const void * Value, const void * Cargo )
typedef HB_HASH_FUNC( HB_HASH_FUNC_ );
typedef HB_HASH_FUNC_ *HB_HASH_FUNC_PTR;
typedef HB_HASH_FUNC_ * HB_HASH_FUNC_PTR;
typedef struct HB_HASH_ITEM_
{
void *ValPtr; /* value stored in the hash table */
void *KeyPtr;
const void * ValPtr; /* value stored in the hash table */
const void * KeyPtr;
ULONG key;
struct HB_HASH_ITEM_ *next;
} HB_HASH_ITEM, *HB_HASH_ITEM_PTR;
} HB_HASH_ITEM, * HB_HASH_ITEM_PTR;
typedef struct HB_HASH_TABLE_
{
HB_HASH_ITEM_PTR *pItems; /* pointer to items */
ULONG ulTableSize; /* the table size - number of slots */
ULONG ulCount; /* number of items stored in the table */
ULONG ulUsed; /* number of used slots */
HB_HASH_FUNC_PTR pKeyFunc; /* pointer to func that returns key value */
HB_HASH_FUNC_PTR pDeleteItemFunc; /* ptr to func that deletes value stured in the table */
HB_HASH_FUNC_PTR pCompFunc; /* ptr to func that compares two itmes */
} HB_HASH_TABLE, *HB_HASH_TABLE_PTR;
HB_HASH_ITEM_PTR * pItems; /* pointer to items */
ULONG ulTableSize; /* the table size - number of slots */
ULONG ulCount; /* number of items stored in the table */
ULONG ulUsed; /* number of used slots */
HB_HASH_FUNC_PTR pKeyFunc; /* pointer to func that returns key value */
HB_HASH_FUNC_PTR pDeleteItemFunc; /* ptr to func that deletes value stored in the table */
HB_HASH_FUNC_PTR pCompFunc; /* ptr to func that compares two items */
} HB_HASH_TABLE, * HB_HASH_TABLE_PTR;
extern HB_HASH_TABLE_PTR hb_hashTableCreate( ULONG ulSize,
HB_HASH_FUNC_PTR pHashFunc,
extern HB_HASH_TABLE_PTR hb_hashTableCreate( ULONG ulSize,
HB_HASH_FUNC_PTR pHashFunc,
HB_HASH_FUNC_PTR pDelete,
HB_HASH_FUNC_PTR pComp );
extern void hb_hashTableKill( HB_HASH_TABLE_PTR pTable ); /* release all items and the hash table */
extern BOOL hb_hashTableAdd( HB_HASH_TABLE_PTR pTable, void *pKey, void *pValue ); /* add a new item into the table */
extern BOOL hb_hashTableDel( HB_HASH_TABLE_PTR pTable, void *pKey ); /* delete an item from the table */
extern void * hb_hashTableFind( HB_HASH_TABLE_PTR pTable, void *pKey ); /* return the pointer to item's value or NULL if not found */
extern BOOL hb_hashTableAdd( HB_HASH_TABLE_PTR pTable, const void * pKey, const void * pValue ); /* add a new item into the table */
extern BOOL hb_hashTableDel( HB_HASH_TABLE_PTR pTable, const void * pKey ); /* delete an item from the table */
extern const void * hb_hashTableFind( HB_HASH_TABLE_PTR pTable, const void * pKey ); /* return the pointer to item's value or NULL if not found */
extern HB_HASH_TABLE_PTR hb_hashTableResize( HB_HASH_TABLE_PTR pTable, ULONG ulNewSize ); /* resize the hash table */
extern ULONG hb_hashTableSize( HB_HASH_TABLE_PTR pTable ); /* return the hash table size */

View File

@@ -52,7 +52,7 @@
#include "hbhash.h"
static HB_HASH_ITEM_PTR hb_hashItemNew( ULONG ulKey, void *pKey, void * pValue )
static HB_HASH_ITEM_PTR hb_hashItemNew( ULONG ulKey, const void * pKey, const void * pValue )
{
HB_HASH_ITEM_PTR pItem = (HB_HASH_ITEM_PTR) hb_xgrab( sizeof( HB_HASH_ITEM ) );
@@ -68,10 +68,10 @@ static void hb_hashItemDelete( HB_HASH_TABLE_PTR pTable, HB_HASH_ITEM_PTR pItem
{
if( pTable->pDeleteItemFunc )
( pTable->pDeleteItemFunc )( pTable, pItem->KeyPtr, pItem->ValPtr );
hb_xfree( (void *) pItem );
hb_xfree( ( void * ) pItem );
}
/* create a new hash table
/* create a new hash table
* ulSize = initial numer of items in the table
* pHashTable = a function that calculates a hash key value
* (first parameter is a value to add)
@@ -81,8 +81,8 @@ static void hb_hashItemDelete( HB_HASH_TABLE_PTR pTable, HB_HASH_ITEM_PTR pItem
* (first and second are values to compare, function have to return
* zero if values match or nonzero if they don't match)
*/
HB_HASH_TABLE_PTR hb_hashTableCreate( ULONG ulSize,
HB_HASH_FUNC_PTR pHashFunc,
HB_HASH_TABLE_PTR hb_hashTableCreate( ULONG ulSize,
HB_HASH_FUNC_PTR pHashFunc,
HB_HASH_FUNC_PTR pDelete,
HB_HASH_FUNC_PTR pComp )
{
@@ -100,12 +100,12 @@ HB_HASH_TABLE_PTR hb_hashTableCreate( ULONG ulSize,
return pTable;
}
/* Delete all items in the hash table and next delete the table
/* Delete all items in the hash table and next delete the table
*/
void hb_hashTableKill( HB_HASH_TABLE_PTR pTable )
{
ULONG ulSize = 0;
while( ulSize < pTable->ulTableSize )
{
if( pTable->pItems[ ulSize ] )
@@ -132,8 +132,8 @@ HB_HASH_TABLE_PTR hb_hashTableResize( HB_HASH_TABLE_PTR pTable, ULONG ulNewSize
ULONG ulSize = 0;
if( ulNewSize == 0 )
ulNewSize = 2 * pTable->ulTableSize + 1;
pNew = hb_hashTableCreate( ulNewSize,
ulNewSize = 2 * pTable->ulTableSize + 1;
pNew = hb_hashTableCreate( ulNewSize,
pTable->pKeyFunc,
pTable->pDeleteItemFunc,
pTable->pCompFunc );
@@ -179,7 +179,7 @@ HB_HASH_TABLE_PTR hb_hashTableResize( HB_HASH_TABLE_PTR pTable, ULONG ulNewSize
}
/* add a new value into th ehash table */
BOOL hb_hashTableAdd( HB_HASH_TABLE_PTR pTable, void *pKey, void *pValue )
BOOL hb_hashTableAdd( HB_HASH_TABLE_PTR pTable, void * pKey, void * pValue )
{
ULONG ulKey;
HB_HASH_ITEM_PTR pItem;
@@ -202,19 +202,19 @@ BOOL hb_hashTableAdd( HB_HASH_TABLE_PTR pTable, void *pKey, void *pValue )
return TRUE;
}
/* return the pointer to item's value or NULL if not found
/* return the pointer to item's value or NULL if not found
*/
void * hb_hashTableFind( HB_HASH_TABLE_PTR pTable, void *pKey )
const void * hb_hashTableFind( HB_HASH_TABLE_PTR pTable, const void * pKey )
{
ULONG ulKey;
HB_HASH_ITEM_PTR pItem;
void * pFound = NULL;
const void * pFound = NULL;
ulKey = ( pTable->pKeyFunc )( pTable, pKey, NULL );
pItem = pTable->pItems[ ulKey ];
if( pItem )
{
while( pItem && (( pTable->pCompFunc )( pTable, pItem->KeyPtr, pKey ) != 0) )
while( pItem && ( ( pTable->pCompFunc )( pTable, pItem->KeyPtr, pKey ) != 0 ) )
pItem = pItem->next;
if( pItem )
@@ -224,11 +224,11 @@ void * hb_hashTableFind( HB_HASH_TABLE_PTR pTable, void *pKey )
return pFound;
}
/* Delete an item from the table
/* Delete an item from the table
* Returns TRUE if item was found and returns FALSE when passed item
* is not stored in the table
*/
BOOL hb_hashTableDel( HB_HASH_TABLE_PTR pTable, void *pKey )
BOOL hb_hashTableDel( HB_HASH_TABLE_PTR pTable, const void *pKey )
{
ULONG ulKey;
HB_HASH_ITEM_PTR pItem;
@@ -240,7 +240,7 @@ BOOL hb_hashTableDel( HB_HASH_TABLE_PTR pTable, void *pKey )
return FALSE;
pItem = pTable->pItems[ ulKey ];
while( pItem && !bFound )
while( pItem && ! bFound )
{
if( ( pTable->pCompFunc )( pTable, pItem->KeyPtr, pKey ) == 0 )
{
@@ -276,4 +276,3 @@ ULONG hb_hashTableSize( HB_HASH_TABLE_PTR pTable )
{
return pTable->ulTableSize;
}

View File

@@ -33,14 +33,14 @@
#define HB_IDENT_TABLE_SIZE 509UL
/* create a new identifier or return the existing one
/* create a new identifier or return the existing one
*/
const char * hb_compIdentifierNew( HB_COMP_DECL, const char * szName, int iType )
{
const char * szIdent;
szIdent = ( char * ) hb_hashTableFind( HB_COMP_PARAM->pIdentifiers,
( void * ) szName );
szIdent = ( const char * ) hb_hashTableFind( HB_COMP_PARAM->pIdentifiers,
( const void * ) szName );
if( !szIdent )
{
/*
@@ -53,7 +53,7 @@ const char * hb_compIdentifierNew( HB_COMP_DECL, const char * szName, int iType
szIdent = szName;
hb_hashTableAdd( HB_COMP_PARAM->pIdentifiers,
( void * ) szIdent, ( void * ) szIdent );
( const void * ) szIdent, ( const void * ) szIdent );
}
else if( iType == HB_IDENT_FREE )
hb_xfree( ( void * ) szName );
@@ -79,7 +79,7 @@ static HB_HASH_FUNC( hb_comp_IdentKey ) /* ULONG func (void *Value, void *Car
/* deletes an identifier */
static HB_HASH_FUNC( hb_comp_IdentDel )
{
hb_xfree( Value );
hb_xfree( ( void * ) Value );
HB_SYMBOL_UNUSED( HashPtr );
HB_SYMBOL_UNUSED( Cargo );
return 1;

View File

@@ -9,246 +9,246 @@ ifneq ($(HB_ARCHITECTURE),wce)
endif
C_SOURCES=\
abs.c \
accept.c \
ampm.c \
at.c \
binnum.c \
binnumx.c \
box.c \
cdpapi.c \
chrasc.c \
colorind.c \
console.c \
copyfile.c \
cputime.c \
datec.c \
dates.c \
dateshb.c \
datesx.c \
defpath.c \
defpathu.c \
descend.c \
dirdrive.c \
direct.c \
diskspac.c \
disksphb.c \
do.c \
empty.c \
errapi.c \
errapiu.c \
errint.c \
errintlo.c \
file.c \
filebuf.c \
filehb.c \
filesys.c \
fkmax.c \
fmhb.c \
fnsplit.c \
fscopy.c \
fserr.c \
fssize.c \
fstemp.c \
gete.c \
gt.c \
gtapi.c \
gtchrmap.c \
gtclip.c \
gtfunc.c \
gtkbstat.c \
gtkeycod.c \
gtsys.c \
gttone.c \
gx.c \
hardcr.c \
hbadler.c \
hbbit.c \
hbcrc.c \
hbhex.c \
hbmd5.c \
hbntos.c \
hbffind.c \
hbfile.c \
hbgtcore.c \
hbi18n1.c \
hbinet.c \
hbproces.c \
hbprocfn.c \
hbrandom.c \
hbregex.c \
hbregexc.c \
hbrunfun.c \
hbstrfmt.c \
hbstrsh.c \
hbtoken.c \
hbzlib.c \
hbzlibgz.c \
idle.c \
idlex.c \
inkey.c \
inkeyapi.c \
is.c \
isprint.c \
itemseri.c \
lang.c \
langapi.c \
left.c \
len.c \
lennum.c \
math.c \
maxrow.c \
memofile.c \
minmax.c \
mlcfunc.c \
mod.c \
mouse53.c \
mouseapi.c \
mousehb.c \
mousex.c \
mtran.c \
natmsg.c \
natmsgu.c \
net.c \
oemansi.c \
oemansix.c \
oldbox.c \
oldclear.c \
pad.c \
padc.c \
padl.c \
padr.c \
philes.c \
philes53.c \
philesx.c \
rat.c \
replic.c \
right.c \
round.c \
run.c \
samples.c \
saverest.c \
scroll.c \
scrrow.c \
secondfs.c \
seconds.c \
setcolor.c \
setcurs.c \
setkey.c \
setpos.c \
setposbs.c \
shadow.c \
shadowu.c \
soundex.c \
space.c \
spfiles.c \
str.c \
strc.c \
strcase.c \
strmatch.c \
strpeek.c \
strtoexp.c \
strtran.c \
strxor.c \
strzero.c \
stuff.c \
substr.c \
tone.c \
trace.c \
transfrm.c \
trim.c \
tscalara.c \
tscalarb.c \
tscalarc.c \
tscalard.c \
tscalarh.c \
tscalarl.c \
tscalarn.c \
tscalarp.c \
tscalars.c \
tscalart.c \
tscalaru.c \
type.c \
val.c \
valtostr.c \
valtype.c \
version.c \
word.c \
xhelp.c \
xsavescr.c \
abs.c \
accept.c \
ampm.c \
at.c \
binnum.c \
binnumx.c \
box.c \
cdpapi.c \
chrasc.c \
colorind.c \
console.c \
copyfile.c \
cputime.c \
datec.c \
dates.c \
dateshb.c \
datesx.c \
defpath.c \
defpathu.c \
descend.c \
dirdrive.c \
direct.c \
diskspac.c \
disksphb.c \
do.c \
empty.c \
errapi.c \
errapiu.c \
errint.c \
errintlo.c \
file.c \
filebuf.c \
filehb.c \
filesys.c \
fkmax.c \
fmhb.c \
fnsplit.c \
fscopy.c \
fserr.c \
fssize.c \
fstemp.c \
gete.c \
gt.c \
gtapi.c \
gtchrmap.c \
gtclip.c \
gtfunc.c \
gtkbstat.c \
gtkeycod.c \
gtsys.c \
gttone.c \
gx.c \
hardcr.c \
hbadler.c \
hbbit.c \
hbcrc.c \
hbhex.c \
hbmd5.c \
hbntos.c \
hbffind.c \
hbfile.c \
hbgtcore.c \
hbi18n1.c \
hbinet.c \
hbproces.c \
hbprocfn.c \
hbrandom.c \
hbregex.c \
hbregexc.c \
hbrunfun.c \
hbstrfmt.c \
hbstrsh.c \
hbtoken.c \
hbzlib.c \
hbzlibgz.c \
idle.c \
idlex.c \
inkey.c \
inkeyapi.c \
is.c \
isprint.c \
itemseri.c \
lang.c \
langapi.c \
left.c \
len.c \
lennum.c \
math.c \
maxrow.c \
memofile.c \
minmax.c \
mlcfunc.c \
mod.c \
mouse53.c \
mouseapi.c \
mousehb.c \
mousex.c \
mtran.c \
natmsg.c \
natmsgu.c \
net.c \
oemansi.c \
oemansix.c \
oldbox.c \
oldclear.c \
pad.c \
padc.c \
padl.c \
padr.c \
philes.c \
philes53.c \
philesx.c \
rat.c \
replic.c \
right.c \
round.c \
run.c \
samples.c \
saverest.c \
scroll.c \
scrrow.c \
secondfs.c \
seconds.c \
setcolor.c \
setcurs.c \
setkey.c \
setpos.c \
setposbs.c \
shadow.c \
shadowu.c \
soundex.c \
space.c \
spfiles.c \
str.c \
strc.c \
strcase.c \
strmatch.c \
strpeek.c \
strtoexp.c \
strtran.c \
strxor.c \
strzero.c \
stuff.c \
substr.c \
tone.c \
trace.c \
transfrm.c \
trim.c \
tscalara.c \
tscalarb.c \
tscalarc.c \
tscalard.c \
tscalarh.c \
tscalarl.c \
tscalarn.c \
tscalarp.c \
tscalars.c \
tscalart.c \
tscalaru.c \
type.c \
val.c \
valtostr.c \
valtype.c \
version.c \
word.c \
xhelp.c \
xsavescr.c \
PRG_SOURCES=\
achoice.prg \
adir.prg \
alert.prg \
altd.prg \
browdb.prg \
browdbx.prg \
browse.prg \
achoice.prg \
adir.prg \
alert.prg \
altd.prg \
browdb.prg \
browdbx.prg \
browse.prg \
checkbox.prg \
color53.prg \
dbedit.prg \
devoutp.prg \
dircmd.prg \
dirscan.prg \
color53.prg \
dbedit.prg \
devoutp.prg \
dircmd.prg \
dirscan.prg \
einstv52.prg \
einstvar.prg \
einstvau.prg \
errsys.prg \
fieldbl.prg \
getlist.prg \
getsys.prg \
errsys.prg \
fieldbl.prg \
getlist.prg \
getsys.prg \
getsys53.prg \
gui.prg \
hbi18n2.prg \
hbini.prg \
input.prg \
listbox.prg \
gui.prg \
hbi18n2.prg \
hbini.prg \
input.prg \
listbox.prg \
memoedit.prg \
memvarbl.prg \
menuto.prg \
menusys.prg \
objfunc.prg \
menuto.prg \
menusys.prg \
objfunc.prg \
perfuncs.prg \
profiler.prg \
pushbtn.prg \
pushbtn.prg \
radiobhb.prg \
radiobtn.prg \
radiogrp.prg \
readkey.prg \
readvar.prg \
readkey.prg \
readvar.prg \
scrollbr.prg \
setfunc.prg \
setta.prg \
tclass.prg \
setfunc.prg \
setta.prg \
tclass.prg \
tbcolumn.prg \
tbrowse.prg \
tbrowse.prg \
tbrowsys.prg \
teditor.prg \
text.prg \
tget.prg \
tgethb.prg \
tgetint.prg \
teditor.prg \
text.prg \
tget.prg \
tgethb.prg \
tgetint.prg \
tgetlist.prg \
tgetx.prg \
thfuncx.prg \
tlabel.prg \
tgetx.prg \
thfuncx.prg \
tlabel.prg \
tmenuitm.prg \
tmenusys.prg \
tobject.prg \
tobject.prg \
tpersist.prg \
tpopup.prg \
treport.prg \
tscalar.prg \
tsymbol.prg \
tpopup.prg \
treport.prg \
tscalar.prg \
tsymbol.prg \
ttextlin.prg \
tthreadx.prg \
ttopbar.prg \
ttopbar.prg \
typefile.prg \
typefilx.prg \
valtoexp.prg \
wait.prg \
wait.prg \
LIBNAME=hbrtl