2001-06-27 21:53:31 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: ucol_sol.c
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created 06/27/2001
|
|
|
|
* created by: Vladimir Weinstein
|
|
|
|
*
|
|
|
|
* Just trying to help Paul Grinberg compile on Solaris 8 using Workshop 6 compiler
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ucol_sol.h"
|
|
|
|
#include "ucol_tok.h"
|
2001-07-02 21:07:35 +00:00
|
|
|
#include "cmemory.h"
|
2001-06-27 21:53:31 +00:00
|
|
|
|
2001-06-27 22:37:31 +00:00
|
|
|
const UChar *rulesToParse = 0;
|
|
|
|
|
2001-06-27 21:53:31 +00:00
|
|
|
int32_t
|
|
|
|
uhash_hashTokens(const void *k) {
|
|
|
|
int32_t hash = 0;
|
|
|
|
if (k != NULL) {
|
|
|
|
uint32_t key = (uint32_t)k;
|
|
|
|
int32_t len = (key & 0xFF000000)>>24;
|
|
|
|
int32_t inc = ((len - 32) / 32) + 1;
|
|
|
|
|
|
|
|
const UChar *p = (key & 0x00FFFFFF) + rulesToParse;
|
|
|
|
const UChar *limit = p + len;
|
|
|
|
|
|
|
|
while (p<limit) {
|
|
|
|
hash = (hash * 37) + *p;
|
|
|
|
p += inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
UBool uhash_compareTokens(const void *key1, const void *key2) {
|
|
|
|
uint32_t p1 = (uint32_t) key1;
|
|
|
|
uint32_t p2 = (uint32_t) key2;
|
|
|
|
const UChar *s1 = (p1 & 0x00FFFFFF) + rulesToParse;
|
|
|
|
const UChar *s2 = (p2 & 0x00FFFFFF) + rulesToParse;
|
|
|
|
uint32_t s1L = ((p1 & 0xFF000000) >> 24);
|
|
|
|
uint32_t s2L = ((p2 & 0xFF000000) >> 24);
|
|
|
|
const UChar *end = s1+s1L-1;
|
|
|
|
|
|
|
|
if (p1 == p2) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if (p1 == 0 || p2 == 0) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if(s1L != s2L) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if(p1 == p2) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
while((s1 < end) && *s1 == *s2) {
|
|
|
|
++s1;
|
|
|
|
++s2;
|
|
|
|
}
|
|
|
|
if(*s1 == *s2) {
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2001-07-02 21:07:35 +00:00
|
|
|
|
|
|
|
void deleteToken(void *token) {
|
|
|
|
UColToken *tok = (UColToken *)token;
|
|
|
|
uprv_free(tok);
|
|
|
|
}
|